mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:17:02 +02:00
webui fixes
This commit is contained in:
99
webui/controller/accounting/accounting.php
Normal file
99
webui/controller/accounting/accounting.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerAccountingAccounting extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
$this->id = "content";
|
||||
$this->template = "accounting/accounting.tpl";
|
||||
$this->layout = "common/layout";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('user/user');
|
||||
$this->load->model('group/group');
|
||||
$this->load->model('accounting/accounting');
|
||||
$counters = new ModelAccountingAccounting();
|
||||
|
||||
$this->data['page'] = 0;
|
||||
$this->data['page_len'] = get_page_length();
|
||||
$this->data['sort'] = 'item';
|
||||
$this->data['sorttype'] = 0;
|
||||
$this->data['order'] = 0;
|
||||
|
||||
// get page
|
||||
if(isset($this->request->get['page']) && is_numeric($this->request->get['page']) && $this->request->get['page'] > 0) {
|
||||
$this->data['page'] = $this->request->get['page'];
|
||||
}
|
||||
|
||||
// get sort field
|
||||
if ( isset($this->request->get['sort']) ) {
|
||||
if(@$this->request->get['sort'] == "item") { $this->data['sort'] = 'item'; }
|
||||
if(@$this->request->get['sort'] == "oldest") { $this->data['sort'] = 'oldest'; $this->data['sorttype'] = 1; }
|
||||
if(@$this->request->get['sort'] == "newest") { $this->data['sort'] = 'newest'; $this->data['sorttype'] = 1; }
|
||||
if(@$this->request->get['sort'] == "sent") { $this->data['sort'] = 'sent'; }
|
||||
if(@$this->request->get['sort'] == "sentsize") { $this->data['sort'] = 'sentsize'; $this->data['sorttype'] = 2; }
|
||||
if(@$this->request->get['sort'] == "sentavg") { $this->data['sort'] = 'sentavg'; $this->data['sorttype'] = 2; }
|
||||
if(@$this->request->get['sort'] == "recd") { $this->data['sort'] = 'recd'; }
|
||||
if(@$this->request->get['sort'] == "recdsize") { $this->data['sort'] = 'recdsize'; $this->data['sorttype'] = 2; }
|
||||
if(@$this->request->get['sort'] == "recdavg") { $this->data['sort'] = 'recdavg'; $this->data['sorttype'] = 2; }
|
||||
}
|
||||
|
||||
// get sort order
|
||||
if(isset($this->request->get['order']) && is_numeric($this->request->get['order'])) {
|
||||
$this->data['order'] = $this->request->get['order'];
|
||||
}
|
||||
|
||||
// get type of accounting view
|
||||
if(@$this->request->get['view'] == "email") {
|
||||
$this->data['view'] = 'email';
|
||||
$this->data['viewname'] = "Emails";
|
||||
$this->data['accounting'] = $counters->get_accounting('email',$this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||
$this->data['total_records'] = $counters->count_accounting('email');
|
||||
}
|
||||
|
||||
if(@$this->request->get['view'] == "domain") {
|
||||
$this->data['view'] = 'domain';
|
||||
$this->data['viewname'] = "Domains";
|
||||
$this->data['accounting'] = $counters->get_accounting('domain',$this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||
$this->data['total_records'] = $counters->count_accounting('domain');
|
||||
}
|
||||
|
||||
if($this->data['accounting']) {
|
||||
foreach($this->data['accounting'] as $id=>$row) {
|
||||
if($this->data['sorttype'] == 0){
|
||||
$this->data['accounting'][$id]['display'] = $row[$this->data['sort']];
|
||||
}
|
||||
if($this->data['sorttype'] == 1){
|
||||
$this->data['accounting'][$id]['display'] = date("d M Y",$row[$this->data['sort']]);
|
||||
}
|
||||
if($this->data['sorttype'] == 2){
|
||||
$this->data['accounting'][$id]['display'] = nice_size($row[$this->data['sort']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->document->title = $this->data['text_accounting'];
|
||||
|
||||
$this->data['today'] = time()-(time()%86400);
|
||||
$this->data['days'] = 15;
|
||||
|
||||
$this->data['timespan'] = @$this->request->get['timespan'];
|
||||
$this->data['uid'] = @$this->request->get['uid'];
|
||||
|
||||
$this->data['admin_user'] = Registry::get('admin_user');
|
||||
$this->data['readonly_admin'] = Registry::get('readonly_admin');
|
||||
|
||||
$this->data['prev_page'] = $this->data['page'] - 1;
|
||||
$this->data['next_page'] = $this->data['page'] + 1;
|
||||
|
||||
$this->data['total_pages'] = floor($this->data['total_records'] / $this->data['page_len']);
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -6,6 +6,9 @@ class ControllerHealthWorker extends Controller {
|
||||
|
||||
public function index(){
|
||||
|
||||
$archivesizeraw = $sqlsizeraw = $sphinxsizeraw = 0;
|
||||
$averagemessagesweekraw = $averagemessagesmonthraw = $averagemessagesizeraw = $averagesizedayraw = $averagesqlsizeraw = $averagesphinxsizeraw = 0;
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "health/worker.tpl";
|
||||
$this->layout = "common/layout-empty";
|
||||
@ -60,7 +63,9 @@ class ControllerHealthWorker extends Controller {
|
||||
$db->select_db($db->database);
|
||||
|
||||
|
||||
list($this->data['archive_size'], $this->data['counters']) = $this->model_stat_counter->get_counters();
|
||||
list($archivesizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters();
|
||||
|
||||
$this->data['archive_size'] = nice_size($archivesizeraw, ' ');
|
||||
|
||||
$this->data['prefix'] = '';
|
||||
if(isset($this->data['counters'][MEMCACHED_PREFIX . 'rcvd'])) { $this->data['prefix'] = MEMCACHED_PREFIX; }
|
||||
@ -68,7 +73,38 @@ class ControllerHealthWorker extends Controller {
|
||||
$this->data['sysinfo'] = $this->model_health_health->sysinfo();
|
||||
|
||||
$this->data['options'] = $this->model_health_health->get_options();
|
||||
|
||||
$sqlsizeraw = $this->model_health_health->get_database_size();
|
||||
|
||||
$sphinxsizeraw = $this->model_health_health->get_sphinx_size();
|
||||
|
||||
/* these next counters are for projecting space */
|
||||
$averagemessagesweekraw = ($this->data['processed_emails'][1]) / 7;
|
||||
$averagemessagesmonthraw = ($this->data['processed_emails'][2]) / 30;
|
||||
$averagemessagesizeraw = $archivesizeraw / $this->data['counters']['rcvd'];
|
||||
$averagesqlsizeraw = $sqlsizeraw / $this->data['counters']['rcvd'];
|
||||
$averagesphinxsizeraw = $sphinxsizeraw / $this->data['counters']['rcvd'];
|
||||
$averagesizedayraw = ($averagemessagesizeraw+$averagesqlsizeraw+$averagesphinxsizeraw) * $averagemessagesweekraw;
|
||||
|
||||
$datapart = 0;
|
||||
foreach($this->data['shortdiskinfo'] as $part) {
|
||||
if( $part['partition'] == DATA_PARTITION ) { $datapart = $part['freespace']*1024; }
|
||||
}
|
||||
|
||||
$this->data['averagemessages'] = round($averagemessagesweekraw); // average of messages over the past week
|
||||
$this->data['averagemessagesize'] = nice_size($averagemessagesizeraw,' '); // average message size on disk
|
||||
$this->data['averagesqlsize'] = nice_size($averagesqlsizeraw,' '); // average metadata size in sql
|
||||
$this->data['averagesphinxsize'] = nice_size($averagesphinxsizeraw,' '); // average sphinx index
|
||||
$this->data['averagesizeday'] = nice_size($averagesizedayraw,' '); // average size per day
|
||||
$this->data['daysleftatcurrentrate'] = convert_days_ymd($datapart / $averagesizedayraw); // number of days of free space left
|
||||
if ( $averagemessagesweekraw > $averagemessagesmonthraw ) {
|
||||
$this->data['usagetrend'] = 1;
|
||||
} elseif( $averagemessagesweekraw < $averagemessagesmonthraw ) {
|
||||
$this->data['usagetrend'] = -1;
|
||||
} else {
|
||||
$this->data['usagetrend'] = 0;
|
||||
}
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user