Example #1
0
 /**
  * Statically checks if there is a session with valid auth information.
  *
  * @access public
  * @see checkAuth
  * @return boolean  Whether or not the user is authenticated.
  * @static
  */
 function staticCheckAuth($options = null)
 {
     static $staticAuth;
     if (!isset($staticAuth)) {
         $staticAuth = new Auth('null', $options);
     }
     $staticAuth->log('Auth::staticCheckAuth() called', AUTH_LOG_DEBUG);
     return $staticAuth->checkAuth();
 }
Example #2
0
 public function log($message, $level = AUTH_LOG_DEBUG, $debug_backtrace = false)
 {
     if (isset($this->options['options']['log_path']) && $this->options['options']['log_path'] != '') {
         $filename = $this->options['options']['log_path'] . '/';
         if (defined('DOMAIN_NAME')) {
             $filename .= strToLower(DOMAIN_NAME) . '_';
         }
         if (defined('APPLICATION_CODE')) {
             $filename .= strToLower(APPLICATION_CODE) . '_';
         }
         $filename .= 'auth.log';
         if ($message == '----') {
             file_put_contents($filename, "---\n", FILE_APPEND);
         } else {
             file_put_contents($filename, basename($_SERVER['PHP_SELF']) . "[{$level}]: " . $message . "\n", FILE_APPEND);
         }
         if ($debug_backtrace) {
             $trace = debug_backtrace();
             $caller = array_shift($trace);
             $function_name = $caller['function'];
             file_put_contents($filename, sprintf('%s: Called from %s:%s', $function_name, $caller['file'], $caller['line']) . "\n", FILE_APPEND);
             foreach ($trace as $entry_id => $entry) {
                 $entry['file'] = $entry['file'] ?: '-';
                 $entry['line'] = $entry['line'] ?: '-';
                 if (empty($entry['class'])) {
                     file_put_contents($filename, sprintf('%s %3s. %s() %s:%s', $function_name, $entry_id + 1, $entry['function'], $entry['file'], $entry['line']) . "\n", FILE_APPEND);
                 } else {
                     file_put_contents($filename, sprintf('%s %3s. %s->%s() %s:%s', $function_name, $entry_id + 1, $entry['class'], $entry['function'], $entry['file'], $entry['line']) . "\n", FILE_APPEND);
                 }
             }
         }
     }
     parent::log($message, $level);
 }