added the webui to the tarball

This commit is contained in:
SJ
2012-02-08 23:14:28 +01:00
parent 79cdeed1b6
commit 1211e9a39c
272 changed files with 26456 additions and 11 deletions

View File

@ -0,0 +1,70 @@
<?php
class ControllerAuditAudit extends Controller {
public function index(){
$this->id = "content";
$this->template = "audit/audit.tpl";
$this->layout = "common/layout-search";
$request = Registry::get('request');
$db = Registry::get('db');
$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']; }
}
}
?>

View File

@ -0,0 +1,103 @@
<?php
class ControllerAuditHelper extends Controller {
private $error = array();
private $search_args = 0;
public function index(){
$this->id = "content";
$this->template = "audit/helper.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('audit/audit');
$this->data['page'] = 0;
if(isset($this->request->post['page'])) { $this->data['page'] = $this->request->post['page']; }
$this->data['page_len'] = get_page_length();
$this->data['n'] = -1;
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->data['actions'][ACTION_UNKNOWN] = '??';
$this->data['actions'][ACTION_LOGIN] = $this->data['text_login2'];
$this->data['actions'][ACTION_LOGIN_FAILED] = $this->data['text_login_failed'];
$this->data['actions'][ACTION_LOGOUT] = $this->data['text_logout2'];
$this->data['actions'][ACTION_VIEW_MESSAGE] = $this->data['text_view_message2'];
$this->data['actions'][ACTION_VIEW_HEADER] = $this->data['text_view_header'];
$this->data['actions'][ACTION_UNAUTHORIZED_VIEW_MESSAGE] = $this->data['text_unauthorized_view_message'];
$this->data['actions'][ACTION_RESTORE_MESSAGE] = $this->data['text_restore_message'];
$this->data['actions'][ACTION_DOWNLOAD_MESSAGE] = $this->data['text_download_message2'];
$this->data['actions'][ACTION_SEARCH] = $this->data['text_search2'];
$this->data['actions'][ACTION_SAVE_SEARCH] = $this->data['text_save_search'];
$this->data['actions'][ACTION_CHANGE_USER_SETTINGS] = $this->data['text_change_user_settings'];
$this->data['actions'][ACTION_REMOVE_MESSAGE] = $this->data['text_remove_message2'];
$this->data['actions'][ACTION_UNAUTHORIZED_REMOVE_MESSAGE] = $this->data['text_unauthorized_remove_message'];
/* paging info */
$this->data['prev_page'] = $this->data['page'] - 1;
$this->data['next_page'] = $this->data['page'] + 1;
$this->data['total_pages'] = ceil($this->data['n'] / $this->data['page_len'])-1;
$this->data['hits_from'] = $this->data['page'] * $this->data['page_len'] + 1;
$this->data['hits_to'] = ($this->data['page']+1) * $this->data['page_len'];
if($this->data['hits_to'] > $this->data['n']) { $this->data['hits_to'] = $this->data['n']; }
$this->render();
}
private function fixup_request($data = array()) {
$arr = array();
if(isset($data['f'])) {
foreach($data['f'] as $f) {
$val = array_shift($data['v']);
if($val == '') { 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(isset($data['action'])) { $arr['action'] = $data['action']; }
if(isset($data['date1'])) { $arr['date1'] = $data['date1']; }
if(isset($data['date2'])) { $arr['date2'] = $data['date2']; }
if(isset($data['sort'])) { $arr['sort'] = $data['sort']; }
if(isset($data['order'])) { $arr['order'] = $data['order']; }
$arr['page'] = $this->data['page'];
$arr['page_len'] = $this->data['page_len'];
return $arr;
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
class ControllerCommonError extends Controller {
public function index(){
$this->id = "content";
$this->template = "common/error.tpl";
$this->layout = "common/layout";
$this->document->title = $this->data['text_error'];
$this->data['errortitle'] = $this->data['text_error'];
if(isset($_SESSION['error'])){
$this->data['errorstring'] = $_SESSION['error'];
unset($_SESSION['error']);
}
else {
$this->data['errorstring'] = "this is the errorstring";
}
$this->render();
}
}
?>

View File

@ -0,0 +1,18 @@
<?php
class ControllerCommonFooter extends Controller {
protected function index() {
$this->id = "footer";
$this->template = "common/footer.tpl";
$this->render();
}
}
?>

View File

@ -0,0 +1,16 @@
<?php
class ControllerCommonLayoutempty extends Controller {
protected function index() {
$this->template = "common/layout-empty.tpl";
$this->render();
}
}
?>

View File

@ -0,0 +1,26 @@
<?php
class ControllerCommonLayoutHealth extends Controller {
protected function index() {
$this->data['title'] = $this->document->title;
$this->template = "common/layout-health.tpl";
$this->children = array(
"common/menu",
"common/footer"
);
$this->render();
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
class ControllerCommonLayoutSearch extends Controller {
protected function index() {
$this->data['title'] = $this->document->title;
$this->template = "common/layout-search.tpl";
$this->data['search_args'] = '';
$this->data['open_saved_search_box'] = 0;
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(
"common/menu",
"common/footer"
);
$this->render();
}
}
?>

View File

@ -0,0 +1,26 @@
<?php
class ControllerCommonLayout extends Controller {
protected function index() {
$this->data['title'] = $this->document->title;
$this->template = "common/layout.tpl";
$this->children = array(
"common/menu",
"common/footer"
);
$this->render();
}
}
?>

View File

@ -0,0 +1,30 @@
<?php
class ControllerCommonMenu extends Controller {
protected function index() {
$this->id = "menu";
$this->template = "common/menu.tpl";
$db = Registry::get('db');
$this->data['admin_user'] = Registry::get('admin_user');
$this->data['auditor_user'] = Registry::get('auditor_user');
$this->data['readonly_admin'] = Registry::get('readonly_admin');
if($this->data['admin_user'] == 1) { $this->template = "common/menu-admin.tpl"; }
$this->render();
}
}
?>

View File

@ -0,0 +1,23 @@
<?php
class ControllerCommonNotfound extends Controller {
public function index(){
$this->id = "content";
$this->template = "common/not_found.tpl";
$this->layout = "common/layout";
$this->document->title = $this->data['title_not_found'];
$this->render();
}
}
?>

View File

@ -0,0 +1,122 @@
<?php
class ControllerDomainDomain extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "domain/list.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('domain/domain');
$this->document->title = $this->data['text_domain'];
$this->data['username'] = Registry::get('username');
$this->data['page'] = 0;
$this->data['page_len'] = get_page_length();
$this->data['total'] = 0;
$this->data['domains'] = array();
/* get search term if there's any */
if($this->request->server['REQUEST_METHOD'] == 'POST'){
$this->data['search'] = @$this->request->post['search'];
}
else {
$this->data['search'] = @$this->request->get['search'];
}
/* 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'];
}
/* check if we are admin */
if(Registry::get('admin_user') == 1) {
if($this->request->server['REQUEST_METHOD'] == 'POST') {
if($this->validate() == true) {
if($this->model_domain_domain->addDomain($this->request->post['domain'], $this->request->post['mapped']) == 1) {
$this->data['x'] = $this->data['text_successfully_added'];
} else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_failed_to_add'];
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
}
/* get list of current policies */
$this->data['domains'] = $this->model_domain_domain->getDomains();
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
}
$this->data['prev_page'] = $this->data['page'] - 1;
$this->data['next_page'] = $this->data['page'] + 1;
$this->data['total'] = floor(count($this->data['domains']) / $this->data['page_len']);
$this->render();
}
private function validate() {
if(!isset($this->request->post['domain']) || strlen($this->request->post['domain']) < 3) {
$this->error['email'] = $this->data['text_invalid_data'];
}
else {
$domains = explode("\n", $this->request->post['domain']);
foreach ($domains as $domain) {
$domain = rtrim($domain);
if(!preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $domain) ) {
$this->error['email'] = $this->data['text_invalid_data'] . ": $domain";
}
}
}
if(!isset($this->request->post['mapped']) || strlen($this->request->post['mapped']) < 3 || !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->post['mapped']) ) {
$this->error['domain'] = $this->data['text_invalid_data'] . ": " . $this->request->post['mapped'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,75 @@
<?php
class ControllerDomainRemove extends Controller {
private $error = array();
private $domains = array();
private $d = array();
public function index(){
$this->id = "content";
$this->template = "domain/remove.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('domain/domain');
$this->document->title = $this->data['text_domain'];
$this->data['username'] = Registry::get('username');
$this->data['domain'] = @$this->request->get['domain'];
$this->data['confirmed'] = (int)@$this->request->get['confirmed'];
if($this->validate() == true) {
if($this->data['confirmed'] == 1) {
$ret = $this->model_domain_domain->deleteDomain($this->data['domain']);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_removed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_remove'];
}
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
$this->render();
}
private function validate() {
if(Registry::get('admin_user') == 0) {
$this->error['admin'] = $this->data['text_you_are_not_admin'];
}
if(!isset($this->request->get['domain']) || strlen($this->request->get['domain']) < 3 || ($this->request->get['domain'] != "local" && !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->get['domain'])) ) {
$this->error['domain'] = $this->data['text_invalid_data'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,32 @@
<?php
class ControllerHealthHealth extends Controller {
public function index(){
$this->id = "content";
$this->template = "health/health.tpl";
$this->layout = "common/layout-health";
$request = Registry::get('request');
$language = Registry::get('language');
$this->document->title = $language->get('text_health_monitor');
/* check if we are admin */
if(Registry::get('admin_user') != 1 && Registry::get('readonly_admin') != 1 && Registry::get('auditor_admin') != 1) {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
}
$this->render();
}
}
?>

View File

@ -0,0 +1,101 @@
<?php
class ControllerHealthWorker extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "health/worker.tpl";
$this->layout = "common/layout-empty";
$db_history = Registry::get('db_history');
$this->load->model('health/health');
$this->load->model('stat/counter');
$request = Registry::get('request');
$lang = Registry::get('language');
$this->data['health'] = array();
if(Registry::get('admin_user') != 1 && Registry::get('readonly_admin') != 1) {
die("go away");
}
foreach (Registry::get('health_smtp_servers') as $smtp) {
$this->data['health'][] = $this->model_health_health->checksmtp($smtp, $lang->data['text_error']);
}
/*$this->data['queues'][] = format_qshape($lang->data['text_active_incoming_queue'], QSHAPE_ACTIVE_INCOMING);
$this->data['queues'][] = format_qshape($lang->data['text_deferred_queue'], QSHAPE_DEFERRED);*/
/*if(file_exists(QSHAPE_ACTIVE_INCOMING_OUT)) {
$this->data['queues_out'][] = format_qshape($lang->data['text_active_incoming_queue'], QSHAPE_ACTIVE_INCOMING_OUT);
$this->data['queues_out'][] = format_qshape($lang->data['text_deferred_queue'], QSHAPE_DEFERRED_OUT);
}*/
$this->data['processed_emails'] = $this->model_health_health->count_processed_emails();
list ($this->data['uptime'], $this->data['cpuload']) = $this->model_health_health->uptime();
$this->data['cpuinfo'] = 100 - (int)file_get_contents(CPUSTAT);
$this->data['archive_size'] = (int)file_get_contents(ARCHIVE_SIZE);
$this->data['quarantinereportinfo'] = @file_get_contents(DAILY_QUARANTINE_REPORT_STAT);
list($this->data['totalmem'], $this->data['meminfo'], $this->data['totalswap'], $this->data['swapinfo']) = $this->model_health_health->meminfo();
$this->data['shortdiskinfo'] = $this->model_health_health->diskinfo();
/*if(file_exists(MAILLOG_PID_FILE)) {
$this->data['maillog_status'] = $lang->data['text_running'];
} else {
$this->data['maillog_status'] = $lang->data['text_not_running'];
}*/
if(ENABLE_LDAP_IMPORT_FEATURE == 1) {
$this->data['adsyncinfo'] = @file_get_contents(AD_SYNC_STAT);
$this->data['total_emails_in_database'] = 0;
$a = preg_split("/ /", $this->data['adsyncinfo']);
list ($this->data['totalusers'], $this->data['totalnewusers'], $this->data['totaldeletedusers'], $this->data['total_emails_in_database']) = preg_split("/\//", $a[count($a)-1]);
$this->data['adsyncinfo'] = $a[0] . " " . $a[1] . " " . $this->data['total_emails_in_database'];
}
/* counter related stuff */
$db = Registry::get('db');
$db->select_db($db->database);
if($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['resetcounters']) && $this->request->post['resetcounters'] == 1) {
if(isset($this->request->post['confirmed']) && $this->request->post['confirmed'] == 1 && Registry::get('admin_user') == 1) {
$this->model_stat_counter->resetCounters();
header("Location: index.php?route=health/health");
exit;
}
else {
$this->template = "health/counter-reset-confirm.tpl";
}
}
$this->data['counters'] = $this->model_stat_counter->getCounters();
$this->data['prefix'] = '';
if(isset($this->data['counters']['_c:rcvd'])) { $this->data['prefix'] = '_c:'; }
$this->data['sysinfo'] = $this->model_health_health->sysinfo();
$this->render();
}
}
?>

View File

@ -0,0 +1,70 @@
<?php
class ControllerLoginLogin extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "login/login.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/auth');
$this->load->model('user/user');
$this->load->model('user/prefs');
$this->document->title = $this->data['text_login'];
if($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) {
if($this->model_user_auth->checkLogin($this->request->post['username'], $_POST['password']) == 1) {
$this->model_user_prefs->get_user_preferences($_SESSION['username']);
LOGGER('logged in');
/*if(isset($_POST['relocation']) && $_POST['relocation']) {
header("Location: " . SITE_URL . "index.php?" . $_POST['relocation']);
} else {
header("Location: " . SITE_URL . "search.php");
}*/
header("Location: " . SITE_URL . "search.php");
exit;
}
$this->data['x'] = $this->data['text_invalid_email_or_password'];
}
$this->render();
}
private function validate() {
if(strlen($this->request->post['username']) < 2){
$this->error['username'] = $this->data['text_invalid_username'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,29 @@
<?php
class ControllerLoginLogout extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "login/logout.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/auth');
$this->document->title = $this->data['text_logout'];
logout();
$this->render();
}
}
?>

View File

@ -0,0 +1,50 @@
<?php
class ControllerMessageDownload extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/headers.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
if(!$this->model_search_search->check_your_permission_by_piler_id($this->data['id'])) {
AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $this->data['id'], '');
header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . $this->data['id'] . ".eml");
header("Content-Transfer-Encoding: binary\n");
print $this->model_search_message->get_raw_message($this->data['id']);
exit;
$this->render();
}
}
?>

View File

@ -0,0 +1,44 @@
<?php
class ControllerMessageHeaders extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/headers.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('user/user');
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
if(!$this->model_search_search->check_your_permission_by_piler_id($this->data['id'])) {
AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_VIEW_HEADER, '', '', $this->data['id'], '');
$this->data['data'] = $this->model_search_message->get_message_headers($this->data['id']);
$this->render();
}
}
?>

View File

@ -0,0 +1,57 @@
<?php
class ControllerMessageRemove extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/remove.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('user/user');
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
if(HOLD_EMAIL == 1) {
AUDIT(ACTION_UNAUTHORIZED_REMOVE_MESSAGE, '', '', $this->data['id'], '');
die("not authorized to remove id: " . $this->data['id']);
}
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
if(Registry::get('admin_user') == 0) {
AUDIT(ACTION_UNAUTHORIZED_REMOVE_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_REMOVE_MESSAGE, '', '', $this->data['id'], '');
if($this->model_search_search->remove_message($this->data['id']) == 1) {
$this->data['data'] = $this->data['text_marked_for_removal'];
} else {
$this->data['data'] = $this->data['text_failed_to_mark_for_removal'];
AUDIT(ACTION_REMOVE_MESSAGE, '', '', $this->data['id'], 'failed');
}
$this->render();
}
}
?>

View File

@ -0,0 +1,65 @@
<?php
class ControllerMessageRestore extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/restore.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('user/user');
$this->load->model('mail/mail');
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
if(!$this->model_search_search->check_your_permission_by_piler_id($this->data['id'])) {
AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_RESTORE_MESSAGE, '', '', $this->data['id'], '');
$this->data['username'] = Registry::get('username');
$rcpt = array();
/* send the email to all the recipients of the original email if we are admin or auditor users */
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) {
$rcpt = $this->model_search_search->get_message_recipients($this->data['id']);
}
else {
array_push($rcpt, $_SESSION['email']);
}
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $this->model_search_message->get_raw_message($this->data['id']) );
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
else { $this->data['data'] = $this->data['text_failed_to_restore']; }
$this->render();
}
}
?>

