From 9a23429cf650c0302a5b3ab8d6a4991bc21a3d90 Mon Sep 17 00:00:00 2001 From: SJ Date: Sun, 28 Jul 2013 20:56:59 +0200 Subject: [PATCH] added dd/mm/yyyy as an acceptable date format --- webui/config.php | 9 ++-- webui/controller/search/helper.php | 4 +- webui/model/audit/audit.php | 2 +- webui/model/search/search.php | 2 +- webui/system/misc.php | 46 ++++--------------- webui/view/javascript/piler-in.js | 4 +- .../theme/default/templates/search/popup.tpl | 4 +- .../theme/mobile/templates/search/popup.tpl | 4 +- 8 files changed, 23 insertions(+), 52 deletions(-) diff --git a/webui/config.php b/webui/config.php index a4c28794..c7301dbd 100644 --- a/webui/config.php +++ b/webui/config.php @@ -173,10 +173,10 @@ $config['PILER_LOGIN_HELPER_PLACEHOLDER'] = 'PILER_COMMENT_FOR_PROPER_LOGIN_SO_T $config['SIZE_X'] = 430; $config['SIZE_Y'] = 250; -$config['AUDIT_DATE_FORMAT'] = 'Y.m.d H:i'; -$config['SEARCH_HIT_DATE_FORMAT'] = 'Y.m.d'; +$config['DATE_TEMPLATE'] = 'Y.m.d'; +$config['DATE_FORMAT'] = 'YYYY-MM-DD'; +$config['JQUERY_DATE_FORMAT'] = 'yy-mm-dd'; -$config['DATE_FORMAT'] = '(Y.m.d.)'; $config['FROM_LENGTH_TO_SHOW'] = 28; @@ -184,8 +184,6 @@ $config['HISTORY_REFRESH'] = 60; $config['HEALTH_REFRESH'] = 60; $config['HEALTH_RATIO'] = 80; -$config['LOG_DATE_FORMAT'] = 'd-M-Y H:i:s'; - $config['MAX_AUDIT_HITS'] = 1000; $config['MIN_PASSWORD_LENGTH'] = 6; @@ -365,4 +363,5 @@ if(!isset($health_smtp_servers)) { $health_smtp_servers = array( array(PILER_HOST, PILER_PORT, "piler"), array(SMARTHOST, SMARTHOST_PORT, "smarthost") ); } + ?> diff --git a/webui/controller/search/helper.php b/webui/controller/search/helper.php index 25f96839..226cc2b1 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -120,7 +120,7 @@ class ControllerSearchHelper extends Controller { while(list($k, $v) = each($b)) { if($v == '') { continue; } - if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v)) { + if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v) || preg_match("/\d{1,2}\/\d{1,2}\/\d{4}/", $v)) { $ndate++; $this->a["date$ndate"] = $v; } @@ -164,7 +164,7 @@ class ControllerSearchHelper extends Controller { else if($v == 'note:') { $token = 'note'; continue; } else if($v == 'ref:') { $token = 'ref'; continue; } else { - if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v)) { + if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v) || preg_match("/\d{1,2}\/\d{1,2}\/\d{4}/", $v)) { $ndate++; $this->a["date$ndate"] = $v; } diff --git a/webui/model/audit/audit.php b/webui/model/audit/audit.php index 0d0d3622..4cbbd076 100644 --- a/webui/model/audit/audit.php +++ b/webui/model/audit/audit.php @@ -91,7 +91,7 @@ class ModelAuditAudit extends Model { 'piler_id' => isset($m[$a['meta_id']]) ? $m[$a['meta_id']] : '', 'action' => $a['action'], 'email' => $a['email'], - 'date' => date(AUDIT_DATE_FORMAT, $a['ts']), + 'date' => date(DATE_TEMPLATE . " H:i", $a['ts']), 'ipaddr' => DEMO_MODE == 1 ? anonimize_ip_addr($a['ipaddr']) : $a['ipaddr'], 'description' => $a['description'], 'shortdescription' => make_short_string($a['description'], MAX_CGI_FROM_SUBJ_LEN) diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 9ecafff7..4baf5ef2 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -510,7 +510,7 @@ class ModelSearchSearch extends Model { $m['subject'] = escape_gt_lt_quote_symbols($m['subject']); $m['shortsubject'] = make_short_string($m['subject'], MAX_CGI_FROM_SUBJ_LEN); - $m['date'] = date(SEARCH_HIT_DATE_FORMAT, $m['sent']); + $m['date'] = date(DATE_TEMPLATE, $m['sent']); $m['size'] = nice_size($m['size']); in_array($m['from'], $_SESSION['emails']) ? $m['yousent'] = 1 : $m['yousent'] = 0; diff --git a/webui/system/misc.php b/webui/system/misc.php index e73e8cd9..3e366525 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -8,14 +8,7 @@ function LOGGER($event = '', $username = '') { else { $username = 'unknown'; } } - $log_entry = sprintf("[%s]: %s, %s, '%s'\n", date(LOG_DATE_FORMAT), $username, $_SERVER['REMOTE_ADDR'], $event); - - if($fp = @fopen(LOG_FILE, 'a')) { - fwrite($fp, $log_entry); - fflush($fp); - fclose($fp); - } - + syslog(LOG_INFO, "username=$username, event='$event'"); } @@ -267,33 +260,6 @@ function my_qp_encode($s){ } -function format_qshape($desc = '', $filename = '') { - $leadingspaces = 999; - - if($filename == '' || !file_exists($filename) ) { return array(); } - - $stat = stat($filename); - - $s = file_get_contents($filename); - - $a = explode("\n", $s); - while(list($k, $v) = each($a)){ - $len1 = strlen($v); - $v = preg_replace("/^\ {0,}/", "", $v); - $delta = $len1 - strlen($v); - if($len1 > 5 && $delta < $leadingspaces) { $leadingspaces = $delta; } - } - - reset($a); $s=""; - - while(list($k, $v) = each($a)){ - $s .= substr($v, $leadingspaces, strlen($v)) . "\n"; - } - - return array('desc' => $desc, 'date' => date(LOG_DATE_FORMAT, $stat['ctime']), 'lines' => $s); -} - - function nice_size($size = 0, $space = '') { if($size < 1000) return "1k"; if($size < 100000) return round($size/1000) . $space . "k"; @@ -436,14 +402,20 @@ function fixup_date_condition($field = '', $date1 = 0, $date2 = 0) { $date = ""; if($date1) { - list($y,$m,$d) = preg_split("/(\.|\-)/", $date1); + list($y,$m,$d) = preg_split("/(\.|\-|\/)/", $date1); + + if(DATE_TEMPLATE == 'd/m/Y') { $a = $y; $y = $d; $d = $a; } + $date1 = mktime(0, 0, 0, $m, $d, $y); if($date1 > 0) { $date .= "$field >= $date1 "; } } if($date2) { - list($y,$m,$d) = preg_split("/(\.|\-)/", $date2); + list($y,$m,$d) = preg_split("/(\.|\-|\/)/", $date2); + + if(DATE_TEMPLATE == 'd/m/Y') { $a = $y; $y = $d; $d = $a; } + $date2 = mktime(23, 59, 59, $m, $d, $y); if($date2 > 0) { diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index 671a1096..243c58b8 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -1037,8 +1037,8 @@ $.datepicker.setDefaults($.datepicker.regional[Piler.piler_ui_lang]); }); - $("#date1").datepicker( {dateFormat: 'yy-mm-dd' }); - $("#date2").datepicker( {dateFormat: 'yy-mm-dd' }); + $("#date1").datepicker( {dateFormat: '' }); + $("#date2").datepicker( {dateFormat: '' }); }); diff --git a/webui/view/theme/default/templates/search/popup.tpl b/webui/view/theme/default/templates/search/popup.tpl index fd5aca5b..e40658f7 100644 --- a/webui/view/theme/default/templates/search/popup.tpl +++ b/webui/view/theme/default/templates/search/popup.tpl @@ -62,14 +62,14 @@
- +
- +
diff --git a/webui/view/theme/mobile/templates/search/popup.tpl b/webui/view/theme/mobile/templates/search/popup.tpl index 5e9c6b7a..043f356a 100644 --- a/webui/view/theme/mobile/templates/search/popup.tpl +++ b/webui/view/theme/mobile/templates/search/popup.tpl @@ -52,12 +52,12 @@
:
-
+
 
-
+