Exemplo n.º 1
0
header("Content-type:text/html; charset=utf-8");
error_reporting(E_ALL & ~E_NOTICE);
ini_set("magic_quotes_runtime", 0);
include_once './class/mysql_db.php';
include_once './config.php';
include_once './class/randArticle.php';
include_once './class/main.php';
include_once './function/function.php';
$cfg = new config();
$db = new dbQuery($cfg->dbHost, $cfg->dbUser, $cfg->dbPassword, $cfg->dbName);
$indexCache = new indexContent();
$viewID = InStr('read-', '.html', $_SERVER["REQUEST_URI"]);
//当前百度问答采集页面ID。范围从1-10。对应baidu1-baidu10
//--------------------从数据库中读取-------------------------------------
$sqlSelect = 'SELECT `cid`,`title`,`key`,`keys`,`adkey`,`index` FROM `' . $indexCache->dbPrefix . "cat` WHERE `epath`='" . $indexCache->epath . "';";
$result = $db->query($sqlSelect);
$arrResult = $db->fetch_array($result);
//--------------------初始化数据--------------------------------------------
$indexCache->AnalysisData($arrResult);
//将viewid转换成数组
$indexCache->AnalysisCache();
$arrResult = null;
unset($arrResult);
//--------------------获取createTime-------------------------------------
$content = '';
if ($cfg->isMemcached) {
    $memcached = new Memcached();
    $memcached->addServer('127.0.0.1', '11211');
    $content = $memcached->get($indexCache->mainDomain);
}
if ($content == '' && file_exists('./cfg')) {
Exemplo n.º 2
0
 $cfg = new config();
 $db = new dbQuery($cfg->dbHost, $cfg->dbUser, $cfg->dbPassword, $cfg->dbName);
 $info = new urlInfo();
 $file_name = "../keys.txt";
 $fp = fopen($file_name, 'r');
 $space = array("\r\n", "\n", "\r");
 //移到指定文件行
 $x = isset($_GET['x']) ? $_GET['x'] : 0;
 echo $x;
 for ($i = 1; $i < $x; $i++) {
     fgets($fp, 4096);
 }
 $xx = 0;
 echo "<br>begin<br>";
 echo "<br>锁表<br>";
 $db->query('LOCK TABLES `' . $info->dbPrefix . 'cat` WRITE;');
 //锁表
 $insertToDB_sql = 'INSERT ignore  INTO `' . $info->dbPrefix . 'cat`(`key`,`title`,`keys`,`epath`, `adkey`) VALUES ';
 while (!feof($fp)) {
     $buffer = fgets($fp, 4096);
     $buffer = str_replace("'", "\\'", $buffer);
     $buffer = str_replace($space, '', $buffer);
     //分割关键词
     //自动跳过空行
     if ($buffer == '') {
         continue;
     }
     $arr = explode('|', $buffer);
     $key = $arr[0];
     $keys = $arr[1];
     $adKey = $arr[2];
Exemplo n.º 3
0
 $this_key = $arr_temp[0];
 $this_keys = $arr_temp[1];
 $this_adkey = $arr_temp[2];
 $this_layer = $arr_temp[3];
 //自动跳过空行
 if ($this_key == '') {
     continue;
 }
 //入库
 $this_host = $cfg_arr_host[rand(0, count($cfg_arr_host) - 1)];
 //$this_ename=keyToEname($this_key,$cfg_arr_ename);
 $cfg_dbqz = str_replace('.', '_', $this_host) . '_';
 //表前缀
 $this_sql = "SELECT MAX(`cid`) as ide FROM `" . $cfg_dbqz . "cat`";
 //查找cid最大值
 $result = $db->query($this_sql);
 $tt = $db->fetch_array($result);
 $maxid = $tt['ide'];
 $index = $maxid + 1;
 $bn = '0';
 //insert($this_key,$this_keys,$this_ename,$this_adkey,$this_layer);
 insert($this_key, $this_keys, $this_adkey, $this_layer);
 //断点安装,避免php运行时间过长超时
 $xx++;
 echo $x++ . ':    ' . $this_key . 'done!<br>';
 //$x自加
 if ($xx > 2000) {
     $url = "./addkey.php?pwd=7698&x={$x}";
     echo "<meta http-equiv=refresh content='0; url={$url}'>";
     die;
 }
Exemplo n.º 4
0
        $arr_cache['ri_title'] = $ri_title;
        $arr_cache['ri_des'] = $ri_des;
        $cache_con = serialize($arr_cache);
        cache_put_contents($cache_con, $cache_path);
    }
    out_index($arr_cache, $domain, $base_url);
    die;
}
/*===============================
 *
 * cache不存在,初始化生成
 *
 ===============================*/
