/**
  * exception handler; allows to remove paths from error messages and show
  * optional stack trace
  **/
 public static function exceptionHandler($exception)
 {
     $exc_class = get_class($exception);
     try {
         $logger = CAT_Helper_KLogger::instance(CAT_PATH . '/temp/logs', 2);
         $logger->logFatal(sprintf('Exception with message [%s] emitted in [%s] line [%s]', $exception->getMessage(), $exception->getFile(), $exception->getLine()));
     } catch (Exception $e) {
     }
     if (isset($exc_class::$exc_trace) && $exc_class::$exc_trace === true) {
         $traceline = "#%s %s(%s): %s(%s)";
         $msg = "Uncaught exception '%s' with message '%s'<br />" . "<div style=\"font-size:smaller;width:80%%;margin:5px auto;text-align:left;\">" . "in %s:%s<br />Stack trace:<br />%s<br />" . "thrown in %s on line %s</div>";
         $trace = $exception->getTrace();
         foreach ($trace as $key => $stackPoint) {
             $trace[$key]['args'] = array_map('gettype', $trace[$key]['args']);
         }
         // build tracelines
         $result = array();
         foreach ($trace as $key => $stackPoint) {
             $result[] = sprintf($traceline, $key, isset($stackPoint['file']) ? $stackPoint['file'] : '-', isset($stackPoint['line']) ? $stackPoint['line'] : '-', $stackPoint['function'], implode(', ', $stackPoint['args']));
         }
         // trace always ends with {main}
         $result[] = '#' . ++$key . ' {main}';
         // write tracelines into main template
         $msg = sprintf($msg, get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), implode("<br />", $result), $exception->getFile(), $exception->getLine());
     } else {
         // filter message
         $message = $exception->getMessage();
         $message = str_replace(array(CAT_Helper_Directory::sanitizePath(CAT_PATH), str_replace('/', '\\', CAT_Helper_Directory::sanitizePath(CAT_PATH))), array('[path to]', '[path to]'), $message);
         $msg = "[{$exc_class}] {$message}";
     }
     // log
     $logger->logFatal($msg);
     // show detailed error information to admin only
     if (CAT_Users::is_authenticated() && CAT_Users::is_root()) {
         CAT_Object::printFatalError($msg);
     } else {
         CAT_Object::printFatalError("An internal error occured. We're sorry for inconvenience.");
     }
 }
Beispiel #2
0
            continue;
        }
        $dir .= '/' . $sub;
        if (file_exists($dir . '/framework/class.secure.php')) {
            include $dir . '/framework/class.secure.php';
            $inc = true;
            break;
        }
    }
    if (!$inc) {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
// protect
$backend = CAT_Backend::getInstance('Start', 'start', false, false);
if (!CAT_Users::is_authenticated()) {
    exit;
}
// just to be _really_ sure...
require CAT_PATH . '/framework/CAT/ExceptionHandler.php';
// register exception/error handlers
set_exception_handler(array("CAT_ExceptionHandler", "exceptionHandler"));
set_error_handler(array("CAT_ExceptionHandler", "errorHandler"));
register_shutdown_function(array("CAT_ExceptionHandler", "shutdownHandler"));
include dirname(__FILE__) . '/../data/config.inc.php';
$widget_name = 'Version check';
$error = $version = $newer = $last = $last_version = NULL;
$debug = false;
$doit = true;
if (!CAT_Helper_Validate::sanitizeGet('blackcat_refresh')) {
    $file = CAT_Helper_Directory::sanitizePath(dirname(__FILE__) . '/../data/.last');
Beispiel #3
0
 /**
  * Check whether a page is visible or not
  * This will check page-visibility, user- and group permissions
  *
  * @access public
  * @param  integer  $page_id
  * @return boolean
  **/
 public static function isVisible($page_id)
 {
     $show_it = false;
     $page = self::properties($page_id);
     switch ($page['visibility']) {
         // never shown in FE
         case 'none':
         case 'deleted':
             $show_it = false;
             break;
             // shown if called, but not in menu
         // shown if called, but not in menu
         case 'hidden':
             if (self::selectPage() == $page_id) {
                 $show_it = true;
             }
             break;
             // always visible
         // always visible
         case 'public':
             $show_it = true;
             break;
             // shown if user is allowed
         // shown if user is allowed
         case 'private':
         case 'registered':
             if (CAT_Users::is_authenticated() == true) {
                 // check language
                 if (CAT_Registry::get('PAGE_LANGUAGES') == 'false' || (self::properties($page_id, 'language') == '' || self::properties($page_id, 'language') == LANGUAGE)) {
                     $show_it = CAT_Users::is_group_match(CAT_Users::get_groups_id(), $page['viewing_groups']) || CAT_Users::is_group_match(CAT_Users::get_user_id(), $page['viewing_users']) || CAT_Users::is_root();
                 }
             } else {
                 $show_it = false;
             }
             break;
     }
     return $show_it;
 }
Beispiel #4
0
 /**
  * get last DB error
  *
  * @access public
  * @return string
  **/
 public function getError()
 {
     // show detailed error message only to global admin
     if (CAT_Users::is_authenticated() && CAT_Users::is_root()) {
         return $this->lasterror;
     } else {
         return "An internal error occured. We're sorry for inconvenience.";
     }
 }
Beispiel #5
0
function Dwoo_Plugin_user_logged_in(Dwoo $dwoo)
{
    return CAT_Users::is_authenticated();
}
Beispiel #6
0
 public function is_authenticated()
 {
     return CAT_Users::is_authenticated();
 }