View File

@ -0,0 +1,70 @@
<?php
class ControllerMessageView extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/view.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('audit/audit');
$this->load->model('user/user');
$this->document->title = $this->data['text_message'];
$this->data['id'] = '';
if(isset($_SERVER['REQUEST_URI'])) { $this->data['id'] = preg_replace("/\/message.php\//", "", $_SERVER['REQUEST_URI']); }
if($this->request->server['REQUEST_METHOD'] == 'POST') {
$this->data['id'] = $this->request->post['id'];
}
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
if(!$this->model_search_search->check_your_permission_by_piler_id($this->data['id'])) {
AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_VIEW_MESSAGE, '', '', $this->data['id'], '');
$this->data['username'] = Registry::get('username');
/* fix username if we are admin */
if(isset($this->request->get['user']) && strlen($this->request->get['user']) > 1 && (Registry::get('admin_user') == 1 || $this->model_user_user->isUserInMyDomain($this->request->get['user']) == 1) ) {
$this->data['username'] = $this->request->get['user'];
}
if($this->request->server['REQUEST_METHOD'] == 'POST') {
$this->model_search_message->add_message_tag($this->data['id'], $_SESSION['uid'], $this->request->post['tag']);
header("Location: " . $_SERVER['HTTP_REFERER']);
exit;
}
$this->data['message'] = $this->model_search_message->extract_message($this->data['id']);
$this->data['message']['tag'] = $this->model_search_message->get_message_tag($this->data['id'], $_SESSION['uid']);
$this->render();
}
}
?>

