Beispiel #1
0
 /**
  * Инициализация задачи
  *
  * @static
  * @param $code
  */
 private static function init($code)
 {
     joosRequest::send_headers_by_code($code);
     if (ob_get_level()) {
         ob_end_clean();
     }
 }
Beispiel #2
0
 public function __construct($message = '', array $params = array())
 {
     joosRequest::send_headers_by_code(503);
     parent::__construct(strtr($message, $params));
     if (isset($params[':error_file'])) {
         $this->file = $params[':error_file'];
     }
     if (isset($params[':error_line'])) {
         $this->line = $params[':error_line'];
     }
     if (isset($params[':error_code'])) {
         $this->code = $params[':error_code'];
     }
     $this->__toString();
 }
Beispiel #3
0
    /**
     * Вывод информации о переменной
     *
     * @tutorial joosDebug::dump( array(1, 'aad', time() ), $var_name );
     * @tutorial joosDebug::dump( $var_name_1,  $var_name_2,  $var_name_3,  $var_name_4 );
     *
     * @param mixed функция принимает неограниченное число параметров - переменных для анализа и вывода
     *
     * @todo расширить для использования в ajax-запросах
     */
    public static function dump()
    {
        joosRequest::send_headers_by_code(503);
        // обозначение места вызова функции отладки
        $trace = debug_backtrace();
        if (isset($trace[1]['file'])) {
            $file_content = self::get_file_context($trace[1]['file'], $trace[1]['line']);
        } else {
            $file_content = self::get_file_context($trace[0]['file'], $trace[0]['line']);
        }
        if (ob_get_level()) {
            ob_end_clean();
        }
        ob_start();
        $func_args = func_get_args();
        $args_count = count($func_args);
        var_dump($args_count == 1 ? $func_args[0] : $func_args);
        $output = ob_get_clean();
        $output = preg_replace('/]\\=>\\n(\\s+)/m', '] => ', $output);
        /**
         * @todo тут надо провреить, переменная судя по всему не используется в полном объёме
         */
        $result = joosFilter::htmlspecialchars($output);
        $file_content = joosFilter::htmlspecialchars($file_content);
        $result = <<<HTML
  <style>
    body { background-color: #fff; color: #333; }
    body, p, ol, ul, td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 25px; }
    pre { background-color: #eee; padding: 10px; font-size: 11px; line-height: 18px; }
    a { color: #000; }
    a:visited { color: #666; }
    a:hover { color: #fff; background-color:#000; }
  </style>
<div style="width:99%; position:relative">
<h2 id='Title'>Результат отладки</h2>
<div id="Context" style="display: block;">Место вызова:<pre>{$file_content}</pre></div>
<div id="Context" style="display: block;">Полученные параметры:<pre>{$result}</pre></div>
HTML;
        $result .= "</div>";
        echo $result;
        die;
    }
Beispiel #4
0
 public static function ajax_error404()
 {
     joosRequest::send_headers_by_code(404);
     return array('error' => 404);
 }
Beispiel #5
0
 /**
  * Системный 301 редирект
  *
  * @param  string $url  ссылка, на которую надо перейти
  * @param  string $msg  текст сообщения, отображаемый после перехода
  * @param  string $type тип перехода - ошибка, предупреждение, сообщение и т.д.
  * @return void
  */
 public function redirect($url, $msg = '', $type = 'success')
 {
     $iFilter = joosInputFilter::instance();
     $url = $iFilter->process($url);
     empty($msg) ? null : joosFlashMessage::add($iFilter->process($msg), $type);
     $url = preg_split("/[\r\n]/", $url);
     $url = $url[0];
     if ($iFilter->badAttributeValue(array('href', $url))) {
         $url = JPATH_SITE;
     }
     if (headers_sent()) {
         echo "<script>document.location.href='{$url}';</script>\n";
     } else {
         !ob_get_level() ?: ob_end_clean();
         joosRequest::send_headers_by_code(301);
         joosRequest::send_headers("Location: " . $url);
     }
     exit;
 }