loadTpl();
$app_Jack_kwd = file(APP_JACK_KEYWORD);
$app_Jack_atl = file(APP_JACK_ARTICLE);
$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;
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)
{ //error
$ud = false;
}
@$scill .= "$ud;";
}
return $scill;
}
Class rndChinaName
{
private $arrXing,$numbXing;
private $arrMing,$numbMing;
function rndChinaName()
{
$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;
//
}
public function run(){
$randtitle = unserialize(APP_RANDTITLE);
$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<=20;$a++){
$this->store['随机段落'.$a] = trim($this->atl[mt_rand(0,$this->atlCount)]).app_Jack_String::symbol_mark();
}
for($a=0;$a<=10;$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<=2000;$a++){
$this->store['随机链接'.$a] = App_GetLink();
}
$this->store['随机链接'.$a] = App_GetLink();
//刷新链接
for($a=0;$a<=500;$a++){
$this->store['刷新链接'.$a] = App_GetLink();
}
$this->store['刷新链接'.$a] = App_GetLink();
for($a=1;$a<=70;$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<=500;$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_F)){
$randVar = file(APP_JACK_BIANLIANG_F);
$countRandVar = count($randVar)-1;
for($a=1;$a<=2000;$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_T)){
$randVar = file(APP_JACK_BIANLIANG_T);
$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['随机变量T'.$a] = trim($tmpVar);
}
}
if(file_exists(APP_JACK_BIANLIANG_C)){
$randVar = file(APP_JACK_BIANLIANG_C);
$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['随机变量C'.$a] = trim($tmpVar);
}
}
if(file_exists(APP_JACK_BIANLIANG_U)){
$randVar = file(APP_JACK_BIANLIANG_U);
$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['随机变量U'.$a] = trim($tmpVar);
}
}
if(file_exists(APP_JACK_BIANLIANG_D)){
$randVar = file(APP_JACK_BIANLIANG_D);
$countRandVar = count($randVar)-1;
for($a=1;$a<=10;$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<=10;$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);
}
}
for($ca=1;$ca<=50;$ca++){
$this->store['随机数字'.$ca] = mt_rand(1,1000);
}
for($ca=1;$ca<=2000;$ca++){
$this->store['随机字符'.$ca] = missclient::rndStr(mt_rand(3,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("Ymd");
$this->store['时间戳'] = date("Y-m-d");
$this->store['时间戳精准'] = date("Y-m-d H:i:s");
$this->store['精准时间'] = date("Ymd H:i");
$this->store['倒数时间'] = date("Y-m-d H:i:s",mt_rand((time()-(1*24*3600)),time()));
$this->store['日期'] = date("m-d");
$this->store['时间'] = date("i:s");
$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 .="
".$par."
\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 = '', $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){
$array = array(";",";","【","】",",","。","、","?","》","《","|",":","“","”","=","-","~","’",'‘',"!","!","-","(",")","(",")","*","&","……","^","$","@","#").app_Jack_String::symbol_mark();
if(trim($text)=='')return '';
$text = str_replace($array,"",$text);
$text = str_replace(" ","",$text);
return trim($text);
}
public function symbol_mark(){
//$symbolarray = array("","","","","","");
$symboltext = "";
for($i=0;$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;
}
?>