View File

@ -0,0 +1,41 @@
<?php
class ControllerPolicyArchiving extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "policy/archiving.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('policy/archiving');
$this->document->title = $this->data['text_archiving_rules'];
$this->data['rules'] = array();
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$rc = $this->model_policy_archiving->add_new_rule($this->request->post);
}
$this->data['rules'] = $this->model_policy_archiving->get_rules();
//print_r($this->data['rules']);
$this->render();
}
}
?>

View File

@ -0,0 +1,76 @@
<?php
class ControllerPolicyRemovearchiving extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "policy/removearchiving.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('policy/archiving');
$this->document->title = $this->data['text_archiving_rules'];
$this->data['username'] = Registry::get('username');
$this->data['id'] = @$this->request->get['id'];
$this->data['confirmed'] = (int)@$this->request->get['confirmed'];
$this->data['rule'] = $this->model_policy_archiving->get_rule($this->data['id']);
if($this->validate() == true) {
if($this->data['confirmed'] == 1) {
$ret = $this->model_policy_archiving->remove_rule($this->data['id']);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_removed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_remove'];
}
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
$this->render();
}
private function validate() {
if(Registry::get('admin_user') == 0) {
$this->error['admin'] = $this->data['text_you_are_not_admin'];
}
if(!isset($this->request->get['id']) || $this->request->get['id'] < 1 ) {
$this->error['rule'] = $this->data['text_invalid_data'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,202 @@
<?php
class ControllerSearchHelper extends Controller {
private $error = array();
private $a = array(
'o_from' => '',
'f_from' => '',
'o_to' => '',
'f_to' => '',
'from' => '',
'to' => '',
'from_domain' => '',
'to_domain' => '',
'subject' => '',
'body' => '',
'date1' => '',
'date2' => '',
'direction' => '',
'size' => '',
'attachment_type' => '',
'tag' => ''
);
public function index(){
$this->id = "content";
$this->template = "search/helper.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$sphx = Registry::get('sphx');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('user/user');
$this->data['page'] = 0;
if(isset($this->request->post['page'])) { $this->data['page'] = $this->request->post['page']; }
$this->data['page_len'] = get_page_length();
$this->data['n'] = -1;
if($this->request->post['searchtype'] == 'advanced') {
$this->preprocess_post_advanced_request($this->request->post);
$this->fixup_post_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
} else if($this->request->post['searchtype'] == 'expert'){
$this->preprocess_post_expert_request($this->request->post);
$this->fixup_post_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
} else {
$this->fixup_post_simple_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']);
}
/* paging info */
$this->data['prev_page'] = $this->data['page'] - 1;
$this->data['next_page'] = $this->data['page'] + 1;
$this->data['total_pages'] = ceil($this->data['n'] / $this->data['page_len'])-1;
$this->data['hits_from'] = $this->data['page'] * $this->data['page_len'] + 1;
$this->data['hits_to'] = ($this->data['page']+1) * $this->data['page_len'];
if($this->data['hits_to'] > $this->data['n']) { $this->data['hits_to'] = $this->data['n']; }
$this->render();
}
private function fixup_post_simple_request() {
if(!isset($this->request->post['date1'])) { $this->request->post['date1'] = ''; }
if(!isset($this->request->post['date2'])) { $this->request->post['date2'] = ''; }
}
private function fixup_post_request() {
while(list($k, $v) = each($this->a)) {
if($this->a[$k]) { $this->a[$k] = substr($this->a[$k], 1, strlen($this->a[$k])); }
}
$this->a['sort'] = $this->request->post['sort'];
$this->a['order'] = $this->request->post['order'];
}
private function preprocess_post_expert_request($data = array()) {
$token = '';
//print_r($data);
$s = preg_replace("/:/", ": ", $data['search']);
$s = preg_replace("/,/", " ", $s);
$s = preg_replace("/\s{1,}/", " ", $s);
$b = explode(" ", $s);
while(list($k, $v) = each($b)) {
if($v == 'from:') { $token = 'from'; continue; }
else if($v == 'to:') { $token = 'to'; continue; }
else if($v == 'subject:') { $token = 'subject'; continue; }
else if($v == 'body:') { $token = 'body'; continue; }
else if($v == 'direction:' || $v == 'd:') { $token = 'direction'; continue; }
else if($v == 'size:') { $token = 'size'; continue; }
else if($v == 'date1:') { $token = 'date1'; continue; }
else if($v == 'date2:') { $token = 'date2'; continue; }
else if($v == 'attachment:' || $v == 'a:') { $token = 'attachment_type'; continue; }
else if($v == 'size') { $token = 'size'; continue; }
else if($v == 'tag:') { $token = 'tag'; continue; }
if($token == 'from') {
$v = fix_email_address($v);
if(!strstr($v, '@')) { $this->a['from_domain'] .= "|$v"; }
else {
$this->a['from'] .= "|$v";
if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; }
}
}
else if($token == 'to') {
$v = fix_email_address($v);
if(!strstr($v, '@')) { $this->a['to_domain'] .= "|$v"; }
else {
$this->a['to'] .= "|$v";
if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; }
}
}
else if($token == 'subject') { $this->a['subject'] .= ' ' . $v; }
else if($token == 'body') { $this->a['body'] .= ' ' . $v; }
else if($token == 'date1') { $this->a['date1'] = $v; }
else if($token == 'date2') { $this->a['date2'] = $v; }
else if($token == 'direction') { $this->a['direction'] = $v; }
else if($token == 'size') { $this->a['size'] .= ' ' . $v; }
else if($token == 'attachment_type') { $this->a['attachment_type'] .= ' ' . $v; }
else if($token == 'tag') { $this->a['tag'] .= ' ' . $v; }
}
}
private function preprocess_post_advanced_request($data = array()) {
if(isset($data['f'])) {
foreach($data['f'] as $f) {
$v = array_shift($data['v']);
if($v == '') { continue; }
if($f == 'from') {
$v = fix_email_address($v);
if(!strstr($v, '@')) { $this->a['from_domain'] .= "|$v"; }
else {
$this->a['from'] .= "|$v";
if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; }
}
}
if($f == 'to') {
$v = fix_email_address($v);
if(!strstr($v, '@')) { $this->a['to_domain'] .= "|$v"; }
else {
$this->a['to'] .= "|$v";
if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; }
}
}
if($f == 'subject') {
$this->a['subject'] .= "|$v";
}
if($f == 'body') {
$this->a['body'] .= "|$v";
}
if($f == 'tag') {
$this->a['tag'] .= "|$v";
}
}
}
}
}
?>