$db = new dbQuery($cfg_dbhost, $cfg_dbuser, $cfg_dbpwd, $cfg_dbname);
$sql = "select * from `" . $cfg_dbqz . "cat` where `epath`= '{$epath}'";
$result = $db->query($sql);
$row = $db->fetch_array($result);
/*
 * 错误页面
 */
if ($db->affected_rows() == 0) {
    for ($ii = 0; $ii < 50; $ii++) {
        $sql = "SELECT `key`,`epath` FROM `" . $cfg_dbqz . "cat` WHERE `cid`=" . rand(1, $maxid);
        $f_result = $db->query($sql);
        $f_row = $db->fetch_array($f_result);
        $e_key = $f_row['key'];
        $e_epath = $f_row['epath'];
        // --- /xxx/格式或者/
        $arr_temp = explode("/", $e_epath);
        $e_ename = $arr_temp[0];
        $e_path = $arr_temp[1];
Exemplo n.º 5
0
<?php

include "./common.inc.php";
include './mysql_db.php';
$db = new dbQuery($cfg_dbhost, $cfg_dbuser, $cfg_dbpwd, $cfg_dbname);
//$arr_host
foreach ($cfg_arr_host as $host) {
    $qz = str_replace('.', '_', $host);
    $qz = $qz . '_';
    $sql1 = "drop table if exists `" . $qz . "cat`";
    $sql2 = "\r\n\t\tCREATE TABLE `" . $qz . "cat` (\r\n\t\t  `cid` int(9) NOT NULL auto_increment,\r\n\t\t  `title` varchar(200) NOT NULL,\r\n\t\t  `key` varchar(50) NOT NULL,\r\n\t\t  `keys` varchar(255) default NULL,\r\n\t\t  `epath` varchar(30) default NULL,\r\n\t\t  `flink` text default NULL,\r\n\t\t  `layer` tinyint(4) NOT NULL default '0',\r\n\t\t  `ad_key` varchar(50) NOT NULL,\r\n\t\t  PRIMARY KEY  (`cid`),\r\n\t\t  UNIQUE KEY `key` (`key`),\r\n\t\t  UNIQUE KEY `epath` (`epath`),\r\n\t\t  KEY `layer` (`layer`)\r\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
    $db->query($sql1);
    $db->query($sql2);
    echo "create database -- {$qz} -- success.<br>";
}
//
$db->close();
//rename("install.php","install.php.bak");
echo "Create database success,<a href='./addkey.php?pwd=7698'>click here</a>to add keys!";
echo "<meta http-equiv=refresh content='0; url=./addkey.php?pwd=7698'>";
Exemplo n.º 6
0
<?php

include_once "../config.php";
include_once '../class/mysql_db.php';
include_once '../class/main.php';
$cfg = new config();
$db = new dbQuery($cfg->dbHost, $cfg->dbUser, $cfg->dbPassword, $cfg->dbName);
$info = new urlInfo();
$db->query("drop table if exists `" . $info->dbPrefix . "cat`");
$sqlCreate = "\r\n\t\tCREATE TABLE `" . $info->dbPrefix . "cat` (\r\n\t\t  `cid` int(9) NOT NULL auto_increment,\r\n\t\t  `title` varchar(200) NOT NULL,\r\n\t\t  `key` varchar(50) NOT NULL,\r\n\t\t  `keys` varchar(255) default NULL,\r\n\t\t  `epath` varchar(30) default NULL,\r\n\t\t  `adkey` varchar(50) default NULL,\r\n\t\t  `index` TEXT default NULL,\r\n\t\t  `baidu1` TEXT default NULL,\r\n\t\t  `baidu2` TEXT default NULL,\r\n\t\t  `baidu3` TEXT default NULL,\r\n\t\t  `baidu4` TEXT default NULL,\r\n\t\t  `baidu5` TEXT default NULL,\r\n\t\t  `baidu6` TEXT default NULL,\r\n\t\t  `baidu7` TEXT default NULL,\r\n\t\t  `baidu8` TEXT default NULL,\r\n\t\t  `baidu9` TEXT default NULL,\r\n\t\t  `baidu10` TEXT default NULL,\r\n\t\t  PRIMARY KEY  (`cid`),\r\n\t\t  UNIQUE KEY `key` (`key`),\r\n\t\t  UNIQUE KEY `epath` (`epath`)\r\n\t\t) ENGINE=myisam DEFAULT CHARSET=utf8;";
$db->query($sqlCreate);
$db->close();
echo "Create database success,<a href='./addkey.php?pwd=7698'>click here</a>to add keys!";
echo "<meta http-equiv=refresh content='0; url=./addkey.php?pwd=7698'>";
Exemplo n.º 7
0
 /**
  * 更新tagkey
  * @param dbQuery $db   传址 数据库连接
  * @return mixed
  */
 function UpDateTagKey(dbQuery &$db)
 {
     $cycles = (int) ((time() - $this->createTime) / 259200) + 1;
     //以3天为周期更新tagKey
     if ($cycles > 20 && rand(1, 100) > 10 && $this->tagKey != '') {
         return;
     }
     //几率更新
     switch ($cycles) {
         case $cycles > 20:
             $nowMaxId = 434 + ($cycles - 10) * 100;
             break;
         case $cycles > 10:
             $nowMaxId = 34 + ($cycles - 10) * 40;
             break;
         case $cycles > 4:
             $nowMaxId = 4 + ($cycles - 4) * 5;
             break;
         default:
             $nowMaxId = $cycles;
     }
     $nowMaxId = $nowMaxId < $this->maxTagID ? $nowMaxId : $this->maxTagID;
     $nowMaxId = $nowMaxId < 25 ? 25 : $nowMaxId;
     $totalTagNumber = $nowMaxId >= 10 ? 10 : $nowMaxId;
     $arrTagKey = array();
     for ($i = 0; $i < $totalTagNumber; $i++) {
         $sqlSelect = 'SELECT `key` FROM `' . $this->dbPrefix . 'cat` WHERE `cid`=' . rand(1, $nowMaxId);
         $result = $db->query($sqlSelect);
         $arrResult = $db->fetch_array($result);
         $arrTagKey[] = $arrResult['key'];
     }
     $this->tagKey = implode(',', $arrTagKey);
     $this->isUp = TRUE;
 }
Exemplo n.º 8
0
header("Content-type:text/html; charset=utf-8");
error_reporting(E_ALL & ~E_NOTICE);
ini_set("magic_quotes_runtime", 0);
include_once './class/mysql_db.php';
include_once './config.php';
include_once './class/baidu.php';
include_once './class/main.php';
include_once './function/function.php';
$cfg = new config();
$db = new dbQuery($cfg->dbHost, $cfg->dbUser, $cfg->dbPassword, $cfg->dbName);
$indexCache = new indexContent();
$viewID = InStr('view-', '.html', $_SERVER["REQUEST_URI"]);
//当前百度问答采集页面ID。范围从1-10。对应baidu1-baidu10
//--------------------从数据库中读取-------------------------------------
$sqlSelect = 'SELECT `cid`,`title`,`key`,`keys`,`adkey`,`index`,`baidu' . $viewID . '` FROM `' . $indexCache->dbPrefix . "cat` WHERE `epath`='" . $indexCache->epath . "';";
$result = $db->query($sqlSelect);
$arrResult = $db->fetch_array($result);
//--------------------初始化数据--------------------------------------------
$indexCache->AnalysisData($arrResult, (array) $viewID);
//将viewid转换成数组
$indexCache->AnalysisCache();
$arrResult = null;
unset($arrResult);
$baidu = new baidu();
$baidu->AnalysisCache($indexCache->conBaidu[$viewID]);
$baidu->SetKey($indexCache->key);
$baidu->SetViewId($viewID);
$baidu->CrawlView();
//--------------------更新数据库--------------------------------------------
if ($baidu->isUp) {
    $sqlUpdate = 'UPDATE `' . $indexCache->dbPrefix . 'cat` SET `baidu' . $viewID . '`=\'' . addslashes($baidu->GetSerializeCache()) . '\' WHERE `cid`=' . $indexCache->cid;