forked from atutor/ATutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_logging_details.php
193 lines (156 loc) · 6.19 KB
/
error_logging_details.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
<?php
/************************************************************************/
/* ATutor */
/************************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/************************************************************************/
// $Id$
define('AT_INCLUDE_PATH', '../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
if (!isset($_POST['data'])) {
$msg->addError('NO_PROFILE_SELECTED');
header('Location: error_logging.php');
exit;
} // else we have a profile we can work with
if (isset($_POST['delete'])) {
$key = substr($_POST['data'], 0, strpos($_POST['data'], ':'));
$date = substr($_POST['data'], strpos($_POST['data'], ':') + 1);
$dir_ = AT_CONTENT_DIR . 'logs/' . $date;
$delete_store;
if (!($dir = opendir($dir_))) {
$msg->printNoLookupFeedback('Could not access /content/logs/' . $date . '. Check that the permission for the <strong>Server</string> user are r+w to it');
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
$cnt = 0;
// Open a read pointer to run through each log date directory getting all the profiles
while (($file = readdir($dir)) !== false) {
if (($file == '.') || ($file == '..') || is_dir($file)) {
continue;
}
if (strpos($file, $key) !== false) { // found a bug associated with our profile key
$delete_store{$file} = $file;
} else {
$cnt++;
}
}
closedir($dir); // clean it up
if (count($delete_store) > 0) {
// Now run through the files and unlink them all
foreach($delete_store as $elem => $val)
unlink($dir_ . '/' . $elem);
}
// remove the directory as well if there are no oother profiles in it
if ($cnt == 0) {
rmdir($dir_);
}
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
header('Location: error_logging.php');
exit;
}
require(AT_INCLUDE_PATH.'header.inc.php');
if (isset($_POST['view'])) {
// Grab all the bugs associated with this $_POST['data'] corresponding md5 key
$key = substr($_POST['data'], 0, strpos($_POST['data'], ':'));
$date = substr($_POST['data'], strpos($_POST['data'], ':') + 1);
$dir_ = AT_CONTENT_DIR . 'logs/' . $date;
$log_profiles_bugs;
?>
<form name="form" method="post" action="<?php echo 'admin/error_logging_view.php'; ?>">
<table class="data" summary="" rules="cols">
<thead>
<tr>
<th scope="col"><?php echo _AT('bug_identifier'); ?></th>
<th scope="col"><?php echo _AT('timestamp'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2">
<input type="hidden" name="profile_id" value="<?php echo $key; ?>"/>
<input type="hidden" name="profile_date" value="<?php echo $date; ?>"/>
<input type="submit" name="view" value="<?php echo _AT('view_selected_bugs'); ?>" />
<input type="submit" name="back" value="<?php echo _AT('back_to_main'); ?>" />
</td>
</tr>
</tfoot>
<tbody>
<?php
if (!($dir = opendir($dir_))) {
$msg->printNoLookupFeedback('Could not access /content/logs/' . $date . '. Check that the permission for the <strong>Server</string> user are r+w to it');
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
// Open a read pointer to run through each log date directory getting all the profiles
while (($file = readdir($dir)) !== false) {
if (($file == '.') || ($file == '..') || is_dir($file) || (strpos($file, 'profile') !== false)) {
continue;
}
if (strpos($file, $key) !== false) { // found a bug associated with our profile key
$log_profile_bugs{$file} = $file;
}
}
closedir($dir); // clean it up
if (empty($log_profile_bugs)) { ?>
<tr>
<td align="center" colspan="2"><small><?php echo _AT('none_found'); ?></small></td>
</tr>
<tr><td height="1" class="row2" colspan="2"></td></tr>
<?php
} else {
$count = 0;
$id_cnt = 1; // give each bug an easier to understand id onscreen
foreach ($log_profile_bugs as $elem => $lm) {
// construct timestamp from millis since epoch in bug identifier
$timestamp = substr($lm, strpos($lm, '_') + 1);
$timestamp = substr($timestamp, 0, strpos($lm, '_') + 2);
$timestamp = AT_Date(_AT('inbox_date_format'), $timestamp, AT_DATE_UNIX_TIMESTAMP);
$str_prefix = substr($lm, 0, strpos($lm, '_'));
?>
<tr onmousedown="document.form['q<?php echo $lm; ?>'].checked = !document.form['q<?php echo $lm; ?>'].checked;">
<td><input type="checkbox" value="<?php echo $date . '/' . $lm; ?>" name="file<?php echo $count; ?>" id="q<?php echo $lm; ?>" onmouseup="this.checked=!this.checked" /><?php echo $id_cnt . '_' . $str_prefix; ?></td>
<td><?php echo $timestamp; ?></td>
</tr>
<?php $count++; $id_cnt++;
}
}
?>
</tbody>
</table>
</form>
<?php
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
} else if (isset($_POST['delete'])) {
$key = substr($_POST['data'], 0, strpos($_POST['data'], ':'));
$date = substr($_POST['data'], strpos($_POST['data'], ':') + 1);
$dir_ = AT_CONTENT_DIR . 'logs/' . $date;
$delete_store;
if (!($dir = opendir($dir_))) {
$msg->printNoLookupFeedback('Could not access /content/logs/' . $date . '. Check that the permission for the <strong>Server</string> user are r+w to it');
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
// Open a read pointer to run through each log date directory getting all the profiles
while (($file = readdir($dir)) !== false) {
if (($file == '.') || ($file == '..') || is_dir($file)) {
continue;
}
if (strpos($file, $key) !== false) { // found a bug associated with our profile key
$delete_store{$file} = $file;
}
}
closedir($dir); // clean it up
// Now run through the files and unlink them all
foreach($delete_store as $elem => $val)
unlink($dir_ . '/' . $elem);
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
header('Location: ' . $_SERVER['PHP_SELF']);
}
?>