Example #1
0
function write_log($comment = "", $q_str_addon = "")
{
    global $db, $setting, $req;
    $link = "http://" . $req->getServer("SERVER_NAME") . $req->getServer("SCRIPT_NAME");
    $q_str = $req->getServer("QUERY_STRING");
    if (!empty($q_str)) {
        $link .= "?" . $q_str;
    }
    if (!empty($q_str_addon)) {
        $link .= (empty($q_str) ? "?" : "&") . $q_str_addon;
    }
    if (preg_match("/(%[\\w]{2})+/", $link)) {
        $link = urldecode($link);
    }
    if (strlen($link) > 250) {
        $link = substrPro($link, 0, 250);
    }
    $data = array("id" => 0, "user" => $req->getSession('username'), "group" => $req->getSession('usertype'), "time" => $req->getServer('REQUEST_TIME'), "link" => $link, "comment" => $comment);
    $db->insert($setting['db']['pre'] . "modify_log", $data);
    return;
}
Example #2
0
     $the_tag = str_replace("¡¢", ",", $the_tag);
     $the_tag = str_replace("£¬", ",", $the_tag);
     $the_tag = str_replace("¡¡", " ", $the_tag);
     $the_tag = str_replace(" ", "_", $the_tag);
     $the_tag = explode(",", $the_tag);
     $max_count = count($the_tag);
     for ($n = 0; $n < $max_count; $n++) {
         $the_tag[$n] = trim($the_tag[$n], "_");
         $the_tag[$n] = mysql_real_escape_string($the_tag[$n]);
         if (strlen($the_tag[$n]) < 3 || preg_match("/[\\d\\.]+/", $the_tag[$n])) {
             $db_tmp->update($setting['db']['pre_sub'] . "news_show", array("tag" => "replace('" . $the_tag[$n] . ",', '', tag)"), array("news_id", "n=", $record['news_id']));
             $db_tmp->update($setting['db']['pre_sub'] . "news_show", array("tag" => "replace('," . $the_tag[$n] . "', '', tag)"), array("news_id", "n=", $record['news_id']));
             continue;
         }
         if (strlen($the_tag[$n] > 50)) {
             $the_tag[$n] = substrPro($the_tag[$n], 0, 50);
         }
         if ($db_tmp->result($setting['db']['pre_sub'] . "news_tag", "id", array("tag", "=", $the_tag[$n]))) {
             $db_tmp->update($setting['db']['pre_sub'] . "news_tag", array("count" => "+1", "update_date" => "UNIX_TIMESTAMP()"), array("tag", "=", $the_tag[$n]));
         } else {
             $db_tmp->insert($setting['db']['pre_sub'] . "news_tag", array(0, $the_tag[$n], 1, 0, "UNIX_TIMESTAMP()", "UNIX_TIMESTAMP()"));
         }
     }
     if (++$n % 50 === 0) {
         $db_tmp->ReConnect(false, $setting['db']['name']);
     }
 }
 $db_tmp->delete($setting['db']['pre_sub'] . "news_tag", array(array("count", "n<", 2), array("click", "n<", 5, "and"), array("add_date", "f<", "UNIX_TIMESTAMP()-60*60*24*10", "and")));
 $db->Free();
 $n = 1;
 $db->select($setting['db']['pre_sub'] . "news_tag", "id, tag");
Example #3
0
<?php

