/** * explainURL * 解释网址 * * @param upurl 网址 typeId 网页类型ID * @access public * @return title 网页标题 typeName 类型名 typyImg 类型标志图 0 出错,网址不正确 */ function explainURL($url) { error_reporting(0); for ($i = 0; $i < 5; $i++) { $file = fopen($url, "r"); if ($file) { break; } } if (!$file) { return ''; } $title = ''; while (!feof($file)) { $line = fgets($file, 1024); $line = safeEncoding($line); if (eregi("<title>(.*)</title>", $line, $out)) { $title = $out[1]; break; } } fclose($file); return $title; }
<?php header("Content-type: text/html; charset=utf-8"); if (isset($_FILES['ajaxUploadFile'])) { echo safeEncoding(file_get_contents($_FILES['ajaxUploadFile']['tmp_name'])); } function safeEncoding($string, $outEncoding = 'UTF-8') { $encoding = "UTF-8"; for ($i = 0; $i < strlen($string); $i++) { if (ord($string[$i]) < 128) { continue; } if ((ord($string[$i]) & 224) == 224) { //第一个字节判断通过 $char = $string[++$i]; if ((ord($char) & 128) == 128) { //第二个字节判断通过 $char = $string[++$i]; if ((ord($char) & 128) == 128) { $encoding = "UTF-8"; break; } } } if ((ord($string[$i]) & 192) == 192) { //第一个字节判断通过 $char = $string[++$i]; if ((ord($char) & 128) == 128) { //第二个字节判断通过 $encoding = "GB2312";
<?php global $keyword, $condition, $limit, $web_id; $mode = $req->getGet("mode"); $keyword = $req->getGet("k"); if (strlen($keyword) >= 4) { $keyword = safeEncoding($keyword, $setting['gen']['charset']); $keyword = substrPro($keyword, 0, 200); $keyword = htmlspecialchars($keyword); if ($record = $db->record($setting['db']['pre'] . "search_keyword", "*", array("keyword", "=", $keyword))) { $record['chg_date'] = time(); $record['count'] += 1; } else { $record['keyword'] = $keyword; $record['count'] = 1; $record['add_date'] = time(); $record['chg_date'] = time(); } $db->replace($setting['db']['pre'] . "search_keyword", $record); if (!empty($mode)) { include dirname(__FILE__) . "/se.php"; $url = $se[$mode]; $goto_url = $url . urlencode(chg_charset($keyword, $setting['gen']['charset'], "utf-8") . " site:" . $setting['info']['web']['host']); } else { $page = $req->getGet("page"); if (!is_numeric($page) || $page < 1) { $page = 1; } $tpl = $mystep->getInstance("MyTpl", $tpl_info, $cache_info); $tpl_info['idx'] = "search"; $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info);
if (!empty($jingweidu)) { if (empty($jiedao)) { $jwdarr = explode(',', $jingweidu); $baidulink = 'http://api.map.baidu.com/geocoder/v2/?ak=*****************************&location=' . $jwdarr[1] . ',' . $jwdarr[0] . '&output=json&pois=0'; $jwdjson = get($baidulink); $jwdstr = (array) json_decode($jwdjson); $jiedao = $jwdstr['result']->formatted_address; } //截取接到位置 $jiedao = preg_replace('/^([^\\d]+).*/', '$1', $jiedao); //从缓存服务器获取该用户上次的地点 //并且判断是否是一个地点提交的数据 $userjiedao = $mem->get($umd5 . 'jiedao'); if ($userjiedao != $jiedao) { //如果不是则插入数据库 $insert = array('geo' => $jingweidu, 'time' => time(), 'ip' => $_SERVER["REMOTE_ADDR"], 'jiedao' => safeEncoding($jiedao), 'umd5' => $umd5); $db->row_insert("zaina", $insert); $mem->set($umd5 . 'jiedao', $jiedao, 0, 600); $update = array('zaina' => $jiedao); $db->row_update('user', $update, " umd5 = '{$umd5}' "); } } if ($juli == '1') { $zainares = $mem->get($umd5 . $sex . 'zaina'); } else { $zainares = $mem->get($sex . 'zaina'); } if (empty($zainares)) { $res = select(); if ($juli == '1') { $mem->set($umd5 . $sex . 'zaina', $res, 0, 60);
public static function referer_analysis() { if (checkSign(255)) { return; } global $db, $setting, $req; $referer = $req->getServer("HTTP_REFERER"); $agent = strtolower($req->getServer('HTTP_USER_AGENT')); if (strpos($agent, "spider") !== false || strpos($agent, "bot") !== false) { return; } $db->update($setting['db']['pre'] . "visit_analysis", array("count_month" => 0), array("month(FROM_UNIXTIME(chg_date))", "f!=", "month(now())")); $db->update($setting['db']['pre'] . "visit_analysis", array("count_year" => 0), array("year(FROM_UNIXTIME(chg_date))", "f!=", "year(now())")); if (strlen($referer) > 10) { $url_info = parse_url($referer); if (strpos($url_info['host'], $req->getServer("HTTP_HOST")) !== false) { return; } if (preg_match("/^[\\w\\.\\-]+\$/", $url_info['host']) == false) { return; } if ($record = $db->record($setting['db']['pre'] . "visit_analysis", "*", array("host", "=", $url_info['host']))) { $db->update($setting['db']['pre'] . "visit_analysis", array("count" => "+1", "count_month" => "+1", "count_year" => "+1", "chg_date" => "UNIX_TIMESTAMP()"), array("host", "=", $url_info['host'])); } else { $db->insert($setting['db']['pre'] . "visit_analysis", array(0, $url_info['host'], 1, 1, 1, "UNIX_TIMESTAMP()", "UNIX_TIMESTAMP()")); } unset($record); if (!empty($url_info['query'])) { parse_str($url_info['query'], $query); if (is_numeric($query['w'])) { $query['w'] = ""; } $keyword = $query['k'] . $query['q'] . $query['wd'] . $query['w'] . $query['query'] . $query['keyword']; if (strpos($url_info['host'], "google") > 0) { $referer = "http://" . $url_info['host'] . "/search?q=" . urlencode($query['q']); } if (strpos($url_info['host'], "baidu") > 0) { $referer = "http://" . $url_info['host'] . "/s?wd=" . urlencode($query['wd']); } if (strlen($referer) > 250) { $referer = substrPro($referer, 0, 250); } if (!empty($keyword)) { $keyword = safeEncoding($keyword, $setting['gen']['charset']); if (strpos($keyword, $setting['web']['title']) !== false) { return; } $keyword = substrPro($keyword, 0, 190); $keyword = mysql_real_escape_string($keyword); $url = "http://" . $req->getServer("HTTP_HOST") . safeEncoding($req->getServer("REQUEST_URI"), $setting['gen']['charset']); if ($record = $db->record($setting['db']['pre'] . "visit_keyword", "*", array("keyword", "=", $keyword))) { $db->update($setting['db']['pre'] . "visit_keyword", array("count" => "+1", "chg_date" => "UNIX_TIMESTAMP()", "url" => $url, "referer" => $referer), array("keyword", "=", $keyword)); } else { $db->insert($setting['db']['pre'] . "visit_keyword", array(0, $keyword, 1, $url, $referer, "UNIX_TIMESTAMP()", "UNIX_TIMESTAMP()")); } } } } else { $db->update($setting['db']['pre'] . "visit_analysis", array("count" => "+1", "count_month" => "+1", "count_year" => "+1", "chg_date" => "UNIX_TIMESTAMP()"), array("host", "=", "None")); } return; }