1 |
dpavlin |
1 |
<?php |
2 |
|
|
// Load globals |
3 |
|
|
require_once ("global_vars.php"); |
4 |
|
|
|
5 |
|
|
// Includes |
6 |
|
|
require_once ($GLOBAL_ADMIN_INC."sessionClass.php"); |
7 |
|
|
require_once ($GLOBAL_ADMIN_INC."accessClass.php"); |
8 |
|
|
require_once ($GLOBAL_ADMIN_INC."db_connect.php"); |
9 |
|
|
require_once ($GLOBAL_ADMIN_INC."app_controls.php"); |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
// HTML header |
13 |
|
|
printf("<HTML>\n"); |
14 |
|
|
printf("<HEAD>\n"); |
15 |
|
|
printf("<title>RQS Subject Statistics</title>\n"); |
16 |
|
|
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
17 |
|
|
printf("</HEAD>\n"); |
18 |
|
|
|
19 |
|
|
|
20 |
dpavlin |
67 |
// Default access settings |
21 |
|
|
$sess_time_human = ""; |
22 |
|
|
$sess_staff_account = ""; |
23 |
|
|
$sess_staff_id = 0; |
24 |
|
|
$sess_access_level = 0; |
25 |
|
|
$sess_access = ""; |
26 |
|
|
$sess_last_name = ""; |
27 |
|
|
$sess_first_name = ""; |
28 |
|
|
|
29 |
|
|
|
30 |
dpavlin |
1 |
// Page header |
31 |
|
|
require_once ($GLOBAL_ADMIN_HEADER); |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
// Collect access information |
35 |
|
|
if (isset($libsession)) { |
36 |
|
|
|
37 |
|
|
// Fetch session information |
38 |
|
|
$sessionClass = new sessionClass("", $libsession, "", ""); |
39 |
|
|
$accessClass = new accessClass($sessionClass); |
40 |
|
|
|
41 |
|
|
// Load user session variables |
42 |
|
|
$sess_time_human = $sessionClass->time_human; |
43 |
|
|
$sess_staff_account = $sessionClass->staff_account; |
44 |
|
|
$sess_access_level = $accessClass->access_level; |
45 |
|
|
$sess_access = $accessClass->access; |
46 |
|
|
$sess_last_name = $accessClass->last_name; |
47 |
|
|
$sess_first_name = $accessClass->first_name; |
48 |
|
|
|
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
// If the cookie is set and access level is appropriate |
52 |
|
|
if(isset($libsession) && $sess_access_level >= 20) { |
53 |
|
|
|
54 |
|
|
// Array of months |
55 |
|
|
$month_array = Array("0", "January", "February", "March", "April", "May", "June", |
56 |
|
|
"July", "August", "September", "October", "November", "December"); |
57 |
|
|
|
58 |
|
|
// Fetch today's date |
59 |
|
|
$today = getdate(); |
60 |
|
|
$mon = $today[mon]; |
61 |
|
|
$mday = $today[mday]; |
62 |
|
|
$year = $today[year]; |
63 |
|
|
|
64 |
|
|
|
65 |
|
|
// Back-fill in case we have single-digits. |
66 |
|
|
if (strlen($mday) < 2) $mday = "0" . $mday; |
67 |
|
|
if (strlen($mon) < 2) $mon = "0" . $mon; |
68 |
|
|
|
69 |
|
|
|
70 |
|
|
// Generate a mySQL-friendly datetime for today's stamp |
71 |
|
|
$today_stamp = $year . "-" . $mon . "-" . $mday; |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
// Outer table & header row |
75 |
|
|
printf("<center>\n"); |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
printf("<span class=\"bigDark\">Research QuickStart Subject Page Load Statistics</span><br><br>\n"); |
79 |
|
|
|
80 |
|
|
printf("<table width=\"95%%\" class=\"backLight\" border =\"1\">\n"); |
81 |
|
|
printf("<tr><td colspan=\"2\" class=\"cellPlain\">\n"); |
82 |
|
|
printf("Dates"); |
83 |
|
|
printf("</td></tr>\n"); |
84 |
|
|
|
85 |
|
|
// Basic information |
86 |
|
|
printf("<tr><td width=\"35%%\" valign=\"middle\" >\n"); |
87 |
|
|
printf("<b>Today's Date:</b> %s<BR>\n", $today_stamp); |
88 |
|
|
|
89 |
|
|
$sql = "SELECT MIN(visit_date) as min_date, MAX(visit_date) as max_date |
90 |
|
|
FROM libstats.substats"; |
91 |
dpavlin |
67 |
$rs = mysql_tryquery($sql); |
92 |
|
|
$row = mysql_fetch_array ($rs, MYSQL_ASSOC); |
93 |
dpavlin |
1 |
$min_date = $row["min_date"]; |
94 |
|
|
$max_date = $row["max_date"]; |
95 |
|
|
|
96 |
|
|
printf("<b>Earliest page load:</b> %s<BR>\n", $min_date); |
97 |
|
|
printf("<b>Most recent page load:</b> %s<BR><br>\n", $max_date); |
98 |
|
|
printf("</td>\n"); |
99 |
|
|
|
100 |
|
|
// Determine whether there are any incoming start/end limits. |
101 |
|
|
// If not, use today's date as the start and end date. |
102 |
|
|
if (strlen($start_year) < 1) $start_year = $year; |
103 |
|
|
if (strlen($start_month) < 1) $start_month = $mon; |
104 |
|
|
if (strlen($start_day) < 1) $start_day = $mday; |
105 |
|
|
|
106 |
|
|
|
107 |
|
|
// Determine whether there are any incoming end limits. |
108 |
|
|
// If not, use today's date as the end date. |
109 |
|
|
if (strlen($end_year) < 1) $end_year = $year; |
110 |
|
|
if (strlen($end_month) < 1) $end_month = $mon; |
111 |
|
|
if (strlen($end_day) < 1) $end_day = $mday; |
112 |
|
|
|
113 |
|
|
|
114 |
|
|
// Generate mySQL-friendly date-time based on current settings |
115 |
|
|
// Back-fill in case we have single-digits. |
116 |
|
|
if (strlen($start_year) < 1) $start_year = $year; |
117 |
|
|
if (strlen($start_month) < 2) $start_month = "0" . $start_month; |
118 |
|
|
if (strlen($start_day) < 2) $start_day = "0" . $start_day; |
119 |
|
|
|
120 |
|
|
|
121 |
|
|
if (strlen($end_year) < 1) $end_year = $year; |
122 |
|
|
if (strlen($end_month) < 2) $end_month = "0" . $end_month; |
123 |
|
|
if (strlen($end_day) < 2) $end_day = "0" . $end_day; |
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
// Generate high/low datetime stamps for SQL. |
128 |
|
|
$start_stamp = $start_year . "-" . $start_month . "-" . $start_day; |
129 |
|
|
$end_stamp = $end_year . "-" . $end_month . "-" . $end_day . " 23:59:59"; |
130 |
|
|
|
131 |
|
|
|
132 |
|
|
/******************** |
133 |
|
|
** Date range form ** |
134 |
|
|
********************/ |
135 |
|
|
|
136 |
|
|
printf("<td>\n"); |
137 |
|
|
printf("<b>Limit by date or range:</b><BR><BR>\n"); |
138 |
|
|
printf("<table border=\"0\">\n"); |
139 |
|
|
printf("<tr>\n"); |
140 |
|
|
printf("<form method =\"post\" action=\"subject_stats.phtml\">\n"); |
141 |
|
|
|
142 |
|
|
|
143 |
|
|
// Start parameters |
144 |
|
|
|
145 |
|
|
|
146 |
|
|
// Start month |
147 |
|
|
printf("<td><b>Start Date:</b></td>"); |
148 |
|
|
printf("<td><select name=\"start_month\">\n"); |
149 |
|
|
for ($count = 1; $count < 13; $count++) { |
150 |
|
|
// Pad 0-9 with a 0. |
151 |
|
|
if ($count < 10) $count_value = "0" . $count; |
152 |
|
|
else $count_value = $count; |
153 |
|
|
printf("<option value=\"%s\"", $count); |
154 |
|
|
if ($count == $start_month) printf(" SELECTED "); |
155 |
|
|
printf(">%s</option>\n", $month_array[$count]); |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
printf("</select> "); |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
// Start day |
162 |
|
|
printf("<select name=\"start_day\">\n"); |
163 |
|
|
for ($count = 1; $count < 32; $count++) { |
164 |
|
|
// Pad 0-9 with a 0. |
165 |
|
|
if ($count < 10) $count_value = "0" . $count; |
166 |
|
|
else $count_value = $count; |
167 |
|
|
printf("<option value=\"%s\"", $count); |
168 |
|
|
if ($count == $start_day) printf(" SELECTED "); |
169 |
|
|
printf(">%s</option>\n", $count_value); |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
printf("</select> "); |
173 |
|
|
|
174 |
|
|
// Start year -- allow previous three years as well |
175 |
|
|
$year_value = $year - 3; |
176 |
|
|
printf("<select name=\"start_year\">\n"); |
177 |
|
|
for ($count = 1; $count < 5; $count++) { |
178 |
|
|
printf("<option value=\"%s\"", $year_value); |
179 |
|
|
if ($year_value == $start_year) printf(" SELECTED "); |
180 |
|
|
printf(">%s</option>\n", $year_value); |
181 |
|
|
$year_value++; |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
printf("</select>\n"); |
185 |
|
|
printf("</td>\n"); |
186 |
|
|
|
187 |
|
|
// Blank cell |
188 |
|
|
printf("<td> </td>\n"); |
189 |
|
|
printf("</tr>\n"); |
190 |
|
|
|
191 |
|
|
|
192 |
|
|
// End parameters |
193 |
|
|
|
194 |
|
|
|
195 |
|
|
// End month |
196 |
|
|
printf("<tr>\n"); |
197 |
|
|
printf("<td><b>End Date:</b></td>"); |
198 |
|
|
printf("<td><select name=\"end_month\">\n"); |
199 |
|
|
for ($count = 1; $count < 13; $count++) { |
200 |
|
|
// Pad 0-9 with a 0. |
201 |
|
|
if ($count < 10) $count_value = "0" . $count; |
202 |
|
|
else $count_value = $count; |
203 |
|
|
|
204 |
|
|
printf("<option value=\"%s\"", $count_value); |
205 |
|
|
if ($count_value == $end_month) printf(" SELECTED "); |
206 |
|
|
printf(">%s</option>\n", $month_array[$count]); |
207 |
|
|
} |
208 |
|
|
|
209 |
|
|
printf("</select> "); |
210 |
|
|
|
211 |
|
|
|
212 |
|
|
// End day |
213 |
|
|
printf("<select name=\"end_day\">\n"); |
214 |
|
|
for ($count = 1; $count < 32; $count++) { |
215 |
|
|
// Pad 0-9 with a 0. |
216 |
|
|
if ($count < 10) $count_value = "0" . $count; |
217 |
|
|
else $count_value = $count; |
218 |
|
|
|
219 |
|
|
printf("<option value=\"%s\"", $count_value); |
220 |
|
|
if ($count_value == $end_day) printf(" SELECTED "); |
221 |
|
|
printf(">%s</option>\n", $count_value); |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
printf("</select> "); |
225 |
|
|
|
226 |
|
|
// End year -- allow previous three years as well |
227 |
|
|
$year_value = $year - 3; |
228 |
|
|
printf("<select name=\"end_year\">\n"); |
229 |
|
|
for ($count = 1; $count < 5; $count++) { |
230 |
|
|
printf("<option value=\"%s\"", $year_value); |
231 |
|
|
if ($year_value == $end_year) printf(" SELECTED "); |
232 |
|
|
printf(">%s</option>\n", $year_value); |
233 |
|
|
$year_value++; |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
printf("</select>\n"); |
237 |
|
|
printf("</td>\n"); |
238 |
|
|
printf("<td align = \"center\" ><input type=\"submit\" value=\"Limit By Dates\"></td>\n"); |
239 |
|
|
printf("</tr>\n"); |
240 |
|
|
printf("</form>"); |
241 |
|
|
printf("</table>\n"); |
242 |
|
|
|
243 |
|
|
|
244 |
|
|
// Outer table |
245 |
|
|
printf("</td></tr></table>\n"); |
246 |
|
|
printf("<BR>\n"); |
247 |
|
|
|
248 |
|
|
|
249 |
|
|
/********************* |
250 |
|
|
** PageScribe Pages ** |
251 |
|
|
*********************/ |
252 |
|
|
|
253 |
|
|
|
254 |
|
|
printf("<span class=\"bigDark\">Research QuickStart Subjects</span><br><br>\n"); |
255 |
|
|
|
256 |
|
|
// Table and header row |
257 |
|
|
printf("<table width=\"95%%\" border=\"1\">\n"); |
258 |
|
|
printf("<tr>\n"); |
259 |
|
|
printf("<td class=\"cellPlain\" width=\"10%%\">Subject ID</td>\n"); |
260 |
|
|
printf("<td class=\"cellPlain\" width=\"70%%\">Subject</td>\n"); |
261 |
|
|
printf("<td class=\"cellPlain\" align=\"center\" width=\"20%%\">RQS Subject Loads</td>\n"); |
262 |
|
|
printf("</tr>\n"); |
263 |
|
|
|
264 |
|
|
|
265 |
|
|
$sql = "SELECT |
266 |
|
|
s.subject_id, |
267 |
|
|
s.subject |
268 |
|
|
FROM subject s |
269 |
|
|
WHERE s.subject_id > 1 |
270 |
|
|
ORDER BY s.subject"; |
271 |
|
|
|
272 |
dpavlin |
67 |
$rs = mysql_tryquery($sql); |
273 |
dpavlin |
1 |
|
274 |
|
|
// Initialize |
275 |
|
|
$rowcount = 0; |
276 |
|
|
$sub_loads_total = 0; |
277 |
|
|
|
278 |
dpavlin |
67 |
while ($row = mysql_fetch_array ($rs, MYSQL_ASSOC)) { |
279 |
dpavlin |
1 |
|
280 |
|
|
// Fetch the stuff |
281 |
|
|
$subject_id = $row["subject_id"]; |
282 |
|
|
$subject = Trim($row["subject"]); |
283 |
|
|
// $date_created = substr($row["date_created"], 0, 10); |
284 |
|
|
// $date_modified = substr($row["date_modified"], 0, 10); |
285 |
|
|
|
286 |
|
|
// Pull out any HTML |
287 |
|
|
$subject = strip_tags($subject); |
288 |
|
|
|
289 |
|
|
// New row |
290 |
|
|
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
291 |
|
|
else $color = ""; |
292 |
|
|
|
293 |
|
|
printf("<tr>\n"); |
294 |
|
|
printf("<td %s>%d</td>\n", $color, $subject_id); |
295 |
|
|
printf("<td %s>%s</td>\n", $color, $subject); |
296 |
|
|
|
297 |
|
|
|
298 |
|
|
// Pull out the page load stats for this page |
299 |
|
|
$stats_sql = "SELECT COUNT(*) as sub_loads |
300 |
|
|
FROM libstats.substats |
301 |
|
|
WHERE subject_id = " |
302 |
|
|
. $subject_id |
303 |
|
|
. " AND visit_date >= '" |
304 |
|
|
. $start_stamp |
305 |
|
|
. "' AND visit_date <= '" |
306 |
|
|
. $end_stamp |
307 |
|
|
. "'"; |
308 |
dpavlin |
67 |
$stats_rs = mysql_tryquery($stats_sql); |
309 |
|
|
$stats_row = mysql_fetch_array ($stats_rs, MYSQL_ASSOC); |
310 |
dpavlin |
1 |
$sub_loads = $stats_row["sub_loads"]; |
311 |
|
|
|
312 |
|
|
printf("<td align=\"center\" %s>%d</td>\n", $color, $sub_loads); |
313 |
|
|
|
314 |
|
|
// Encode the date limits |
315 |
|
|
$start = urlencode($start_stamp); |
316 |
|
|
$end = urlencode($end_stamp); |
317 |
|
|
|
318 |
|
|
// Close row |
319 |
|
|
printf("</tr>\n"); |
320 |
|
|
|
321 |
|
|
// Increment |
322 |
|
|
$rowcount++; |
323 |
|
|
$sub_loads_total = $sub_loads_total + $sub_loads; |
324 |
|
|
|
325 |
|
|
} |
326 |
|
|
|
327 |
|
|
// Summary row |
328 |
|
|
printf("<tr><td colspan=\"2\"> </td>\n"); |
329 |
|
|
printf("<td class=\"backLight\"><b>Total:</b> %d</td>\n", $sub_loads_total); |
330 |
|
|
|
331 |
|
|
printf("</table><br>\n"); |
332 |
|
|
|
333 |
|
|
|
334 |
|
|
// Link to return to admin console |
335 |
|
|
adminReturn($sess_access_level); |
336 |
|
|
|
337 |
|
|
|
338 |
|
|
printf("</center>\n"); |
339 |
|
|
|
340 |
|
|
|
341 |
|
|
} // logged in user |
342 |
|
|
|
343 |
|
|
// No access page |
344 |
|
|
else require_once ($GLOBAL_NO_ACCESS); |
345 |
|
|
|
346 |
|
|
|
347 |
|
|
// Page footer |
348 |
|
|
require_once ($GLOBAL_ADMIN_FOOTER); |
349 |
|
|
?> |
350 |
|
|
|
351 |
|
|
</body> |
352 |
|
|
</html> |