Пример #1
0
 /**
  * Initializer
  *
  * @param array $setting Configure array
  *
  * @return bool Return true when initialized, false when fail.
  *              Remember re-init cause fail too
  */
 public static function init(array $setting = array())
 {
     if (!self::$inited) {
         self::$cores = Framework::getAllCores();
         self::$defaults = array('Setting' => array('CookieKey' => isset($setting['CookieKey']) ? $setting['CookieKey'] : '!', 'Expire' => isset($setting['Expire']) ? (int) $setting['Expire'] : 3600, 'Salt' => isset($setting['Salt']) ? $setting['Salt'] : '', 'RandomKeyLen' => isset($setting['RandomKeyLen']) ? (int) $setting['RandomKeyLen'] : 16));
         self::$inited = true;
         register_shutdown_function(function () {
             return self::update();
         });
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * Constructor of an error
  *
  * @param string $errorCode The code of the error, like: NO_ERROR
  * @param array $errorAssign Information for formatting the error message
  * @param string $errorType Error type: ERROR, WARNING, NOTICE, DEPRECATED
  */
 public final function __construct($errorCode, array $errorAssign = array(), $errorType = 'NOTICE')
 {
     $cores = Framework::getAllCores();
     if (!isset(static::$errorTypes[$errorType])) {
         trigger_error('Specified error type ' . $errorType . ' not found.', E_USER_ERROR);
         return;
     }
     $backTrace = debug_backtrace();
     array_shift($backTrace);
     if (!isset($backTrace[0])) {
         trigger_error('The trace result not exist. Must be called from current function.', E_USER_ERROR);
         return;
     }
     if (isset($backTrace[0]['file'])) {
         $this->file = $backTrace[0]['file'];
     }
     if (isset($backTrace[0]['line'])) {
         $this->line = $backTrace[0]['line'];
     }
     if (isset($backTrace[0]['function'])) {
         $this->function = $backTrace[0]['function'];
     }
     if (isset($backTrace[0]['class'])) {
         $this->class = $backTrace[0]['class'];
     }
     if (isset($backTrace[0]['type'])) {
         $this->functionType = $backTrace[0]['type'];
     }
     if (isset($backTrace[0]['args'])) {
         $this->args = $backTrace[0]['args'];
     }
     $this->trace = $backTrace;
     $this->lastTrace = $backTrace[0];
     $this->assigned = $errorAssign;
     if (isset(static::$errorStrings[$errorCode])) {
         $this->message = $this->trimErrorMessage(vsprintf(static::$errorStrings[$errorCode], $this->assigned));
     } else {
         $this->message = $errorCode;
     }
     if (!isset($cores['debug'])) {
         trigger_error('[' . $this->class . ']: ' . $this->message, static::$errorTypes[$errorType]);
         return;
     }
     $cores['debug']->error(static::$errorTypes[$errorType], '[' . $this->class . ']: ' . $this->message, $this->file, $this->line, array(), $this->trace);
 }
Пример #3
0
 /**
  * A initializer method that will be auto automatically call by Object core
  *
  * In this very case, it will load all Facula cores into current instance space
  *
  * @return bool Return true when initialize complete, false otherwise.
  */
 public final function init()
 {
     $this->cores = Framework::getAllCores();
     return true;
 }