forked from atutor/ATutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_logging.php
175 lines (146 loc) · 5.53 KB
/
error_logging.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
<?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);
require(AT_INCLUDE_PATH.'header.inc.php');
?>
<form name="form" method="post" action="admin/error_logging_details.php">
<table class="data" summary="">
<thead>
<tr>
<th><?php echo _AT('profile'); ?></th>
<th><?php echo _AT('date'); ?></th>
<th><?php echo _AT('bug_count'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">
<input type="submit" name="view" value="<?php echo _AT('view_profile_bugs'); ?>" />
<input type="submit" name="delete" value="<?php echo _AT('delete_profile'); ?>" />
</td>
</tr>
</tfoot>
<tbody>
<?php
$dir_ = AT_CONTENT_DIR . 'logs';
if (!is_dir($dir_)) {
mkdir($dir_);
}
if (!($dir = @opendir($dir_))) {
$msg->printNoLookupFeedback('Could not access /content/logs. Check that the permission for the <strong>Server</string> user are r+w to it');
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
/**
* Run through the logs directory and lets get all the profiles of all the logs of all the dates, sort
* by primary key as date, secondary key is profile name
*/
$logdirs;
// loop through folder to get files and directory listing
while (($file = readdir($dir)) !== false) {
/* if the name is not a directory */
if( ($file == '.') || ($file == '..')) {
continue;
}
if (is_dir($dir_ . '/' . $file)) {
$logdirs{$file} = $file; // store the day log dir
}
}
closedir($dir); // clean it up
if (empty($logdirs)) { ?>
<tr>
<td colspan="3"><?php echo _AT('none_found'); ?></td>
</tr>
<?php
} else {
$count_ = 1;
foreach ($logdirs as $row => $val) {
$log_profiles; // store all the profiles under the dir /content/logs/$val
$log_profiles_bug_count; // store the amount of bugs per profile
if (!($dir = opendir($dir_ . '/' . $val))) {
$msg->printNoLookupFeedback('Could not access /content/logs/' . $val . '. 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, 'profile') !== false) { // found a profile, store its md5 key identifier
$tmp_ = substr($file, strpos($file, '_') + 1);
$tmp_ = substr($tmp_, 0, strpos($tmp_, '.log.php'));
$log_profiles{$file} = $tmp_;
}
}
closedir($dir); // clean it up
/**
* Open a read pointer to run through each log date directory getting all the bugs associated
* all the profiles in $log_profiles
*/
if (empty($log_profiles)) {
$msg->printNoLookupFeedback('Warning. No profile found in ' . $dir_ . '/' . $val);
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
foreach ($log_profiles as $elem => $val_) {
$count = 0;
/* for each profile get the number of bugs associated with it */
if (!($dir = opendir($dir_ . '/' . $val))) {
$msg->printNoLookupFeedback('Could not access /content/logs' . $val . '. Check that the permission for the <strong>Server</string> user are r+w to it');
require(AT_INCLUDE_PATH.'footer.inc.php');
exit;
}
while (($file = readdir($dir)) !== false) {
// make sure we ignore profiles too!, just look at bug files
if( ($file == '.') || ($file == '..') || is_dir($file) || (strpos($file, 'profile') !== false)) {
continue;
}
// found a bug that maps to $val_ md5 profile identifer
if (strpos($file, $val_) !== false) {
$count++;
}
}
closedir($dir);
// store the amount of bugs associated with profile
$log_profiles_bug_count{$val}[$val_] = $count;
}
$log_profiles = array();
}
/**
* At this point ($log_profiles => key) = ($log_profiles_bug_count => key).
*
* Lets print out <td> rows corresponding to all profiles found in the following format:
*
* Profile name, profile date, profile bug count.
*/
foreach ($log_profiles_bug_count as $day => $profile) :
foreach ($profile as $stamp => $total) :
?>
<tr onmousedown="document.form['<?php echo $stamp.$day; ?>'].checked = true;rowselect(this);" id="r_<?php echo $stamp.$day; ?>">
<td><input type="radio" id="<?php echo $stamp.$day; ?>" value="<?php echo $stamp.':'.$day; ?>" name="data" /><label for="<?php echo $stamp.$day; ?>"><?php echo $count_; ?></label></td>
<td><?php echo $day; ?></td>
<td><?php echo $total; ?></td>
</tr>
<?php
$count_++;
endforeach;
endforeach;
}
?>
</tbody>
</table>
</form>
<?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>