示例#1
0
 /**
  * Get framework version
  * @param bool $long
  * @return string
  */
 public static function getFrameworkVersion($long = true)
 {
     return ($long ? self::VERSION . '.' . self::POSTFIX : self::VERSION) . (Envi::isProduction() ? '' : '/' . time());
 }
示例#2
0
    /**
     * If page rendered too long, report to developers
     * @throws Exception
     */
    public static function checkSlow()
    {
        // TODO: merge this method with Exception::sendNotification()
        $time = self::getTimer();
        if (!$time <= 1) {
            return;
        }
        // don't send notifications on development environment
        if (!Envi::isProduction()) {
            return;
        }
        $notificationMail = self::getNotificationMail();
        // no notification mail is set
        if (!$notificationMail) {
            return;
        }
        $output = '<pre>';
        foreach (self::$output as $line) {
            if (!isset($line['type'])) {
                $line['type'] = null;
            }
            $output .= "{$line['timer']}\t{$line['class']}\t{$line['type']}\t{$line['message']}\n";
        }
        $date = date('r');
        $server = print_r($_SERVER, true);
        $post = print_r($_POST, true);
        $cookie = print_r($_COOKIE, true);
        $host = Envi::getHost();
        $uri = Envi::getUri();
        $user = Auth::getInstance()->getEmail();
        $output .= <<<MSG

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

\$_SERVER:
{$server}

\$_POST:
{$post}

\$_COOKIE:
{$cookie}
MSG;
        $output .= '</pre>';
        Mailer::getInstance()->sendMail(self::getNotificationMail(), 'Slow script', print_r($output, true));
    }