PHP相关 | LsevenTT博客-站群哥 - Part 4
   

LsevenTT博客-站群哥

认真你就输了

现在php泛站群程序的2种PHP源码加密的方法

现在php泛站群程序的2种PHP源码加密的方法

一. urlencode/urldecode方式

 

<?php
function RandAbc($length=""){//返回随机字符串
	$str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	return str_shuffle($str);
}

$filename='foo.php';

$T_k1=RandAbc();//随机密匙1
$T_k2=RandAbc();//随机密匙2

$vstr=file_get_contents($filename);//要加密的文件
$v1=base64_encode($vstr);

$c=strtr($v1,$T_k1,$T_k2);//根据密匙替换对应字符。
$c=$T_k1.$T_k2.$c;

$q1="O00O0O";
$q2="O0O000";
$q3="O0OO00";
$q4="OO0O00";
$q5="OO0000";
$q6="O00OO0";
$s='$'.$q6.'=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$'.$q1.'=$'.$q6.'{3}.$'.$q6.'{6}.$'.$q6.'{33}.$'.$q6.'{30};$'.$q3.'=$'.$q6.'{33}.$'.$q6.'{10}.$'.$q6.'{24}.$'.$q6.'{10}.$'.$q6.'{24};$'.$q4.'=$'.$q3.'{0}.$'.$q6.'{18}.$'.$q6.'{3}.$'.$q3.'{0}.$'.$q3.'{1}.$'.$q6.'{24};$'.$q5.'=$'.$q6.'{7}.$'.$q6.'{13};$'.$q1.'.=$'.$q6.'{22}.$'.$q6.'{36}.$'.$q6.'{29}.$'.$q6.'{26}.$'.$q6.'{30}.$'.$q6.'{32}.$'.$q6.'{35}.$'.$q6.'{26}.$'.$q6.'{30};eval($'.$q1.'("'.base64_encode('$'.$q2.'="'.$c.'";eval(\'?>\'.$'.$q1.'($'.$q3.'($'.$q4.'($'.$q2.',$'.$q5.'*2),$'.$q4.'($'.$q2.',$'.$q5.',$'.$q5.'),$'.$q4.'($'.$q2.',0,$'.$q5.'))));').'"));';

$s='<?php
'.$s.'
?>';

echo $s;
//生成 加密后的PHP文件
$fpp1 = fopen('temp'.$filename,'w');
fwrite($fpp1,$s) or die('写文件错误');

 

 

新建encrypt.php文件,将以上代码复制进该文件,$filename是要加密的php文件

 

原foo.php

<?php

echo phpinfo();

 

加密之后tempfoo.php

<?php
$O00OO0=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$O00O0O=$O00OO0{3}.$O00OO0{6}.$O00OO0{33}.$O00OO0{30};$O0OO00=$O00OO0{33}.$O00OO0{10}.$O00OO0{24}.$O00OO0{10}.$O00OO0{24};$OO0O00=$O0OO00{0}.$O00OO0{18}.$O00OO0{3}.$O0OO00{0}.$O0OO00{1}.$O00OO0{24};$OO0000=$O00OO0{7}.$O00OO0{13};$O00O0O.=$O00OO0{22}.$O00OO0{36}.$O00OO0{29}.$O00OO0{26}.$O00OO0{30}.$O00OO0{32}.$O00OO0{35}.$O00OO0{26}.$O00OO0{30};eval($O00O0O("JE8wTzAwMD0iQlpQQWZ2bWppVVh4Y05rclFUeldKb3REZXVHYnlNU3FzaENwZEZnSUtSVkhZbkxFYXdsT3Z1TUVOcGZCREpoT3pzYWVWcmlIUWJLQ2xBR1RJUldVdFp5ZGdGUHdvbmN4bWtqTFlxWFNNQzlxWXhFc3lQMG91SHNiVEl2cVl4dmRUZnVwb3lhNyI7ZXZhbCgnPz4nLiRPMDBPME8oJE8wT08wMCgkT08wTzAwKCRPME8wMDAsJE9PMDAwMCoyKSwkT08wTzAwKCRPME8wMDAsJE9PMDAwMCwkT08wMDAwKSwkT08wTzAwKCRPME8wMDAsMCwkT08wMDAwKSkpKTs="));
?>

 

二. php_screw方式

 

下载:http://pan.baidu.com/share/link?shareid=180128&uk=704879932

 

安装

1.用tar解压缩 tar -zxvf php_screw-1.5.tar.gz

 

2.进入php_screw-1.5目录开始安装

cd php_screw-1.5

phpize

关于phpize ,它在php5-dev扩展模块中 只要安装php5-dev模块就行了。

./confiugre

 

3.设置自己用来加密的密码

vi my_screw.h

