- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 - 70
 - 71
 - 72
 - 73
 - 74
 - 75
 - 76
 - 77
 - 78
 - 79
 
                        <?php
error_reporting(0);
ini_set('display_errors', '0');
mb_internal_encoding('UTF-8');
header('Access-Control-Allow-Origin: *');
function str_replace_first($from, $to, $subject){
$from='/'.preg_quote($from, '/i').'/';
return preg_replace($from, $to, $subject, 1);
}
require_once('morphy/src/common.php');
$opts=array(
'storage'=>PHPMORPHY_STORAGE_MEM,
'predict_by_suffix'=>true, 
'predict_by_db'=>true,
'graminfo_as_text'=>true
);
$dir='morphy/dicts';
$lang='ru_RU';
try{
$morphy=new phpMorphy($dir, $lang, $opts);
}catch(phpMorphy_Exception $e){
die('Error occurred while creating phpMorphy instance: '.PHP_EOL.$e);
}
$morphy->getDefaultGrammemsProvider()->excludeGroups('С', 'род');
$wanal=array();
$wanal['p']=explode(' : ', file_get_contents('wanal_p.txt'));
$wanal['s']=explode(' : ', file_get_contents('wanal_s.txt'));
$wanal['g']=explode(' : ', file_get_contents('wanal_g.txt'));
shuffle($wanal['p']);
shuffle($wanal['s']);
shuffle($wanal['g']);
$current_wanal=$wanal;
$string=trim($_GET['q']);
$modified_comment=$string;
preg_match_all('/(\w+)/u', str_replace('_', '', $string), $matches);
$words=$matches[1];
foreach($words as $word){
if(mb_strtoupper($word)=='НАХУЙ' || mb_strtoupper($word)=='ХУЙ' || mb_strtoupper($word)=='ТУТ'){
continue;
}
$info=$morphy->getGramInfo(mb_strtoupper($word));
$type='';
if(trim($info[0][0]['pos'])=='П'){
$type='p';
}
if(trim($info[0][0]['pos'])=='С'){
$type='s';
}
if(trim($info[0][0]['pos'])=='Г' || trim($info[0][0]['pos'])=='ИНФИНИТИВ'){
$type='g';
}
if($type!=''){
$replacement=trim($current_wanal[$type][array_rand($wanal[$type])]);
if($replacement!=''){
$casted=$morphy->castFormByPattern(mb_strtoupper($replacement), mb_strtoupper($word), null, true);
if(count($casted)>0){
$replacement=reset($casted);
if(md5(mb_substr($word, 0, 1))==md5(mb_strtolower(mb_substr($word, 0, 1)))){
$replacement=mb_strtolower($replacement);
} elseif(md5(mb_strtoupper($word))==md5($word)){
$replacement=mb_strtoupper($replacement);
} elseif(md5(mb_substr($word, 0, 1))==md5(mb_strtoupper(mb_substr($word, 0, 1)))){
$replacement=mb_convert_case(mb_strtolower($replacement), MB_CASE_TITLE);
}
$modified_comment=str_replace_first($word, $replacement, $modified_comment);
$base=$morphy->getBaseForm(mb_strtoupper($word));
if($base){
$wanal[$type][]=mb_strtoupper($base[0]);
$wanal[$type]=array_filter(array_unique($wanal[$type]));
}
}
}
}
}
file_put_contents('wanal_p.txt', implode(' : ', $wanal['p']));
file_put_contents('wanal_s.txt', implode(' : ', $wanal['s']));
file_put_contents('wanal_g.txt', implode(' : ', $wanal['g']));
echo $modified_comment;
?>
                                     
        
            Какой-то такой модификатор чужих комментариев на основе ещё более ранних комментариев.