forked from Needlworks/Textcube
/
index.php
479 lines (437 loc) · 22.6 KB
/
index.php
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<?php
/// Copyright (c) 2004-2012, Needlworks / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
if (isset($_POST['page']))
$_GET['page'] = $_POST['page'];
if (isset($_GET['category'])) $_POST['category'] = $_GET['category'];
if (isset($_GET['name'])) $_POST['name'] = $_GET['name'];
if (isset($_GET['ip'])) $_POST['ip'] = $_GET['ip'];
if (isset($_GET['site'])) $_POST['site'] = $_GET['site'];
if (isset($_GET['url'])) $_POST['url'] = $_GET['url'];
if (isset($_GET['withSearch'])) $_POST['withSearch'] = $_GET['withSearch'];
if (isset($_GET['search'])) $_POST['search'] = $_GET['search'];
if (isset($_GET['trashType'])) $_POST['trashType'] = $_GET['trashType'];
$IV = array(
'GET' => array(
'page' => array('int', 1, 'default' => 1)
),
'POST' => array(
'category' => array('int', 'default' => 0),
'site' => array('string', 'default' => ''),
'url' => array('url', 'default' => ''),
'ip' => array('ip', 'default' => ''),
'withSearch' => array(array('on'), 'mandatory' => false),
'search' => array('string', 'default' => ''),
'perPage' => array('int', 10, 30, 'mandatory' => false)
)
);
require ROOT . '/library/preprocessor.php';
requireModel("blog.response.remote");
requireModel("blog.trash");
$categoryId = empty($_POST['category']) ? 0 : $_POST['category'];
$site = empty($_POST['site']) ? '' : $_POST['site'];
$url = empty($_POST['url']) ? '' : $_POST['url'];
$ip = empty($_POST['ip']) ? '' : $_POST['ip'];
$search = empty($_POST['withSearch']) || empty($_POST['search']) ? '' : trim($_POST['search']);
$perPage = Setting::getBlogSettingGlobal('rowsPerPage', 10);
if (isset($_POST['perPage']) && is_numeric($_POST['perPage'])) {
$perPage = $_POST['perPage'];
Setting::setBlogSettingGlobal('rowsPerPage', $_POST['perPage']);
}
$tabsClass = array();
$tabsClass['postfix'] = null;
$tabsClass['postfix'] .= isset($_POST['category']) ? '&category='.$_POST['category'] : '';
$tabsClass['postfix'] .= isset($_POST['site']) ? '&site='.$_POST['site'] : '';
$tabsClass['postfix'] .= isset($_POST['ip']) ? '&ip='.$_POST['ip'] : '';
$tabsClass['postfix'] .= isset($_POST['search']) ? '&search='.$_POST['search'] : '';
$tabsClass['trash'] = true;
list($trackbacks, $paging) = getTrashTrackbackWithPagingForOwner($blogid, $categoryId, $site, $url, $ip, $search, $suri['page'], $perPage);
require ROOT . '/interface/common/owner/header.php';
?>
<script type="text/javascript">
//<![CDATA[
function changeState(caller, value, mode) {
try {
if (caller.className == 'block-icon bullet') {
var command = 'unblock';
} else {
var command = 'block';
}
var name = caller.id.replace(/\-[0-9]+$/, '');
param = '?value=' + encodeURIComponent(value);
param += '&mode=' + mode;
param += '&command=' + command;
var request = new HTTPRequest("GET", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/filter/change/" + param);
var iconList = document.getElementsByTagName("a");
for (var i = 0; i < iconList.length; i++) {
icon = iconList[i];
if(icon.id == null || icon.id.replace(/\-[0-9]+$/, '') != name) {
continue;
} else {
if (command == 'block') {
icon.className = 'block-icon bullet';
icon.innerHTML = '<span class="text"><?php echo _t('[차단됨]');?><\/span>';
icon.setAttribute('title', "<?php echo _t('이 사이트는 차단되었습니다. 클릭하시면 차단을 해제합니다.');?>");
} else {
icon.className = 'unblock-icon bullet';
icon.innerHTML = '<span class="text"><?php echo _t('[허용됨]');?><\/span>';
icon.setAttribute('title', "<?php echo _t('이 사이트는 차단되지 않았습니다. 클릭하시면 차단합니다.');?>");
}
}
}
request.send();
} catch(e) {
alert(e.message);
}
}
function deleteTrackback(id) {
if (!confirm("<?php echo _t('선택된 걸린글을 지웁니다. 계속 하시겠습니까?');?>"))
return;
var request = new HTTPRequest("GET", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/delete/" + id);
request.onSuccess = function() {
document.getElementById('list-form').submit();
}
request.onError = function () {
alert("<?php echo _t('걸린글을 지우지 못했습니다.');?>");
}
request.send();
}
function deleteTrackbackAll() {
if (!confirm("<?php echo _t('휴지통 내의 모든 걸린글을 삭제합니다. 계속 하시겠습니까?');?>"))
return;
var request = new HTTPRequest("GET", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/emptyTrash/?type=2&ajaxcall");
request.onSuccess = function() {
window.location.reload();
}
request.onError = function () {
alert("<?php echo _t('비우기에 실패하였습니다.');?>");
}
request.send();
}
function deleteTrackbacks() {
try {
if (!confirm("<?php echo _t('선택된 걸린글을 삭제합니다. 계속 하시겠습니까?');?>"))
return false;
var oElement;
var targets = '';
for (i = 0; document.getElementById('list-form').elements[i]; i ++) {
oElement = document.getElementById('list-form').elements[i];
if ((oElement.name == "entry") && oElement.checked) {
targets+=oElement.value+'~*_)';
}
}
var request = new HTTPRequest("POST", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/delete/");
request.onSuccess = function() {
document.getElementById('list-form').submit();
}
request.onError = function () {
alert("<?php echo _t('걸린글을 지우지 못했습니다.');?>");
}
request.send("targets=" + targets);
} catch(e) {
alert(e.message);
}
}
function revertTrackback(id) {
if (!confirm("<?php echo _t('선택된 걸린글을 복원합니다. 계속 하시겠습니까?');?>"))
return;
var request = new HTTPRequest("GET", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/revert/" + id);
request.onSuccess = function() {
document.getElementById('list-form').submit();
}
request.onError = function () {
alert("<?php echo _t('걸린글을 복원하지 못했습니다.');?>");
}
request.send();
}
function revertTrackbacks() {
try {
if (!confirm("<?php echo _t('선택된 걸린글을 복원합니다. 계속 하시겠습니까?');?>"))
return false;
var oElement;
var targets = '';
for (i = 0; document.getElementById('list-form').elements[i]; i ++) {
oElement = document.getElementById('list-form').elements[i];
if ((oElement.name == "entry") && oElement.checked) {
targets+=oElement.value+'~*_)';
}
}
var request = new HTTPRequest("POST", "<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/revert/");
request.onSuccess = function() {
document.getElementById('list-form').submit();
}
request.onError = function () {
alert("<?php echo _t('걸린글을 지우지 못했습니다.');?>");
}
request.send("targets=" + targets);
} catch(e) {
alert(e.message);
}
}
function checkAll(checked) {
for (i = 0; document.getElementById('list-form').elements[i]; i++) {
if (document.getElementById('list-form').elements[i].name == "entry") {
if (document.getElementById('list-form').elements[i].checked != checked) {
document.getElementById('list-form').elements[i].checked = checked;
toggleThisTr(document.getElementById('list-form').elements[i]);
}
}
}
}
window.addEventListener("load", execLoadFunction, false);
function execLoadFunction() {
document.getElementById('allChecked').disabled = false;
removeItselfById('category-move-button');
trashSelect = document.createElement("SELECT");
trashSelect.id = "category";
trashSelect.name = "category";
trashSelect.onchange = function() { document.getElementById('trash-form').page.value=1; document.getElementById('trash-form').submit(); return false; };
trashOption = document.createElement("OPTION");
trashOption.innerHTML = "<?php echo _t('전체');?>";
trashOption.value = "0";
trashSelect.appendChild(trashOption);
<?php
foreach (getCategories($blogid) as $category) {
?>
trashOption = document.createElement("OPTION");
trashOption.innerHTML = "<?php echo htmlspecialchars($category['name']);?>";
trashOption.value = "<?php echo $category['id'];?>";
<?php
if ($category['id'] == $categoryId) {
?>
trashOption.setAttribute("selected", "selected");
<?php
}
?>
trashSelect.appendChild(trashOption);
<?php
foreach ($category['children'] as $child) {
?>
trashOption = document.createElement("OPTION");
trashOption.innerHTML = " ― <?php echo htmlspecialchars($child['name']);?>";
trashOption.value = "<?php echo $child['id'];?>";
<?php
if ($child['id'] == $categoryId) {
?>
trashOption.setAttribute("selected", "selected");
<?php
}
?>
trashSelect.appendChild(trashOption);
<?php
}
}
?>
document.getElementById('track-radio-trackback').appendChild(trashSelect);
}
function toggleThisTr(obj) {
objTR = getParentByTagName("TR", obj);
if (objTR.className.match('inactive')) {
objTR.className = objTR.className.replace('inactive', 'active');
} else {
objTR.className = objTR.className.replace('active', 'inactive');
}
}
//]]>
</script>
<div id="part-post-trash" class="part">
<h2 class="caption">
<span class="main-text"><?php echo _t('삭제 대기중인 걸린글입니다');?></span>
<?php
if (strlen($site) > 0 || strlen($ip) > 0) {
if (strlen($site) > 0) {
?>
<span class="filter-condition"><?php echo htmlspecialchars($site);?></span>
<?php
}
if (strlen($ip) > 0) {
?>
<span class="filter-condition"><?php echo htmlspecialchars($ip);?></span>
<?php
}
}
?>
</h2>
<?php
require ROOT . '/interface/common/owner/communicationTab.php';
?>
<div class="main-explain-box">
<p class="explain"><?php echo _t('휴지통에 버려진 걸린글은 15일이 지나면 자동으로 지워집니다. 광고 걸린글의 차단 및 분석을 위하여 휴지통의 데이터를 사용하는 플러그인이 있을 수 있으므로 수동으로 지우지 않는 것을 권장합니다.');?></p>
</div>
<form id="trash-form" method="post" action="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash">
<fieldset class="section">
<legend><?php echo _t('삭제된 파일 보기 설정');?></legend>
<input type="hidden" name="page" value="<?php echo $suri['page'];?>" />
<dl id="trash-type-line" class="line">
<dt><?php echo _t('종류');?></dt>
<dd>
<div id="track-radio-comment">
<input type="radio" class="radio" id="track-type-comment" name="trashType" value="comment" onclick="document.getElementById('trash-form').submit()" /><label for="track-type-comment"><?php echo _t('댓글 및 방명록');?></label>
</div>
<div id="track-radio-trackback">
<input type="radio" class="radio" id="track-type-trackback" name="trashType" value="trackback" onclick="document.getElementById('trash-form').submit()" checked="checked" /><label for="track-type-trackback"><?php echo _t('글걸기');?></label>
</div>
</dd>
</dl>
<input type="submit" id="category-move-button" value="<?php echo _t('이동');?>" />
</fieldset>
</form>
<form id="list-form" method="post" action="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback">
<table class="data-inbox" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="selection"><input type="checkbox" id="allChecked" class="checkbox" onclick="checkAll(this.checked);" disabled="disabled" /></th>
<th class="date"><span class="text"><?php echo _t('등록일자');?></span></th>
<th class="site"><span class="text"><?php echo _t('사이트명');?></span></th>
<th class="category"><span class="text"><?php echo _t('분류');?></span></th>
<th class="title"><span class="text"><?php echo _t('제목');?></span></th>
<th class="ip"><acronym title="Internet Protocol">ip</acronym></th>
<th class="delete"><span class="text"><?php echo _t('복원');?></span></th>
<th class="delete"><span class="text"><?php echo _t('삭제');?></span></th>
</tr>
</thead>
<?php
if (sizeof($trackbacks) > 0) echo " <tbody>";
$siteNumber = array();
for ($i=0; $i<sizeof($trackbacks); $i++) {
$trackback = $trackbacks[$i];
$isFilterURL = Filter::isFiltered('url', $trackback['url']);
$filteredURL = getURLForFilter($trackback['url']);
$filter = new Filter();
if (Filter::isFiltered('ip', $trackback['ip'])) {
$isIpFiltered = true;
} else {
$isIpFiltered = false;
}
if (!isset($siteNumber[$trackback['site']])) {
$siteNumber[$trackback['site']] = $i;
$currentSite = $i;
} else {
$currentSite = $siteNumber[$trackback['site']];
}
$className = ($i % 2) == 1 ? 'even-line' : 'odd-line';
$className .= ($i == sizeof($trackbacks) - 1) ? ' last-line' : '';
?>
<tr class="<?php echo $className;?> inactive-class" onmouseover="rolloverClass(this, 'over')" onmouseout="rolloverClass(this, 'out')">
<td class="selection"><input type="checkbox" class="checkbox" name="entry" value="<?php echo $trackback['id'];?>" onclick="document.getElementById('allChecked').checked=false; toggleThisTr(this);" /></td>
<td class="date"><?php echo Timestamp::formatDate($trackback['written']);?></td>
<td class="site">
<?php
if ($isFilterURL) {
?>
<a id="urlFilter<?php echo $currentSite;?>-<?php echo $i;?>" class="block-icon bullet" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/filter/change/?value=<?php echo urlencode($filteredURL);?>&mode=url&command=unblock" onclick="changeState(this,'<?php echo $filteredURL;?>','url'); return false;" title="<?php echo _t('이 사이트는 차단되었습니다. 클릭하시면 차단을 해제합니다.');?>"><span class="text"><?php echo _t('[차단됨]');?></span></a>
<?php
} else {
?>
<a id="urlFilter<?php echo $currentSite;?>-<?php echo $i;?>" class="unblock-icon bullet" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/filter/change/?value=<?php echo urlencode($filteredURL);?>&mode=url&command=block" onclick="changeState(this,'<?php echo $filteredURL;?>','url'); return false;" title="<?php echo _t('이 사이트는 차단되지 않았습니다. 클릭하시면 차단합니다.');?>"><span class="text"><?php echo _t('[허용됨]');?></span></a>
<?php
}
?>
<a href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback?url=<?php echo urlencode(escapeJSInAttribute($trackback['url']));?>" title="<?php echo _t('이 사이트에서 건 글 목록을 보여줍니다.');?>"><?php echo htmlspecialchars($trackback['site']);?></a>
</td>
<td class="category">
<?php
if (!empty($trackback['categoryName'])) {
?>
<span class="categorized"><?php echo htmlspecialchars($trackback['categoryName']);?></span>
<?php
} else {
?>
<span class="uncategorized"><?php echo htmlspecialchars($trackback['categoryName']);?></span>
<?php
}
?>
</td>
<td class="title">
<a href="<?php echo $trackback['url'];?>" onclick="window.open(this.href); return false;" title="<?php echo _t('글을 건 글을 보여줍니다.');?>"><?php echo htmlspecialchars($trackback['subject']);?></a>
</td>
<td class="ip">
<?php
if ($isIpFiltered) {
?>
<a id="ipFilter<?php echo urlencode($trackback['ip']);?>-<?php echo $i;?>" class="block-icon bullet" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/filter/change/?value=<?php echo urlencode($trackback['ip']);?>&mode=ip&command=unblock" onclick="changeState(this,'<?php echo urlencode($trackback['ip']);?>', 'ip'); return false;" title="<?php echo _t('이 IP는 차단되었습니다. 클릭하시면 차단을 해제합니다.');?>"><span class="text"><?php echo _t('[차단됨]');?></span></a>
<?php
} else {
?>
<a id="ipFilter<?php echo urlencode($trackback['ip']);?>-<?php echo $i;?>" class="unblock-icon bullet" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/filter/change/?value=<?php echo urlencode($trackback['ip']);?>&mode=ip&command=block" onclick="changeState(this,'<?php echo urlencode($trackback['ip']);?>', 'ip'); return false;" title="<?php echo _t('이 IP는 차단되지 않았습니다. 클릭하시면 차단합니다.');?>"><span class="text"><?php echo _t('[허용됨]');?></span></a>
<?php
}
?>
<a href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback?ip=<?php echo urlencode(escapeJSInAttribute($trackback['ip']));?>" title="<?php echo _t('이 IP로 등록된 걸린글 목록을 보여줍니다.');?>"><span class="text"><?php echo $trackback['ip'];?></span></a>
</td>
<td class="revert">
<a class="revert-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/revert/<?php echo $trackback['id'];?>" onclick="revertTrackback(<?php echo $trackback['id'];?>); return false;" title="<?php echo _t('이 걸린글을 복원합니다.');?>"><span class="text"><?php echo _t('복원');?></span></a>
</td>
<td class="delete">
<a class="delete-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback/delete/<?php echo $trackback['id'];?>" onclick="deleteTrackback(<?php echo $trackback['id'];?>); return false;" title="<?php echo _t('이 걸린글을 삭제합니다.');?>"><span class="text"><?php echo _t('삭제');?></span></a>
</td>
</tr>
<?php
}
if (sizeof($trackbacks) > 0) echo " </tbody>";
?>
</table>
<hr class="hidden" />
<div class="data-subbox">
<input type="hidden" name="page" value="<?php echo $suri['page'];?>" />
<input type="hidden" name="site" value="" />
<input type="hidden" name="ip" value="" />
<div id="delete-section" class="section">
<span class="label"><?php echo _t('선택한 걸린글을');?></span>
<input type="submit" class="delete-button input-button" value="<?php echo _t('삭제');?>" onclick="deleteTrackbacks(); return false;" />
<input type="submit" class="revert-button input-button" value="<?php echo _t('복구');?>" onclick="revertTrackbacks(); return false;" />
</div>
<div id="page-section" class="section">
<div id="page-navigation">
<span id="page-list">
<?php
//$paging['url'] = 'document.getElementById('list-form').page.value=';
//$paging['prefix'] = '';
//$paging['postfix'] = '; document.getElementById('list-form').submit()';
$pagingTemplate = '[##_paging_rep_##]';
$pagingItemTemplate = '<a [##_paging_rep_link_##]>[##_paging_rep_link_num_##]</a>';
print getPagingView($paging, $pagingTemplate, $pagingItemTemplate, false);
?>
</span>
<span id="total-count"><?php echo _f('총 %1건', empty($paging['total']) ? "0" : $paging['total']);?></span>
</div>
<div class="page-count">
<?php echo getArrayValue(explode('%1', _t('한 페이지에 글 %1건 표시')), 0);?>
<select name="perPage" onchange="document.getElementById('list-form').page.value=1; document.getElementById('list-form').submit()">
<?php
for ($i = 10; $i <= 30; $i += 5) {
if ($i == $perPage) {
?>
<option value="<?php echo $i;?>" selected="selected"><?php echo $i;?></option>
<?php
} else {
?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php
}
}
?>
</select>
<?php echo getArrayValue(explode('%1', _t('한 페이지에 글 %1건 표시')), 1);?>
</div>
</div>
</div>
</form>
<hr class="hidden" />
<form id="search-form" class="data-subbox" method="post" action="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/trackback">
<h2><?php echo _t('검색');?></h2>
<div class="section">
<label for="search"><?php echo _t('제목');?>, <?php echo _t('사이트명');?>, <?php echo _t('내용');?></label>
<input type="text" id="search" class="input-text" name="search" value="<?php echo htmlspecialchars($search);?>" onkeydown="if (event.keyCode == '13') { document.getElementById('search-form').withSearch.value = 'on'; document.getElementById('search-form').submit(); }" />
<input type="hidden" name="withSearch" value="" />
<input type="submit" class="search-button input-button" value="<?php echo _t('검색');?>" onclick="document.getElementById('search-form').withSearch.value = 'on'; document.getElementById('search-form').submit();" />
</div>
</form>
<div class="button-box">
<a class="all-delete-button button" href="<?php echo $context->getProperty('uri.blog');?>/owner/communication/trash/emptyTrash/?type=2" onclick="deleteTrackbackAll(); return false;" title="<?php echo _t('휴지통의 걸린글을 한 번에 삭제합니다.');?>"><span class="text"><?php echo _t('휴지통 비우기');?></span></a>
</div>
</div>
<?php
require ROOT . '/interface/common/owner/footer.php';
?>