Exemple #1
0
 /**
  * Register framework event handlers
  */
 public static function init()
 {
     static $initDone = false;
     if ($initDone) {
         return;
     }
     $initDone = true;
     foreach (self::$types as $type) {
         self::$events[$type] = [];
     }
     self::register('core-init', 'Difra\\Debugger', 'init');
     self::register('core-init', 'Difra\\Envi\\Setup', 'run');
     self::register('core-init', 'Difra\\Envi\\Session', 'init');
     self::register('core-init', 'Difra\\Autoloader', 'init');
     self::register('plugins-load', 'Difra\\Plugger', 'init');
     if (Envi::getMode() == 'web') {
         self::register('action-find', 'Difra\\Controller', 'init');
         self::register('action-run', 'Difra\\Controller', 'run');
         self::register('render-run', 'Difra\\View\\Output', 'start');
     }
     if (file_exists($initPHP = DIR_ROOT . '/lib/init.php')) {
         /** @noinspection PhpIncludeInspection */
         include_once $initPHP;
     }
 }
Exemple #2
0
    /**
     * @static
     * @param \Difra\Exception|\exception $exception
     */
    public static function sendNotification($exception)
    {
        // TODO: merge this method with Exception::sendNotification()
        // don't send notifications on development environment
        if (!Envi::isProduction()) {
            return;
        }
        $notificationMail = Debugger::getNotificationMail();
        // no notification mail is set
        if (!$notificationMail) {
            return;
        }
        $date = date('r');
        $server = print_r($_SERVER, true);
        $post = print_r($_POST, true);
        $cookie = print_r($_COOKIE, true);
        $user = Auth::getInstance()->getEmail();
        $uri = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '-';
        $host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '-';
        $exceptionClass = get_class($exception);
        $text = <<<MSG

Page:\t{$uri}
Time:\t{$date}
Host:\t{$host}
User:\t{$user}

Type:   {$exceptionClass}
File:\t{$exception->getFile()}
Line:\t{$exception->getLine()}

Exception: {$exception->getMessage()}

{$exception->getTraceAsString()}

\$_SERVER:
{$server}

\$_POST:
{$post}

\$_COOKIE:
{$cookie}
MSG;
        mail($notificationMail, $host . ': ' . $exception->getMessage(), $text);
    }
Exemple #3
0
 /**
  * Display confirmation window (Are you sure? [Yes] [No])
  * @param $text
  */
 public static function confirm($text)
 {
     self::addAction(['action' => 'display', 'html' => '<form action="' . Envi::getUri() . '" class="ajaxer">' . '<input type="hidden" name="confirm" value="1"/>' . '<div>' . $text . '</div>' . '<input type="submit" value="' . Locales::get('ajaxer/confirm-yes') . '"/>' . '<input type="button" value="' . Locales::get('ajaxer/confirm-no') . '" onclick="ajaxer.close(this)"/>' . '</form>']);
 }