mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 18:30:12 +01:00
accounting fixes + restrict it to admin user only
This commit is contained in:
parent
7a096bceb7
commit
625087b082
@ -22,7 +22,18 @@ class ControllerAccountingAccounting extends Controller {
|
|||||||
$this->data['sort'] = 'item';
|
$this->data['sort'] = 'item';
|
||||||
$this->data['sorttype'] = 0;
|
$this->data['sorttype'] = 0;
|
||||||
$this->data['order'] = 0;
|
$this->data['order'] = 0;
|
||||||
|
|
||||||
|
if(Registry::get('admin_user') == 0) {
|
||||||
|
die("go away");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data['search'] = '';
|
||||||
|
|
||||||
|
/* get search term if there's any */
|
||||||
|
|
||||||
|
if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; }
|
||||||
|
else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; }
|
||||||
|
|
||||||
// get page
|
// get page
|
||||||
if(isset($this->request->get['page']) && is_numeric($this->request->get['page']) && $this->request->get['page'] > 0) {
|
if(isset($this->request->get['page']) && is_numeric($this->request->get['page']) && $this->request->get['page'] > 0) {
|
||||||
$this->data['page'] = $this->request->get['page'];
|
$this->data['page'] = $this->request->get['page'];
|
||||||
@ -50,15 +61,15 @@ class ControllerAccountingAccounting extends Controller {
|
|||||||
if(@$this->request->get['view'] == "email") {
|
if(@$this->request->get['view'] == "email") {
|
||||||
$this->data['view'] = 'email';
|
$this->data['view'] = 'email';
|
||||||
$this->data['viewname'] = "Emails";
|
$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['accounting'] = $counters->get_accounting('email',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||||
$this->data['total_records'] = $counters->count_accounting('email');
|
$this->data['total_records'] = $counters->count_accounting('email',$this->data['search']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@$this->request->get['view'] == "domain") {
|
if(@$this->request->get['view'] == "domain") {
|
||||||
$this->data['view'] = 'domain';
|
$this->data['view'] = 'domain';
|
||||||
$this->data['viewname'] = "Domains";
|
$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['accounting'] = $counters->get_accounting('domain',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||||
$this->data['total_records'] = $counters->count_accounting('domain');
|
$this->data['total_records'] = $counters->count_accounting('domain',$this->data['search']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->data['accounting']) {
|
if($this->data['accounting']) {
|
||||||
|
@ -14,6 +14,9 @@ class ControllerAuditAudit extends Controller {
|
|||||||
|
|
||||||
$this->load->model('audit/audit');
|
$this->load->model('audit/audit');
|
||||||
|
|
||||||
|
if(Registry::get('admin_user') == 0) {
|
||||||
|
die("go away");
|
||||||
|
}
|
||||||
|
|
||||||
$this->render();
|
$this->render();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,10 @@ class ControllerAuditHelper extends Controller {
|
|||||||
|
|
||||||
$this->load->model('audit/audit');
|
$this->load->model('audit/audit');
|
||||||
|
|
||||||
|
if(Registry::get('admin_user') == 0) {
|
||||||
|
die("go away");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->data['page'] = 0;
|
$this->data['page'] = 0;
|
||||||
if(isset($this->request->post['page'])) { $this->data['page'] = $this->request->post['page']; }
|
if(isset($this->request->post['page'])) { $this->data['page'] = $this->request->post['page']; }
|
||||||
|
@ -90,7 +90,7 @@ class ModelAccountingAccounting extends Model
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_accounting($item = 'email',$page=0,$pagelen=0,$sort='item',$order=0 ) {
|
public function get_accounting($item = 'email',$search='',$page=0,$pagelen=0,$sort='item',$order=0 ) {
|
||||||
|
|
||||||
// item can be either email or domain, maybe folder in the future??
|
// item can be either email or domain, maybe folder in the future??
|
||||||
|
|
||||||
@ -116,18 +116,24 @@ class ModelAccountingAccounting extends Model
|
|||||||
$account_for_emails = $this->__getEmails();
|
$account_for_emails = $this->__getEmails();
|
||||||
$account_for_domains = $this->__getDomains();
|
$account_for_domains = $this->__getDomains();
|
||||||
|
|
||||||
|
$search = preg_replace("/\s{1,}/", "", $search);
|
||||||
|
|
||||||
if ($item == 'email') {
|
if ($item == 'email') {
|
||||||
$account_for_emails = $this->__getEmails();
|
$account_for_emails = $this->__getEmails();
|
||||||
$account_for_domains = $this->__getDomains();
|
$account_for_domains = $this->__getDomains();
|
||||||
$query = "SELECT `email` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,SUM(`sentsize`) as `sentsize`,AVG(`sentsize`) as `sentavg`,SUM(`recdsize`) as `recdsize`,AVG(`recdsize`) as `recdavg` FROM " . TABLE_STAT_COUNTER;
|
$query = "SELECT `email` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,SUM(`sentsize`) as `sentsize`,AVG(`sentsize`) as `sentavg`,SUM(`recdsize`) as `recdsize`,AVG(`recdsize`) as `recdavg` FROM " . TABLE_STAT_COUNTER;
|
||||||
$where = "WHERE `email` IN ('".implode("','",$account_for_emails)."') OR `domain` IN ('".implode("','",$account_for_domains)."')";
|
$where = "WHERE ( `email` IN ('".implode("','",$account_for_emails)."') OR `domain` IN ('".implode("','",$account_for_domains)."') )";
|
||||||
|
if($search){
|
||||||
|
$where .= " AND ( `email` like '%".$search."%' OR `domain` like '%".$search."%' )";
|
||||||
|
}
|
||||||
$group = "GROUP BY `email`";
|
$group = "GROUP BY `email`";
|
||||||
} elseif ($item == 'domain') {
|
} elseif ($item == 'domain') {
|
||||||
$account_for_domains = $this->__getDomains();
|
$account_for_domains = $this->__getDomains();
|
||||||
$query = "SELECT `domain` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,SUM(`sentsize`) as `sentsize`,AVG(`sentsize`) as `sentavg`,SUM(`recdsize`) as `recdsize`,AVG(`recdsize`) as `recdavg` FROM " . TABLE_STAT_COUNTER;
|
$query = "SELECT `domain` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,SUM(`sentsize`) as `sentsize`,AVG(`sentsize`) as `sentavg`,SUM(`recdsize`) as `recdsize`,AVG(`recdsize`) as `recdavg` FROM " . TABLE_STAT_COUNTER;
|
||||||
$where = "WHERE `domain` IN ('".implode("','",$account_for_domains)."')";
|
$where = "WHERE ( `domain` IN ('".implode("','",$account_for_domains)."') )";
|
||||||
|
if($search){
|
||||||
|
$where .= " AND `domain` like '%".$search."%'";
|
||||||
|
}
|
||||||
$group = "GROUP BY `domain`";
|
$group = "GROUP BY `domain`";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -154,18 +160,30 @@ class ModelAccountingAccounting extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function count_accounting($item = 'email') {
|
public function count_accounting($item = 'email',$search='') {
|
||||||
|
|
||||||
$account_for_emails = $this->__getEmails();
|
$account_for_emails = $this->__getEmails();
|
||||||
$account_for_domains = $this->__getDomains();
|
$account_for_domains = $this->__getDomains();
|
||||||
|
|
||||||
|
$search = preg_replace("/\s{1,}/", "", $search);
|
||||||
|
|
||||||
|
if($search){
|
||||||
|
$search_cond .= " AND ( `email` like '%".$search."%' OR `domain` like '%".$search."%' )";
|
||||||
|
}
|
||||||
|
|
||||||
$query = "SELECT `email` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,sum(`sentsize`) as `sentsize`,sum(`recdsize`) as `recdsize` FROM " . TABLE_STAT_COUNTER;
|
$query = "SELECT `email` AS `item`,MIN(`date`) as `oldest`,MAX(`date`) as `newest`,sum(`sent`) as `sent`,sum(`recd`) as `recd`,sum(`sentsize`) as `sentsize`,sum(`recdsize`) as `recdsize` FROM " . TABLE_STAT_COUNTER;
|
||||||
|
|
||||||
if ($item == 'email') {
|
if ($item == 'email') {
|
||||||
$where = "WHERE `email` IN ('".implode("','",$account_for_emails)."') OR `domain` IN ('".implode("','",$account_for_domains)."')";
|
$where = "WHERE `email` IN ('".implode("','",$account_for_emails)."') OR `domain` IN ('".implode("','",$account_for_domains)."')";
|
||||||
|
if($search){
|
||||||
|
$where .= " AND ( `email` like '%".$search."%' OR `domain` like '%".$search."%' )";
|
||||||
|
}
|
||||||
$group = "GROUP BY `email`";
|
$group = "GROUP BY `email`";
|
||||||
} elseif ($item == 'domain') {
|
} elseif ($item == 'domain') {
|
||||||
$where = "WHERE `domain` IN ('".implode("','",$account_for_domains)."')";
|
$where = "WHERE `domain` IN ('".implode("','",$account_for_domains)."')";
|
||||||
|
if($search){
|
||||||
|
$where .= " AND `domain` like '%".$search."%'";
|
||||||
|
}
|
||||||
$group = "GROUP BY `domain`";
|
$group = "GROUP BY `domain`";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user