View File

@ -0,0 +1,41 @@
<?php
class ControllerSearchSave extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "search/save.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$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();
}
}
?>

View File

@ -0,0 +1,95 @@
<?php
class ControllerSearchSearch extends Controller {
public function index(){
$this->id = "content";
$this->template = "search/search.tpl";
$this->layout = "common/layout-search";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->data['searchtype'] = 'simple';
if(isset($this->request->get['type'])) {
if($this->request->get['type'] == 'advanced') {
$this->template = "search/advanced.tpl";
$this->data['searchtype'] = 'advanced';
}
if($this->request->get['type'] == 'expert') {
$this->template = "search/expert.tpl";
$this->data['searchtype'] = 'expert';
}
}
if(isset($this->request->post['searchterm'])) {
$this->fixup_post_request();
$a = preg_replace("/\&loaded=1$/", "", $this->request->post['searchterm']);
$this->model_search_search->update_search_term($a);
}
$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);
if(isset($a['from'])) { $this->data['from'] = $a['from']; }
if(isset($a['to'])) { $this->data['to'] = $a['to']; }
if(isset($a['subject'])) { $this->data['subject'] = $a['subject']; }
if(isset($a['search'])) { $this->data['_search'] = $a['search']; }
if(isset($a['sort'])) { $this->data['sort'] = $a['sort']; }
if(isset($a['order'])) { $this->data['order'] = $a['order']; }
if(isset($a['f'])) {
foreach($a['f'] as $f) {
$val = array_shift($a['v']);
if($val == '') { continue; }
if($i == 0) {
$this->data['key0'] = 0;
if($f == 'from') { $this->data['key0'] = 0; }
else if($f == 'to') { $this->data['key0'] = 1; }
else if($f == 'subject') { $this->data['key0'] = 2; }
else if($f == 'body') { $this->data['key0'] = 3; }
$this->data['val0'] = $val;
}
else {
array_push($this->data['blocks'], array('key' => $f, 'val' => $val));
}
$i++;
}
}
if(isset($a['date1'])) { $this->data['date1'] = $a['date1']; }
if(isset($a['date2'])) { $this->data['date2'] = $a['date2']; }
if(isset($a['direction'])) { $this->data['direction'] = $a['direction']; }
}
}
?>

