-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathic2_viewtable.php
More file actions
174 lines (149 loc) · 4.14 KB
/
ic2_viewtable.php
File metadata and controls
174 lines (149 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* ImageCache2 - エラーログ・ブラックリスト閲覧
*/
// {{{ p2基本設定読み込み&認証
define('P2_OUTPUT_XHTML', 1);
require_once './conf/conf.inc.php';
$_login->authorize();
if (!$_conf['expack.ic2.enabled']) {
p2die('ImageCache2は無効です。', 'conf/conf_admin_ex.inc.php の設定を変えてください。');
}
// }}}
// {{{ 初期化
// ライブラリ読み込み
require_once 'HTML/Template/Flexy.php';
require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
// }}}
// {{{ 設定と消去
// 設定ファイル読み込み
$ini = ic2_loadconfig();
if (!isset($_REQUEST['table'])) {
p2die('ImageCache2 - 不正なクエリ');
}
$mode = $_REQUEST['table'];
switch ($mode) {
case 'errlog':
$table = new IC2_DataObject_Errors;
$table->orderBy('occured ASC');
$title = 'エラーログ';
break;
case 'blacklist':
$table = new IC2_DataObject_BlackList;
$table->orderBy('uri ASC');
$title = 'ブラックリスト';
break;
default:
p2die('ImageCache2 - 不正なクエリ');
}
$db = $table->getDatabaseConnection();
if (isset($_POST['clean'])) {
$sql = 'DELETE FROM ' . $db->quoteIdentifier($table->__table);
$result = $db->query($sql);
if (DB::isError($result)) {
p2die($result->getMessage());
}
} elseif (isset($_POST['delete']) && isset($_POST['target']) && is_array($_POST['target'])) {
foreach ($_POST['target'] as $target) {
$delete = clone $table;
$delete->uri = $target;
$delete->delete();
}
}
// }}}
// {{{ 出力
$_flexy_options = array(
'locale' => 'ja',
'charset' => 'cp932',
'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2',
'templateDir' => P2EX_LIB_DIR . '/ic2/templates',
'numberFormat' => '', // ",0,'.',','" と等価
);
$flexy = new HTML_Template_Flexy($_flexy_options);
$flexy->setData('php_self', $_SERVER['SCRIPT_NAME']);
$flexy->setData('skin', $skin_en);
$flexy->setData('title', $title);
$flexy->setData('mode', $mode);
$flexy->setData('reload_js', $_SERVER['SCRIPT_NAME'] . '?nt=' . time() . '&table=' . $mode);
$flexy->setData('info_msg', P2Util::getInfoHtml());
$flexy->setData('pc', !$_conf['ktai']);
$flexy->setData('iphone', $_conf['iphone']);
$flexy->setData('doctype', $_conf['doctype']);
$flexy->setData('extra_headers', $_conf['extra_headers_ht']);
$flexy->setData('extra_headers_x', $_conf['extra_headers_xht']);
if ($table->find()) {
switch ($mode) {
case 'errlog':
$flexy->setData('data_renderer_errlog', TRUE);
$flexy->setData('data', ic2_dump_table_errlog($table));
break;
case 'blacklist':
$flexy->setData('data_renderer_blacklist', TRUE);
$flexy->setData('data', ic2_dump_table_blacklist($table));
break;
}
}
P2Util::header_nocache();
$flexy->compile('ic2vt.tpl.html');
$flexy->output();
// }}}
// {{{ 関数
// {{{ ic2_dump_table_errlog()
/**
* エラーログを取得する
*/
function ic2_dump_table_errlog($dbdo)
{
$data = array();
while ($dbdo->fetch()) {
$obj = new stdClass;
$obj->uri = $dbdo->uri;
$obj->date = date('Y-m-d (D) H:i:s', $dbdo->occured);
$obj->code = $dbdo->errcode;
$obj->message = mb_convert_encoding($dbdo->errmsg, 'CP932', 'UTF-8');
$data[] = $obj;
}
return $data;
}
// }}}
// {{{ ic2_dump_table_blacklist()
/**
* ブラックリストを取得する
*/
function ic2_dump_table_blacklist($dbdo)
{
$data = array();
while ($dbdo->fetch()) {
$obj = new stdClass;
$obj->uri = $dbdo->uri;
switch ($dbdo->type) {
case '0':
$obj->type = 'お腹いっぱい';
break;
case '1':
$obj->type = 'あぼーん';
break;
case '2':
$obj->type = 'ウィルス感染';
break;
default:
$type = '???';
}
$obj->size = $dbdo->size;
$obj->md5 = $dbdo->md5;
$data[] = $obj;
}
return $data;
}
// }}}
// }}}
/*
* Local Variables:
* mode: php
* coding: cp932
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: