-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathviewlog.php
127 lines (106 loc) · 4.98 KB
/
viewlog.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
<?php
/**
* Coppermine Photo Gallery
*
* v1.0 originally written by Gregory Demar
*
* @copyright Copyright (c) 2003-2020 Coppermine Dev Team
* @license GNU General Public License version 3 or later; see LICENSE
*
* viewlog.php
* @since 1.6.08
*/
define('IN_COPPERMINE',1);
define('VIEWLOG_PHP',1);
require('include/init.inc.php');
$folder_icon = cpg_fetch_icon('folder', 0);
$delete_all_icon = cpg_fetch_icon('delete', 2);
$delete_this_icon = cpg_fetch_icon('erase', 2);
$view_icon = cpg_fetch_icon('file', 2);
function display_log_list()
{
global $lang_viewlog_php, $folder_icon, $delete_all_icon, $delete_this_icon, $view_icon, $lang_date;
$log_list = getloglist('logs/');
if (count($log_list)>0) {
foreach ($log_list as $log) {
$mtime = localised_date($log['mtime'], $lang_date['log']);
$filesize = cpg_format_bytes($log['filesize']);
echo <<<EOT
<tr>
<td class="tableb">
{$folder_icon} <a href= "viewlog.php?log={$log['logname']}">{$log['logname']}</a>
( <em>$filesize</em>, {$lang_viewlog_php['last_updated']}: <em>$mtime</em>)
</td>
</tr>
EOT;
}
echo <<<EOT
<tr>
<td class="tableb" align="center">
<button type="button" class="button" name="dall" value="{$lang_viewlog_php['delete_all']}" id="dall" onclick="window.location='viewlog.php?action=dall';">{$delete_all_icon}{$lang_viewlog_php['delete_all']}</button>
</td>
</tr>
EOT;
} else {
cpg_die(INFORMATION, $lang_viewlog_php['no_logs'], __FILE__, __LINE__);
}
}
function display_log($logname)
{
global $lang_viewlog_php, $folder_icon, $delete_all_icon, $delete_this_icon, $view_icon, $LINEBREAK;
echo <<<EOT
<tr>
<td class="tableb" align="center">
<button type="button" class="button" name="dall" value="{$lang_viewlog_php['delete_all']}" id="dall" onclick="window.location='viewlog.php?action=dall';">{$delete_all_icon}{$lang_viewlog_php['delete_all']}</button>
<button type="button" class="button" value="{$lang_viewlog_php['view_logs']}" name="back1" id="back1" onclick="window.location='viewlog.php';">{$view_icon}{$lang_viewlog_php['view_logs']}</button>
<button type="button" class="button" value="{$lang_viewlog_php['delete_this']}" name="dthis1" id="dthis1" onclick="window.location='viewlog.php?action=dthis&log=$logname';">{$delete_this_icon}{$lang_viewlog_php['delete_this']}</button>
</td>
</tr>
<tr>
<td class="tableb">
<ul class="log-display">
EOT;
$log_array = explode('---' , log_read($logname));
foreach ($log_array as $log_entry) {
if ($log_entry != '' && $log_entry != $LINEBREAK) {
echo '<li>' . nl2br(htmlspecialchars(trim($log_entry))) . '</li>' . $LINEBREAK;
}
}
echo <<<EOT
</ul>
</td>
</tr>
<tr>
<td class="tableb" align="center">
<button class="button" type="button" value="{$lang_viewlog_php['delete_all']}" name="dall2" id="dall2" onclick="window.location='viewlog.php?action=dall';">{$delete_all_icon}{$lang_viewlog_php['delete_all']}</button>
<button class="button" type="button" value="{$lang_viewlog_php['view_logs']}" name="back2" id="back2" onclick="window.location='viewlog.php';">{$view_icon}{$lang_viewlog_php['view_logs']}</button>
<button class="button" type="button" value="{$lang_viewlog_php['delete_this']}" name="dthis2" id="dthis2" onclick="window.location='viewlog.php?action=dthis&log=$logname';">{$delete_this_icon}{$lang_viewlog_php['delete_this']}</button>
</td>
</tr>
EOT;
}
$log = $superCage->get->getAlnum('log');
$action = $superCage->get->getAlpha('action');
pageheader('Logs :: '.$log);
if (!GALLERY_ADMIN_MODE) {
cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
starttable("100%", cpg_fetch_icon('view_logs', 2) . "Logs :: " . $log);
if (isset($action)) {
if ($action == 'dthis' && isset($log)) {
log_delete($log);
unset($log);
} elseif ($action == 'dall') {
unset($log);
log_delete();
}
}
// If log variable not set or log file's directory is not current directory then display logs list else display log with given name stripping risky characters from it
if (!isset($log) || dirname($log) != '.') {
display_log_list();
} else {
display_log($log);
}
endtable();
pagefooter();
//EOF