View File

@ -0,0 +1,45 @@
<?php
class ControllerStatChart extends Controller {
private $error = array();
public function index(){
$request = Registry::get('request');
$db = Registry::get('db');
$db_history = Registry::get('db_history');
$this->load->model('user/user');
$this->load->model('stat/chart');
$this->load->helper('libchart/classes/libchart');
$this->data['username'] = Registry::get('username');
$timespan = @$this->request->get['timespan'];
$db->select_db($db->database);
$emails = "";
/* let the admin users see the whole statistics */
if(Registry::get('admin_user') == 0 && Registry::get('readonly_admin') == 0) {
$uid = $this->model_user_user->getUidByName($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$uid)) . "')";
}
else if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0){
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$this->request->get['uid'])) . "')";
}
$aa = new ModelStatChart();
$aa->pieChartHamSpam($emails, $timespan, $this->data['text_ham_and_spam_messages'], "");
}
}
?>

View File

@ -0,0 +1,51 @@
<?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->resetCounters();
header("Location: index.php?route=stat/counter");
exit;
}
$this->data['counters'] = $this->model_stat_counter->getCounters();
$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();
}
}
?>

View File

@ -0,0 +1,47 @@
<?php
class ControllerStatGraph extends Controller {
private $error = array();
public function index(){
$request = Registry::get('request');
$db = Registry::get('db');
$db_history = Registry::get('db_history');
$this->load->model('user/user');
$this->load->model('stat/chart');
$this->load->helper('libchart/classes/libchart');
$this->data['username'] = Registry::get('username');
$timespan = @$this->request->get['timespan'];
$db->select_db($db->database);
$emails = "";
/* let the admin users see the whole statistics */
if(Registry::get('admin_user') == 0 && Registry::get('readonly_admin') == 0) {
$uid = $this->model_user_user->getUidByName($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$uid)) . "')";
}
else if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0){
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$this->request->get['uid'])) . "')";
}
$aa = new ModelStatChart();
$aa->lineChartHamSpam($emails, $timespan, $this->data['text_archived_messages'], SIZE_X, SIZE_Y, "");
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
class ControllerStatStat extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "stat/stat.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/user');
$this->document->title = $this->data['text_statistics'];
$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->render();
}
}
?>

