mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 19:00:12 +01:00
updated accounting
This commit is contained in:
parent
60e41da7be
commit
4bc2dadc15
@ -3,7 +3,7 @@
|
|||||||
$webuidir = '';
|
$webuidir = '';
|
||||||
$process_all = false;
|
$process_all = false;
|
||||||
$start = NULL;
|
$start = NULL;
|
||||||
$end = NULL;
|
$stop = NULL;
|
||||||
$timestart = microtime(true);
|
$timestart = microtime(true);
|
||||||
|
|
||||||
// get options from command line
|
// get options from command line
|
||||||
@ -11,7 +11,7 @@ $opts = 'h::';
|
|||||||
$lopts = array(
|
$lopts = array(
|
||||||
'webui:',
|
'webui:',
|
||||||
'start::',
|
'start::',
|
||||||
'end::',
|
'stop::',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $options = getopt( $opts, $lopts ) )
|
if ( $options = getopt( $opts, $lopts ) )
|
||||||
@ -31,12 +31,14 @@ if ( $options = getopt( $opts, $lopts ) )
|
|||||||
{
|
{
|
||||||
display_help();
|
display_help();
|
||||||
exit;
|
exit;
|
||||||
} elseif ( isset($options['start']) )
|
}
|
||||||
|
if ( isset($options['start']) )
|
||||||
{
|
{
|
||||||
$start = $options['start'];
|
$start = $options['start'];
|
||||||
} elseif ( isset($options['end']) )
|
}
|
||||||
|
if ( isset($options['stop']) )
|
||||||
{
|
{
|
||||||
$end = $options['end'];
|
$stop = $options['stop'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
display_help();
|
display_help();
|
||||||
@ -72,16 +74,15 @@ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|||||||
|
|
||||||
extract($language->data);
|
extract($language->data);
|
||||||
|
|
||||||
//$day_to_process = strtotime($day_to_process);
|
$records = $messagestats->run_counters($start,$stop);
|
||||||
$records = $messagestats->run_counters($start,$end);
|
|
||||||
|
|
||||||
$timeend = microtime(true);
|
$timeend = microtime(true);
|
||||||
$timegone = $timeend - $timestart;
|
$timegone = $timeend - $timestart;
|
||||||
|
|
||||||
echo("\nFinished Executing Statistics Generation\n");
|
echo("\nFinished Executing Statistics Generation\n");
|
||||||
echo("*************************************************\n");
|
echo("*************************************************\n");
|
||||||
echo("Start Date: ".date("d M Y",$records['starttimestamp'])."\n");
|
echo("Start Date: ".date(DATE_TEMPLATE,$records['starttimestamp'])."\n");
|
||||||
echo("Stop Date: ".date("d M Y",$records['endtimestamp'])."\n");
|
echo("Stop Date: ".date(DATE_TEMPLATE,$records['stoptimestamp'])."\n");
|
||||||
echo("Removed ".$records['deletedstats']." records\n");
|
echo("Removed ".$records['deletedstats']." records\n");
|
||||||
echo("Added ".$records['addedstats']." records\n");
|
echo("Added ".$records['addedstats']." records\n");
|
||||||
echo("Completed Run in ".$timegone." seconds\n\n");
|
echo("Completed Run in ".$timegone." seconds\n\n");
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
class ModelAccountingAccounting extends Model
|
class ModelAccountingAccounting extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
public function run_counters( $start=NULL, $end = NULL )
|
public function run_counters( $start=NULL, $stop = NULL )
|
||||||
{
|
{
|
||||||
$now = time();
|
$now = time();
|
||||||
$counter = array();
|
$counter = array();
|
||||||
$accepteddomains = array_flip( $this->__getAcceptedDomains() );
|
$accepteddomains = array_flip( $this->__getAcceptedDomains() );
|
||||||
$return = array(
|
$return = array(
|
||||||
'starttimestamp' => 0,
|
'starttimestamp' => 0,
|
||||||
'endtimestamp' => 0,
|
'stoptimestamp' => 0,
|
||||||
'addedstats' => 0,
|
'addedstats' => 0,
|
||||||
'deletedstats' => 0,
|
'deletedstats' => 0,
|
||||||
);
|
);
|
||||||
@ -24,23 +24,23 @@ class ModelAccountingAccounting extends Model
|
|||||||
$start = $this->__decodeDate( "00:00:00" );
|
$start = $this->__decodeDate( "00:00:00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !is_null($end) )
|
if ( !is_null($stop) )
|
||||||
{
|
{
|
||||||
$end = $this->__decodeDate( $end );
|
$stop = $this->__decodeDate( $stop );
|
||||||
$end = $end + 86400;
|
$stop = $stop + 86400;
|
||||||
} elseif ( is_null($end) )
|
} elseif ( is_null($stop) )
|
||||||
{
|
{
|
||||||
//if we are passed nothing, operate on today
|
//if we are passed nothing, operate on today
|
||||||
$end = $this->__decodeDate( "00:00:00" );
|
$stop = $this->__decodeDate( "00:00:00" );
|
||||||
$end = $end + 86400;
|
$stop = $stop + 86400;
|
||||||
}
|
}
|
||||||
|
|
||||||
$return['starttimestamp'] = $start;
|
$return['starttimestamp'] = $start;
|
||||||
$return['endtimestamp'] = $end;
|
$return['stoptimestamp'] = $stop;
|
||||||
|
|
||||||
// run query to return all messages
|
// run query to return all messages
|
||||||
$tousers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`to`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= '.$start.' AND `sent` < '.$end.' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `to`;');
|
$tousers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`to`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= '.$start.' AND `sent` < '.$stop.' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `to`;');
|
||||||
$fromusers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`from`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= '.$start.' AND `sent` < '.$end.' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `from`;');
|
$fromusers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`from`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= '.$start.' AND `sent` < '.$stop.' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `from`;');
|
||||||
|
|
||||||
// process results from above four queries
|
// process results from above four queries
|
||||||
if($tousers->num_rows > 0)
|
if($tousers->num_rows > 0)
|
||||||
@ -85,7 +85,7 @@ class ModelAccountingAccounting extends Model
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added",date(DATE_TEMPLATE, $return['starttimestamp']),date(DATE_TEMPLATE, $return['endtimestamp']),$return['deletedstats'],$return['addedstats'])); }
|
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added",date(DATE_TEMPLATE, $return['starttimestamp']),date(DATE_TEMPLATE, $return['stoptimestamp']),$return['deletedstats'],$return['addedstats'])); }
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user