转换 * @param array/string $data 数组 * @param string $output 转换后的编码 * Created on 2016-7-13 */ public function array_iconv($data, $output = 'utf-8') { $encode_arr = array('ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP','UTF-8'); $encoded = mb_detect_encoding($data, $encode_arr); if (!is_array($data)) { return mb_convert_encoding($data, $output, $encoded); } else { foreach ($data as $key=>$val) { $key = array_iconv($key, $output); $encoded = mb_detect_encoding($val, $encode_arr); if(is_array($val)) { $data[$key] = array_iconv($val, $output); } else if (is_array($encoded,'GBK','GB2312')) { $data[$key] = mb_convert_encoding($data, $output, $encoded); } else { $data[$key] = $data; } } return $data; } } /** * 自动识别编码 */ public function bianma($data) { $encode_arr = array('ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP','UTF-8'); $encoded = mb_detect_encoding($data, $encode_arr); return $encoded; } //获取远程数据 curl public function huoqu($url="",$timeout=5,$REFERER="") { $REFERER = $REFERER?:$url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); //设置访问的url地址 curl_setopt($ch,CURLOPT_HEADER,0); //是否显示头部信息 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); //设置超时秒 可以是floor //curl_setopt($ch, CURLOPT_USERAGENT,""); //用户访问代理 User-Agent curl_setopt($ch, CURLOPT_REFERER,$REFERER); //设置 referer //curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); //跟踪301 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回结果 $r = curl_exec($ch); curl_close($ch); return $r; } /* CURL采集调用代码 $url = 'http://www.baidu.com/'; //网址 $times = 5; //超时设置(秒) $headers = 0; //是否显示头部信息 $content_s = curls($url,$times,$headers); //调用 */ //CURL采集 public function curls($url_s="",$time_s=5,$httpheader_s,$header_s=0,$useragent_s='',$REFERER="") { //网址,超时设置,是否显示头部信息,浏览器信息 $useragent_s = $useragent_s?:'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'; //默认浏览器信息 $ch = curl_init(); //初始化 curl_setopt($ch, CURLOPT_URL,$url_s); //网址 curl_setopt($ch, CURLOPT_TIMEOUT,$time_s); //只需要设置一个秒的数量就可以 curl_setopt($ch, CURLOPT_HTTPHEADER , $httpheader_s); //头部 curl_setopt($ch, CURLOPT_HEADER, $header_s); //头部 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //获取页面内容,不直接输出到页面 //if (stristr($url_s,"https://")) { //https 自动判断 随时开启防止http 301或302跳转到httpS上面 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。https请求 不验证证书和hosts curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //} curl_setopt($ch, CURLOPT_ENCODING,'gzip'); if ($REFERER) { curl_setopt($ch, CURLOPT_REFERER,$REFERER); //设置 referer } curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 3); curl_setopt($ch, CURLOPT_USERAGENT, $useragent_s); //浏览器 $ret = curl_exec($ch); //执行 $info = curl_getinfo($ch); //相关执行记录 关联数组 //检查是否有错误发生 if(curl_errno($ch)) { $ret = ""; //'HTTP CODE:'.$info['http_code'].' TIME:'.$info['total_time'].'秒 ERROR:'.curl_errno($ch).''; } curl_close($ch); //关闭cURL资源,并且释放系统资源 return array($info['http_code'],$ret,$info['total_time'],curl_errno($ch),$info['content_type']); //返回数据 } /* CURL采集调用代码 $url = 'http://www.baidu.com/'; //网址 $times = 5; //超时设置(秒) $headers = 0; //是否显示头部信息 $content_s = curls_url($url,$times,$headers); //调用 */ //CURL采集 public function curls_url($url_s="",$time_s=5,$header_s=0,$gzsly=0,$useragent_s='') { //网址,超时设置,是否显示头部信息,跟踪301,浏览器信息 $useragent_s = $useragent_s?:'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'; //默认浏览器信息 $ch = curl_init(); //初始化 curl_setopt($ch, CURLOPT_URL,$url_s); //网址 curl_setopt($ch, CURLOPT_TIMEOUT,$time_s); //只需要设置一个秒的数量就可以 curl_setopt($ch, CURLOPT_HEADER, $header_s); //头部 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //获取页面内容,不直接输出到页面 //if (stristr($url_s,"https://")) { //https 自动判断 随时开启防止http 301或302跳转到httpS上面 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。https请求 不验证证书和hosts curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //} if ($gzsly) { //跟踪301 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 3); //跟踪301 } curl_setopt($ch, CURLOPT_USERAGENT, $useragent_s); //浏览器 $ret = curl_exec($ch); //执行 $info = curl_getinfo($ch); //相关执行记录 关联数组 //检查是否有错误发生 if(curl_errno($ch)) { $rets = array( "kb"=>round($info['size_download']/1024,3), //大小 "time"=>$info['total_time'], //耗时 "time_dns"=>$info['namelookup_time'], //DNS查询耗时 "ip"=>$info["local_ip"].",".$info["primary_ip"], //IP "code"=>$info['http_code'], //HTTP CODE "title"=>curl_errno($ch), //标题 ); } else { preg_match_all("/(.*)<\/title>/i",$ret,$ret_title); //取出标题 $rets = array( "kb"=>round($info['size_download']/1024,3), //大小 "time"=>$info['total_time'], //耗时 "time_dns"=>$info['namelookup_time'], //DNS查询耗时 "ip"=>$info["local_ip"].",".$info["primary_ip"], //IP "code"=>$info['http_code'], //HTTP CODE "title"=>str_replace("text/html; charset=","",($info["redirect_url"]?:$ret_title[1][0]."(".$info["content_type"].")")), //标题 ); } curl_close($ch); //关闭cURL资源,并且释放系统资源 return $rets; //返回数据 } //采集链接网址自动补齐 public function url_buqi($url_l,$list_url_caiji_s) { preg_match_all("/^(http|https)\:\/\/(.*?)\//i",$url_l,$urlcj_preg); //取出网址 $file_dir_name = explode("/",$url_l); //取出文件名 $file_dir_lj = str_replace(end($file_dir_name),"",$url_l); //过滤文件名剩余目录 preg_match_all("/^(http:\/\/|https:\/\/|\/\/)(.*?)\//i",$list_url_caiji_s,$list_url_caiji_s_preg); //取出网址 if ($list_url_caiji_s_preg[0]) { if (substr($list_url_caiji_s_preg[1][0],0,2) == "//") { //跟随当期协议的绝对路径 $list_url_caiji_s = $urlcj_preg[1][0].":".$list_url_caiji_s; //域名 } } else { //当前路径 if (substr($list_url_caiji_s,0,1) == "/") { //当前路径的根目录 $list_url_caiji_s = $urlcj_preg[1][0]."://".$urlcj_preg[2][0].$list_url_caiji_s; //图片地址 } else { //当前目录 $list_url_caiji_s = $file_dir_lj.$list_url_caiji_s; //图片地址 } } return $list_url_caiji_s; } //算出多个固定数值 public function gudingzhi_num($url_yuan=1,$guanjianzi_guize_shuliang=1,$nums=1) { $gudingshu = array(); for ($i=0;$i<$nums;$i++) { $url_yuan = $gudingshu[$i-1]?:$url_yuan; $gudingshu[] = $this->gudingzhi_nums($url_yuan,$guanjianzi_guize_shuliang); } return $gudingshu; } //算出固定数值 public function gudingzhi_nums($url_yuan=1,$guanjianzi_guize_shuliang=1) { $preggdt4 = "#(\d)#iUs"; //匹配正则 preg_match_all( $preggdt4, md5($url_yuan), $urlsmd5); //匹配正则 $urlmd5s = implode("",$urlsmd5[0]); $gudingshu = substr( $urlmd5s, 0, 5 ); //截取md5字符串的5位数 while ( $gudingshu > $guanjianzi_guize_shuliang) { //如果5位数大于数量,则五位数除以2,直到五位数小于数量. $gudingshu = $gudingshu / 2; } $gudingshu = floor( $gudingshu ); //生成的固定数 return $gudingshu; } //内容替换 public function contents_th($str) { $str_ks = array("'",'"',' '); $str_js = array('\'','\"',''); $centent = str_replace($str_ks,$str_js,$str); return $centent; } //内容替换1 public function contents_th1($str) { $str_ks = array("'",'"'); $str_js = array('\'','\"'); $centent = str_replace($str_ks,$str_js,$str); return $centent; } //隐藏中间几位字符 public function display_name($str="",$num_1="",$num_2="",$num_3="") { //display_name(原始字符串,前面显示几位,中间*显示几位,后面显示几位) $name = mb_substr($str,0,$num_1,'utf-8'); //前面显示几位 for ($i=0;$i<$num_2;$i++) { //中间*显示几位 $name .= "*"; } $name .= mb_substr($str,mb_strlen($str)-$num_3,$num_3,'utf-8'); //后面显示几位 return $name; } //图片水印 public function pic_sy($pic,$sy,$new_pic,$pic_tm=50) { //$pic 原始图片地址 //$sy 水印图片地址 //$new_pic 新的图片地址 //$pic_tm 水印图片透明度 global $shuiyin_color_array; //默认水印文字颜色 global $pic_shuiyinfont; //默认水印字体路径 global $pic_shuiyinmoshi; //水印模式 global $shuiyin_text_array; //水印文字 //创建图片的实例 $dst = imagecreatefromstring(file_get_contents($pic)); //原始图片 //获取原始图片的宽高 list($dst_w, $dst_h, $dst_type) = getimagesize($pic); if ($pic_shuiyinmoshi == 1) { //图片水印 $src = imagecreatefromstring(file_get_contents($sy)); //水印图片 //获取水印图片的宽高 list($src_w, $src_h) = getimagesize($sy); //将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果 imagecopymerge($dst, $src, $dst_w-$src_w, $dst_h-$src_h, 0, 0, $src_w, $src_h, $pic_tm); //如果水印图片本身带透明色,则使用imagecopy方法 //imagecopy($dst, $src, 10, 10, 0, 0, $src_w, $src_h); } else { //文字水印 $black = imagecolorallocate($dst, $shuiyin_color_array[0], $shuiyin_color_array[1], $shuiyin_color_array[2]); //字体颜色 imagefttext($dst, 25, 0, 10, 30, $black, $pic_shuiyinfont, $shuiyin_text_array[rand(0,count($shuiyin_text_array)-1)]); } if ($dst_type == 1) { //header('Content-Type: image/gif'); imagegif($dst,$new_pic); } else if ($dst_type == 2) { //header('Content-Type: image/jpeg'); imagejpeg($dst,$new_pic); } else if ($dst_type == 3) { //header('Content-Type: image/png'); imagepng($dst,$new_pic); } else { return -1; exit(); } imagedestroy($dst); imagedestroy($src); if (is_file($new_pic)) { return 1; } else { return 0; } } //采集图片自动水印 public function pic_cjsy($pic,$sy,$new_pic,$pic_tm=50,$REFERER) { //$pic 原始图片地址 //$sy 水印图片地址 //$new_pic 新的图片地址 //$pic_tm 水印图片透明度 //$REFERER 前一页来源地址 global $shuiyin_color_array; //默认水印文字颜色 global $pic_shuiyinfont; //默认水印字体路径 global $pic_shuiyinmoshi; //水印模式 global $shuiyin_text_array; //水印文字 //创建图片的实例 $dst = imagecreatefromstring($this->curls($pic,10,0,"",$REFERER)); //原始图片 //获取原始图片的宽高 list($dst_w, $dst_h, $dst_type) = getimagesize($pic); if ($pic_shuiyinmoshi == 1) { //图片水印 $src = imagecreatefromstring(file_get_contents($sy)); //水印图片 //获取水印图片的宽高 list($src_w, $src_h) = getimagesize($sy); //将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果 imagecopymerge($dst, $src, $dst_w-$src_w, $dst_h-$src_h, 0, 0, $src_w, $src_h, $pic_tm); //如果水印图片本身带透明色,则使用imagecopy方法 //imagecopy($dst, $src, 10, 10, 0, 0, $src_w, $src_h); } else { //文字水印 $black = imagecolorallocate($dst, $shuiyin_color_array[0], $shuiyin_color_array[1], $shuiyin_color_array[2]); //字体颜色 imagefttext($dst, 25, 0, 10, 30, $black, $pic_shuiyinfont, $shuiyin_text_array[rand(0,count($shuiyin_text_array)-1)]); } if ($dst_type == 1) { //header('Content-Type: image/gif'); imagegif($dst,$new_pic); } else if ($dst_type == 2) { //header('Content-Type: image/jpeg'); imagejpeg($dst,$new_pic); } else if ($dst_type == 3) { //header('Content-Type: image/png'); imagepng($dst,$new_pic); } else { return -1; exit(); } imagedestroy($dst); imagedestroy($src); if (is_file($new_pic)) { return 1; } else { return 0; } } //自动创建无限目录 public function file_dirs($file_dirs="",$nums=1) { $dirs = explode("/",$file_dirs); //分割目录 $dir_nums = count($dirs); //统计总数 $dir_files = ""; //当前目录,累计 for ($i=0;$i<$dir_nums-$nums;$i++) { //自动循环创建无限目录 $dir_files .= $dirs[$i].'/'; //当前目录,累计 if (!is_dir($dir_files)) { //判断是否此存在 mkdir($dir_files); //不存在就创建 } } if (is_dir($dir_files)) { //判断是否创建成功 return 1; //成功 } else { return 0; //失败 } } //判断文件夹或者文件是否存在 public function file_exists_s($filename="") { if (file_exists($filename)) { return true; } else { return false; } } //打开文件 public function dk($files) { return file_get_contents($files); } //保存文件 public function bc($str="",$contents="",$w='w') { $fp2 = @fopen($str, "".$w.""); //创建一个新文件 fwrite($fp2, $contents);//向当前目录数据 fclose($fp2); //关闭 } //解压文件 public function zip_rar($name="",$files="") { $zip = new ZipArchive; $res = $zip->open($name); if ($res) { //解压到指定文件夹 $zip->extractTo($files); $zip->close(); return true; } else { echo 'failed, code:'.$res; } } //删除指定目录包含所有文件 public function deldir($dir="",$dirs="") { //先删除目录下的文件 $dh=opendir($dir); while ($file=readdir($dh)) { if($file!="." && $file!=".."){ $fullpath=$dir."/".$file; if(!is_dir($fullpath)) { unlink($fullpath); } else { $this->deldir($fullpath,$dirs); } } } if ($dir != $dirs) { closedir($dh); //删除当前文件夹 if(rmdir($dir)){ return true; } else { return false; } } } // 过滤掉emoji表情 public function filterEmoji($str) { $str = preg_replace_callback( '/./u', function (array $match) { return strlen($match[0]) >= 4 ? '' : $match[0]; }, $str); return $str; } //正则内容为空自动过滤 public function zhengzetihuan($str="") { for ($i=0;$i<count($str);$i++) { if ($str[$i]) { $str_s[] = $str[$i]; } } return $str_s; } // check if wap public function check_wap($str="") { // 先检查是否为wap代理,准确度高 if(stristr($_SERVER['HTTP_VIA'],"wap")){ return true; } // 检查浏览器是否接受 WML. elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){ return true; } //检查USER_AGENT else if(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){ return true; } else{ return false; } } }str_\������������ffff][0]9����������eiye[$i][1],$content_yuanzhan_s); } } //全局内页替换规则 for ($i=0;$i<count($tihuan_guize_all_neiye);$i++) { $preggdt4s = '/'.$tihuan_guize_all_neiye[$i][0].'/is'; //匹配正则 $content_yuanzhan_s = preg_replace($preggdt4s,$tihuan_guize_all_neiye[$i][1],$content_yuanzhan_s); //preg_match_all( $preggdt4s, $content_yuanzhan_s, $deltitles); //匹配正则 //$content_yuanzhan_s h^������eplace($deltitles[0][0],$tihuan_guize_all_neiye[$i][1],$content_yuanzhan_s); } } //全局替换规则 //站内全站替换规则 for ($i=0;$i<count($tihuan_guize);$i++) { if ($tihuan_guize[$i][2] == 2) { //普通替换 $content_yuanzhan_s = str_ireplace($tihuan_guize[$i][0],$tihuan_guize[$i][1],$content_yuanzhan_s); } else { $preggdt4 = '/'.$tihuan_guize[$i][0].'/isu'; //匹配正则 preg_match_all( $preggdt4, $content_yuanzhan_s, $deltitle); //匹配正则 $content_yuanzhan_s = str_ireplace($deltitle[0][0],$tihuan_guize[$i][1],$content_yuanzhan_s); } } //全局全站替换规则 for ($i=0;$i<count($tihuan_guize_all);$i++) { $preggdt4s = '/'.$tihuan_guize_all[$i][0].'/is'; //匹配正则 $content_yuanzhan_s = preg_replace($preggdt4s,$tihuan_guize_all[$i][1],$content_yuanzhan_s); //preg_match_all( $preggdt4s, $content_yuanzhan_s, $deltitles); //匹配正则 //$content_yuanzhan_s = str_ireplace($deltitles[0][0],$tihuan_guize_all[$i][1],$content_yuanzhan_s); } //将二级域名替换成二级目录 //将站外链接替换成指定链接(列表顺序) $preggdt4_1 = "/(href|src)=(\"|\'|)([^\"\']+)/is"; //匹配正则 全部网址 preg_match_all( $preggdt4_1, $content_yuanzhan_s, $deltitle1); //匹配正则 $preggdt4_1 = "|url\((.*)\)|U"; //css背景图片匹配正则 全部网址 preg_match_all( $preggdt4_1, $content_yuanzhan_s, $deltitle2); //css背景图片匹配正则 //print_r($deltitle2); $deltitle1[3] = array_merge($deltitle1[3],$deltitle2[1]); //print_r($deltitle1); //$deltitle13 = array(); $lj_rand_i = 0; $list_str = ""; //站群二级域名 for ($i=0;$i<count($deltitle1[3]);$i++){ $deltitle131 = TRIM($deltitle1[3][$i]); //链接 $deltitle134 = explode("/",$deltitle131); //域名 $deltitle132 = explode($configs["url"],$deltitle134[2]); //站外 $deltitle135 = end($deltitle134); //js $deltitle136 = explode("?",$deltitle135); //js $deltitle137 = explode(".",$deltitle136[0]); //js $deltitle138 = end($deltitle137); //js if (mb_substr($deltitle131,0,4) == "http" && count($deltitle132) == 1 && $deltitle138 != "js") { //站外链接 js除外 //$deltitle13[] = $deltitle131; if ($lj_rand_i >= $configs["content_nums"]) { $lj_rand_i = 0; } $content_yuanzhan_s = str_ireplace($deltitle131,$configs["content"][$lj_rand_i],$content_yuanzhan_s); $lj_rand_i++; } else if ((mb_substr($deltitle131,0,4) == "http" || mb_substr($deltitle131,0,2) == "//") && count($deltitle132) > 1) { //站内链接 将二级域名替换成二级目录 忽略www $deltitle133 = explode(".",str_ireplace($configs["url"],"",$deltitle134[2])); //站外 //print_r($deltitle133); $deltitle133_num = count($deltitle133); $list_str_linshis=""; //将二级域名替换成二级目录 忽略www if ($deltitle133_num > 2) { //二级以上域名 $list_str_linshi = array(); if ($deltitle133[$deltitle133_num-1]) { //有端口 $list_str_linshis = "duank".str_ireplace(":","",$deltitle133[$deltitle133_num-1])."_"; //合并 } for ($eji=0;$eji<($deltitle133_num-1);$eji++) { //合并 $list_str_linshi[] = $deltitle133[$eji]; } $list_str_linshis .= implode("_",$list_str_linshi); //合并 if (!in_array($list_str_linshis,$url_erijiwangzhi)) { //检查二级域名记录是否存在 $list_str .= '$url_erijiwangzhi[] = "'.$list_str_linshis.'"; '; $url_erijiwangzhi[] = $list_str_linshis; //新增二级域名记录 } } else if ($deltitle133_num > 1 && ($deltitle133[0] != "www" || $deltitle133[1])) { //二级域名 忽略www if ($deltitle133[1]) { //有端口 $list_str_linshis = "duank".str_ireplace(":","",$deltitle133[1])."_"; //合并 } if ($deltitle133[0] != "www") { $list_str_linshis .= $deltitle133[0]."_".$deltitle133[0]; //合并 } if (!in_array($list_str_linshis,$url_erijiwangzhi)) { //检查二级域名记录是否存在 $list_str .= '$url_erijiwangzhi[] = "'.$list_str_linshis.'"; '; $url_erijiwangzhi[] = $list_str_linshis; //新增二级域名记录 } } if ($list_str_linshis) { //将二级域名替换成二级目录 忽略www $list_str_linshis1 = "www.".$configs["url"]."/".$list_str_linshis."/"; // $content_yuanzhan_s = str_ireplace($deltitle134[2],$list_str_linshis1,$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace($list_str_linshis1."/",$list_str_linshis1,$content_yuanzhan_s); } } } if ($list_str) { //站群二级域名保存 $list_dir_erji = "../inc/domain/".$configs["url"]."_erji.php"; //站群二级域名保存地址 $changyong->bc($list_dir_erji,$list_str,"a+"); //保存配置到本地 } /*//print_r($deltitle13); $preggdt4 = "#(http:\/\/|https:\/\/|\/\/)([0-9a-zA-z\-]+)\.(".$dqurl_host.")#iUs"; //匹配正则 站内网址 //print_r($deltitle); preg_match_all( $preggdt4, $content_yuanzhan_s, $deltitle); //匹配正则 $list_str = ""; for($i=0;$i<count($deltitle[2]);$i++) { if ($deltitle[2][$i] != "www") { //将二级域名替换成二级目录 忽略www $eriji_yuming_s = $deltitle[2][$i]."_".$deltitle[2][$i]; if (!in_array($eriji_yuming_s,$url_erijiwangzhi)) { //检查二级域名记录是否存在 $list_str .= '$url_erijiwangzhi[] = "'.$eriji_yuming_s.'"; '; $url_erijiwangzhi[] = $eriji_yuming_s; //新增二级域名记录 } $deltitle[5][] = $tihuan_ks = array($deltitle[0][$i],$eriji_yuming_s."//"); //$deltitle[6][] = $tihuan_js = array($deltitle[1][$i]."www.".$deltitle[3][$i].$deltitle[4][$i]."/".$eriji_yuming_s."/",$eriji_yuming_s."/"); //匹配正则 全部网址 $deltitle[6][] = $tihuan_js = array($deltitle[1][$i]."www.".$deltitle[3][$i]."/".$eriji_yuming_s."/",$eriji_yuming_s."/"); //匹配正则 站内网址 $content_yuanzhan_s = str_ireplace($tihuan_ks,$tihuan_js,$content_yuanzhan_s); } } if ($list_str) { //站群二级域名保存 $list_dir_erji = "../inc/domain/".$configs["url"]."_erji.php"; //站群二级域名保存地址 $changyong->bc($list_dir_erji,$list_str,"a+"); //保存配置到本地 }*/ $preggdt4 = "/(href|src)=([\"|']?)([^\"'>]+)/i"; //匹配正则 所有src(引用) href(连接) preg_match_all( $preggdt4, $content_yuanzhan_s, $deltitle); //匹配正则 $deltitle_array_str = ""; //二级域名的/链接 $deltitle_array_str1 = array(); //二级域名的链接 for($i=0;$i<count($deltitle[3]);$i++) { if ($deltitle[3][$i] || !in_array($deltitle[3][$i],$deltitle_array_str1)) { //没有替换过 $deltitle_array_str1[] = $deltitle[3][$i]; //记录替换 防止重复替换 if ($deltitle[3][$i] == "/" && $yuanzhan_erji_yumings) { //二级域名的/链接 $deltitle_array_str = $deltitle[0][$i]; } else if (mb_substr($deltitle[3][$i],0,2,"utf-8") != "//" && mb_substr($deltitle[3][$i],0,1,"utf-8") == "/") { //二级域名替换到对应二级目录 $content_yuanzhan_s = str_ireplace($deltitle[3][$i],$yuanzhan_erji_yumings.$deltitle[3][$i],$content_yuanzhan_s); } else if (mb_substr($deltitle[3][$i],0,2,"utf-8") != "//" && decoct(ord(mb_substr($deltitle[3][$i],0,1,"utf-8"))) == 134) { //二级域名替换到对应二级目录 js $js_erjiyum_ks = array('src=\"\/','src=\'\/','href=\"\/','href=\'\/'); $js_erjiyum_js = array('src=\"\/'.$yuanzhan_erji_yumings_js.$deltitle[3][$i],'src=\'\/'.$yuanzhan_erji_yumings_js.$deltitle[3][$i],'href=\"\/'.$yuanzhan_erji_yumings_js.$deltitle[3][$i],'href=\'\/'.$yuanzhan_erji_yumings_js.$deltitle[3][$i]); $content_yuanzhan_s = str_ireplace($js_erjiyum_ks,$js_erjiyum_js,$content_yuanzhan_s); } } } if ($yuanzhan_erji_yumings) { //二级域名的/链接 $content_yuanzhan_s = str_ireplace($deltitle_array_str,$deltitle_array_str.$yuanzhan_erji_yumings."/",$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace($yuanzhan_erji_yumings."//",$yuanzhan_erji_yumings."/",$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace("/".$yuanzhan_erji_yumings,$yuanzhan_erji_yumings,$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace($yuanzhan_erji_yumings.$yuanzhan_erji_yumings."/",$yuanzhan_erji_yumings."/",$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace($yuanzhan_erji_yumings.$yuanzhan_erji_yumings."/",$yuanzhan_erji_yumings."/",$content_yuanzhan_s); $content_yuanzhan_s = str_ireplace($yuanzhan_erji_yumings.$yuanzhan_erji_yumings."/",$yuanzhan_erji_yumings."/",$content_yuanzhan_s); } //全局标签替换规则 设置 $tihuan_guize_qujubiaoqian = array(); $tihuan_guize_qujubiaoqian[] = array('charset "gb2312"','charset "utf-8"'); //替换编码到UTF-8 $tihuan_guize_qujubiaoqian[] = array("charset=gbk","charset=utf-8"); //替换编码到UTF-8 $tihuan_guize_qujubiaoqian[] = array("charset=gb2312","charset=utf-8"); //替换编码到UTF-8 //静态标签 $tihuan_guize_qujubiaoqian[] = array("[域名]",$configs["url"]); //域名 $tihuan_guize_qujubiaoqian[] = array("[网站名称]",$configs["title"]); //网站名称 $tihuan_guize_qujubiaoqian[] = array("[网站简称]",$configs["titles"]); //网站简称 $tihuan_guize_qujubiaoqian[] = array("[针对搜索引擎关键字]",$configs["keywords"]); //针对搜索引擎关键字 $tihuan_guize_qujubiaoqian[] = array("[针对搜索引擎说明]",$configs["description"]); //针对搜索引擎说明 $tihuan_guize_qujubiaoqian[] = array("[版权]",$configs["copyright"]); //版权 $tihuan_guize_qujubiaoqian[] = array("[附加内容]",$configs["content"]); //附加内容 $tihuan_guize_qujubiaoqian[] = array("[友情链接]",$configs["yqlj"]); //友情链接 $tihuan_guize_qujubiaoqian[] = array("[流量统计]",$configs["tongji"]); //流量统计 $tihuan_guize_qujubiaoqian[] = array("[随机关键字1]",$guanjianzi_guize[$guanjianzi_gudingzhi[0]]); //随机关键字1 $tihuan_guize_qujubiaoqian[] = array("[随机关键字2]",$guanjianzi_guize[$guanjianzi_gudingzhi[1]]); //随机关键字2 $tihuan_guize_qujubiaoqian[] = array("[随机关键字3]",$guanjianzi_guize[$guanjianzi_gudingzhi[2]]); //随机关键字3 $tihuan_guize_qujubiaoqian[] = array("[随机关键字4]",$guanjianzi_guize[$guanjianzi_gudingzhi[3]]); //随机关键字4 //全局标签替换规则 for ($i=0;$i<count($tihuan_guize_qujubiaoqian);$i++) { $tihuan_guize_qujubiaoqian[$i][0] = $tihuan_guize_qujubiaoqian[$i][0]; //普通替换方式 $content_yuanzhan_s = str_ireplace($tihuan_guize_qujubiaoqian[$i][0],$tihuan_guize_qujubiaoqian[$i][1],$content_yuanzhan_s); } } if ($content_yuanzhan_s && (($configs["huancun_bendi_on"] == "YES" && !in_array($cache_dir_lj_s5,$zhuanhuan_bianma_wdlx)) || ($configs["huancun_html_on"] == "YES" && in_array($cache_dir_lj_s5,$zhuanhuan_bianma_wdlx)))) { //保存文件到本地 $changyong->file_dirs($cache_dir_lj_file,$cache_dir_lj_nums); //自动创建目录 if ($cache_dir_lj_file_houzui) { //MD5缓存后缀 $content_yuanzhan_type_images = explode("/",$content_yuanzhan_type); //图片后缀 $content_yuanzhan_type_images = explode(";",$content_yuanzhan_type_images[1]); //图片后缀 $wendangleixing_type = array( array("/htm","html"), //网页编码 array("/plain","txt"), //纯文本格式 array("image/",$content_yuanzhan_type_images[0]), //图片 array("/zip","zip"), // ZIP文件 array("compressed","pdf"), // PDF文件 array("/mpeg","mpeg"), // 音频文件 array("/css","css"), //css文件 array("/javascript","js"), //js文件 array("/json","json"), //json array("/xml","xml"), //xml array("flash","swf"), //Flash动画 array("/rss+xml","rss"), //rss array("/atom+xml","atom"), //atom ); for ($i=0;$i<count($wendangleixing_type);$i++) { //文档类型后缀识别 $content_yuanzhan_type1 = explode($wendangleixing_type[$i][0],$content_yuanzhan_type); //图片后缀 if (count($content_yuanzhan_type1) > 1) { if ($wendangleixing_type[$i][1] == "pdf") { header("Content-type: application/pdf"); } else { header("".$content_yuanzhan_type.""); } $changyong->bc($cache_dir_lj_file,$wendangleixing_type[$i][1]."【我是可爱的后缀分割符】".$content_yuanzhan_s); //保存文件到本地 $i = 100; } } } else { $changyong->bc($cache_dir_lj_file,$content_yuanzhan_s); //保存文件到本地 //全局标签替换规则 设置 $tihuan_guize_qujubiaoqian = array(); //动态标签 $tihuan_guize_qujubiaoqian[] = array("【域名】",$configs["url"]); //域名 $tihuan_guize_qujubiaoqian[] = array("【网站名称】",$configs["title"]); //网站名称 $tihuan_guize_qujubiaoqian[] = array("【网站简称】",$configs["titles"]); //网站简称 $tihuan_guize_qujubiaoqian[] = array("【针对搜索引擎关键字】",$configs["keywords"]); //针对搜索引擎关键字 $tihuan_guize_qujubiaoqian[] = array("【针对搜索引擎说明】",$configs["description"]); //针对搜索引擎说明 $tihuan_guize_qujubiaoqian[] = array("【版权】",$configs["copyright"]); //版权 $tihuan_guize_qujubiaoqian[] = array("【附加内容】",$configs["content"]); //附加内容 $tihuan_guize_qujubiaoqian[] = array("【友情链接】",$configs["yqlj"]); //友情链接 $tihuan_guize_qujubiaoqian[] = array("【流量统计】",$configs["tongji"]); //流量统计 $tihuan_guize_qujubiaoqian[] = array("【随机关键字1】",$guanjianzi_guize[$guanjianzi_gudingzhi[0]]); //随机关键字1 $tihuan_guize_qujubiaoqian[] = array("【随机关键字2】",$guanjianzi_guize[$guanjianzi_gudingzhi[1]]); //随机关键字2 $tihuan_guize_qujubiaoqian[] = array("【随机关键字3】",$guanjianzi_guize[$guanjianzi_gudingzhi[2]]); //随机关键字3 $tihuan_guize_qujubiaoqian[] = array("【随机关键字4】",$guanjianzi_guize[$guanjianzi_gudingzhi[3]]); //随机关键字4 //全局标签替换规则 for ($i=0;$i<count($tihuan_guize_qujubiaoqian);$i++) { $tihuan_guize_qujubiaoqian[$i][0] = $tihuan_guize_qujubiaoqian[$i][0]; //普通替换方式 $content_yuanzhan_s = str_ireplace($tihuan_guize_qujubiaoqian[$i][0],$tihuan_guize_qujubiaoqian[$i][1],$content_yuanzhan_s); } } if (is_file($cache_dir_lj_file) && in_array($cache_dir_lj_s5,$zhuanhuan_bianma_wdlx)) { //页面记录到日志方便清除 $list_dir_url_all = "../inc/domain/".$configs["url"]."_yemian.php"; //站群页面记录日志文件路径 require($list_dir_url_all); if (!in_array($cache_dir_lj_file,$url_yemian_all)) { //还没有记录 $list_str .= ' $url_yemian_all[] = "'.$cache_dir_lj_file.'"; '; $changyong->bc($list_dir_url_all,$list_str,"a+"); //保存配置到本地 } } } echo $content_yuanzhan_s; } else { //源站抓取错误 if (is_file($cache_dir_lj_file)) { //有本地缓存文件 $contents_cache_str = file_get_contents($cache_dir_lj_file); if (mb_substr($contents_cache_str,0,9,"UTF-8") != "HTTP CODE") { if ($cache_dir_lj_file_houzui) { //MD5缓存后缀 $cache_dir_lj_file_str1 = explode("【我是可爱的后缀分割符】",$contents_cache_str); if ($cache_dir_lj_file_str1[0] == "css") { //css头 header("Content-type: text/css; charset=utf-8"); } else if ($cache_dir_lj_file_str1[0] == "pdf") { header('Content-Type: application/pdf'); // PDF文件 } else if ($cache_dir_lj_file_str1[0] == "js") { //js头 header("Content-type: application/x-javascript;"); } echo $cache_dir_lj_file_str1[1]; //读取本地缓存文件 exit(); } else { echo $contents_cache_str; //读取本地缓存文件 exit(); } } } header("HTTP/1.1 404 Not Found ".$dqurl_host.""); header("Status: 404 Not Found"); if ($content_yuanzhan[0] == "404") { echo $content_yuanzhan[1]; } else { require('../temps/404.php'); } exit(); } }