View File

@ -0,0 +1,136 @@
<?php
class ControllerUserAdd extends Controller {
private $error = array();
private $domains = array();
public function index(){
$this->id = "content";
$this->template = "user/add.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/user');
$this->document->title = $this->data['text_user_management'];
$this->data['domains'] = array();
/* check if we are admin */
if(Registry::get('admin_user') == 1) {
/* query available domains */
$this->data['domains'] = $this->model_user_user->get_domains();
$this->domains = $this->model_user_user->get_email_domains();
if($this->request->server['REQUEST_METHOD'] == 'POST') {
$ret = 0;
if($this->validate() == true){
$ret = $this->model_user_user->addUser($this->request->post);
$_SESSION['last_domain'] = $this->request->post['domain'];
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_added'];
} else {
$this->data['errorstring'] = $this->data['text_failed_to_add'] . ": " . $ret;
}
}
else {
$this->data['errorstring'] = array_pop($this->error);
}
if($ret == 0) {
$this->data['post'] = $this->request->post;
$this->data['next_user_id'] = $this->model_user_user->getNextUid();
}
}
else {
$this->data['next_user_id'] = $this->model_user_user->getNextUid();
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
}
$this->render();
}
private function validate() {
if(!isset($this->request->post['password']) || !isset($this->request->post['password2']) ) {
$this->error['password'] = $this->data['text_missing_password'];
}
if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) {
$this->error['password'] = $this->data['text_too_short_password'];
}
if($this->request->post['password'] != $this->request->post['password2']) {
$this->error['password'] = $this->data['text_password_mismatch'];
}
if(!isset($this->request->post['uid']) || !is_numeric($this->request->post['uid']) || $this->request->post['uid'] < 0) {
$this->error['uid'] = $this->data['text_invalid_uid'];
}
if(!isset($this->request->post['email']) || strlen($this->request->post['email']) < 3) {
$this->error['email'] = $this->data['text_invalid_email'];
}
else {
$emails = explode("\n", $this->request->post['email']);
foreach ($emails as $email) {
$email = rtrim($email);
$ret = checkemail($email, $this->domains);
if($ret == 0) {
$this->error['email'] = $this->data['text_invalid_email'] . ": $email";
}
else if($ret == -1) {
$this->error['email'] = $this->data['text_email_in_unknown_domain'] . ": $email";
}
}
}
if(!isset($this->request->post['username']) || strlen($this->request->post['username']) < 2) {
$this->error['username'] = $this->data['text_invalid_username'];
}
if(isset($this->request->post['username']) && $this->model_user_user->getUidByName($this->request->post['username']) > 0) {
$this->error['username'] = $this->data['text_existing_user'];
}
if(!isset($this->request->post['domain'])) {
$this->error['domain'] = $this->data['text_missing_data'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,142 @@
<?php
class ControllerUserEdit extends Controller {
private $error = array();
private $domains = array();
public function index(){
$this->data['uid'] = 0;
$this->data['email'] = "";
$this->id = "content";
$this->template = "user/edit.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$language = Registry::get('language');
$this->load->model('user/user');
$this->document->title = $language->get('text_user_management');
$this->data['domains'] = array();
if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0) {
$this->data['uid'] = $this->request->get['uid'];
}
if(isset($this->request->post['uid']) && is_numeric($this->request->post['uid']) && $this->request->post['uid'] > 0) {
$this->data['uid'] = $this->request->post['uid'];
}
$this->domains = $this->model_user_user->get_email_domains();
if(isset($this->request->get['email']) && checkemail($this->request->get['email'], $this->domains) == 1) {
$this->data['email'] = $this->request->get['email'];
}
/* check if we are admin */
if(Registry::get('admin_user') == 1) {
$this->data['domains'] = $this->model_user_user->get_domains();
if($this->request->server['REQUEST_METHOD'] == 'POST') {
if($this->validate() == true){
$ret = $this->model_user_user->updateUser($this->request->post);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_modified'];
} else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_failed_to_modify'] . ": " . $ret;
}
$__username = $this->request->post['username'];
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
}
else {
$this->data['user'] = $this->model_user_user->getUserByUid($this->data['uid']);
$this->data['user']['group_membership'] = $this->model_user_user->get_additional_uids($this->data['uid']);
$this->data['emails'] = $this->model_user_user->getEmails($this->data['user']['username']);
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
}
$this->render();
}
private function validate() {
if(isset($this->request->post['password']) && strlen(@$this->request->post['password']) > 1) {
if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) {
$this->error['password'] = $this->data['text_invalid_password'];
}
if($this->request->post['password'] != $this->request->post['password2']) {
$this->error['password'] = $this->data['text_password_mismatch'];
}
}
if(!isset($this->request->post['uid']) || !is_numeric($this->request->post['uid']) || (int)$this->request->post['uid'] < 0) {
$this->error['uid'] = $this->data['text_invalid_uid'];
}
if(strlen(@$this->request->post['email']) < 4) {
$this->error['email'] = $this->data['text_invalid_email'];
} else {
$emails = explode("\n", $this->request->post['email']);
foreach ($emails as $email) {
$email = rtrim($email);
$ret = checkemail($email, $this->domains);
if($ret == 0) {
$this->error['email'] = $this->data['text_invalid_email'] . ": $email";
}
else if($ret == -1) {
$this->error['email'] = $this->data['text_email_in_unknown_domain'] . ": $email";
}
}
}
if(!isset($this->request->post['username']) || strlen($this->request->post['username']) < 2 ) {
$this->error['username'] = $this->data['text_invalid_username'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,101 @@
<?php
class ControllerUserList extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "user/list.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$language = Registry::get('language');
$this->load->model('user/user');
$this->document->title = $language->get('text_user_management');
$this->data['page'] = 0;
$this->data['page_len'] = get_page_length();
$this->data['total_users'] = 0;
$users = array();
/* get search term if there's any */
if($this->request->server['REQUEST_METHOD'] == 'POST'){
$this->data['search'] = @$this->request->post['search'];
}
else {
$this->data['search'] = @$this->request->get['search'];
}
/* 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'];
}
$this->data['sort'] = 'username';
$this->data['order'] = (int)@$this->request->get['order'];
if(@$this->request->get['sort'] == "uid") { $this->data['sort'] = "uid"; }
if(@$this->request->get['sort'] == "realname") { $this->data['sort'] = "realname"; }
if(@$this->request->get['sort'] == "email") { $this->data['sort'] = "email"; }
if(@$this->request->get['sort'] == "domain") { $this->data['sort'] = "domain"; }
if(@$this->request->get['sort'] == "policy") { $this->data['sort'] = "policy_group"; }
/* check if we are admin */
if(Registry::get('admin_user') == 1) {
$users = $this->model_user_user->getUsers($this->data['search'], $this->data['page'], $this->data['page_len'],
$this->data['sort'], $this->data['order']);
$this->data['total_users'] = $this->model_user_user->howManyUsers($this->data['search']);
foreach ($users as $user) {
$policy_group = DEFAULT_POLICY;
$this->data['users'][] = array(
'uid' => $user['uid'],
'username' => $user['username'],
'realname' => $user['realname'],
'email' => $user['email'],
'shortemail' => short_email($user['email']),
'domain' => $user['domain'],
'policy_group' => $policy_group,
'isadmin' => $user['isadmin']
);
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_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_users'] / $this->data['page_len']);
$this->render();
}
}
?>

View File

@ -0,0 +1,76 @@
<?php
class ControllerUserRemove extends Controller {
private $error = array();
private $domains = array();
private $d = array();
public function index(){
$this->id = "content";
$this->template = "user/remove.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/user');
$this->document->title = $this->data['text_user_management'];
$this->data['username'] = Registry::get('username');
$this->data['uid'] = (int)@$this->request->get['uid'];
$this->data['user'] = @$this->request->get['user'];
$this->data['confirmed'] = (int)@$this->request->get['confirmed'];
if($this->validate() == true) {
if($this->data['confirmed'] == 1) {
$ret = $this->model_user_user->deleteUser($this->data['uid']);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_removed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_remove'];
}
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
$this->render();
}
private function validate() {
if(Registry::get('admin_user') == 0) {
$this->error['admin'] = $this->data['text_you_are_not_admin'];
}
if(!isset($this->request->get['uid']) || !is_numeric($this->request->get['uid']) || $this->request->get['uid'] < 1 ) {
$this->error['username'] = $this->data['text_invalid_uid'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,78 @@
<?php
class ControllerUserSettings extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "user/settings.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('user/auth');
$this->load->model('user/prefs');
$this->document->title = $this->data['text_home'];
if(isset($this->request->post['pagelen']) && isset($this->request->post['lang']) && isset($this->request->post['theme'])) {
$this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post);
AUDIT(ACTION_CHANGE_USER_SETTINGS, '', '', '', 'lang:' . $this->request->post['lang'] . ', pagelen:' . $this->request->post['pagelen'] . ', theme:' . $this->request->post['theme']);
Header("Location: settings.php");
return;
}
if($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) {
if($this->model_user_auth->changePassword(Registry::get('username'), $this->request->post['password']) == 1) {
$this->data['x'] = $this->data['text_password_changed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_change_password'];
}
}
$this->data['page_len'] = get_page_length();
$this->render();
}
private function validate() {
if(!isset($this->request->post['password']) || !isset($this->request->post['password2']) ) {
$this->error['password'] = $this->data['text_missing_password'];
}
if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) {
$this->error['password'] = $this->data['text_invalid_password'];
}
if($this->request->post['password'] != $this->request->post['password2']) {
$this->error['password'] = $this->data['text_password_mismatch'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>