mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:17:02 +02:00
heavy code cleanup in the webui
This commit is contained in:
@ -7,7 +7,7 @@ class ControllerAuditAudit extends Controller {
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "audit/audit.tpl";
|
||||
$this->layout = "common/layout";
|
||||
$this->layout = "common/layout-audit";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
@ -15,56 +15,9 @@ class ControllerAuditAudit extends Controller {
|
||||
$this->load->model('audit/audit');
|
||||
|
||||
|
||||
/*if(isset($this->request->post['searchterm'])) {
|
||||
$this->fixup_post_request();
|
||||
|
||||
$a = preg_replace("/\&loaded=1$/", "", $this->request->post['searchterm']);
|
||||
}*/
|
||||
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
||||
private function fixup_post_request() {
|
||||
$i = 0;
|
||||
$a = array();
|
||||
|
||||
$this->data['blocks'] = array();
|
||||
|
||||
$this->data['searchterm'] = $this->request->post['searchterm'];
|
||||
|
||||
parse_str($this->request->post['searchterm'], $a);
|
||||
|
||||
foreach($a['f'] as $f) {
|
||||
$val = array_shift($a['v']);
|
||||
|
||||
if($val == '') { continue; }
|
||||
|
||||
if($i == 0) {
|
||||
$this->data['key0'] = 0;
|
||||
|
||||
if($f == 'user') { $this->data['key0'] = 0; }
|
||||
else if($f == 'ipaddr') { $this->data['key0'] = 1; }
|
||||
else if($f == 'ref') { $this->data['key0'] = 2; }
|
||||
|
||||
$this->data['val0'] = $val;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if(isset($a['date1'])) { $this->data['date1'] = $a['date1']; }
|
||||
if(isset($a['date2'])) { $this->data['date2'] = $a['date2']; }
|
||||
|
||||
if(isset($a['action'])) { $this->data['action'] = $a['action']; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -3,7 +3,18 @@
|
||||
|
||||
class ControllerAuditHelper extends Controller {
|
||||
private $error = array();
|
||||
private $search_args = 0;
|
||||
private $a = array(
|
||||
'user' => '',
|
||||
'ipaddr' => '',
|
||||
'action' => '',
|
||||
'ref' => '',
|
||||
'date1' => '',
|
||||
'date2' => '',
|
||||
'order' => '',
|
||||
'sort' => '',
|
||||
'page_len' => 50
|
||||
);
|
||||
|
||||
|
||||
public function index(){
|
||||
|
||||
@ -28,8 +39,8 @@ class ControllerAuditHelper extends Controller {
|
||||
|
||||
|
||||
if(isset($this->request->post)) {
|
||||
$a = $this->fixup_request($this->request->post);
|
||||
list($this->data['n'], $this->data['messages']) = $this->model_audit_audit->search_audit($a);
|
||||
$this->fixup_request($this->request->post);
|
||||
list($this->data['n'], $this->data['messages']) = $this->model_audit_audit->search_audit($this->a);
|
||||
}
|
||||
|
||||
$this->data['actions'][ACTION_UNKNOWN] = '??';
|
||||
@ -68,33 +79,39 @@ class ControllerAuditHelper extends Controller {
|
||||
|
||||
|
||||
private function fixup_request($data = array()) {
|
||||
$arr = array();
|
||||
$ndate = 0;
|
||||
|
||||
if(isset($data['f'])) {
|
||||
foreach($data['f'] as $f) {
|
||||
$val = array_shift($data['v']);
|
||||
if(!isset($data['search'])) { return; }
|
||||
|
||||
$s = preg_replace("/:/", ": ", $data['search']);
|
||||
$s = preg_replace("/,/", " ", $s);
|
||||
$s = preg_replace("/\s{1,}/", " ", $s);
|
||||
$b = explode(" ", $s);
|
||||
|
||||
if($val == '') { continue; }
|
||||
while(list($k, $v) = each($b)) {
|
||||
if($v == '') { continue; }
|
||||
|
||||
if($f == 'user') { if(isset($arr['user'])) { $arr['user'] .= '*' . $val; } else { $arr['user'] = $val; } }
|
||||
if($f == 'ipaddr') { if(isset($arr['ipaddr'])) { $arr['ipaddr'] .= '*' . $val; } else { $arr['ipaddr'] = $val; } }
|
||||
if($f == 'ref') { if(isset($arr['ref'])) { $arr['ref'] .= '*' . $val; } else { $arr['ref'] = $val; } }
|
||||
if(preg_match("/\@/", $v)) { $this->a['user'] .= '*' . $v; }
|
||||
if(preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $v)) { $this->a['ipaddr'] .= '*' . $v; }
|
||||
if(preg_match("/^\d{1,}$/", $v)) { $this->a['ref'] .= '*' . $v; }
|
||||
if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v) || preg_match("/\d{4}\.\d{1,2}\.\d{1,2}/", $v)) {
|
||||
$ndate++;
|
||||
$this->a["date$ndate"] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['action'])) { $arr['action'] = $data['action']; }
|
||||
|
||||
if(isset($data['date1'])) { $arr['date1'] = $data['date1']; }
|
||||
if(isset($data['date2'])) { $arr['date2'] = $data['date2']; }
|
||||
$this->a['user'] = preg_replace("/^\*/", "", $this->a['user']);
|
||||
$this->a['ipaddr'] = preg_replace("/^\*/", "", $this->a['ipaddr']);
|
||||
$this->a['ref'] = preg_replace("/^\*/", "", $this->a['ref']);
|
||||
|
||||
if(isset($data['sort'])) { $arr['sort'] = $data['sort']; }
|
||||
if(isset($data['order'])) { $arr['order'] = $data['order']; }
|
||||
//if(isset($data['action'])) { $arr['action'] = $data['action']; }
|
||||
|
||||
$arr['page'] = $this->data['page'];
|
||||
$arr['page_len'] = $this->data['page_len'];
|
||||
if(isset($data['sort'])) { $this->a['sort'] = $data['sort']; }
|
||||
if(isset($data['order'])) { $this->a['order'] = $data['order']; }
|
||||
if(isset($data['page'])) { $this->a['page'] = $data['page']; }
|
||||
if(isset($data['page_len'])) { $this->a['page_len'] = $data['page_len']; }
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
|
32
webui/controller/common/layout-audit.php
Normal file
32
webui/controller/common/layout-audit.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class ControllerCommonLayoutAudit extends Controller {
|
||||
|
||||
protected function index() {
|
||||
|
||||
|
||||
$this->data['title'] = $this->document->title;
|
||||
|
||||
$this->template = "common/layout-audit.tpl";
|
||||
|
||||
$this->data['search_args'] = '';
|
||||
|
||||
$this->data['open_saved_search_box'] = 0;
|
||||
|
||||
|
||||
$this->children = array(
|
||||
"common/menu",
|
||||
"search/folder",
|
||||
"search/popup",
|
||||
"common/footer"
|
||||
);
|
||||
|
||||
$this->render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,24 +1,24 @@
|
||||
<?php
|
||||
|
||||
class ControllerCommonLayoutNew extends Controller {
|
||||
class ControllerCommonLayoutSearch extends Controller {
|
||||
|
||||
protected function index() {
|
||||
|
||||
|
||||
$this->data['title'] = $this->document->title;
|
||||
|
||||
$this->template = "common/layout-new.tpl";
|
||||
$this->template = "common/layout-search.tpl";
|
||||
|
||||
$this->data['search_args'] = '';
|
||||
|
||||
$this->data['open_saved_search_box'] = 0;
|
||||
|
||||
|
||||
if(isset($_SERVER['REQUEST_URI'])) {
|
||||
/*if(isset($_SERVER['REQUEST_URI'])) {
|
||||
$this->data['search_args'] = preg_replace("/\/([\w]+)\.php\?{0,1}/", "", $_SERVER['REQUEST_URI']);
|
||||
|
||||
if(preg_match("/\&a\=1/", $this->data['search_args'])) { $this->data['open_saved_search_box'] = 1; }
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
$this->children = array(
|
@ -16,24 +16,12 @@ class ControllerSearchSave extends Controller {
|
||||
|
||||
$this->load->model('search/search');
|
||||
|
||||
//print_r($this->request->post); exit;
|
||||
|
||||
if(isset($this->request->post['save'])) {
|
||||
$a = preg_replace("/\&save=1$/", "", http_build_query($this->request->post));
|
||||
|
||||
$this->model_search_search->add_search_term($a);
|
||||
}
|
||||
|
||||
|
||||
$this->data['searchterms'] = $this->model_search_search->get_search_terms();
|
||||
//print_r($this->data['searchterms']); exit;
|
||||
|
||||
$this->data['n'] = count($this->data['searchterms']);
|
||||
|
||||
$this->data['select_size'] = $this->data['n'] + 1;
|
||||
if($this->data['select_size'] > 7) { $this->data['select_size'] = 7; }
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class ControllerSearchSearch extends Controller {
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "search/search.tpl";
|
||||
$this->layout = "common/layout-new";
|
||||
$this->layout = "common/layout-search";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerStatCounter extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "stat/counter.tpl";
|
||||
$this->layout = "common/layout";
|
||||
|
||||
|
||||
$request = Registry::get('request');
|
||||
|
||||
$db = Registry::get('db');
|
||||
$db->select_db($db->database);
|
||||
|
||||
$this->load->model('stat/counter');
|
||||
|
||||
$this->document->title = $this->data['text_counters'];
|
||||
|
||||
|
||||
if(Registry::get('admin_user') == 1) {
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST' && @$this->request->post['reset'] == 1) {
|
||||
$this->model_stat_counter->reset_counters();
|
||||
header("Location: index.php?route=stat/counter");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->data['counters'] = $this->model_stat_counter->get_counters();
|
||||
|
||||
$this->data['prefix'] = '';
|
||||
|
||||
if(isset($this->data['counters']['_c:rcvd'])) { $this->data['prefix'] = '_c:'; }
|
||||
|
||||
}
|
||||
else {
|
||||
$this->template = "common/error.tpl";
|
||||
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
|
||||
}
|
||||
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user