From b95d1cdbc4fe25e3f0df3b94e990f6af7b330c63 Mon Sep 17 00:00:00 2001 From: Michael Rasmussen Date: Sun, 31 May 2015 23:36:52 +0200 Subject: [PATCH] Fix indentation, hopefully;-) --- auth.php | 104 +++++----- index.php | 170 ++++++++-------- js/timer.js | 22 +-- lib/db_factory.php | 18 +- lib/db_implementation.php | 16 +- lib/db_mysqli.inc.php | 270 ++++++++++++------------- lib/utils.inc.php | 404 +++++++++++++++++++------------------- mail_report.php | 216 ++++++++++---------- message_view.php | 160 +++++++-------- quarantine.php | 156 +++++++-------- show_headers.php | 104 +++++----- 11 files changed, 820 insertions(+), 820 deletions(-) diff --git a/auth.php b/auth.php index 120f84b..be1a20d 100644 --- a/auth.php +++ b/auth.php @@ -1,37 +1,37 @@ root . 'lib/utils.inc.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - $auth_url = $_SERVER['PHP_SELF'] . '?op=login'; - $login = $_SERVER['PHP_SELF']; - $login_form = << - - - Login - - - -
-
-

Login

-
-
- - - - -
-
-
- -
- + + + Login + + + +
+
+

Login