— Please change the encryption SEED key (pm9screw_mycryptkey) into the

values according to what you like.

The encryption will be harder to break, if you add more values to the

encryption SEED array. However, the size of the SEED is unrelated to

the time of the decrypt processing.

* If you can read and understand the source code, to modify an original

encryption logic will be possible. But in general, this should not

be necessary.

OPTIONAL: Encrypted scripts get a stamp added to the beginning of the

file. If you like, you may change this stamp defined by

PM9SCREW and PM9SCREW_LEN in php_screw.h. PM9SCREW_LEN must

be less than or equal to the size of PM9SCREW.

4.编译

make

 

5.拷贝modules目录下的php_screw.so文件到/usr/lib/php5/extension目录下

cp modules/php_screw.so /usr/lib/php5/extension/

 

6.编辑php.ini文件

在php.ini文件里,加入如下语句

extension=php_screw.so

 

7.重新启动Apache

/etc/init.d/apache2 restart

 

8.编译加密工具

cd tools

make

 

9.将tools目录下加密用的工具screw拷贝到适当目录

cp screw /usr/bin/

 

经过以上的10步,就已经把php_screw-1.5全部安装完成了。并且现在的php也已经支持解释加密过的php文件了

 

使用

1.现写一个要加密的php文件。

我写了如下的一个用来测试php速度的test.php文件

<?

$a=0;
$t=time();

for($i=0;$i<5000000;$i++){$a=$a*$i;}

$t1=time();
echo "<p>";
echo "It used:";
echo $t1-$t;
echo "seconds";

?>

 

将上面的test.php文件放到/var/www/目录下。通过浏览器访问,将显示出php在大量计算时的速度(粗略估计)

 

2.将我们写的php文件加密

cd /var/www/

screw test.php

 

我们加密后,现在目录下的test.php文件就是我们已经加密的了。而源文件被改名为test.php.screw存放了。

我们现在再测试一下test.php,看看能否正常使用?速度如何?

我比较了一下,加密前后的速度大概一样,基本没有太多的损失。

 

3批处理加密文件

在debian, apache2, php5上测试过对.html文件加密后,能正确解析;

php_screw如何对当前目录下,对目录下包含的文件,以及包含目录下的文件进行整体加密

find ./ -name “*.php” -print|xargs -n1 screw //加密所有的.php文件

find ./ -name “*.screw” -print/xargs -n1 rm //删除所有的.php源文件的备份文件

这样在当前目录下的所有.php文件就全部背加密了

php正则过滤html标签、空格、换行符的代码

