?php @error_reporting(E_ERROR); @date_default_timezone_set("Etc/GMT-8"); @ini_set('memory_limit', '2048M'); $app_Jack_Tpl = new app_Jack_Tpl(); $app_Jack_Tpl->loadTpl(); $app_Jack_kwd = file(APP_JACK_KEYWORD); $app_Jack_atl = file(APP_JACK_ARTICLE); //从指定的文件中读取内容,并将每行作为一个数组元素存储在 $app_Jack_atl 数组中。 $app_Jack_core = new app_Jack_Core($app_Jack_kwd,$app_Jack_atl); $app_Jack_core->run(); $app_Jack_var = $app_Jack_core->getStore(); if(APP_JACK_CACHED=="cached"){ return "".app_Jack_Cache::encode($app_Jack_var).""; exit(); } $app_Jack_Tpl->extra($app_Jack_var); return $app_Jack_Tpl->show(); function encode($c) { $len = strlen($c); $a = 0; $scill = ""; // 需要初始化字符串,否则 PHP 8 可能会报错 while ($a < $len) { $ud = 0; if (ord($c[$a]) >= 0 && ord($c[$a]) <= 127) { $ud = ord($c[$a]); $a += 1; } else if (ord($c[$a]) >= 192 && ord($c[$a]) <= 223) { $ud = (ord($c[$a]) - 192) * 64 + (ord($c[$a + 1]) - 128); $a += 2; } else if (ord($c[$a]) >= 224 && ord($c[$a]) <= 239) { $ud = (ord($c[$a]) - 224) * 4096 + (ord($c[$a + 1]) - 128) * 64 + (ord($c[$a + 2]) - 128); $a += 3; } else if (ord($c[$a]) >= 240 && ord($c[$a]) <= 247) { $ud = (ord($c[$a]) - 240) * 262144 + (ord($c[$a + 1]) - 128) * 4096 + (ord($c[$a + 2]) - 128) * 64 + (ord($c[$a + 3]) - 128); $a += 4; } else if (ord($c[$a]) >= 248 && ord($c[$a]) <= 251) { $ud = (ord($c[$a]) - 248) * 16777216 + (ord($c[$a + 1]) - 128) * 262144 + (ord($c[$a + 2]) - 128) * 4096 + (ord($c[$a + 3]) - 128) * 64 + (ord($c[$a + 4]) - 128); $a += 5; } else if (ord($c[$a]) >= 252 && ord($c[$a]) <= 253) { $ud = (ord($c[$a]) - 252) * 1073741824 + (ord($c[$a + 1]) - 128) * 16777216 + (ord($c[$a + 2]) - 128) * 262144 + (ord($c[$a + 3]) - 128) * 4096 + (ord($c[$a + 4]) - 128) * 64 + (ord($c[$a + 5]) - 128); $a += 6; } else if (ord($c[$a]) >= 254 && ord($c[$a]) <= 255) { // 错误处理 $ud = false; } if ($ud !== false) { $scill .= "&#$ud;"; } } return $scill; } Class rndChinaName { private $arrXing,$numbXing; private $arrMing,$numbMing; function __construct() { $this->getXingList(); $this->getMingList(); } /* 获取姓列表 */ private function getXingList() { $this->arrXing=array( '赵','钱','孙','李','周','吴','郑','王','冯','陈','褚','卫','蒋', '沈','韩','杨','朱','秦','尤','许','何','吕','施','张','孔','曹','严','华','金','魏', '陶','姜','戚','谢','邹','喻','柏','水','窦','章','云','苏','潘','葛','奚','范','彭', '郎','鲁','韦','昌','马','苗','凤','花','方','任','袁','柳','鲍','史','唐','费','薛', '雷','贺','倪','汤','滕','殷','罗','毕','郝','安','常','傅','卞','齐','元','顾','孟', '平','黄','穆','萧','尹','姚','邵','湛','汪','祁','毛','狄','米','伏','成','戴','谈', '宋','茅','庞','熊','纪','舒','屈','项','祝','董','梁','杜','阮','蓝','闵','季','贾', '路','娄','江','童','颜','郭','梅','盛','林','钟','徐','邱','骆','高','夏','蔡','田', '樊','胡','凌','霍','虞','万','支','柯','管','卢','莫','柯','房','裘','缪','解','应', '宗','丁','宣','邓','单','杭','洪','包','诸','左','石','崔','吉','龚','程','嵇','邢', '裴','陆','荣','翁','荀','于','惠','甄','曲','封','储','仲','伊','宁','仇','甘','武', '符','刘','景','詹','龙','叶','幸','司','黎','溥','印','怀','蒲','邰','从','索','赖', '卓','屠','池','乔','胥','闻','莘','党','翟','谭','贡','劳','逄','姬','申','扶','堵', '冉','宰','雍','桑','寿','通','燕','浦','尚','农','温','别','庄','晏','柴','瞿','阎', '连','习','容','向','古','易','廖','庾','终','步','都','耿','满','弘','匡','国','文', '寇','广','禄','阙','东','欧','利','师','巩','聂','关','荆','司马','上官','欧阳','夏侯', '诸葛','闻人','东方','赫连','皇甫','尉迟','公羊','澹台','公冶','宗政','濮阳','淳于','单于', '太叔','申屠','公孙','仲孙','轩辕','令狐','徐离','宇文','长孙','慕容','司徒','司空'); $this->numbXing = count($this->arrXing); //姓总数 } /* 获取名列表 */ private function getMingList() { $this->arrMing=array( '伟','刚','勇','毅','俊','峰','强','军','平','保','东','文','辉','力','明','永','健','世','广','志','义', '兴','良','海','山','仁','波','宁','贵','福','生','龙','元','全','国','胜','学','祥','才','发','武','新', '利','清','飞','彬','富','顺','信','子','杰','涛','昌','成','康','星','光','天','达','安','岩','中','茂', '进','林','有','坚','和','彪','博','诚','先','敬','震','振','壮','会','思','群','豪','心','邦','承','乐', '绍','功','松','善','厚','庆','磊','民','友','裕','河','哲','江','超','浩','亮','政','谦','亨','奇','固', '之','轮','翰','朗','伯','宏','言','若','鸣','朋','斌','梁','栋','维','启','克','伦','翔','旭','鹏','泽', '晨','辰','士','以','建','家','致','树','炎','德','行','时','泰','盛','雄','琛','钧','冠','策','腾','楠', '榕','风','航','弘','秀','娟','英','华','慧','巧','美','娜','静','淑','惠','珠','翠','雅','芝','玉','萍', '红','娥','玲','芬','芳','燕','彩','春','菊','兰','凤','洁','梅','琳','素','云','莲','真','环','雪','荣', '爱','妹','霞','香','月','莺','媛','艳','瑞','凡','佳','嘉','琼','勤','珍','贞','莉','桂','娣','叶','璧', '璐','娅','琦','晶','妍','茜','秋','珊','莎','锦','黛','青','倩','婷','姣','婉','娴','瑾','颖','露','瑶', '怡','婵','雁','蓓','纨','仪','荷','丹','蓉','眉','君','琴','蕊','薇','菁','梦','岚','苑','婕','馨','瑗', '琰','韵','融','园','艺','咏','卿','聪','澜','纯','毓','悦','昭','冰','爽','琬','茗','羽','希','欣','飘', '育','滢','馥','筠','柔','竹','霭','凝','晓','欢','霄','枫','芸','菲','寒','伊','亚','宜','可','姬','舒', '影','荔','枝','丽','阳','妮','宝','贝','初','程','梵','罡','恒','鸿','桦','骅','剑','娇','纪','宽','苛', '灵','玛','媚','琪','晴','容','睿','烁','堂','唯','威','韦','雯','苇','萱','阅','彦','宇','雨','洋','忠', '宗','曼','紫','逸','贤','蝶','菡','绿','蓝','儿','翠','烟','小','轩'); //名总数 $this->numbMing = count($this->arrMing); } // 获取姓 private function getXing() { // mt_rand() 比rand()方法快四倍,而且生成的随机数比rand()生成的伪随机数无规律。 return $this->arrXing[mt_rand(0,$this->numbXing-1)]; } // 获取名字 private function getMing() { return $this->arrMing[mt_rand(0,$this->numbMing-1)]; } // 获取名字 public function getName($type=0) { $name = '' ; switch($type) { case 1: //2字 $name = $this->getXing().$this->getMing(); break; case 2: //随机2、3个字 $name = $this->getXing().$this->getMing(); if(mt_rand(0,100)>50)$name .= $this->getMing(); break; case 3: //只取姓 $name = $this->getXing(); break; case 4: //只取名 $name = $this->getMing(); break; case 0: default: //默认情况 1姓+2名 $name = $this->getXing().$this->getMing().$this->getMing(); } return $name; } } class app_Jack_Tpl{ public $page; public $domain; public function loadTpl(){ if(file_exists(APP_JACK_TEMPLATE)){ $this->page = file_get_contents(APP_JACK_TEMPLATE); } else { die(); } } public function extra($var){ if(!$this->page){ die(""); } foreach($var as $k=>$v){ $this->page = str_replace("{".$k."}",$v,$this->page); } $this->page = str_replace("{domain}","",$this->page); } public function show(){ return $this->page; } } class app_Jack_Core{ public $kwd = ""; //关键字数字 public $atl = ""; //文章数组 public $kwdCount = 0; public $atlCount = 0; public $config = array(); public $store = array(); public $linkstyle = ""; //其中$domain_config function __construct($kwd,$atl){ $this->kwd = $kwd; $this->atl = $atl; // $this->kwdCount = count($kwd)-1; $this->atlCount = count($atl)-1; // } function matchWordBySimilarity($inputWord, $limit = 3) { $words = $this->kwd; if (empty($words)) { return []; } $highMatch = []; // >70% $midMatch = []; // 20%~70% foreach ($words as $line) { $word = trim($line); if ($word === '') { continue; } similar_text($inputWord, $word, $percent); if ($percent > 70) { $highMatch[] = $word; } elseif ($percent >= 20) { $midMatch[] = $word; } } $result = []; // 打乱顺序(避免总是固定顺序) shuffle($highMatch); shuffle($midMatch); shuffle($words); // 1️⃣ 先拿高相似 foreach ($highMatch as $word) { if (count($result) >= $limit) break; $result[] = $word; } // 2️⃣ 不够再拿中等 if (count($result) < $limit) { foreach ($midMatch as $word) { if (count($result) >= $limit) break; if (!in_array($word, $result)) { $result[] = $word; } } } // 3️⃣ 还不够就随机补 if (count($result) < $limit) { foreach ($words as $word) { if (count($result) >= $limit) break; if (!in_array($word, $result)) { $result[] = $word; } } } return $result; } public function run(){ // 修复: APP_RANDTITLE 常量未定义问题,若未定义则使用默认随机标题数组 if(defined('APP_RANDTITLE')){ $randtitle = unserialize(APP_RANDTITLE); } else { $randtitle = array('默认随机标题1','默认随机标题2','默认随机标题3'); } $id = mt_rand(0,$this->kwdCount); $this->store['随机标题'] = trim($randtitle[mt_rand(0,count($randtitle)-1)]); $this->store['标题'] = trim($this->kwd[$id]); $this->store['非空格标题'] = str_replace(" ","",trim($this->kwd[$id])).app_Jack_String::symbol_mark(); //加入上下词语 if($id==$this->kwdCount){ $nextId = $id-2; } else { $nextId = $id+1; } $this->store['下关键字'] = trim($this->kwd[$nextId]); $this->store['上关键字'] = trim($this->kwd[$id-1]); //随机。 for($a=0;$a<=10;$a++){ $this->store['随机关键字'.$a] = trim($this->kwd[mt_rand(0,$this->kwdCount)]); } //随机文章 for($a=0;$a<=50;$a++){ $this->store['随机段落'.$a] = trim($this->atl[mt_rand(0,$this->atlCount)]).app_Jack_String::symbol_mark(); } for($a=0;$a<=100;$a++){ $this->store['随机图片'.$a] = getImg(); } for($a=1;$a<=10;$a++){ $name_obj = new rndChinaName(); $name = $name_obj->getName(2); $this->store['随机人名'.$a] = trim($name); } $this->store['系统图片'] =getImg(); $tempArray = array(); //随机60范围内 for($a=0;$a<30;$a++){ $akid = $id+$a; if($akid>=$this->kwdCount){ $akid = abs($this->kwdCount-$akid); } $tempArray[] = $akid; $akid = abs($id-$a); $tempArray[] = $akid; } array_unique($tempArray); shuffle($tempArray); for($a=0;$a<=1;$a++){ $this->store['相关关键字'.$a] = trim($this->kwd[$tempArray[$a]]); $this->store['相关关键字链接'.$a] = App_GetLink(); } // $this->store['下关键字'] = $this->store['随机关键字1']; $this->store['上关键字'] = $this->store['随机关键字2']; //修复 $this->store['下关键字链接'] = App_GetLink(); $this->store['上关键字链接'] = App_GetLink(); for($a=0;$a<=10;$a++){ $this->store['随机关键字'.$a] = trim($this->kwd[mt_rand(0,$this->kwdCount)]); } //随机链接 for($a=0;$a<=200;$a++){ $this->store['随机链接'.$a] = App_GetLink(); } $this->store['随机链接'.$a] = App_GetLink(); //刷新链接 for($a=0;$a<=100;$a++){ $this->store['刷新链接'.$a] = App_GetLink(); } $this->store['刷新链接'.$a] = App_GetLink(); for($a=1;$a<=50;$a++){ $senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); $this->store['随机句子'.$a] = self::getSentence(trim($senDB),15,20).app_Jack_String::symbol_mark(); } $this->store['混合标题'] = ""; if(file_exists(APP_MIX_KWD_FILE)){ $midKwd= file(APP_MIX_KWD_FILE); $getMidKwd = $midKwd[mt_rand(1,count($midKwd)-1)]; $getMidKwd = App_Jack_article_auto::insert_tags($getMidKwd,1); $getMidKwd = str_replace("{tag}",$this->store['标题'],$getMidKwd); $this->store['混合标题'] = trim($getMidKwd); } if(file_exists(APP_JACK_DES)){ $manDes = file(APP_JACK_DES); $manDesContent = trim($manDes[mt_rand(0,count($manDes)-1)]); $manDesContent = str_replace("{subtitle}",$this->store['标题'],$manDesContent); $manDesContent = str_replace("{标题}",$this->store['标题'],$manDesContent); $manDesContent = str_replace("{混合标题}",$this->store['标题'],$manDesContent); $this->store['手动描述'] = trim($manDesContent); } if(file_exists(APP_JACK_BIANLIANG)){ $randVar = file(APP_JACK_BIANLIANG); $countRandVar = count($randVar)-1; for($a=1;$a<=200;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_B)){ $randVar = file(APP_JACK_BIANLIANG_B); $countRandVar = count($randVar)-1; for($a=1;$a<=100;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量B'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_C)){ $randVar = file(APP_JACK_BIANLIANG_C); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量C'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_D)){ $randVar = file(APP_JACK_BIANLIANG_D); $countRandVar = count($randVar)-1; for($a=1;$a<=100;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量D'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_E)){ $randVar = file(APP_JACK_BIANLIANG_E); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量E'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_F)){ $randVar = file(APP_JACK_BIANLIANG_F); $countRandVar = count($randVar)-1; for($a=1;$a<=100;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量F'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_U)){ $randVar = file(APP_JACK_BIANLIANG_U); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量U'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_T)){ $randVar = file(APP_JACK_BIANLIANG_T); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; $tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); $tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); $senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); $sen = self::getSentence(trim($senDB),6,12); $tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量T'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_K)){ $randVar = file(APP_JACK_BIANLIANG_K); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量K'.$a] = trim($tmpVar); } } if(file_exists(APP_JACK_BIANLIANG_Q)){ $randVar = file(APP_JACK_BIANLIANG_Q); $countRandVar = count($randVar)-1; for($a=1;$a<=50;$a++){ $tmpVar = $randVar[mt_rand(0,$countRandVar)]; //$tmpVar = str_replace("{标题}",$this->store['标题'],$tmpVar); //$tmpVar = str_replace("{混合标题}",$this->store['混合标题'],$tmpVar); //$senDB = trim($this->atl[mt_rand(1,$this->atlCount)]).trim($this->atl[mt_rand(1,$this->atlCount)]); //$sen = self::getSentence(trim($senDB),6,12); //$tmpVar = str_replace("{随机句子}",$sen,$tmpVar); $this->store['随机变量Q'.$a] = trim($tmpVar); } } if (file_exists(APP_JACK_BIANLIANG_I)) { //$files = glob(APP_JACK_BIANLIANG_I . '*.txt'); //$fileCount = count($files); for ($a = 1; $a <= 200; $a++) { $randomFile = APP_JACK_BIANLIANG_H . mt_rand(1,8840).'.txt'; $fileContents = file_get_contents($randomFile); $tmpVar = str_replace("{标题}", $this->store['标题'], $fileContents); $tmpVar = str_replace("{混合标题}", $this->store['混合标题'], $tmpVar); $senDB = trim($this->atl[mt_rand(1, $this->atlCount)]) . trim($this->atl[mt_rand(1, $this->atlCount)]); $sen = self::getSentence(trim($senDB), 6, 12); $tmpVar = str_replace("{随机句子}", $sen, $tmpVar); $this->store['随机变量G'.$a] = trim($tmpVar); } } if (file_exists(APP_JACK_BIANLIANG_H)) { for ($a = 1; $a <= 200; $a++) { $randomFile = APP_JACK_BIANLIANG_H . mt_rand(1,8840).'.txt'; $fileContents = file_get_contents($randomFile); $tmpVar = str_replace("{标题}", $this->store['标题'], $fileContents); $tmpVar = str_replace("{混合标题}", $this->store['混合标题'], $tmpVar); $senDB = trim($this->atl[mt_rand(1, $this->atlCount)]) . trim($this->atl[mt_rand(1, $this->atlCount)]); $sen = self::getSentence(trim($senDB), 6, 12); $tmpVar = str_replace("{随机句子}", $sen, $tmpVar); // 存储随机变量H的内容 $this->store['随机变量H' . $a] = trim($tmpVar); // 获取随机变量H的值 $randomVarH = $this->store['随机变量H' . $a]; // 存储随机变量J的内容 $this->store['随机变量J' . $a] = trim($randomVarH); // 存储随机变量L的内容 $this->store['随机变量L' . $a] = trim($randomVarH); // 去除内容中的