+
+
+ + + + +
+
+
+ +
+ LF; @@ -59,29 +59,29 @@ LF; LE; - $util = Utils::getInstance(); - if (isset($_GET['op'])) - $action = $_GET['op']; - else - $action = 'default'; + $util = Utils::getInstance(); + if (isset($_GET['op'])) + $action = $_GET['op']; + else + $action = 'default'; - if ($action == 'logout') { - // logout - $util->logout(); - echo $login_form; - } else if ($action == 'login') { - // login - $user = $_POST['user']; - $password = $_POST['password']; - if ($util->login($user, $password)) { - header('Location: index.php'); - } else { - $error = $util->getLoginStatus(); - $error = str_replace('__ERROR__', $error, $login_error); - echo $error; - } - } else { - echo $login_form; - } + if ($action == 'logout') { + // logout + $util->logout(); + echo $login_form; + } else if ($action == 'login') { + // login + $user = $_POST['user']; + $password = $_POST['password']; + if ($util->login($user, $password)) { + header('Location: index.php'); + } else { + $error = $util->getLoginStatus(); + $error = str_replace('__ERROR__', $error, $login_error); + echo $error; + } + } else { + echo $login_form; + } ?> diff --git a/index.php b/index.php index 9bbd08d..47c88ba 100644 --- a/index.php +++ b/index.php @@ -1,101 +1,101 @@ root . 'lib/db_factory.php'; - require_once $CFG->root . 'lib/utils.inc.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/db_factory.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - $util = Utils::getInstance(); - unset($_SESSION['mailInfo']); - - if ($util->isLoggedIn()) { - if (isset($_GET['rowsperpage'])) { - $rowsPerPage = $_GET['rowsperpage']; - } else { - $rowsPerPage = 20; - } + $util = Utils::getInstance(); + unset($_SESSION['mailInfo']); - $pageNum = 1; - if (isset($_GET['page'])) { - $pageNum = $_GET['page']; - } + if ($util->isLoggedIn()) { + if (isset($_GET['rowsperpage'])) { + $rowsPerPage = $_GET['rowsperpage']; + } else { + $rowsPerPage = 20; + } - $offset = ($pageNum - 1) * $rowsPerPage; + $pageNum = 1; + if (isset($_GET['page'])) { + $pageNum = $_GET['page']; + } - $util->setHeading('Quarantine Administration'); - echo $util->getHeader(); - echo $util->getHeading(); + $offset = ($pageNum - 1) * $rowsPerPage; - echo "{$util->getUser()} - Logout"; - $which = ($util->isAdmin() == true) ? 'all' : $util->getUser(); - $rows = $DB->getQMails($offset, $rowsPerPage, $which); - $numrows = $DB->numRows(); - echo "$numrows quarantined mail(s)"; - echo ""; + $util->setHeading('Quarantine Administration'); + echo $util->getHeader(); + echo $util->getHeading(); + + echo "{$util->getUser()} + Logout"; + $which = ($util->isAdmin() == true) ? 'all' : $util->getUser(); + $rows = $DB->getQMails($offset, $rowsPerPage, $which); + $numrows = $DB->numRows(); + echo "$numrows quarantined mail(s)"; + echo "
"; echo "
"; echo ""; - echo ""; + echo ""; - $mailInfo = array(); - $i = 0; - foreach ($rows as $row) { - if ($i % 2) - echo ''; - else - echo ''; - $id = $row->mail_id; - $mailInfo[$id] = serialize($row); - $url = urlencode($id); - $recipient = "{$row->recipient}"; - $action = ""; - $action .= "\"Release\""; - $action .= " "; - $action .= "\"Delete\""; - $sender = $row->sender; - $received = strftime("%c", $row->time_iso); - $quaratinefor = $util->convertContent($row->quaratinefor); - $subject = $row->subject; + $mailInfo = array(); + $i = 0; + foreach ($rows as $row) { + if ($i % 2) + echo ''; + else + echo ''; + $id = $row->mail_id; + $mailInfo[$id] = serialize($row); + $url = urlencode($id); + $recipient = "{$row->recipient}"; + $action = ""; + $action .= "\"Release\""; + $action .= " "; + $action .= "\"Delete\""; + $sender = $row->sender; + $received = strftime("%c", $row->time_iso); + $quaratinefor = $util->convertContent($row->quaratinefor); + $subject = $row->subject; echo "". ""; - $i++; - } - $_SESSION['mailInfo'] = $mailInfo; - echo "
ReceivedCauseSenderRecipientSubjectAction
$received". "$quaratinefor$sender$recipient$subject$action
"; + $i++; + } + $_SESSION['mailInfo'] = $mailInfo; + echo ""; + + $maxPage = ceil($numrows/$rowsPerPage); + $self = $_SERVER['PHP_SELF']; + + if ($pageNum > 1) { + $page = $pageNum - 1; + $prev = " [Prev]"; + $first = " [First Page] "; + } else { + $prev = ' '; // we're on page one, don't print previous link + $first = ' '; // nor the first page link + } - $maxPage = ceil($numrows/$rowsPerPage); - $self = $_SERVER['PHP_SELF']; - - if ($pageNum > 1) { - $page = $pageNum - 1; - $prev = " [Prev]"; - $first = " [First Page] "; - } else { - $prev = ' '; // we're on page one, don't print previous link - $first = ' '; // nor the first page link - } - - if ($pageNum < $maxPage) { - $page = $pageNum + 1; - $next = " [Next]"; - $last = "[Last Page] "; - } else { - $next = ' '; // we're on the last page, don't print next link - $last = ' '; // nor the last page link - } - $marked = $DB->getMarked($which); - $_SESSION['marked'] = serialize($marked); - echo ''; - echo "

$first$prev Showing page $pageNum of - $maxPage pages $next$last

"; + if ($pageNum < $maxPage) { + $page = $pageNum + 1; + $next = " [Next]"; + $last = "[Last Page] "; + } else { + $next = ' '; // we're on the last page, don't print next link + $last = ' '; // nor the last page link + } + $marked = $DB->getMarked($which); + $_SESSION['marked'] = serialize($marked); + echo ''; + echo "

$first$prev Showing page $pageNum of + $maxPage pages $next$last

"; - echo $util->getFooter(); - } else { - header('Location: auth.php'); - } + echo $util->getFooter(); + } else { + header('Location: auth.php'); + } ?> diff --git a/js/timer.js b/js/timer.js index a7e9c1d..1db783c 100644 --- a/js/timer.js +++ b/js/timer.js @@ -3,18 +3,18 @@ var timerRef=setInterval(function(){myTimer()},1000); var timeStart = new Date().getTime() + timeout; function myTimer() { - var elapsed = new Date().getTime(); - var expire = timeStart - elapsed; - var timeLeft = Math.round(((expire % 86400000) % 3600000) / 60000); + var elapsed = new Date().getTime(); + var expire = timeStart - elapsed; + var timeLeft = Math.round(((expire % 86400000) % 3600000) / 60000); - if (timeLeft < 0) { - timeLeft = 'Expired'; - document.getElementById("time").style.background = "red"; - clearInterval(timerRef); - } else { - timeLeft += 1; - timeLeft = '< ' + timeLeft + ' min'; - } + if (timeLeft < 0) { + timeLeft = 'Expired'; + document.getElementById("time").style.background = "red"; + clearInterval(timerRef); + } else { + timeLeft += 1; + timeLeft = '< ' + timeLeft + ' min'; + } document.getElementById("timer").innerHTML = timeLeft; } diff --git a/lib/db_factory.php b/lib/db_factory.php index 68b1ee5..f40e327 100644 --- a/lib/db_factory.php +++ b/lib/db_factory.php @@ -1,15 +1,15 @@ db_driver)) { - switch ($CFG->db_driver) { - case 'mysqli': - require_once $CFG->root . 'lib/db_mysqli.inc.php'; - $DB = DBMysqli::getInstance(); - break; - default: - die ('Unknow database driver: ' . $CFG->db_driver); - } + switch ($CFG->db_driver) { + case 'mysqli': + require_once $CFG->root . 'lib/db_mysqli.inc.php'; + $DB = DBMysqli::getInstance(); + break; + default: + die ('Unknow database driver: ' . $CFG->db_driver); + } } else { - die ('Missing config file'); + die ('Missing config file'); } ?> diff --git a/lib/db_implementation.php b/lib/db_implementation.php index c35754f..4304328 100644 --- a/lib/db_implementation.php +++ b/lib/db_implementation.php @@ -2,13 +2,13 @@ /* vim: set ts=4 tw=0 sw=4 noet: */ abstract class DBImpl { - private function __clone() {} + private function __clone() {} - abstract protected static function getInstance(); - abstract protected function getQMails($offset = -1, $rowsPerPage = -1, $recipient = 'all'); - abstract protected function getMarked($recipient = 'all'); - abstract protected function numRows(); - abstract protected function getMail($id); - abstract protected function setCharset($charset = 'utf8'); - abstract protected function update($sql); + abstract protected static function getInstance(); + abstract protected function getQMails($offset = -1, $rowsPerPage = -1, $recipient = 'all'); + abstract protected function getMarked($recipient = 'all'); + abstract protected function numRows(); + abstract protected function getMail($id); + abstract protected function setCharset($charset = 'utf8'); + abstract protected function update($sql); } diff --git a/lib/db_mysqli.inc.php b/lib/db_mysqli.inc.php index 5e5b157..584e843 100644 --- a/lib/db_mysqli.inc.php +++ b/lib/db_mysqli.inc.php @@ -4,147 +4,147 @@ require_once $CFG->root .'lib/db_implementation.php'; class DBMysqli extends DBImpl { - private static $_instance = null; - private $con = null; - private $charset = 'utf8'; - private $numRows = -1; - - private function __construct() { - $this->connect(); - } - - function __destruct() { - if ($this->con) { - $this->con->close(); - $this->con = null; - } - } - - private function __clone() {} - - public static function getInstance() { - if (!is_object(self::$_instance)) { - self::$_instance = new DBMysqli(); - } - return self::$_instance; - } - - private function connect() { - global $CFG; - - if (!$this->con) { - $this->con = new mysqli($CFG->amavisd_db_host, $CFG->amavisd_db_user, - $CFG->amavisd_db_password, $CFG->amavisd_db_name, - $CFG->amavisd_db_port); - if ($this->con->connect_error) { - die ('Connect error ('.$this->con->connect_errno.') '. - $this->con->connect_error); - } - } - } - - public function setCharset($charset = 'utf8') { - $this->charset = $charset; - } - - private function changeCharset() { - if (!$this->con->set_charset($this->charset)) { - printf("Error loading character set %s: %s\n", $this->charset, $this->con->error); - } - } - - public function update($sql) { - $success = true; - - if (! is_array($sql)) { - $sql = array($sql); - } - - $this->con->autocommit(false); - foreach ($sql as $query) { - $this->con->query($query) ? null : $success = false; - } - $success ? $this->con->commit() : $this->con->rollback(); - $this->con->autocommit(true); - - return $success; - } - - function getMarked($recipient = 'all') { - $all = array(); - - $query = "select distinct m.mail_id as id from quarantine q, msgrcpt m, msgs s, maddr r "; - $query .= "where m.mail_id = q.mail_id and q.mail_id = s.mail_id and m.rid = r.id "; - $query .= "and (m.rs = 'R' or m.rs = 'D')"; + private static $_instance = null; + private $con = null; + private $charset = 'utf8'; + private $numRows = -1; + + private function __construct() { + $this->connect(); + } + + function __destruct() { + if ($this->con) { + $this->con->close(); + $this->con = null; + } + } + + private function __clone() {} + + public static function getInstance() { + if (!is_object(self::$_instance)) { + self::$_instance = new DBMysqli(); + } + return self::$_instance; + } + + private function connect() { + global $CFG; + + if (!$this->con) { + $this->con = new mysqli($CFG->amavisd_db_host, $CFG->amavisd_db_user, + $CFG->amavisd_db_password, $CFG->amavisd_db_name, + $CFG->amavisd_db_port); + if ($this->con->connect_error) { + die ('Connect error ('.$this->con->connect_errno.') '. + $this->con->connect_error); + } + } + } + + public function setCharset($charset = 'utf8') { + $this->charset = $charset; + } + + private function changeCharset() { + if (!$this->con->set_charset($this->charset)) { + printf("Error loading character set %s: %s\n", $this->charset, $this->con->error); + } + } + + public function update($sql) { + $success = true; + + if (! is_array($sql)) { + $sql = array($sql); + } + + $this->con->autocommit(false); + foreach ($sql as $query) { + $this->con->query($query) ? null : $success = false; + } + $success ? $this->con->commit() : $this->con->rollback(); + $this->con->autocommit(true); + + return $success; + } + + function getMarked($recipient = 'all') { + $all = array(); + + $query = "select distinct m.mail_id as id from quarantine q, msgrcpt m, msgs s, maddr r "; + $query .= "where m.mail_id = q.mail_id and q.mail_id = s.mail_id and m.rid = r.id "; + $query .= "and (m.rs = 'R' or m.rs = 'D')"; if ($recipient != 'all') { $query .= " and email = '$recipient'"; } if ($result = $this->con->query($query)) { - while ($row = $result->fetch_object()) { - $all[] = $row->id; - } - } - - return $all; - } - - public function getQMails($offset = -1, $rowsPerPage = -1, $recipient = 'all') { - $row = array(); - $this->changeCharset(); - $query = "SELECT DISTINCT quarantine.mail_id, secret_id, rs, bspam_level, "; - $query .= "(UNIX_TIMESTAMP(time_iso) + (3600 * 2)) AS time_iso, "; - $query .= "SUBSTRING(sender.email,1,35) AS sender, "; - $query .= "SUBSTRING(recipient.email,1,28) AS recipient, size, msgrcpt.content "; - $query .= "AS quaratinefor, SUBSTRING( subject, 1, 25) AS subject FROM "; - $query .= "`quarantine` LEFT JOIN msgrcpt ON msgrcpt.mail_id = quarantine.mail_id "; - $query .= "LEFT JOIN msgs ON msgs.mail_id = quarantine.mail_id LEFT JOIN maddr AS "; - $query .= "recipient ON msgrcpt.rid = recipient.id LEFT JOIN maddr AS sender ON "; - $query .= "msgs.sid = sender.id WHERE msgrcpt.rs != 'R' AND msgrcpt.rs != 'D'"; - - if ($recipient != 'all') { - $query .= " and recipient.email = '$recipient'"; - } - - if ($offset >= 0 && $rowsPerPage >= 0) { - $result = $this->con->query($query, MYSQLI_STORE_RESULT); - if ($result) { - $this->numRows = $result->num_rows; - $result->free(); - } else { - $this->numRows = 0; - } - $query .= " ORDER BY time_iso DESC LIMIT $offset, $rowsPerPage"; - } - - if ($result = $this->con->query($query, MYSQLI_USE_RESULT)) { - if ($this->numRows < 0) - $this->numRows = $result->num_rows; - while ($obj = $result->fetch_object()) { - $row[] = $obj; - } - $result->free(); - } - - return $row; - } - - public function numRows() { - return $this->numRows; - } - - public function getMail($id) { - $row = null; - - $this->changeCharset(); - $query = "SELECT * FROM quarantine WHERE mail_id = '$id'"; - if ($result = $this->con->query($query, MYSQLI_USE_RESULT)) { - $row = $result->fetch_object(); - } - - return $row; - } + while ($row = $result->fetch_object()) { + $all[] = $row->id; + } + } + + return $all; + } + + public function getQMails($offset = -1, $rowsPerPage = -1, $recipient = 'all') { + $row = array(); + $this->changeCharset(); + $query = "SELECT DISTINCT quarantine.mail_id, secret_id, rs, bspam_level, "; + $query .= "(UNIX_TIMESTAMP(time_iso) + (3600 * 2)) AS time_iso, "; + $query .= "SUBSTRING(sender.email,1,35) AS sender, "; + $query .= "SUBSTRING(recipient.email,1,28) AS recipient, size, msgrcpt.content "; + $query .= "AS quaratinefor, SUBSTRING( subject, 1, 25) AS subject FROM "; + $query .= "`quarantine` LEFT JOIN msgrcpt ON msgrcpt.mail_id = quarantine.mail_id "; + $query .= "LEFT JOIN msgs ON msgs.mail_id = quarantine.mail_id LEFT JOIN maddr AS "; + $query .= "recipient ON msgrcpt.rid = recipient.id LEFT JOIN maddr AS sender ON "; + $query .= "msgs.sid = sender.id WHERE msgrcpt.rs != 'R' AND msgrcpt.rs != 'D'"; + + if ($recipient != 'all') { + $query .= " and recipient.email = '$recipient'"; + } + + if ($offset >= 0 && $rowsPerPage >= 0) { + $result = $this->con->query($query, MYSQLI_STORE_RESULT); + if ($result) { + $this->numRows = $result->num_rows; + $result->free(); + } else { + $this->numRows = 0; + } + $query .= " ORDER BY time_iso DESC LIMIT $offset, $rowsPerPage"; + } + + if ($result = $this->con->query($query, MYSQLI_USE_RESULT)) { + if ($this->numRows < 0) + $this->numRows = $result->num_rows; + while ($obj = $result->fetch_object()) { + $row[] = $obj; + } + $result->free(); + } + + return $row; + } + + public function numRows() { + return $this->numRows; + } + + public function getMail($id) { + $row = null; + + $this->changeCharset(); + $query = "SELECT * FROM quarantine WHERE mail_id = '$id'"; + if ($result = $this->con->query($query, MYSQLI_USE_RESULT)) { + $row = $result->fetch_object(); + } + + return $row; + } } diff --git a/lib/utils.inc.php b/lib/utils.inc.php index e9e8518..2f1671d 100644 --- a/lib/utils.inc.php +++ b/lib/utils.inc.php @@ -4,145 +4,145 @@ require_once $CFG->root .'config.php'; class Utils { - private static $_instance = null; - private $server; - private $user; - private $is_admin; - private $loginStatus; - private $header = ' + private static $_instance = null; + private $server; + private $user; + private $is_admin; + private $loginStatus; + private $header = ' - - - - - __TITLE__ + + + + + __TITLE__ '; - private $footer = ''; - private $heading = '

Session timeout: -

__TITLE__

'; - - private function __construct() { - global $CFG; - - $this->server = $_SERVER; - session_start(); - - $this->user = null; - $this->is_admin = false; - $this->loginStatus = 'Not logged in'; - - if (isset($_SESSION['user'])) { - $this->user = $_SESSION['user']; - $this->loginStatus = 'OK'; - $this->is_admin = $_SESSION['is_admin']; - } else { - if ($CFG->auth_method == 'HTTP_AUTH') { - if (isset($this->server['PHP_AUTH_USER'])) { - $this->user = $this->server['PHP_AUTH_USER']; - $this->loginStatus = 'OK'; - if ($CFG->admin_user == $this->user) - $this->is_admin = true; - } - } - } - $_SESSION['user'] = $this->user; - $_SESSION['is_admin'] = $this->is_admin; - } - - private function __clone() {} - - public static function getInstance() { - global $CFG; - - if (!is_object(self::$_instance)) { - self::$_instance = new Utils(); - } - // Session timeout handler - if ('' == session_id()) - session_start(); - if (isset($CFG->session_timeout)) { - $timeout = $CFG->session_timeout * 60; - } else { - $timeout = 20 * 60; - } - - if (ini_get('session.gc_maxlifetime') != $timeout) - ini_set('session.gc_maxlifetime', $timeout); - if (ini_get('session.cookie_lifetime') != $timeout) - ini_set('session.cookie_lifetime', $timeout); - $time = $_SERVER['REQUEST_TIME']; - if (isset($_SESSION['LAST_ACTIVITY']) && ($time - $_SESSION['LAST_ACTIVITY']) >= $timeout) { - session_unset(); - session_destroy(); - session_start(); - self::$_instance->user = null; - self::$_instance->is_admin = false; - } - $_SESSION['LAST_ACTIVITY'] = $time; - - return self::$_instance; - } - - public function logout() { - $_SESSION = array(); - if (ini_get('session.use_cookies')) { - $params = session_get_cookie_params(); - setcookie(session_name(), '', time() - 42000, - $params['path'], $params['domain'], - $params['secure'], $params['httponly']); - } - session_unset(); - session_destroy(); - $this->user = null; - $this->is_admin = false; - } - - public function isAdmin() { - //file_put_contents('/tmp/login.txt', var_export($this, true)); - return $this->is_admin; - } - - public function login($user, $pw) { - global $CFG; - $result = false; - - unset($_SESSION['user']); - unset($_SESSION['is_admin']); - $this->user = null; - $this->is_admin = false; - - $p = explode('@', $user); - if (count($p) != 2) { - $this->loginStatus = 'Bad username'; - return false; - } - $domain = $p[1]; - $dn = "mail=$user,ou=Users,domainName=$domain,$CFG->ldap_base_dn"; + private $footer = ''; + private $heading = '

Session timeout: +

__TITLE__

'; + + private function __construct() { + global $CFG; + + $this->server = $_SERVER; + session_start(); + + $this->user = null; + $this->is_admin = false; + $this->loginStatus = 'Not logged in'; + + if (isset($_SESSION['user'])) { + $this->user = $_SESSION['user']; + $this->loginStatus = 'OK'; + $this->is_admin = $_SESSION['is_admin']; + } else { + if ($CFG->auth_method == 'HTTP_AUTH') { + if (isset($this->server['PHP_AUTH_USER'])) { + $this->user = $this->server['PHP_AUTH_USER']; + $this->loginStatus = 'OK'; + if ($CFG->admin_user == $this->user) + $this->is_admin = true; + } + } + } + $_SESSION['user'] = $this->user; + $_SESSION['is_admin'] = $this->is_admin; + } + + private function __clone() {} + + public static function getInstance() { + global $CFG; + + if (!is_object(self::$_instance)) { + self::$_instance = new Utils(); + } + // Session timeout handler + if ('' == session_id()) + session_start(); + if (isset($CFG->session_timeout)) { + $timeout = $CFG->session_timeout * 60; + } else { + $timeout = 20 * 60; + } + + if (ini_get('session.gc_maxlifetime') != $timeout) + ini_set('session.gc_maxlifetime', $timeout); + if (ini_get('session.cookie_lifetime') != $timeout) + ini_set('session.cookie_lifetime', $timeout); + $time = $_SERVER['REQUEST_TIME']; + if (isset($_SESSION['LAST_ACTIVITY']) && ($time - $_SESSION['LAST_ACTIVITY']) >= $timeout) { + session_unset(); + session_destroy(); + session_start(); + self::$_instance->user = null; + self::$_instance->is_admin = false; + } + $_SESSION['LAST_ACTIVITY'] = $time; + + return self::$_instance; + } + + public function logout() { + $_SESSION = array(); + if (ini_get('session.use_cookies')) { + $params = session_get_cookie_params(); + setcookie(session_name(), '', time() - 42000, + $params['path'], $params['domain'], + $params['secure'], $params['httponly']); + } + session_unset(); + session_destroy(); + $this->user = null; + $this->is_admin = false; + } + + public function isAdmin() { + //file_put_contents('/tmp/login.txt', var_export($this, true)); + return $this->is_admin; + } + + public function login($user, $pw) { + global $CFG; + $result = false; + + unset($_SESSION['user']); + unset($_SESSION['is_admin']); + $this->user = null; + $this->is_admin = false; + + $p = explode('@', $user); + if (count($p) != 2) { + $this->loginStatus = 'Bad username'; + return false; + } + $domain = $p[1]; + $dn = "mail=$user,ou=Users,domainName=$domain,$CFG->ldap_base_dn"; $filter = "(&(objectclass=mailUser)(accountStatus=active)(mail=$user))"; $ds = @ldap_connect($CFG->ldap_dsn); if ($ds) { - @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); $r = @ldap_bind($ds, $dn, $pw); if ($r) { $sr = @ldap_search($ds, $CFG->ldap_base_dn, $filter, array('mail','domainglobaladmin')); $info = @ldap_get_entries($ds, $sr); // array if ($info['count'] > 0) { - $_SESSION['user'] = $user; - $this->user = $user; - $result = true; - $this->loginStatus = 'OK'; - $admin = 'NO'; - if (isset($info[0]['domainglobaladmin'])) { - $admin = $info[0]['domainglobaladmin'][0]; - $admin = strtoupper($admin); - } - $this->is_admin = ($admin == 'YES') ? true : false; - $_SESSION['is_admin'] = $this->is_admin; + $_SESSION['user'] = $user; + $this->user = $user; + $result = true; + $this->loginStatus = 'OK'; + $admin = 'NO'; + if (isset($info[0]['domainglobaladmin'])) { + $admin = $info[0]['domainglobaladmin'][0]; + $admin = strtoupper($admin); + } + $this->is_admin = ($admin == 'YES') ? true : false; + $_SESSION['is_admin'] = $this->is_admin; } else { $this->loginStatus = 'Login failed'; } @@ -154,80 +154,80 @@ class Utils { $this->loginStatus = 'Connect to LDAP server failed'; } - return $result; - } - - public function getLoginStatus() { - return $this->loginStatus; - } - - public function isLoggedIn() { - global $CFG; - $loggedIn = false; - - if ($this->user) { - $loggedIn = true; - } else if (isset($_SESSION['user'])) { - $this->user = $_SESSION['user']; - $loggedIn = true; - } else { - if ($CFG->auth_method == 'HTTP_AUTH') { - if (isset($this->server['PHP_AUTH_USER'])) { - $this->user = $this->server['PHP_AUTH_USER']; - $loggedIn = true; - } - } - } - - return $loggedIn; - } - - public function getUser() { - $this->isLoggedIn(); - return $this->user; - } - - public function getHeader() { - return $this->header; - } - - public function getFooter() { - return $this->footer; - } - - public function getHeading() { - return $this->heading; - } - - public function setHeading($heading) { - global $CFG; - - $timeout = $CFG->session_timeout * 60 * 1000; - $this->heading = str_replace('__TITLE__', $heading, $this->heading); - $this->header = str_replace('__TITLE__', $heading, $this->header); - $this->header = str_replace('__ROOT__', $CFG->wwwroot, $this->header); - $this->header = str_replace('__TIMEOUT__', $timeout, $this->header); - } - - public function convertContent($code) { - $table = array( - 'V' => 'Virus', - 'B' => 'Banned', - 'U' => 'Unchecked', - 'S' => 'Spam', - 'Y' => 'Spammy', - 'M' => 'Bad Mime', - 'H' => 'Bad Header', - 'O' => 'Over sized', - 'T' => 'MTA err', - 'C' => 'Clean' - ); - - $string = $table[$code]; - if (empty($string)) - $string = 'Unknown'; - - return $string; - } + return $result; + } + + public function getLoginStatus() { + return $this->loginStatus; + } + + public function isLoggedIn() { + global $CFG; + $loggedIn = false; + + if ($this->user) { + $loggedIn = true; + } else if (isset($_SESSION['user'])) { + $this->user = $_SESSION['user']; + $loggedIn = true; + } else { + if ($CFG->auth_method == 'HTTP_AUTH') { + if (isset($this->server['PHP_AUTH_USER'])) { + $this->user = $this->server['PHP_AUTH_USER']; + $loggedIn = true; + } + } + } + + return $loggedIn; + } + + public function getUser() { + $this->isLoggedIn(); + return $this->user; + } + + public function getHeader() { + return $this->header; + } + + public function getFooter() { + return $this->footer; + } + + public function getHeading() { + return $this->heading; + } + + public function setHeading($heading) { + global $CFG; + + $timeout = $CFG->session_timeout * 60 * 1000; + $this->heading = str_replace('__TITLE__', $heading, $this->heading); + $this->header = str_replace('__TITLE__', $heading, $this->header); + $this->header = str_replace('__ROOT__', $CFG->wwwroot, $this->header); + $this->header = str_replace('__TIMEOUT__', $timeout, $this->header); + } + + public function convertContent($code) { + $table = array( + 'V' => 'Virus', + 'B' => 'Banned', + 'U' => 'Unchecked', + 'S' => 'Spam', + 'Y' => 'Spammy', + 'M' => 'Bad Mime', + 'H' => 'Bad Header', + 'O' => 'Over sized', + 'T' => 'MTA err', + 'C' => 'Clean' + ); + + $string = $table[$code]; + if (empty($string)) + $string = 'Unknown'; + + return $string; + } } diff --git a/mail_report.php b/mail_report.php index 82380fa..55b7ac4 100644 --- a/mail_report.php +++ b/mail_report.php @@ -1,142 +1,142 @@ root . 'lib/db_factory.php'; - require_once $CFG->root . 'lib/utils.inc.php'; + require_once 'Mail/mimeDecode.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/db_factory.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - $util = Utils::getInstance(); - $loggedIn = $util->isLoggedIn(); - if ($loggedIn && isset($_GET['id'])) { - $util->setHeading('Spam Report'); - echo $util->getHeader(); - echo $util->getHeading(); + $util = Utils::getInstance(); + $loggedIn = $util->isLoggedIn(); + if ($loggedIn && isset($_GET['id'])) { + $util->setHeading('Spam Report'); + echo $util->getHeader(); + echo $util->getHeading(); - $id = $_GET['id']; - $mail = unserialize($_SESSION['mailInfo'][$id]); + $id = $_GET['id']; + $mail = unserialize($_SESSION['mailInfo'][$id]); - $row = $DB->getMail($id); - $string = $row->mail_text; - $sa_tests = null; - $params['include_bodies'] = false; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - $params['input'] = $string; - $params['crlf'] = "\r\n"; - - $structure = Mail_mimeDecode::decode($params); - $headers = $structure->headers; - $rows = array(); - foreach ($headers as $header => $value) { - if ($header == 'x-spam-status') { - if (preg_match('/^(.*),\s*score=([\d\.]+).*tests=\[(.*)\].*/', - $value, $matches)) { - $sa_tests = array('x-spam-status' => $matches[1], - 'score' => $matches[2], 'tests' => $matches[3]); - } - } else if ($header == 'x-spam-flag') { + $row = $DB->getMail($id); + $string = $row->mail_text; + $sa_tests = null; + $params['include_bodies'] = false; + $params['decode_bodies'] = true; + $params['decode_headers'] = true; + $params['input'] = $string; + $params['crlf'] = "\r\n"; + + $structure = Mail_mimeDecode::decode($params); + $headers = $structure->headers; + $rows = array(); + foreach ($headers as $header => $value) { + if ($header == 'x-spam-status') { + if (preg_match('/^(.*),\s*score=([\d\.]+).*tests=\[(.*)\].*/', + $value, $matches)) { + $sa_tests = array('x-spam-status' => $matches[1], + 'score' => $matches[2], 'tests' => $matches[3]); + } + } else if ($header == 'x-spam-flag') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); - $rows['spam'] = "Spam$value"; + $value = str_replace(">", ">", $value); + $rows['spam'] = "Spam$value"; } else if ($header == 'x-spam-score') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['score'] = "Spam Score$value"; } else if ($header == 'x-spam-level') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['level'] = "Spam Level$value"; } else if ($header == 'date') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['date'] = "Date$value"; } else if ($header == 'from') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['from'] = "From$value"; } else if ($header == 'reply-to') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['reply-to'] = "Reply-to$value"; } else if ($header == 'to') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['to'] = "To$value"; } else if ($header == 'subject') { $value = str_replace("<", "<", $value); - $value = str_replace(">", ">", $value); + $value = str_replace(">", ">", $value); $rows['subject'] = "Subject$value"; } else if ($header == 'received') { - $headers = ''; - foreach ($value as $val) { + $headers = ''; + foreach ($value as $val) { $val = str_replace("<", "<", $val); - $val = str_replace(">", ">", $val); + $val = str_replace(">", ">", $val); $headers .= ($headers == '') ? "$val" : "

$val"; } $rows['headers'] = "Headers$headers"; - } - } - $bayes = array(); - if ($sa_tests) { - $sa_tests['tests'] = str_replace(" ","",$sa_tests['tests']); - $sa_rules = explode(",",$sa_tests['tests']); - $sa_count = count($sa_rules); - for ($i = 0; $i < $sa_count; $i++) { - $sa_rule = explode("=", $sa_rules[$i]); - $bayes[$i] = "$sa_rule[0]$sa_rule[1]"; - } - $bayes['total'] = "TOTAL".$sa_tests['score'].""; - } else { - $bayes['total'] = "TOTAL-"; - } - $plain = "?id=$id&format=plain"; - $html = "?id=$id&format=html"; - echo '

Message ID : ' . $mail->mail_id . '

'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; - echo ''; - if (isset($rows['spam'])) - echo $rows['spam']; - if (isset($rows['score'])) - echo $rows['score']; - if (isset($rows['level'])) - echo $rows['level']; - if (isset($rows['headers'])) - echo $rows['headers']; - if (isset($rows['date'])) - echo $rows['date']; - if (isset($rows['from'])) - echo $rows['from']; - if (isset($rows['reply-to'])) - echo $rows['reply-to']; - if (isset($rows['to'])) - echo $rows['to']; - if (isset($rows['subject'])) - echo $rows['subject']; - echo '
'; - echo '

Spamassassin Report

'; - echo ''; - foreach ($bayes as $key => $row) { - if ($key != 'total') { - echo $row; - } - } - echo $bayes['total']; - echo '
RuleScore
'; - echo $util->getFooter(); - } else if ($loggedIn) { - header('Location: index.php'); - } else { - header('Location: auth.php'); - } + } + } + $bayes = array(); + if ($sa_tests) { + $sa_tests['tests'] = str_replace(" ","",$sa_tests['tests']); + $sa_rules = explode(",",$sa_tests['tests']); + $sa_count = count($sa_rules); + for ($i = 0; $i < $sa_count; $i++) { + $sa_rule = explode("=", $sa_rules[$i]); + $bayes[$i] = "$sa_rule[0]$sa_rule[1]"; + } + $bayes['total'] = "TOTAL".$sa_tests['score'].""; + } else { + $bayes['total'] = "TOTAL-"; + } + $plain = "?id=$id&format=plain"; + $html = "?id=$id&format=html"; + echo '

Message ID : ' . $mail->mail_id . '

'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + echo ''; + if (isset($rows['spam'])) + echo $rows['spam']; + if (isset($rows['score'])) + echo $rows['score']; + if (isset($rows['level'])) + echo $rows['level']; + if (isset($rows['headers'])) + echo $rows['headers']; + if (isset($rows['date'])) + echo $rows['date']; + if (isset($rows['from'])) + echo $rows['from']; + if (isset($rows['reply-to'])) + echo $rows['reply-to']; + if (isset($rows['to'])) + echo $rows['to']; + if (isset($rows['subject'])) + echo $rows['subject']; + echo '
'; + echo '

Spamassassin Report

'; + echo ''; + foreach ($bayes as $key => $row) { + if ($key != 'total') { + echo $row; + } + } + echo $bayes['total']; + echo '
RuleScore
'; + echo $util->getFooter(); + } else if ($loggedIn) { + header('Location: index.php'); + } else { + header('Location: auth.php'); + } ?> diff --git a/message_view.php b/message_view.php index aeaa496..751b65b 100644 --- a/message_view.php +++ b/message_view.php @@ -1,94 +1,94 @@ root . 'lib/db_factory.php'; - require_once $CFG->root . 'lib/utils.inc.php'; + require_once 'Mail/mimeDecode.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/db_factory.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - $util = Utils::getInstance(); - $loggedIn = $util->isLoggedIn(); - if ($loggedIn && isset($_GET['id'])) { + $util = Utils::getInstance(); + $loggedIn = $util->isLoggedIn(); + if ($loggedIn && isset($_GET['id'])) { $id = $_GET['id']; $id = urldecode($id); - $util->setHeading("Message ID : $id"); - echo $util->getHeader(); - echo $util->getHeading(); + $util->setHeading("Message ID : $id"); + echo $util->getHeader(); + echo $util->getHeading(); - $mail = unserialize($_SESSION['mailInfo'][$id]); + $mail = unserialize($_SESSION['mailInfo'][$id]); - $row = $DB->getMail($id); - $string = $row->mail_text; - $sa_tests = null; - $params['include_bodies'] = true; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - $params['input'] = $string; - $params['crlf'] = "\r\n"; - - $structure = Mail_mimeDecode::decode($params); - $headers = $structure->headers; + $row = $DB->getMail($id); + $string = $row->mail_text; + $sa_tests = null; + $params['include_bodies'] = true; + $params['decode_bodies'] = true; + $params['decode_headers'] = true; + $params['input'] = $string; + $params['crlf'] = "\r\n"; - echo ''; - echo ''; - echo ''; - echo '
'; + $structure = Mail_mimeDecode::decode($params); + $headers = $structure->headers; - echo ''; - $from = $headers['from']; - $from = str_replace("<", "<", $from); - $from = str_replace(">", ">", $from); - echo ""; - $to = $headers['to']; - $to = str_replace("<", "<", $to); - $to = str_replace(">", ">", $to); - echo ""; - $date = $headers['date']; - $date = str_replace("<", "<", $date); - $date = str_replace(">", ">", $date); - echo ""; - echo ""; - echo '
From$from
To$to
Date$date
Subject".$headers['subject']."
Body'; - if (isset($structure->parts)) { - foreach ($structure->parts as $part) { - if ($_GET['format'] == 'html') { - if ($part->ctype_primary=="text" and $part->ctype_secondary=="html") { - $bodytext = str_replace("\n", " ",$part->body); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - echo $bodytext; - } - } else { - if ($part->ctype_primary=="text" and $part->ctype_secondary=="plain") { - $bodytext = str_replace("\n", "
",$part->body); - echo $bodytext; - } - } - } - } else { - if ($_GET['format'] == 'html') { - $bodytext = str_replace("\n", " ",$structure->body); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); + echo ''; + echo ''; + echo ''; + echo '
'; - $bodytext = str_replace("", "", $bodytext); - $bodytext = str_replace("", "", $bodytext); - echo $bodytext; - } else { - $bodytext = $structure->body; - $bodytext = wordwrap($bodytext, 90, "
"); - echo $bodytext; - } - } - echo '
'; - echo $util->getFooter(); + echo ''; + $from = $headers['from']; + $from = str_replace("<", "<", $from); + $from = str_replace(">", ">", $from); + echo ""; + $to = $headers['to']; + $to = str_replace("<", "<", $to); + $to = str_replace(">", ">", $to); + echo ""; + $date = $headers['date']; + $date = str_replace("<", "<", $date); + $date = str_replace(">", ">", $date); + echo ""; + echo ""; + echo '
From$from
To$to
Date$date
Subject".$headers['subject']."
Body'; + if (isset($structure->parts)) { + foreach ($structure->parts as $part) { + if ($_GET['format'] == 'html') { + if ($part->ctype_primary=="text" and $part->ctype_secondary=="html") { + $bodytext = str_replace("\n", " ",$part->body); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + echo $bodytext; + } + } else { + if ($part->ctype_primary=="text" and $part->ctype_secondary=="plain") { + $bodytext = str_replace("\n", "
",$part->body); + echo $bodytext; + } + } + } + } else { + if ($_GET['format'] == 'html') { + $bodytext = str_replace("\n", " ",$structure->body); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + + $bodytext = str_replace("", "", $bodytext); + $bodytext = str_replace("", "", $bodytext); + echo $bodytext; + } else { + $bodytext = $structure->body; + $bodytext = wordwrap($bodytext, 90, "
"); + echo $bodytext; + } + } + echo '
'; + echo $util->getFooter(); } else if ($loggedIn) { header('Location: index.php'); } else { diff --git a/quarantine.php b/quarantine.php index 9186378..9155602 100644 --- a/quarantine.php +++ b/quarantine.php @@ -1,90 +1,90 @@ root . 'lib/db_factory.php'; - require_once $CFG->root . 'lib/utils.inc.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/db_factory.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - function error($error) { - $util = Utils::getInstance(); - $util->setHeading("Error"); - echo $util->getHeader(); - echo $util->getHeading(); - echo "

$error

"; - echo 'Return'; - echo $util->getFooter(); - } + function error($error) { + $util = Utils::getInstance(); + $util->setHeading("Error"); + echo $util->getHeader(); + echo $util->getHeading(); + echo "

$error

"; + echo 'Return'; + echo $util->getFooter(); + } - $util = Utils::getInstance(); - $loggedIn = $util->isLoggedIn(); - $request = isset($_GET['op']) ? $_GET['op'] : ''; - if ($loggedIn && isset($_GET['id'])) { + $util = Utils::getInstance(); + $loggedIn = $util->isLoggedIn(); + $request = isset($_GET['op']) ? $_GET['op'] : ''; + if ($loggedIn && isset($_GET['id'])) { $mail_id = urldecode($_GET['id']); - $mail = unserialize($_SESSION['mailInfo']["$mail_id"]); - $secret_id = $mail->secret_id; - $recipient = $mail->recipient; + $mail = unserialize($_SESSION['mailInfo']["$mail_id"]); + $secret_id = $mail->secret_id; + $recipient = $mail->recipient; - $query = array(); - if ($request == 'release') { - $amavisserver = $CFG->amavisd_db_host; - $policy_port = $CFG->amavis_policy_port; + $query = array(); + if ($request == 'release') { + $amavisserver = $CFG->amavisd_db_host; + $policy_port = $CFG->amavis_policy_port; - $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30); - if (!$fp) { - error("$errstr ($errno)"); - exit; - } - $out = "request=" . $request . "\r\n"; - $out .= "mail_id=" . $mail_id . "\r\n"; - $out .= "recipient=" . $recipient . "\r\n"; - $out .= "secret_id=" . $secret_id . "\r\n\r\n"; - fwrite($fp, $out); - $response = fread($fp, 8192); - fclose($fp); - $response = urldecode($response); - if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) { - error("Request to release failed [$out][$response]"); - exit; - } - if ($matches[1] != '2.0.0') { - error($matches[2]); - exit; - } + $fp = fsockopen($amavisserver, $policy_port, $errno, $errstr, 30); + if (!$fp) { + error("$errstr ($errno)"); + exit; + } + $out = "request=" . $request . "\r\n"; + $out .= "mail_id=" . $mail_id . "\r\n"; + $out .= "recipient=" . $recipient . "\r\n"; + $out .= "secret_id=" . $secret_id . "\r\n\r\n"; + fwrite($fp, $out); + $response = fread($fp, 8192); + fclose($fp); + $response = urldecode($response); + if (! preg_match("/^setreply=250\s+([\d\.]+)\s+(.*)/", $response, $matches)) { + error("Request to release failed [$out][$response]"); + exit; + } + if ($matches[1] != '2.0.0') { + error($matches[2]); + exit; + } - $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'"; - } else if ($request == 'delete') { - $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'"; - } else { - error("Unknown operation [$request]"); - exit; - } - $success = $DB->update($query); - if (! $success) { - error("Message not released, contact administrator [$query]"); - exit; - } - header('Location: index.php'); + $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'"; + } else if ($request == 'delete') { + $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'"; + } else { + error("Unknown operation [$request]"); + exit; + } + $success = $DB->update($query); + if (! $success) { + error("Message not released, contact administrator [$query]"); + exit; + } + header('Location: index.php'); } else if ($loggedIn && $request == 'purge') { - $marked = unserialize($_SESSION['marked']); - unset($_SESSION['marked']); - $query = array(); - $error = array(); - foreach ($marked as $mail_id) { - $query[] = "delete from msgs where mail_id = '$mail_id'"; - $query[] = "delete from msgrcpt where mail_id = '$mail_id'"; - $query[] = "delete from quarantine where mail_id = '$mail_id'"; - $success = $DB->update($query); - if (! $success) { - $error[] = $mail_id; - } - } - if (count($error) > 0) { - $str = implode(', ', $error); - error("The following messages was not purged [$str], contact administrator"); - exit; - } - header('Location: index.php'); - } else if ($loggedIn) { - header('Location: index.php'); + $marked = unserialize($_SESSION['marked']); + unset($_SESSION['marked']); + $query = array(); + $error = array(); + foreach ($marked as $mail_id) { + $query[] = "delete from msgs where mail_id = '$mail_id'"; + $query[] = "delete from msgrcpt where mail_id = '$mail_id'"; + $query[] = "delete from quarantine where mail_id = '$mail_id'"; + $success = $DB->update($query); + if (! $success) { + $error[] = $mail_id; + } + } + if (count($error) > 0) { + $str = implode(', ', $error); + error("The following messages was not purged [$str], contact administrator"); + exit; + } + header('Location: index.php'); + } else if ($loggedIn) { + header('Location: index.php'); } else { header('Location: auth.php'); } diff --git a/show_headers.php b/show_headers.php index 4c8f3d9..e1bef17 100644 --- a/show_headers.php +++ b/show_headers.php @@ -1,59 +1,59 @@ root . 'lib/db_factory.php'; - require_once $CFG->root . 'lib/utils.inc.php'; + require_once 'Mail/mimeDecode.php'; + require_once 'config.php'; + require_once $CFG->root . 'lib/db_factory.php'; + require_once $CFG->root . 'lib/utils.inc.php'; - $util = Utils::getInstance(); - $loggedIn = $util->isLoggedIn(); - if ($loggedIn && isset($_GET['id'])) { - $util->setHeading('Full Headers Report'); - echo $util->getHeader(); - echo $util->getHeading(); + $util = Utils::getInstance(); + $loggedIn = $util->isLoggedIn(); + if ($loggedIn && isset($_GET['id'])) { + $util->setHeading('Full Headers Report'); + echo $util->getHeader(); + echo $util->getHeading(); - $id = $_GET['id']; - $mail = unserialize($_SESSION['mailInfo'][$id]); + $id = $_GET['id']; + $mail = unserialize($_SESSION['mailInfo'][$id]); - $row = $DB->getMail($id); - $string = $row->mail_text; - $sa_tests = null; - $params['include_bodies'] = false; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - $params['input'] = $string; - $params['crlf'] = "\r\n"; - - $structure = Mail_mimeDecode::decode($params); - $headers = $structure->headers; - $output = ''; - foreach ($headers as $header => $value) { - if (is_array($value)) { - $text = ''; - foreach ($value as $val) { - if ($text == '') { - $text = $val; - } else { - $text .= "

$val"; - } - } - } else { - $text = $value; - } - $output .= ""; - } - $output .= '
HeaderValue
$header$text
'; - echo ''; - echo ''; - echo ''; - echo '
'; - echo $output; - echo $util->getFooter(); - } else if ($loggedIn) { - header('Location: index.php'); - } else { - header('Location: auth.php'); - } + $row = $DB->getMail($id); + $string = $row->mail_text; + $sa_tests = null; + $params['include_bodies'] = false; + $params['decode_bodies'] = true; + $params['decode_headers'] = true; + $params['input'] = $string; + $params['crlf'] = "\r\n"; + + $structure = Mail_mimeDecode::decode($params); + $headers = $structure->headers; + $output = ''; + foreach ($headers as $header => $value) { + if (is_array($value)) { + $text = ''; + foreach ($value as $val) { + if ($text == '') { + $text = $val; + } else { + $text .= "

$val"; + } + } + } else { + $text = $value; + } + $output .= ""; + } + $output .= '
HeaderValue
$header$text
'; + echo ''; + echo ''; + echo ''; + echo '
'; + echo $output; + echo $util->getFooter(); + } else if ($loggedIn) { + header('Location: index.php'); + } else { + header('Location: auth.php'); + } ?> -- 2.39.2