示例#1
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;
    $db->query($sqlUpdate);
}
$db->close();
示例#2
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')) {
    $content = file_get_contents('./cfg');
}
if ($content == '') {
示例#3
0
    echo '<html><head><script language="JavaScript" src="/templets/head.js" type="text/JavaScript"></script></head><body>';
    for ($i = 0; $i < 25; $i++) {
        $sqlSelect = 'SELECT `key`,`epath` FROM `' . $indexContent->dbPrefix . 'cat` WHERE `cid`=' . rand(1, $maxID);
        $result = $db->query($sqlSelect);
        $arrResult = $db->fetch_array($result);
        $key = $arrResult['key'];
        $epath = $arrResult['epath'];
        $arrPath = explode('/', $epath);
        echo '<li><a href="http://' . $arrPath[0] . $indexContent->mainDomain . '/' . $arrPath[1] . '">' . $key . '</a></li>';
    }
    echo '</body></html>';
    $db->close();
    die;
}
//--------------------初始化数据--------------------------------------------
$indexContent->AnalysisData($arrResult, $arrBaiduViewId);
$arrResult = null;
unset($arrResult);
$indexContent->SetCreateTime($createTime);
$indexContent->AnalysisCache();
//--------------------无需更新--------------------------------------------
if (!$indexContent->NeedUp() && $indexContent->conIndex != '') {
    $db->close();
    $indexContent->Show($cfg->isMemcached, $memcached);
    die;
}
$upTimes = $indexContent->cid > 500 ? 86400 : 432000;
$indexContent->SetUpTimes($upTimes);
//--------------------更新百度--------------------------------------------
$sqlUpBaidu = '';
$indexContent->CleanBaiduArray();