diff --git a/webui/config.php b/webui/config.php index 66daa5f4..e81d7fca 100644 --- a/webui/config.php +++ b/webui/config.php @@ -1,6 +1,7 @@ = NORMAL) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added",date(DATE_TEMPLATE, $return['starttimestamp']),date(DATE_TEMPLATE, $return['stoptimestamp']),$return['deletedstats'],$return['addedstats'])); } return $return; } diff --git a/webui/model/audit/audit.php b/webui/model/audit/audit.php index bf85c38d..f73027f8 100644 --- a/webui/model/audit/audit.php +++ b/webui/model/audit/audit.php @@ -74,7 +74,7 @@ class ModelAuditAudit extends Model { $query = $this->db->query("SELECT COUNT(*) AS count FROM " . TABLE_AUDIT . " $where", $arr); $n = $query->row['count']; - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("audit query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->row['count'])); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("audit query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->row['count'])); } } else { $n = MAX_AUDIT_HITS; } @@ -87,7 +87,7 @@ class ModelAuditAudit extends Model { $this->session->set("audit_query", array('where' => $where, 'sortorder' => $sortorder, 'arr' => $arr)); - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("audit query: '%s', param: '%s' in %.2f s, %d hits", $query->query, implode(' ', $arr), $query->exec_time, $query->num_rows)); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("audit query: '%s', param: '%s' in %.2f s, %d hits", $query->query, implode(' ', $arr), $query->exec_time, $query->num_rows)); } if(isset($query->rows)) { diff --git a/webui/model/policy/retention.php b/webui/model/policy/retention.php index 7bb74f27..7ff99b32 100644 --- a/webui/model/policy/retention.php +++ b/webui/model/policy/retention.php @@ -55,7 +55,7 @@ class ModelPolicyRetention extends Model { $query = $this->db->query("UPDATE " . VIEW_MESSAGES . " SET retained = ? WHERE arrived > ? AND (todomain=? OR fromdomain=?)", array($retained, $start_ts, $data['domain'], $data['domain'])); - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("update retention date: domain='%s', days=%d, hits=%d, exec time=%.2f sec", $data['domain'], $data['days'], $this->db->countAffected(), $query->exec_time)); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("update retention date: domain='%s', days=%d, hits=%d, exec time=%.2f sec", $data['domain'], $data['days'], $this->db->countAffected(), $query->exec_time)); } return $this->db->countAffected(); } diff --git a/webui/model/search/message.php b/webui/model/search/message.php index a854a8cc..fa615662 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -62,6 +62,8 @@ class ModelSearchMessage extends Model { if($id == '' || !preg_match("/^([0-9a-f]+)$/", $id)) { return $s; } + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, DECRYPT_BINARY . " $id"); } + $handle = popen(DECRYPT_BINARY . " $id", "r"); while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))) { $s .= $buf; @@ -89,6 +91,8 @@ class ModelSearchMessage extends Model { if($piler_id == '' || $attachment_id == '' || !preg_match("/^([0-9a-f]+)$/", $piler_id) || !preg_match("/^([0-9m]+)$/", $attachment_id)) { return $data; } + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, DECRYPT_ATTACHMENT_BINARY . " $piler_id $attachment_id"); } + $handle = popen(DECRYPT_ATTACHMENT_BINARY . " $piler_id $attachment_id", "r"); while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))){ $data .= $buf; diff --git a/webui/model/user/auth.php b/webui/model/user/auth.php index 3218ee21..4aa77e17 100644 --- a/webui/model/user/auth.php +++ b/webui/model/user/auth.php @@ -148,7 +148,7 @@ class ModelUserAuth extends Model { foreach($params as $param) { $ret = $this->checkLoginAgainstLDAP_real($username, $password, $data, $param); - syslog(LOG_INFO, "ldap auth result against " . $param['ldap_host'] . " / " . $param['ldap_type'] . ": $ret"); + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "ldap auth result against " . $param['ldap_host'] . " / " . $param['ldap_type'] . ": $ret"); } if($ret == 1) { return $ret; } } @@ -208,7 +208,7 @@ class ModelUserAuth extends Model { $ldap_auth = new LDAP($ldap_host, $a['dn'], $password); - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, "ldap auth against '" . $ldap_host . "', dn: '" . $a['dn'] . "', result: " . $ldap_auth->is_bind_ok()); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "ldap auth against '" . $ldap_host . "', dn: '" . $a['dn'] . "', result: " . $ldap_auth->is_bind_ok()); } if($ldap_auth->is_bind_ok()) { @@ -241,7 +241,7 @@ class ModelUserAuth extends Model { } } } - else if(ENABLE_SYSLOG == 1) { + else if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "cannot bind to '" . $ldap_host . "' as '" . $ldap_helper_dn . "'"); } @@ -281,7 +281,7 @@ class ModelUserAuth extends Model { $data = array(); foreach($e as $a) { - //syslog(LOG_INFO, "checking ldap entry dn: " . $a['dn'] . ", cn: " . $a['cn']); + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking ldap entry dn: " . $a['dn'] . ", cn: " . $a['cn']); } foreach (array("mail", "mailalternateaddress", "proxyaddresses", "zimbraMailForwardingAddress", "member", "memberOfGroup") as $mailattr) { if(isset($a[$mailattr])) { @@ -289,7 +289,7 @@ class ModelUserAuth extends Model { if(is_array($a[$mailattr])) { for($i = 0; $i < $a[$mailattr]['count']; $i++) { - //syslog(LOG_INFO, "checking entry: " . $a[$mailattr][$i]); + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking entry: " . $a[$mailattr][$i]); } $a[$mailattr][$i] = strtolower($a[$mailattr][$i]); @@ -305,7 +305,7 @@ class ModelUserAuth extends Model { } } else { - //syslog(LOG_INFO, "checking entry #2: " . $a[$mailattr]); + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking entry #2: " . $a[$mailattr]); } $email = strtolower(preg_replace("/^([\w]+)\:/i", "", $a[$mailattr])); if(validemail($email) && !in_array($email, $data)) { array_push($data, $email); } @@ -440,7 +440,7 @@ class ModelUserAuth extends Model { if(isset($u[1])) { $username = $u[1]; } else { $username = $_SERVER['REMOTE_USER']; } - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, "sso login: $username"); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "sso login: $username"); } $ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD); @@ -455,7 +455,7 @@ class ModelUserAuth extends Model { $username = strtolower(preg_replace("/^smtp\:/i", "", $username)); if($username == '') { - syslog(LOG_INFO, "no email address found for " . $a['dn']); + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "no email address found for " . $a['dn']); } return 0; } diff --git a/webui/sso.php b/webui/sso.php index 406dbc37..0316f00f 100644 --- a/webui/sso.php +++ b/webui/sso.php @@ -24,7 +24,7 @@ Registry::set('load', $loader); $language = new Language(); Registry::set('language', $language); -if(ENABLE_SYSLOG == 1) { openlog("piler-webui", LOG_PID, LOG_MAIL); } +openlog("piler-webui", LOG_PID, LOG_MAIL); $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX); diff --git a/webui/system/database/ldap.php b/webui/system/database/ldap.php index 3b957a63..49f30ff6 100644 --- a/webui/system/database/ldap.php +++ b/webui/system/database/ldap.php @@ -36,7 +36,7 @@ class LDAP { $results = ldap_get_entries($this->link, $sr); - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("ldap query: base dn='%s', filter='%s', attr='%s', %d hits", $basedn, $filter, implode(" ", $justthese), $results['count'])); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("ldap query: base dn='%s', filter='%s', attr='%s', %d hits", $basedn, $filter, implode(" ", $justthese), $results['count'])); } for($i=0; $i < $results['count']; $i++) { for($k=0; $k < $results[$i]['count']; $k++) { diff --git a/webui/system/database/mysql.php b/webui/system/database/mysql.php index 32465ca5..82147d6e 100644 --- a/webui/system/database/mysql.php +++ b/webui/system/database/mysql.php @@ -30,6 +30,8 @@ class MySQL { public function query($sql, $arr = array()) { $query = new stdClass(); + if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "sql=$sql, arr=" . implode(";", $arr)); } + $query->error = 1; $query->errmsg = "Error"; $query->query = $sql; diff --git a/webui/system/database/sphinx.php b/webui/system/database/sphinx.php index f57eeefc..a4ec3e28 100644 --- a/webui/system/database/sphinx.php +++ b/webui/system/database/sphinx.php @@ -70,7 +70,7 @@ class Sphinx { if($v[0] == "total_found") { $query->total_found = $v[1]; } } - if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("sphinx query: '%s' in %.2f s, %d hits, %d total found", $query->query, $query->exec_time, $query->num_rows, $query->total_found)); } + if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("sphinx query: '%s' in %.2f s, %d hits, %d total found", $query->query, $query->exec_time, $query->num_rows, $query->total_found)); } $session = Registry::get('session'); $sphx_query = '';