リビジョン | 364 (tree) |
---|---|
日時 | 2017-10-24 09:10:04 |
作者 | kmorimatsu |
(メッセージはありません)
@@ -1,98 +0,0 @@ | ||
1 | -<?php | |
2 | -/* | |
3 | - * Jeans CMS (GPL license) | |
4 | - * $Id$ | |
5 | - */ | |
6 | - | |
7 | - | |
8 | -class error extends jeans { | |
9 | - static private function debug_mode(){ | |
10 | - if (!defined('_CONF_DEBUG_MODE')) return false; | |
11 | - if ($_SERVER['REMOTE_ADDR']=='127.0.0.1') return true; | |
12 | - if (_CONF_DEBUG_MODE==='admin') return member::is_admin(); | |
13 | - return true; | |
14 | - } | |
15 | - static public function quit($text,$data=array()){ | |
16 | - self::show($text,$data,'quit'); | |
17 | - exit; | |
18 | - } | |
19 | - static public function show($text,$data=array(),$log='show'){ | |
20 | - if (preg_match('/^_([A-Z][A-Z0-9]*)_([A-Z0-9]*)(?:_[A-Z0-9]*)*$/',$text,$m)) $text=self::translate($text); | |
21 | - // Leave log | |
22 | - $row=sql::query("SELECT count(*) as result FROM sqlite_master WHERE name='jeans_log'")->fetch(); | |
23 | - if ($row['result']==1) core::log(self::fill_html($text,$data),__CLASS__,$log); | |
24 | - // Redirect, if possible | |
25 | - if (!self::debug_mode()) { | |
26 | - if (error_reporting() & E_WARNING) { | |
27 | - $text=self::fill_html($text,$data); | |
28 | - if (headers_sent() || isset($_GET['error'])) { | |
29 | - self::echo_html('<!--\'"--><%0%>',$text); | |
30 | - } else { | |
31 | - core::set_cookie('note_text',$text); | |
32 | - core::redirect_local('?error'); | |
33 | - } | |
34 | - } | |
35 | - return; | |
36 | - } | |
37 | - if (!is_array($data)) $data=array($data); | |
38 | - self::echo_html('<!--\'"-->'.$text,$data); | |
39 | - $db=debug_backtrace(); | |
40 | - self::echo_html('<!--'); | |
41 | - ob_start(); | |
42 | - print_r($db); | |
43 | - self::p(ob_get_clean()); | |
44 | - self::echo_html('-->'); | |
45 | - for ($i=0;$i<count($db);$i++) { | |
46 | - if ($db[$i]['class']=='error') continue; | |
47 | - $db=$db[$i-1]; | |
48 | - break; | |
49 | - } | |
50 | - $db['file']=@preg_replace('/^.*[\/\\\\]([a-z0-9_]+\.php)$/i','$1',$db['file']); | |
51 | - self::echo_html("<br />\r\nError occured at line <%line%> in <%file%>",$db); | |
52 | - } | |
53 | - static private $note=array(); | |
54 | - static public function note($text,$data=false){ | |
55 | - if ($data===false) { | |
56 | - self::$note[]=self::quote_html($text); | |
57 | - } else { | |
58 | - if (preg_match('/^_([A-Z][A-Z0-9]*)_([A-Z0-9]*)(?:_[A-Z0-9]*)*$/',$text)) $text=self::translate($text); | |
59 | - self::$note[]=self::fill_html($text,$data); | |
60 | - } | |
61 | - } | |
62 | - static public function fatal($text=false,$data=false){ | |
63 | - static $fatal=false; | |
64 | - if ($text===false) return $fatal; | |
65 | - $fatal=true; | |
66 | - self::note($text,$data); | |
67 | - } | |
68 | - static public function get_note(){ | |
69 | - foreach (self::$note as $key=>$error) { | |
70 | - if (preg_match('/^_([A-Z][A-Z0-9]*)_([A-Z0-9]*)(?:_[A-Z0-9]*)*$/',$error)) self::$note[$key]=self::translate($error); | |
71 | - } | |
72 | - return self::$note; | |
73 | - } | |
74 | - static public function tag_note(&$data,$skin){ | |
75 | - $array=array(); | |
76 | - foreach (self::get_note() as $error) { | |
77 | - $array[]=array('error'=>$error); | |
78 | - } | |
79 | - view::show_using_array($data,$array,$skin); | |
80 | - } | |
81 | - // From view.php | |
82 | - static public function compile_error($source,$compiled){ | |
83 | - if (self::debug_mode()) { | |
84 | - $array=array(&$source,&$compiled); | |
85 | - foreach($array as &$temp) { | |
86 | - $temp=preg_split('/(\r\n|\r|\n)/',$temp); | |
87 | - foreach($temp as $key=>$line) $temp[$key]=substr(' '.($key+1).':',-4).$line; | |
88 | - $temp=implode("\n",$temp); | |
89 | - } | |
90 | - self::echo_html('<hr /><pre><%0%><hr /><%1%></pre><hr />',array($source,$compiled),'hsc'); | |
91 | - } | |
92 | - return create_function('','return false;'); | |
93 | - } | |
94 | - // From core.php | |
95 | - static public function set_error($mode,$error,$array=array()){ | |
96 | - | |
97 | - } | |
98 | -} | |
\ No newline at end of file |