コード例 #1
0
<?php

/**
 * READ THIS
 * to use this file for reporting, due to the fact APC is shared amongst apache processes and is not shared with CLI php
 * code, we need to ping this page via apache.
 * The cron job should do this
 * wget http://192.168.240.70/crawlerstrunk/cronjobs/googleproxyreporter.php
 * for every once in a while you want the data to be collected
 *
 */
$_home = '/home/eyezeek/crawlers/www/crawlerstrunk';
include_once "{$_home}/crawler/engine/classes/Config.php";
include_once "{$_home}/crawler/engine/classes/DBAdapter2.class.php";
include_once "{$_home}/googleproxy/MemoryData.php";
$conf = new Config("/home/eyezeek/db.conf", "ini");
$o_db = new DBAdapter2(array('host' => $conf->crawler->host, 'username' => 'proxyuser', 'password' => 'E.Z.2011', 'schema' => 'proxy_reports'));
$_numRequests = MemoryData::getNumRequestsResetCounter(true);
$_sql = "INSERT INTO reports (`hourofreport`, `requests`) VALUES (now(), {$_numRequests}) ";
try {
    $tmpArr = array();
    $o_db->executeSQL($_sql, $tmpresult, $tmpArr);
    // if successully updated the DB, reset the counter
    $_numRequests = MemoryData::getNumRequestsResetCounter();
} catch (DBAdapter2Exception $e) {
    echo $e->getMessage();
}