php正则过滤html标签、空格、换行符的代码

 

  • php正则过滤HTML的代码,可以用来过滤空格、换行符等html代码,可以根据自己的需求继续扩展。

    $str=preg_replace(“/\s+/”, ” “, $str); //过滤多余回车
    $str=preg_replace(“/<[ ]+/si”,”<“,$str); //过滤<__(“<“号后面带空格)

    $str=preg_replace(“/<\!–.*?–>/si”,””,$str); //注释
    $str=preg_replace(“/<(\!.*?)>/si”,””,$str); //过滤DOCTYPE
    $str=preg_replace(“/<(\/?html.*?)>/si”,””,$str); //过滤html标签
    $str=preg_replace(“/<(\/?head.*?)>/si”,””,$str); //过滤head标签
    $str=preg_replace(“/<(\/?meta.*?)>/si”,””,$str); //过滤meta标签
    $str=preg_replace(“/<(\/?body.*?)>/si”,””,$str); //过滤body标签
    $str=preg_replace(“/<(\/?link.*?)>/si”,””,$str); //过滤link标签
    $str=preg_replace(“/<(\/?form.*?)>/si”,””,$str); //过滤form标签
    $str=preg_replace(“/cookie/si”,”COOKIE”,$str); //过滤COOKIE标签

    $str=preg_replace(“/<(applet.*?)>(.*?)<(\/applet.*?)>/si”,””,$str); //过滤applet标签
    $str=preg_replace(“/<(\/?applet.*?)>/si”,””,$str); //过滤applet标签

    $str=preg_replace(“/<(style.*?)>(.*?)<(\/style.*?)>/si”,””,$str); //过滤style标签
    $str=preg_replace(“/<(\/?style.*?)>/si”,””,$str); //过滤style标签

    $str=preg_replace(“/<(title.*?)>(.*?)<(\/title.*?)>/si”,””,$str); //过滤title标签
    $str=preg_replace(“/<(\/?title.*?)>/si”,””,$str); //过滤title标签

    $str=preg_replace(“/<(object.*?)>(.*?)<(\/object.*?)>/si”,””,$str); //过滤object标签
    $str=preg_replace(“/<(\/?objec.*?)>/si”,””,$str); //过滤object标签

    $str=preg_replace(“/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si”,””,$str); //过滤noframes标签
    $str=preg_replace(“/<(\/?noframes.*?)>/si”,””,$str); //过滤noframes标签

    $str=preg_replace(“/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si”,””,$str); //过滤frame标签
    $str=preg_replace(“/<(\/?i?frame.*?)>/si”,””,$str); //过滤frame标签

    $str=preg_replace(“/<(script.*?)>(.*?)<(\/script.*?)>/si”,””,$str); //过滤script标签
    $str=preg_replace(“/<(\/?script.*?)>/si”,””,$str); //过滤script标签
    $str=preg_replace(“/javascript/si”,”Javascript”,$str); //过滤script标签
    $str=preg_replace(“/vbscript/si”,”Vbscript”,$str); //过滤script标签
    $str=preg_replace(“/on([a-z]+)\s*=/si”,”On\\1=”,$str); //过滤script标签
    $str=preg_replace(“/&#/si”,”&#”,$str); //过滤script标签,如javAsCript:alert(

php汉字转拼音

php汉字转拼音

 

 

代码已记下。

 

<?php

 

/***************************************************************************

 

* Pinyin.php

 

* ——————————

 

* Date : Nov 7, 2006

 

* Copyright : 更改自网络源代码,版权归原作者所有

 

* Mail :

 

* Desc. : 拼音转换

 

* History :

 

* Date :

 

* Author :

 

* Modif. :

 

* Usage Example :

 

***************************************************************************/

 

 

 

function Pinyin($_String, $_Code=’gb2312′)

 

{

 

$_DataKey = “a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|ca|cai|can|cang|cao|ce|ceng|cha”.

 

“|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|”.

 

“cuan|cui|cun|cuo|da|dai|dan|dang|dao|de|deng|di|dian|diao|die|ding|diu|dong|dou|du|duan|dui|dun|duo|e|en|er”.

 

“|fa|fan|fang|fei|fen|feng|fo|fou|fu|ga|gai|gan|gang|gao|ge|gei|gen|geng|gong|gou|gu|gua|guai|guan|guang|gui”.

 

“|gun|guo|ha|hai|han|hang|hao|he|hei|hen|heng|hong|hou|hu|hua|huai|huan|huang|hui|hun|huo|ji|jia|jian|jiang”.

 

“|jiao|jie|jin|jing|jiong|jiu|ju|juan|jue|jun|ka|kai|kan|kang|kao|ke|ken|keng|kong|kou|ku|kua|kuai|kuan|kuang”.

 

“|kui|kun|kuo|la|lai|lan|lang|lao|le|lei|leng|li|lia|lian|liang|liao|lie|lin|ling|liu|long|lou|lu|lv|luan|lue”.

 

“|lun|luo|ma|mai|man|mang|mao|me|mei|men|meng|mi|mian|miao|mie|min|ming|miu|mo|mou|mu|na|nai|nan|nang|nao|ne”.

 

“|nei|nen|neng|ni|nian|niang|niao|nie|nin|ning|niu|nong|nu|nv|nuan|nue|nuo|o|ou|pa|pai|pan|pang|pao|pei|pen”.

 

“|peng|pi|pian|piao|pie|pin|ping|po|pu|qi|qia|qian|qiang|qiao|qie|qin|qing|qiong|qiu|qu|quan|que|qun|ran|rang”.

 

“|rao|re|ren|reng|ri|rong|rou|ru|ruan|rui|run|ruo|sa|sai|san|sang|sao|se|sen|seng|sha|shai|shan|shang|shao|”.

 

“she|shen|sheng|shi|shou|shu|shua|shuai|shuan|shuang|shui|shun|shuo|si|song|sou|su|suan|sui|sun|suo|ta|tai|”.

 

“tan|tang|tao|te|teng|ti|tian|tiao|tie|ting|tong|tou|tu|tuan|tui|tun|tuo|wa|wai|wan|wang|wei|wen|weng|wo|wu”.

 

“|xi|xia|xian|xiang|xiao|xie|xin|xing|xiong|xiu|xu|xuan|xue|xun|ya|yan|yang|yao|ye|yi|yin|ying|yo|yong|you”.

 

“|yu|yuan|yue|yun|za|zai|zan|zang|zao|ze|zei|zen|zeng|zha|zhai|zhan|zhang|zhao|zhe|zhen|zheng|zhi|zhong|”.

 

“zhou|zhu|zhua|zhuai|zhuan|zhuang|zhui|zhun|zhuo|zi|zong|zou|zu|zuan|zui|zun|zuo”;

 

 

 

$_DataValue = “-20319|-20317|-20304|-20295|-20292|-20283|-20265|-20257|-20242|-20230|-20051|-20036|-20032|-20026|-20002|-19990”.

 

“|-19986|-19982|-19976|-19805|-19784|-19775|-19774|-19763|-19756|-19751|-19746|-19741|-19739|-19728|-19725”.

 

“|-19715|-19540|-19531|-19525|-19515|-19500|-19484|-19479|-19467|-19289|-19288|-19281|-19275|-19270|-19263”.

 

“|-19261|-19249|-19243|-19242|-19238|-19235|-19227|-19224|-19218|-19212|-19038|-19023|-19018|-19006|-19003”.

 

“|-18996|-18977|-18961|-18952|-18783|-18774|-18773|-18763|-18756|-18741|-18735|-18731|-18722|-18710|-18697”.

 

“|-18696|-18526|-18518|-18501|-18490|-18478|-18463|-18448|-18447|-18446|-18239|-18237|-18231|-18220|-18211”.

 

“|-18201|-18184|-18183|-18181|-18012|-17997|-17988|-17970|-17964|-17961|-17950|-17947|-17931|-17928|-17922”.

 

“|-17759|-17752|-17733|-17730|-17721|-17703|-17701|-17697|-17692|-17683|-17676|-17496|-17487|-17482|-17468”.

 

“|-17454|-17433|-17427|-17417|-17202|-17185|-16983|-16970|-16942|-16915|-16733|-16708|-16706|-16689|-16664”.

 

“|-16657|-16647|-16474|-16470|-16465|-16459|-16452|-16448|-16433|-16429|-16427|-16423|-16419|-16412|-16407”.

 

“|-16403|-16401|-16393|-16220|-16216|-16212|-16205|-16202|-16187|-16180|-16171|-16169|-16158|-16155|-15959”.

 

“|-15958|-15944|-15933|-15920|-15915|-15903|-15889|-15878|-15707|-15701|-15681|-15667|-15661|-15659|-15652”.

 

“|-15640|-15631|-15625|-15454|-15448|-15436|-15435|-15419|-15416|-15408|-15394|-15385|-15377|-15375|-15369”.

 

“|-15363|-15362|-15183|-15180|-15165|-15158|-15153|-15150|-15149|-15144|-15143|-15141|-15140|-15139|-15128”.

 

“|-15121|-15119|-15117|-15110|-15109|-14941|-14937|-14933|-14930|-14929|-14928|-14926|-14922|-14921|-14914”.

 

“|-14908|-14902|-14894|-14889|-14882|-14873|-14871|-14857|-14678|-14674|-14670|-14668|-14663|-14654|-14645”.

 

“|-14630|-14594|-14429|-14407|-14399|-14384|-14379|-14368|-14355|-14353|-14345|-14170|-14159|-14151|-14149”.

 

“|-14145|-14140|-14137|-14135|-14125|-14123|-14122|-14112|-14109|-14099|-14097|-14094|-14092|-14090|-14087”.

 

“|-14083|-13917|-13914|-13910|-13907|-13906|-13905|-13896|-13894|-13878|-13870|-13859|-13847|-13831|-13658”.

 

“|-13611|-13601|-13406|-13404|-13400|-13398|-13395|-13391|-13387|-13383|-13367|-13359|-13356|-13343|-13340”.

 

“|-13329|-13326|-13318|-13147|-13138|-13120|-13107|-13096|-13095|-13091|-13076|-13068|-13063|-13060|-12888”.

 

“|-12875|-12871|-12860|-12858|-12852|-12849|-12838|-12831|-12829|-12812|-12802|-12607|-12597|-12594|-12585”.

 

“|-12556|-12359|-12346|-12320|-12300|-12120|-12099|-12089|-12074|-12067|-12058|-12039|-11867|-11861|-11847”.

 

“|-11831|-11798|-11781|-11604|-11589|-11536|-11358|-11340|-11339|-11324|-11303|-11097|-11077|-11067|-11055”.

 

“|-11052|-11045|-11041|-11038|-11024|-11020|-11019|-11018|-11014|-10838|-10832|-10815|-10800|-10790|-10780”.

 

“|-10764|-10587|-10544|-10533|-10519|-10331|-10329|-10328|-10322|-10315|-10309|-10307|-10296|-10281|-10274”.

 

“|-10270|-10262|-10260|-10256|-10254”;

 

$_TDataKey = explode(‘|’, $_DataKey);

 

$_TDataValue = explode(‘|’, $_DataValue);

 

 

 

$_Data = (PHP_VERSION>=’5.0′) ? array_combine($_TDataKey, $_TDataValue) : _Array_Combine($_TDataKey, $_TDataValue);

 

arsort($_Data);

 

reset($_Data);

 

 

 

if($_Code != ‘gb2312’) $_String = _U2_Utf8_Gb($_String);

 

$_Res = ”;

 

for($i=0; $i<strlen($_String); $i++)

 

{

 

$_P = ord(substr($_String, $i, 1));

 

if($_P>160) { $_Q = ord(substr($_String, ++$i, 1)); $_P = $_P*256 + $_Q – 65536; }

 

$_Res .= _Pinyin($_P, $_Data);

 

}

 

return PageRankeg_replace(“/[^a-z0-9]*/”, ”, $_Res);

 

}

 

 

 

function _Pinyin($_Num, $_Data)

 

{

 

if ($_Num>0 && $_Num<160 ) return chr($_Num);

 

elseif($_Num<-20319 || $_Num>-10247) return ”;

 

else {

 

foreach($_Data as $k=>$v){ if($v<=$_Num) break; }

 

return $k;

 

}

 

}

 

 

 

function _U2_Utf8_Gb($_C)

 

{

 

$_String = ”;

 

if($_C < 0x80) $_String .= $_C;

 

elseif($_C < 0x800)

 

{

 

$_String .= chr(0xC0 | $_C>>6);

 

$_String .= chr(0x80 | $_C & 0x3F);

 

}elseif($_C < 0x10000){

 

$_String .= chr(0xE0 | $_C>>12);

 

$_String .= chr(0x80 | $_C>>6 & 0x3F);

 

$_String .= chr(0x80 | $_C & 0x3F);

 

} elseif($_C < 0x200000) {

 

$_String .= chr(0xF0 | $_C>>18);

 

$_String .= chr(0x80 | $_C>>12 & 0x3F);

 

$_String .= chr(0x80 | $_C>>6 & 0x3F);

 

$_String .= chr(0x80 | $_C & 0x3F);

 

}

 

return iconv(‘UTF-8’, ‘GB2312’, $_String);

 

}

 

 

 

function _Array_Combine($_Arr1, $_Arr2)

 

{

 

for($i=0; $i<count($_Arr1); $i++) $_Res[$_Arr1[$i]] = $_Arr2[$i];

 

return $_Res;

 

}

?>

 

 

用法:
echo Pinyin(‘大家好我是站群哥’); //默认是gb编码
echo Pinyin(‘大家好我是站群哥’,1); //第二个参数随意设置即为utf8编码

根据标题获得百度热门相关关键字的SEO函数

根据标题获得百度热门相关关键字的SEO函数


根据标题获得百度热门相关关键字的SEO函数
function baiduKeyword($title,$num=5,$charset="UTF-8"){

$title=iconv($charset, “GB2312”, $title);
$w=file_get_contents(‘http://d.baidu.com/rs.php?q=’.urlencode($title).’&tn=baidu’);
//die($w);
//获得列表部分
preg_match_all(“|

(.*)

|isU”,$w,$con);
$list=$con[1][0];
//获得具体内容
preg_match_all(“|

|isU”,$list,$content);
//合并成数组,被搜索次数做为键值
$c=array_combine($content[4],$content[3]);
//排序
krsort($c);
//取前N条
$r=array_slice($c, 0, $num);
//转换成字符串
$result=implode(“,”, $r);
$result=iconv(“GB2312”, $charset,$result);
return $result;
}

//通过DZ获取文章关键字,输入标题和内容 即可返回5个关键字数组
function getTags($title,$content){

$subjectenc = rawurlencode(strip_tags($title));
$messageenc = rawurlencode(strip_tags(preg_replace(“/\[.+?\]/U”, ”,$content)));
$subjectenc =substr($subjectenc,0,60);
$messageenc=substr($messageenc,0,1200);
$data = @implode(”, file(“http://keyword.discuz.com/related_kw.html?title=$subjectenc&content=$messageenc&ics=utf-8&ocs=utf-8”));

$kws = array();
if($data) {
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $index);
xml_parser_free($parser);
foreach($values as $valuearray) {
if($valuearray[‘tag’] == ‘kw’ || $valuearray[‘tag’] == ‘ekw’) {
$kw =trim($valuearray[‘value’]);
$kws[] =$kw ;

}
}
}
return $kws;
}

echo baiduKeyword(“ajax”,20,”GB2312″);

?>

php实现SEO伪原创同义词替换函数

php实现SEO伪原创同义词替换函数

近日和一朋友讨论PHP关于同义词替换的SEO伪原创问题,写了如下函数,并为emlog做成插件。
function strtr_words($str)
{
$words=array();
$content = file_get_contents(‘words.txt’);//词库
$content = str_replace( “\r”, “”,$content); //去掉换行符(以便兼容Linux主机)
$content = preg_split(‘/\n/’, $content, -1, PREG_SPLIT_NO_EMPTY);//\n分割字符
foreach($content as $k=>$v)
{
if($k!=0)
{
$str_data = explode(‘→’,$v);//关键词分割符
$words+=array(“$str_data[0]“=>”$str_data[1]“);
}
}
return strtr($str,$words);//返回结果
}

词库words.txt格式如下:

恳求→哀求
悲悼→哀伤
悲痛→哀思
悲伤→哀痛
顺序→挨次
受饿→挨饿
靠拢→挨近

注意,每一行一组同义词,中间用“→”分割。

php小偷程序 觉得有用,先收下了。

php小偷程序 觉得有用,先收下了。

inc.php文件代码:

 

 

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_magic_quotes_runtime(0);
define('l_path', substr(dirname(__FILE__), 0, -4));
define('l_ok',true);
if(PHP_VERSION < '4.1.0') {
	$_GET = &$HTTP_GET_VARS;
	$_POST = &$HTTP_POST_VARS;
	$_COOKIE = &$HTTP_COOKIE_VARS;
	$_SERVER = &$HTTP_SERVER_VARS;
	$_ENV = &$HTTP_ENV_VARS;
	$_FILES = &$HTTP_POST_FILES;
}
function filter($string, $force = 0) {
	if(!$GLOBALS['magic_quotes_gpc'] || $force) {
		if(is_array($string)) {
			foreach($string as $key => $val) {
				$string[$key] = filter($val, $force);
			}
		} else {
			$string = addslashes($string);
		}
	}
	return $string;
}
$magic_quotes_gpc = get_magic_quotes_gpc();
$register_globals = @ini_get('register_globals');
if(!$register_globals || !$magic_quotes_gpc) {
	@extract(filter($_POST));
	@extract(filter($_GET));
	if(!$magic_quotes_gpc) {
		$_FILES = filter($_FILES);
	}
}
//创建目录
function mkpaths($paths){
	if($paths) {
		$listpath = explode('/',$paths);
		$mkpath='';
		for($i=1;$i<=count($listpath);$i++) {
			$mkpath = $mkpath.'/'.$listpath[$i];
			if(!is_dir(l_path.'.'.$mkpath)){
				if(!@mkdir(l_path.'.'.$mkpath,0777)) {
						exit('&#x6307;&#x5b9a;&#x76ee;&#x5f55;&#x4e0d;&#x5b58;&#x5728;&#x6216;&#x4e0d;&#x5141;&#x8bb8;&#x64cd;&#x4f5c;&#x2c;&#x8bf7;&#x68c0;&#x67e5;&#x76ee;&#x5f55;&#x6743;&#x9650;&#x662f;&#x5426;&#x4e3a;&#x20; 0777');
				}
			}
		}
	}
}
//判断数字
function ispage($number) {
	return !empty($number) && preg_match ("/^([0-9]+)$/", $number);
}
//写入文件
function writetofile($file_name,$data,$method='w') {
	if($filenum=@fopen($file_name,$method)){
		flock($filenum,LOCK_EX);
		$file_data=fwrite($filenum,$data);
		fclose($filenum);
		//require_once $file_name;
		return $file_data;
	}else{
		exit('Can not fopen please check the file or PHP.INI');
	}
}
//读取文件
function readfromfile($file){
	if(!@$fp = fopen($file, 'r')) {
		return false;
	} else {
		$str = @fread($fp, filesize($file));
		fclose($fp);
		return $str;
	}
}

function set_gzip($content)
{    
    if(extension_loaded("zlib") && strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip"))
    {
     $content = gzencode($content,9);
    }
    return $content;
}
function gzdecode($data)
{
    $flags = ord(substr($data, 3, 1));
    $headerlen = 10;
    $extralen = 0;
    $filenamelen = 0;
    if ($flags & 4) 
    {
        $extralen = unpack('v' ,substr($data, 10, 2));
        $extralen = $extralen[1];
        $headerlen += 2 + $extralen;
    }
    if ($flags & 8)
    $headerlen = strpos($data, chr(0), $headerlen) + 1;
    if ($flags & 16)
    $headerlen = strpos($data, chr(0), $headerlen) + 1;
    if ($flags & 2)
    $headerlen += 2;
    $unpacked = @gzinflate(substr($data, $headerlen));
    if ($unpacked === FALSE)
    $unpacked = $data;
    return $unpacked;
}

// 重新载入页面
function cw_404(){
global $webwzurl;
echo "<script>\n";
echo "window.location=\"".$webwzurl."\";\n";
echo "</script>";
exit();
}
// 重新载入页面
function js_reload(){
	echo "<script type='text/javascript'>parent.document.location.reload();;</script>";
}
//自动检测内容是编码进行转换 get_encoding($data,"GB2312");
function get_encoding($data,$to)
{
$encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
$encoded = mb_detect_encoding($data, $encode_arr);
$data = mb_convert_encoding($data,$to,$encoded);
return $data;
}
//验证文件修改时间
function gethchtml($filename,$evryhour=0){
	if(file_exists($filename)){
		if($evryhour==0){
    return "ok";
		}elseif((time()-filemtime($filename))<($evryhour*60)){
    return "ok";
		}
  }
}
//格式化路径
function FixPath($aim, $baseUrl) 
{ 
        $strSource = $baseUrl; 
        if(preg_match_all('/([^:\\/]+)\//', $strSource, $aryResult1, PREG_PATTERN_ORDER)){ 
                /// baseUrl存在路径分隔符/,则获取其路径层次 
                $intUrlLevel= count($aryResult1[0]); 
        }else 
        { 
                /// baseUrl不存在路径分隔符/,则生成后面需要的数据 
                $intUrlLevel = 0; 
                preg_match_all('/http:\/\/(.+?)$/', $strSource, $aryResult1, PREG_PATTERN_ORDER); 
                $aryResult1[0][0] = $aryResult1[1][0] . "/"; 
        } 

        $strSource = $aim; 
		if(substr($strSource,0,7) == 'http://'){ 
             return $aim; 
        }else{
			if(preg_match_all("/^\//",$strSource, $aryResult2, PREG_PATTERN_ORDER)){ 
					/// aim以/开头,则为根目录路径 
					$strAimUrl = "http://" . $aryResult1[1][0] . str_replace("../","",$aim); 
			}else{ 
					/// 分析aim的../,即相对路径的层次 
					preg_match_all('/(\\.\\.\/)/', $strSource, $aryResult2, PREG_PATTERN_ORDER); 
					$intAimUrlLevel= count($aryResult2[0]); 
					/// 获取aim的相对路径的层次 
					if($intUrlLevel<=$intAimUrlLevel){ 
							/// baseUrl的路径层次小于aim的相对路径的层次,则从根目录开始 
							$strAimUrl = "http://" . $aryResult1[0][0] . str_replace("../","",$aim); 
					}else{ 
							/// baseUrl的路径层次大于aim的相对路径的层次,则生成大于部分的路径 
							$strAimUrl = "http://" . implode("",array_slice ($aryResult1[0], 0, $intUrlLevel - $intAimUrlLevel)) . str_replace("../","",$aim); 
					} 
			} 
			return $strAimUrl; 
		}
}
function geshuaurl($body, $url) {
preg_match_all("/(href|HREF)=[\"|'|]((.*)\.(html|htm|shtml|asp|php|jsp))/isU",$body,$urls_array);
if(count($urls_array[2])) {
$curls = array_unique($urls_array[2]);
foreach($curls as $key => $urlid ){
$nurlid=FixPath($urlid,$url);
$body=str_replace($urlid,$nurlid,$body); 
}
}
return $body;
}
//采集目标地址/进行编码转换
function get_url_content($url) {
global $charset;
if(function_exists('file_get_contents')) {
$file_contents = file_get_contents($url);
} else {
$ch = curl_init();
$timeout = 5; 
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
}
$file_contents = get_encoding($file_contents, $charset );
return $file_contents;
}
//截取
function cut($string,$start,$end)
{
	$message = explode($start,$string);
	$message = explode($end,$message[1]); 
	return trim($message[0]);
}
function cutdel($string,$start,$end)
{
	$message = explode($start,$string);
	$message = explode($end,$message[1]); 
	return $message[0];
}
//分页
function showpage($add,$patt,$page,$allpage){
//共有'.$allpage.'页
$re1 = '<div class="pages">';
$re="";
for ($i = $page-5;$i <= $page+5 && $i <= $allpage; $i++)
{
if ($i > 0)
{
if ($i == $page)
{
$re .= " <strong>$i</strong> ";
} else 
{
$re .= " <a href=\"".$add.$patt."/".$i."/\">$i</a> ";
}
}
}
$ss=1;
if ($page > 6) $re = "<a href=\"".$add.$patt."/".$ss."/\" title=\"首页\">首页</a> ...".$re;
if ($page + 5 < $allpage) $re .= "... <a href=\"".$add.$patt."/".$allpage."/\" title=\"尾页\">尾页</a>";
$re = $re1.$re."</div>";
if ($allpage <= 1) $re = '';
return $re;
}
//数字除法
function get_szi($str,$c=""){
if($c){
$urlidno = strstr($str, ",");
if($urlidno){
$str=str_replace(",","/",$str);
} else {
$ks = explode("-",$str);
$str=($ks[0]*8888);
if($ks[1]) $str=$str+$ks[1];
}
} else {
$urlidno = strstr($str, "/");
if($urlidno){
$str=str_replace("/",",",$str);
} else {
$str=floor($str/8888)."-".$str%8888;
}
}
return $str;
}
//base64加密解密
function bbb($str,$de=0) {
	if ($de) {
		return base64_decode($str);
	}else{
		return base64_encode($str);
	}
}

//读取数组
function get_data($dataname) {
	include l_path.'./db/'.$dataname.'.php';
	return $weblistdb;
}
//保存数组
function set_data($dataname,$dataarray) {
$datafile=l_path.'./db/'.$dataname.'.php';
$datacontent="<?php\r\n".'$weblistdb='.var_export($dataarray,true).';'."\r\n?>";
return writetofile($datafile,$datacontent);
}
//删除数组
function del_data($dataname,$dataarray,$delid=0) {
array_splice($dataarray,intval($delid),1);
if (set_data($dataname,$dataarray)) {
return 'ok';
}else{
return 'error';
}
}

//图片地址处理
function Getpics($body)
{
global $weburl;
  //$body = strtolower($body);
	$img_array = array();
	preg_match_all("/(src|SRC)=[\"|'| ]{0,}((http|HTTP):\/\/(.*)\.(gif|jpg|GIF|JPG|png))/isU",$body,$img_array);
	$img_array = array_unique($img_array[2]);
	foreach($img_array as $key=>$value)
	{
		$url = $value;
		$fileurl = "/pic.php?s=".base64_encode($url);
		$body = str_replace($url,$fileurl,$body);
	  }
	return $body;
}

//搜索热门关键字
function get_keys($n=8){
global $weburl,$sourl;
$keyss = file(l_path."./incs/key.txt");
if(count($keyss)<$n) $n=count($keyss);
$r_keys=array_rand($keyss,$n);
for($i=0;$i<$n;$i++) {
//$ii=($i+1);urlencode(
$keys.="<span><a href='/".$sourl.bbb(bbb(trim($keyss[$r_keys[$i]])))."/'>".trim($keyss[$r_keys[$i]])."</a></span>";
}
return $keys;
}
function repinfozz( $text )
{
    $text = str_replace( "*", "(.*?)", $text );
    $text = str_replace( "/", "\\/", $text );
    $text = "/".$text."/is";
    return $text;
}
function rephtml($content,$htmltrim)
 {
		$htmlarr=explode(',',$htmltrim);
		foreach ($htmlarr as $curhtml) {
			if (in_array($curhtml,array('br','img'))) {
				$searcharray[]='/<'.$curhtml.'([^>]*?)>/is';
				$replacearray[]='';
			} else if (in_array($curhtml,array('script','style','iframe'))) {
				$searcharray[]='/<'.$curhtml.'([^>]*?)>([\s\S]*)<\/'.$curhtml.'>/is';
				$replacearray[]='';
			} else {
				$searcharray[]='/<'.$curhtml.'([^>]*?)>(.*?)<\/'.$curhtml.'>/is';
				$replacearray[]='$2';
			}
		}
    return preg_replace($searcharray,$replacearray,$content);
	}
//伪原创
function keyshtml($content){
require l_path.'./incs/keyword.php';
return strtr($content,$keyword_arr);
unset($keyword_arr);
}
//获取文件后缀名
function hdhzm($file)
{
$extend =explode("." , $file);
$va=count($extend)-1;
return $extend[$va];
}  
require_once l_path.'./config.inc.php';
?>

 

keyword.php源码

<?php
$keyword_arr = array (
'破除' => '废除',
'破费' => '花费',
'站群排名' => '站群优化',
'阿姨' => '姨妈',
'阿谀' => '谄谀',
'阿谀奉承' => '攀龙趋凤',
'阿谀奉迎' => '攀龙趋凤',
'煊赫一时' => '炙手可热',
);
?>

 

 

 

 

php百度检测网页是否被收录

php百度检测网页是否被收录

 

<?php

/*

* 检测网页是否被百度收录,返回1则表示收录 返回0表示没有收录

* @ param string $url 待检测的网址www.LsevenTT.com

*/

function checkBaiduInclude($url){

$url=’http://www.baidu.com/s?wd=’.$url;

$curl=curl_init();

curl_setopt($curl,CURLOPT_URL,$url);

curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);

$rs=curl_exec($curl);

curl_close($curl);

if(!strpos($rs,’抱歉,没有找到’)){

return 1;

}else{

return 0;

}

}

?>

php 随机读取关键字

php 随机读取关键字

 

 

<?

/*

http://www.LsevenTT.com

/*

$key = file_get_contents( DIR.”/ttkey.txt” );

$keyarr = explode(“\r\n” , trim($key));//分割关键词已换行符分割

$keyline = count( $keyarr );//关键词行数

echo mt_rand(0,$keyline);

?>