X-Git-Url: http://git.datanom.net/qtadmin.git/blobdiff_plain/07124c3728ccb26c74cc18b0c8ff93a92bf28551..56c841014682b373b486d3627ce1ea1f37403ff1:/lib/utils.inc.php diff --git a/lib/utils.inc.php b/lib/utils.inc.php index dcdd851..197b26f 100644 --- a/lib/utils.inc.php +++ b/lib/utils.inc.php @@ -1,6 +1,7 @@ root .'config.php'; +require_once $CFG->root . 'lib/session_handler.inc.php'; class Utils { @@ -18,11 +19,13 @@ class Utils { + __TITLE__ -'; - private $footer = ''; +
'; + private $footer = '
'; private $heading = '

Session timeout:

__TITLE__

'; @@ -82,7 +85,21 @@ class Utils { switch ($this->log_method) { case 'file': + if (isset($CFG->log_file)) { + if ($CFG->log_file[0] == '/') { + $file = $CFG->log_file; + } else { + $file = $CFG->root.$CFG->log_file; + } + } else { + $file = $CFG->root.'qtadmin.log'; + } + file_put_contents($file, "[$time]: $message\n", FILE_APPEND | LOCK_EX); + chmod($file, 0600); + break; case 'stderr': + file_put_contents('php://stderr', "[$time]: $message\n"); + break; case 'syslog': syslog($priority, $message); break; @@ -125,8 +142,9 @@ class Utils { if (ini_get('session.gc_maxlifetime') != $this->timeout) ini_set('session.gc_maxlifetime', $this->timeout); - if (ini_get('session.cookie_lifetime') != $this->timeout) - ini_set('session.cookie_lifetime', $this->timeout); + //if (ini_get('session.cookie_lifetime') != $this->timeout) + // ini_set('session.cookie_lifetime', $this->timeout); + ini_set('session.cookie_lifetime', 0); session_start(); } @@ -275,9 +293,8 @@ class Utils { } if ($loggedIn == false) { - echo '$this->settings: '.var_export($this->settings, true); - echo 'R_TIME: '.date('c', $_SERVER['REQUEST_TIME']).' L_ACT: '.date('c', $_SESSION['LAST_ACTIVITY']); - //exit; + $this->log('$this->settings: '.var_export($this->settings, true), 3); + $this->log('R_TIME: '.date('c', $_SERVER['REQUEST_TIME']).' L_ACT: '.date('c', $_SESSION['LAST_ACTIVITY']), 3); } $_SESSION['settings'] = $this->settings; @@ -297,6 +314,19 @@ class Utils { return $user; } + public function authorized($recipient) { + $authorized = false; + + $this->log("authorized '$recipient'", 3); + + if ($this->isAdmin() || $this->getUser() == $recipient) { + $authorized = true; + } + $this->log("authorize '".$this->getUser()."' rcpt '$recipient'", 3); + + return $authorized; + } + public function getHeader() { $this->log("getHeader", 4);