%PDF- %PDF-
| Direktori : /www/awstats/ |
| Current File : /www/awstats/stats.php |
<?php
include "/www/varak.net/practiscore.varak.net/lib/dibi.phar";
function getmicrotime()
{
list($usec,$sec)=explode(" ",microtime());
return ((double)$usec+(double)$sec);
}
dibi::connect([
'driver' => 'sqlite3',
'charset' => 'utf8',
'database' => '/home/waritko/awstats/stats.sqlite',
'profiler' => [
'run' => TRUE,
'file' => '/home/waritko/awstats/stats.log',
],
]);
$start = getmicrotime();
$txt = "";
$f = fopen( 'php://stdin', 'r' );
while( $line = fgets( $f ) )
{
echo $line;
$txt .= $line;
}
fclose( $f );
$end = getmicrotime();
preg_match_all("/Found ([0-9]+) new qualified/m", $txt, $matches);
//$data = json_decode(file_get_contents("/home/waritko/awstats/stats.json"));
$conf = trim($argv[1]);
//if(!isset($data->$conf))
//{
// $data->$conf = new stdClass();
// $data->$conf->stats = new stdClass();
// $data->$conf->lines = 0;
// $data->$conf->time = (double)0;
//}
//$date = date("Y-m-d");
//$data->$conf->stats->$date = new stdClass();
//$data->$conf->stats->$date->lines = (int)$matches[1][0];
//$data->$conf->stats->$date->time = (double)($end - $start);
//$data->$conf->lines += (int)$matches[1][0];
//$data->$conf->time += (double)($end - $start);
//file_put_contents("/home/waritko/awstats/stats.json", json_encode($data, JSON_PRETTY_PRINT));
$data = array(
"date" => date("Y-m-d"),
"domain" => $conf,
"lines" => (int)$matches[1][0],
"elapsed" => (double)($end - $start)
);
dibi::query("INSERT INTO [stats]", $data);