require "inc.php";
$path_upload = ROOT_PATH . "/" . $setting['path']['upload'] . date("/Y/m/d/");
$script = "";
set_time_limit(0);
$upload = $mystep->getInstance("MyUploader", $path_upload, true);
$upload->DoIt(false);
$watermark = $setting['watermark']['mode'] & 2 ? 1 : 0;
if ($upload->upload_result[0]['error'] == 0) {
    $upload->upload_result[0]['name'] = getString(urldecode($upload->upload_result[0]['name']));
    $ext = strtolower(strrchr($upload->upload_result[0]['name'], "."));
    $name = str_replace($ext, "", $upload->upload_result[0]['name']);
    $upload->upload_result[0]['name'] = substrPro($name, 0, 80) . $ext;
    $ext = str_replace(".", "", $ext);
    $upload->upload_result[0]['new_name'] = str_replace(".upload", "", $upload->upload_result[0]['new_name']);
    $db->insert($setting['db']['pre'] . "attachment", array(0, 0, 0, $upload->upload_result[0]['name'], $upload->upload_result[0]['type'], $upload->upload_result[0]['size'], '', substr($upload->upload_result[0]['new_name'], 0, 13), 0, '', $req->getSession('username'), $watermark));
    $new_id = $db->GetInsertId();
    if ($new_id != 0) {
        $upload->upload_result[0]['att_id'] = $new_id;
        if (strpos($upload->upload_result[0]['type'], "image") === 0) {
            $upload->MakeDir("{$path_upload}/preview/");
            $img_info = GetImageSize("{$path_upload}/" . $upload->upload_result[0]['new_name']);
            $the_width = $img_info[0];
            $the_height = $img_info[1];
            $zoom = 400;
            if ($the_width > $zoom) {
                $the_height *= $zoom / $the_width;
                $the_width = (int) $zoom;
                img_thumb($path_upload . "/" . $upload->upload_result[0]['new_name'], $the_width, $the_height, $path_upload . "/preview/" . $upload->upload_result[0]['new_name']);
            } else {
Example #4
0
 unset($_POST['setop_mode']);
 $get_remote_file = $_POST['get_remote_file'];
 unset($_POST['get_remote_file']);
 $db->ReConnect(true, $setting['db']['name']);
 if ($method == "add_ok") {
     $log_info = $setting['language']['admin_art_content_add'];
     $_POST['add_user'] = $req->getSession("username");
     $_POST['add_date'] = "now()";
     $tag = explode(",", $_POST['tag']);
     $max_count = count($tag);
     for ($n = 0; $n < $max_count; $n++) {
         $tag[$n] = trim($tag[$n], "_");
         if (strlen(trim($tag[$n])) < 2) {
             continue;
         }
         $tag[$n] = substrPro($tag[$n], 0, 15);
         $tag[$n] = mysql_real_escape_string($tag[$n]);
         if ($db->result($setting['db']['pre_sub'] . "news_tag", "id", array("tag", "=", $tag[$n]))) {
             $db->update($setting['db']['pre_sub'] . "news_tag", array("count" => "+1", "update_date" => "UNIX_TIMESTAMP()"), array("tag", "=", $tag[$n]));
         } else {
             $db->insert($setting['db']['pre_sub'] . "news_tag", array(0, $tag[$n], 1, 0, "UNIX_TIMESTAMP()", "UNIX_TIMESTAMP()"));
         }
     }
     $db->insert($setting['db']['pre_sub'] . "news_show", $_POST);
     $news_id = $db->GetInsertId();
 } else {
     $log_info = $setting['language']['admin_art_content_edit'];
     unset($_POST['news_id']);
     $db->delete($setting['db']['pre_sub'] . "news_detail", array("news_id", "n=", $news_id));
     $db->update($setting['db']['pre_sub'] . "news_show", $_POST, array("news_id", "n=", $news_id));
     delCacheFile($news_id, $setting_sub["info"]['web_id']);
function snatchGetList($record, &$info)
{
    global $db, $setting, $req;
    $idx = $req->getCookie("ns_idx");
    if (empty($idx)) {
        $idx = 0;
    }
    for ($i = $idx, $m = count($info['newList']); $i < $m; $i++) {
        if (isset($info['para']['pre_max']) && $i - $idx >= $info['para']['pre_max']) {
            break;
        }
        $record['subject'] = $info['newList'][$i][1];
        $record['original'] = "搜狐网";
        $record['url'] = $info['newList'][$i][2];
        $record['add_date'] = date("Y") . "/" . $info['newList'][$i][3];
        $record['item_2'] = $info['newList'][$i][4];
        if (strpos($record['url'], ".sohu.com") === false) {
            continue;
        }
        if ($content = GetRemoteContent($record['url'], $info['header'])) {
            if (preg_match("/来源:<span.+?>(.+?)<\\/span>/i", $content, $matches)) {
                $record['original'] = strip_tags($matches[1]);
                unset($matches);
            }
            if (preg_match("/<meta name=\"keywords\" content=\"(.+?)\">/i", $content, $matches)) {
                $record['item_3'] = str_replace(" ", ",", $matches[1]);
                unset($matches);
            }
            if (preg_match("/<meta name=\"description\" content=\"(.+?)\">/i", $content, $matches)) {
                $record['item_4'] = str_replace(" ", ",", $matches[1]);
                $record['item_4'] = substrPro($record['item_4'], 0, 230);
                unset($matches);
            }
            $flag = false;
            if (preg_match("/<\\!\\-\\- 正文 st \\-\\->[\r\n\\s]+<div.+?>(.+?)<\\/div>[\r\n\\s]+<\\!\\-\\- 正文 end \\-\\->/is", $content, $matches)) {
                $record['content'] = $matches[1];
                $record['content'] = preg_replace("/<div class\\=\"tagIntg.+?<\\/div>/is", "", $record['content']);
                $record['content'] = preg_replace("/<div class\\=\"tagHotg.+?<\\/div>/is", "", $record['content']);
                $record['content'] = preg_replace("/<div class\\=\"editer.+?<\\/div>/is", "", $record['content']);
                unset($matches);
                $flag = true;
            } elseif (preg_match("/<div class\\=\"textcont\" id\\=\"textcont\">(.+?)<\\/div>/is", $content, $matches)) {
                $cur_content = array();
                $cur_content[0] = $matches[1];
                $cur_content[0] = preg_replace("/<p class\\=\"editUsr.+?<\\/p>/is", "", $cur_content[0]);
                $cur_content[0] = preg_replace("/<p>.+?<p>/is", "<p>", $cur_content[0]);
                $cur_content[0] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $cur_content[0]);
                $cur_content[0] = preg_replace("/^[\r\n\\s]+/is", "", $cur_content[0]);
                $cur_content[0] = preg_replace("/[\r\n\\s]+\$/is", "", $cur_content[0]);
                unset($matches);
                if (preg_match("/<img id\\=\"slide_pic\" src\\=\"(.+?)\" alt\\=\"(.+?)\".*?>/is", $content, $matches)) {
                    $cur_content[0] = "<p>" . $matches[0] . "</p>\n" . $cur_content[0];
                }
                unset($matches);
                if (preg_match("/<span id\\=\"pageNum\">1\\/(\\d+)<\\/span>/is", $content, $matches)) {
                    $pages = $matches[1];
                    unset($matches);
                    for ($n = 1; $n < $pages; $n++) {
                        $cur_url = preg_replace("/(\\.\\w+)\$/i", "_" . $n . "\\1", $record['url']);
                        if ($page_content = GetRemoteContent($cur_url, $info['header'])) {
                            if (preg_match("/<div class\\=\"textcont\" id\\=\"textcont\">(.+?)<\\/div>/is", $page_content, $matches)) {
                                $cur_content[$n] = $matches[1];
                                $cur_content[$n] = preg_replace("/<p class\\=\"editUsr.+?<\\/p>/is", "", $cur_content[$n]);
                                $cur_content[$n] = preg_replace("/<p>.+?<p>/is", "<p>", $cur_content[$n]);
                                $cur_content[$n] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $cur_content[$n]);
                                $cur_content[$n] = preg_replace("/^[\r\n\\s]+/is", "", $cur_content[$n]);
                                $cur_content[$n] = preg_replace("/[\r\n\\s]+\$/is", "", $cur_content[$n]);
                            }
                            unset($matches);
                            if (preg_match("/<img id\\=\"slide_pic\" src\\=\"(.+?)\" alt\\=\"(.+?)\".*?>/is", $page_content, $matches)) {
                                $cur_content[$n] = "<p>" . $matches[0] . "</p>\n" . $cur_content[$n];
                            }
                            unset($matches);
                        }
                    }
                }
                $record['content'] = implode("<!-- pagebreak -->", $cur_content);
                $flag = true;
            } elseif (preg_match("/<div.+?id\\=\"contentText\">(.+?)<\\/div>/is", $content, $matches)) {
                $record['content'] = $matches[1];
                $record['content'] = preg_replace("/<div class\\=\"editer.+?<\\/div>/is", "", $record['content']);
                $record['content'] = preg_replace("/<p>.+?<p>/is", "<p>", $record['content']);
                $record['content'] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $record['content']);
                $record['content'] = preg_replace("/^[\r\n\\s]+/is", "", $record['content']);
                $record['content'] = preg_replace("/[\r\n\\s]+\$/is", "", $record['content']);
                unset($matches);
                $flag = true;
            } elseif (preg_match("/<div id\\=\"news_c\".+?>(.+?)<div id\\=\"news_s\"/is", $content, $matches)) {
                $record['content'] = $matches[1];
                unset($matches);
                $flag = true;
            } else {
                snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="failed" style="color:red;">失败!</span></div>');
            }
            if ($flag) {
                if ($db->record($setting['db']['pre'] . "news_snatch", "id", array("url", "=", $record['url'])) === false) {
                    $record['content'] = preg_replace("/<script.+?<\\/script>/is", "", $record['content']);
                    $record['content'] = preg_replace("/<style.+?<\\/style>/is", "", $record['content']);
                    $record['content'] = preg_replace("/<form.+?<\\/form>/is", "", $record['content']);
                    $record['content'] = preg_replace("/<iframe.+?<\\/iframe>/is", "", $record['content']);
                    $record['content'] = preg_replace("/^[\r\n\\s]+/is", "", $record['content']);
                    $record['content'] = preg_replace("/[\r\n\\s]+\$/is", "", $record['content']);
                    $record['content'] = preg_replace("/延伸阅读.+\$/", "", $record['content']);
                    $record['content'] = preg_replace("/<DIV class\\=\"tvsubject.+\$/", "", $record['content']);
                    $record['content'] = str_replace("微博推荐", "", $record['content']);
                    $record['content'] = str_replace("我来纠错", "", $record['content']);
                    $record['content'] = str_replace('<div class="line"></div>', "", $record['content']);
                    $record['content'] = preg_replace("/<div class\\=\"stockTrends.+?<\\/div>/s", "", $record['content']);
                    $record['content'] = preg_replace("/<div class\\=\"shareIn.+?<\\/div>/s", "", $record['content']);
                    $record['content'] = preg_replace("/[\r\n]+<div class\\=\"muLink.+?<\\/div>[\r\n]+/", "", $record['content']);
                    $record['content'] = preg_replace("/<DIV class\\=\"tvsubject.+\$/s", "", $record['content']);
                    if (preg_match("/<img.+?src=(.?)(http.+?)\\1.+?>/is", $record['content'], $matches)) {
                        $record['item_5'] = $matches[2];
                    } else {
                        $record['item_5'] = "";
                    }
                    if ($record['item_5'] == "http://images.sohu.com/ccc.gif" || $record['item_5'] == "http://photo.sohu.com/20040809/Img221437781.gif" || $record["item_5"] == "http://photocdn.sohu.com/20090828/dot.gif") {
                        $record['item_5'] = "";
                    }
                    snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="succeed" style="color:green;">成功!</span></div>');
                    $db->insert($setting['db']['pre'] . "news_snatch", $record);
                } else {
                    snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> <span class="duplicate" style="color:black;">已存在!</span></div>');
                }
            }
        } else {
            snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="failed" style="color:red;">失败!</span></div>');
        }
        $req->setCookie("ns_idx", $i, 86400);
    }
    if ($i >= $m) {
        $req->setCookie("ns_idx");
    }
    return true;
}
Example #6
0
<?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);
Example #7
0
 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;
 }