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