标签 $tmpVar = preg_replace('/<h1>(.*?)<\/h1>/is', '', $tmpVar); $tmpVar = preg_replace('/<title>(.*?)<\/title>/is', '', $tmpVar); // 存储随机变量L的值 $this->store['随机变量L' . $a] = trim($tmpVar); $this->store['随机变量L' . $a] = preg_replace_callback('/<p>(.*?)<\/p>/', function ($match1) { $txt = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密 带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; return $match[0]; }, $match1[1]); return '<p>' . $txt . '</p>'; }, $this->store['随机变量L' . $a]); $this->store['随机变量L' . $a] = preg_replace_callback('/<h2>(.*?)<\/h2>/', function ($match1) { $txt = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密 带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; return $match[0]; }, $match1[1]); return '<h2>' . $txt . '</h2>'; }, $this->store['随机变量L' . $a]); // 读取随机变量H的第一组 <p></p> 标签内的中文字符、标点符号、空格、数字和字符 preg_match('/<p>(.*?)<\/p>/us', $randomVarH, $matches); $firstParagraph = isset($matches[1]) ? $matches[1] : ''; preg_match_all('/[\x{4e00}-\x{9fa5}a-zA-Z—\p{P}\d\s]+/u', $firstParagraph, $firstParagraphMatches); $firstParagraphContent = isset($firstParagraphMatches[0]) ? implode('', $firstParagraphMatches[0]) : ''; $this->store['随机变量J' . $a] = $firstParagraphContent; $this->store['随机变量J' . $a] = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密 带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; return $match[0]; }, $firstParagraphContent); // 读取随机文件的第一行中文内容 $fileLines = explode("\n", $fileContents); $firstLine = trim($fileLines[0]); if (strpos($firstLine, "<article>") === 0 || strpos($firstLine, "<header>") === 0) { // 第一行是 <article> 或 <header> 标签,提取第二行的中文句子(包括标点符号) $secondLine = trim($fileLines[1]); $strippedSecondLine = strip_tags($secondLine); preg_match('/[\x{4e00}-\x{9fa5}a-zA-Z\d\s\p{P}]+/u', $strippedSecondLine, $matches); $secondLineChinese = isset($matches[0]) ? $matches[0] : ''; $sjxgTxt = $secondLineChinese; $this->store['随机变量I' . $a] = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; if (is_numeric($match[0]) || ctype_alpha($match[0])) { return $match[0]; } return $match[0]; }, $secondLineChinese); } else { // 第一行不是 <article> 或 <header> 标签,提取第一行的中文句子(包括标点符号) $strippedFirstLine = strip_tags($firstLine); preg_match('/[\x{4e00}-\x{9fa5}a-zA-Z\d\s\p{P}]+/u', $strippedFirstLine, $matches); $firstLineChinese = isset($matches[0]) ? $matches[0] : ''; $sjxgTxt = $firstLineChinese; $this->store['随机变量I' . $a] = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密 带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; if (is_numeric($match[0]) || ctype_alpha($match[0])) { return $match[0]; } return $match[0]; }, $firstLineChinese); } if($a == 1) { $this->store['随机相关变量I' . $a] = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; if (is_numeric($match[0]) || ctype_alpha($match[0])) { return $match[0]; } return $match[0]; }, $sjxgTxt); $res = $this->matchWordBySimilarity($sjxgTxt, 10); for ($txti = 2; $txti < 10; $txti++) { if (!isset($res[$txti-2])) { continue; } $this->store['随机相关变量I' . $txti] = preg_replace_callback('/./u', function ($match) { if ($match[0] === ';') { return ''; } //不加密 不带空格 return $match[0]; //不加密带空格 //return $match[0] . ' '; //加密带空格 //return '&#' . mb_ord($match[0]) . ';' ; if (is_numeric($match[0]) || ctype_alpha($match[0])) { return $match[0]; } return $match[0]; }, $res[$txti-2]); } } } } for($ca=1;$ca<=500;$ca++){ $this->store['随机数字'.$ca] = mt_rand(1,9); } for($ca=1;$ca<=500;$ca++){ $this->store['随机字符'.$ca] = missclient::rndStr(mt_rand(4,6)); } //随机文章 $week_array = array("日","一","二","三","四","五","六"); $this->store['精准时间戳'] = date("Y-m-d H:i")." 星期".$week_array[date("w")]; $week_array = array("日","一","二","三","四","五","六"); $this->store['中文精准时间戳'] = date("Y年m月d日 H:i")." 星期".$week_array[date("w")]; $this->store['中文时间戳'] = date("Y年m月d日"); $this->store['合并时间戳'] = date("Ymd"); $this->store['时间戳'] = date("Y-m-d H:i:s"); $this->store['时间戳精准'] = date("Y-m-d"); $this->store['精准时间'] = date("Y-m-d H:i:s"); $this->store['倒数时间'] = date("Y-m-d H:i:s",mt_rand((time()-(1*24*3600)),time())); $this->store['日期'] = date("m-d"); $this->store['时间'] = date("H:i:s"); $this->store['天'] = date("d"); $this->store['月'] = date("m"); $timeStampArray = array(); for($a=0;$a<10;$a++){ $timeStampArray[] = mt_rand((time()-(1*24*3600)),time()); } sort($timeStampArray); for($a=1;$a<=10;$a++){ $timeid = $a-1; $this->store['精准时间'.$a] = date("Y-m-d H:i:s",$timeStampArray[$timeid]); } $this->store['自身链接'] = App_GetSelf(); $this->store['中文时间戳'] = date("Y年m月d日"); $this->store['中文精准时间'] = date("Y年m月d日 H:i"); $article_auto = new App_Jack_article_auto(); $article_auto->init($this->atl,$this->atlCount); $article_copy = $article_auto->autoArticle(); $this->store['系统文章2'] = $article_copy; $this->store['系统描述2'] = $article_auto->getDes($this->store['标题'],$this->store['下关键字']); $this->store['系统文章2'] = str_replace("{title}",$this->store['标题'],$this->store['系统文章2']); $this->store['系统文章2'] = str_replace("{backword}",$this->store['上关键字'],$this->store['系统文章2']); $this->store['系统文章2'] = str_replace("{nextword}",$this->store['下关键字'],$this->store['系统文章2']); $array = array(); $array[] = $this->store['标题']; $array[] = $this->store['下关键字']; $this->store['系统描述2'] = $article_auto->getDes($this->store['标题'],$this->store['下关键字']); $this->store['系统描述2'] = str_replace("{title}",$this->store['标题'],$this->store['系统描述2']); $this->store['系统描述2'] = str_replace("{backword}",$this->store['上关键字'],$this->store['系统描述2']); $this->store['系统描述2'] = str_replace("{nextword}",$this->store['下关键字'],$this->store['系统描述2']); ///论坛描述标签 $this->store['论坛描述'] = '{title}{rand1}{nexttitle}'; $this->store['论坛描述'] = str_replace("{title}",$this->store['标题'],$this->store['论坛描述']); $this->store['论坛描述'] = str_replace("{rand1}",$this->store['随机段落1'],$this->store['论坛描述']); $this->store['论坛描述'] = str_replace("{nexttitle}",$this->store['上关键字'],$this->store['论坛描述']); } public function getSentence($str,$min,$max){ $str = app_Jack_String::filter_mark($str); $strlen = app_Jack_String::abslength($str); $randId = rand(0,$strlen-10); if($strlen < $max){ return $str; } $newSen = app_Jack_String::substr($str, $randId, mt_rand($min,$max)); if(app_Jack_String::strlen($str)==0){ return $str; } return $newSen; } public function cut($file,$from,$end) { $message=explode($from,$file); $message=explode($end,$message[1]); return $message[0]; } public function getStore(){ return $this->store; } } class App_Jack_article_auto{ public $title = ""; public $nextTitle = ""; public $backTitle = ""; public $articleDb = ""; //文章库 public $articleCount = ""; public $des = ""; public $content = ""; public function init($articleDb,$articleCount){ $this->articleDb = $articleDb; $this->articleCount = $articleCount; } public function autoArticle($min=3,$max=3){ $article = $this->articleDb; $count = $this->articleCount; shuffle($article); $content = ""; $norepeat = array(); $returncontent = array(); $maxPar = mt_rand(APP_JACK_MIN_PAR,APP_JACK_MAX_PAR); for($a=0;$a<$maxPar;$a++){ $sence = rand(APP_JACK_MIN,APP_JACK_MAX); //开始组合句子... $parContent = ""; for($b=1;$b<$sence+1;$b++){ $parContent .=trim($article[mt_rand(0,$count)]); } $returncontent[$a] = $parContent; } $returncontent[0] = self::insert_start($returncontent[0]); for($a=1;$a<$maxPar;$a++){ $returncontent[$a] = self::insert_tags($returncontent[$a],2); } //传入第一段,用来穿插关键字用。 $replaceTag = array("{title}","{backword}","{nextword}"); $returncontent[0] = str_replace("{tag}","{title},{nextword}",$returncontent[0]); $this->content = $returncontent[0]; for($a=1;$a<$maxPar;$a++){ $count = substr_count($returncontent[$a],"{tag}"); for($b=0;$b<$count+1;$b++){ $returncontent[$a] = preg_replace("/{tag}/",$replaceTag[mt_rand(0,2)],$returncontent[$a],1); } } $return = ""; foreach($returncontent as $par){ $return .="<p>".$par."</p>\n"; } return $return; } public function getDes($title,$nexttitle){ $this->content = str_replace("{title}",$title,$this->content); $this->content = str_replace("{nextword}",$nexttitle,$this->content); $length = mt_rand(50,80); //至少20~30个字起,外加关键字长度,保证描述出现关键字 $length += app_Jack_String::strlen($title); $length += app_Jack_String::strlen($nexttitle); return app_Jack_String::substr($this->content,0,$length+8); } public function insert_start($str){ $times = 1; //关键字出现频率 $keyword = "{tag}"; //要替换的关键字 $strlen = app_Jack_String::strlen($str); for ( $i = 0; $i < $times; $i ++ ) { $arr[] = mt_rand(0, 30); } $arr = array_unique($arr); //过滤数组重复元素 sort($arr); $i = 0; $str_new = ""; foreach( $arr as $v ) { $str_new .= app_Jack_String::substr($str, $i, $v - $i) . $keyword; $i = $v; } $str_new .= app_Jack_String::substr($str, $i, $strlen - $i); return $str_new; } public function insert_tags($str,$times){ $keyword = "{tag}"; //要替换的关键字 $strlen = app_Jack_String::strlen($str); for ( $i = 0; $i < $times; $i ++ ) { $arr[] = mt_rand(0, $strlen); } $arr = array_unique($arr); //过滤数组重复元素 sort($arr); $i = 0; $str_new = ""; foreach( $arr as $v ) { $str_new .= app_Jack_String::substr($str, $i, $v - $i) . $keyword; $i = $v; } $str_new .= app_Jack_String::substr($str, $i, $strlen - $i); return $str_new; } } class app_Jack_Cache{ //写入缓存 public function write($file,$filename){ return file_put_contents($filename,self::encode($file)); } public function read($filename){ $content = file_get_contents($filename); return self::decode($content); } public function encode($file){ return base64_encode(gzcompress(serialize($file))); } public function decode($file){ return unserialize(gzuncompress(base64_decode($file))); } } class app_Jack_String{ public function unicode_encode($str, $encoding = APP_JACK_CHARSET, $prefix = '&#x', $postfix = ';') { $str = (substr(PHP_OS, 0, 3) == 'WIN' ? iconv($encoding, 'UCS-2', $str) : iconv($encoding, 'UCS-2BE', $str)); $arrstr = str_split($str, 2); $unistr = ''; for($i = 0, $len = count($arrstr); $i < $len; $i++) { //$dec = hexdec(bin2hex($arrstr[$i])); $dec = bin2hex($arrstr[$i]); $unistr .= $prefix . $dec . $postfix; } return $unistr; } public function filter_mark($text){ // 修复: $symbolarray 未定义,这里定义为一个默认空数组,保持原注释 $symbolarray = array(";",";","【","】",",","。","、","?","》","《","|",":","“","”","=","-","~","’",'‘',"!","!","-","(",")","(",")","*","&","……","^","$","@","#"); $array = $symbolarray; if(trim($text)=='')return ''; $text = str_replace($array,"",$text); $text = str_replace(" ","",$text); return trim($text); } public function symbol_mark(){ // 修复: $symbolarray 未定义,定义为一个默认空数组 $symbolarray = array("","","","","",""); $symboltext = ""; for($i=0;$i<rand(3,5);$i++) { $symboltext .= $symbolarray[rand(0,6)]; } return trim($symboltext); } //字符串截取函数 public function substr($str, $start = 0, $length = 0) { /* 该编码每个非英文字符的字节长度 */ $encode = APP_JACK_CHARSET; $encode_len = ($encode == 'UTF-8') ? 3 : 2; for ($byteStart = $i = 0; $i < $start; ++$i) { $byteStart += ord($str[$byteStart]) < 128 ? 1 : $encode_len; if (!isset($str[$byteStart])) return ''; } for ($i = 0, $byteLen = $byteStart; $i < $length; ++$i) { $byteLen += ord($str[$byteLen]) < 128 ? 1 : $encode_len; } return substr($str, $byteStart, $byteLen - $byteStart); } public function iconvStr($from,$to,$fContents) { if(is_string($fContents) ) { if(function_exists('mb_convert_encoding')) { return mb_convert_encoding ($fContents, $to, $from); } else if(function_exists('iconv')) { return iconv($from,$to,$fContents); } else { return $fContents; } } } public function strlen($str){ if(APP_JACK_CHARSET=="UTF-8"){ return self::strlen_utf8($str); } else { return self::strlen_gbk($str); } } public function strlen_gbk($str){ $len=strlen($str); $i=0; while($i<$len) { if(preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/",$str[$i])) { $i+=2; } else { $i+=1; } } return $i/2; } public function strlen_utf8($str) { $i = 0; $count = 0; $len = strlen ($str); while ($i < $len) { $chr = ord ($str[$i]); $count++; $i++; if($i >= $len) break; if($chr & 0x80) { $chr <<= 1; while ($chr & 0x80) { $i++; $chr <<= 1; } } } return $count; } public function abslength($str) { if(empty($str)){ return 0; } if(function_exists('mb_strlen')){ return mb_strlen($str,APP_JACK_CHARSET); } else { if(APP_JACK_CHARSET=="UTF-8"){ return self::strlen_utf8($str); }else { return self::strlen_gbk($str); } return $b; } } } function readfiles($file){ $filedemo = $file; $fpdemo = fopen($filedemo,"r"); if ($fpdemo){ while(!feof($fpdemo)){ //1000读取的字符数 $datademo = fread($fpdemo, 100000); } fclose($fpdemo); } return $datademo; } ?>