/[libdata]/trunk/admin/scribe_stats_page.phtml
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/admin/scribe_stats_page.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations)
Thu Mar 18 20:33:37 2004 UTC (20 years, 1 month ago) by dpavlin
File size: 8066 byte(s)
changes made in version 2.00

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>Page Detail Statistics</title>\n");
16 printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS);
17 printf("</HEAD>\n");
18
19
20 // 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 // 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 // Date ranges
55 $start_stamp = rawurldecode($start);
56 $end_stamp = rawurldecode($end);
57
58
59 // Pull out statistical information
60 $sql = "SELECT MIN(visit_date) as min_date, MAX(visit_date) as max_date
61 FROM libstats.elementstats
62 WHERE page_id = "
63 . $page_id;
64 $rs = xx_tryquery($sql);
65 $row = xx_fetch_array ($rs, xx_ASSOC);
66 $min_date = $row["min_date"];
67 $max_date = $row["max_date"];
68
69 // Lookup the page title
70 $sql = "SELECT
71 p.page_title,
72 c.course_concat
73 FROM page p
74 LEFT JOIN course c using (page_id)
75 WHERE p.page_id = "
76 . $page_id;
77
78 $rs = xx_tryquery($sql);
79 $row = xx_fetch_array ($rs, xx_ASSOC);
80 $page_title = $row["page_title"];
81 $course_concat = $row["course_concat"];
82
83 // Use the concatenated course name for title if this is a CourseScribe page
84 if (strlen($course_concat) > 0) $page_title = $course_concat;
85
86 // Pull out any HTML
87 $page_title = strip_tags($page_title);
88
89
90 // Header row
91 printf("<center>\n");
92 printf("<span class=\"bigDark\">Page Detail Statistics for: %s</span><br><br>\n", $page_title);
93
94
95 printf("<table width=\"95%%\" class=\"backLight\" border =\"1\">\n");
96 printf("<tr><td class=\"cellPlain\">\n");
97 printf("Dates");
98 printf("</td>\n");
99
100
101 printf("</tr>\n");
102 printf("<tr><td colspan=\"2\"><br>\n");
103 printf("<b>Selected period from:</b> %s <b>to:</b> %s<br><br>\n", $start_stamp, $end_stamp);
104 printf("<b>Earliest link followed on this page:</b> %s<BR>\n", $min_date);
105 printf("<b>Most recent link followed on this page:</b> %s<BR><br>\n", $max_date);
106 printf("</td></tr>\n");
107 printf("</table><br>\n");
108
109
110 /************************************************
111 ** For a specific page, show all element stats **
112 ************************************************/
113
114
115 printf("<span class=\"bigDark\">Element Usage</span><br><br>\n");
116
117 // Table and header row
118 printf("<table width=\"95%%\" border=\"1\">\n");
119 printf("<tr>\n");
120 printf("<td class=\"cellPlain\">Element ID</td>\n");
121 printf("<td class=\"cellPlain\">Element Title</td>\n");
122 printf("<td class=\"cellPlain\">URL</td>\n");
123 printf("<td class=\"cellPlain\">Times Followed</td>\n");
124 printf("</tr>\n");
125
126 $sql = "SELECT
127 p.page_title,
128 c.course_concat,
129 r.resource_id,
130 r.title,
131 r.url,
132 v.service_id,
133 v.service,
134 v.serviceURL,
135 l.location_id,
136 l.location,
137 l.mainURL,
138 s.staff_id,
139 s.last_name,
140 s.first_name,
141 s.staff_account,
142 s.staff_email,
143 b.subject,
144 b.subject_id,
145 e.element_id,
146 e.label,
147 e.label_url,
148 e.element_order
149 FROM page p
150 LEFT JOIN element e using (page_id)
151 LEFT JOIN course c on p.page_id = c.page_id
152 LEFT JOIN resource r on e.resource_id = r.resource_id
153 LEFT JOIN service v on e.service_id = v.service_id
154 LEFT JOIN location l on e.location_id = l.location_id
155 LEFT JOIN staff s on e.staff_id = s.staff_id
156 LEFT JOIN subject b on e.subject_id = b.subject_id
157 WHERE p.page_id = "
158 . $page_id
159 . " ORDER BY e.element_order";
160
161 //printf($sql);
162
163 $rs = xx_tryquery($sql);
164
165 // Initialize counters
166 $row_num = 0;
167 $total_hits = 0;
168
169 while ($row = xx_fetch_array ($rs, xx_ASSOC)) {
170
171 // Element related
172 $element_id = $row["element_id"];
173 $label = $row["label"];
174 $label_url = $row["label_url"];
175
176 // Page related
177 $page_title = Trim($row["page_title"]);
178 $course_concat = Trim($row["course_concat"]);
179
180 // Resource
181 $resource_id = $row["resource_id"];
182 $title = $row["title"];
183 $url = $row["url"];
184
185 // Service
186 $service_id = $row["service_id"];
187 $service = $row["service"];
188 $serviceURL = $row["serviceURL"];
189
190 // Location
191 $location_id = $row["location_id"];
192 $location = $row["location"];
193 $mainURL = $row["mainURL"];
194
195 // Staff
196 $staff_id = $row["staff_id"];
197 $last_name = $row["last_name"];
198 $first_name = $row["first_name"];
199 $staff_account = $row["staff_account"];
200 $staff_email = $row["staff_email"];
201
202 // Subject
203 $subject_id = $row["subject_id"];
204 $subject = $row["subject"];
205 $subjectURL = $GLOBAL_RQS_URL."rqs.phtml?subject_id=".$subject_id;
206
207 // Use full course name if this is a coursescribe page
208 if (strlen($course_concat) > 0) $page_title = $course_concat;
209
210
211
212
213 // Initialize display anew for each row
214 $item_display = "";
215 $item_url = "";
216 $item_descr = "";
217 $element_hits = 0;
218
219 // Determine the element title, description and URL
220
221 // Resource
222 if ($resource_id > 0) {
223 $item_display = $title;
224 $item_url = $url;
225 }
226 // Location
227 else if ($location_id > 0) {
228 $item_display = $location;
229 $item_url = $mainURL;
230 }
231 // Service
232 else if ($service_id > 0) {
233 $item_display = $service;
234 $item_url = $serviceURL;
235 }
236 // Staff
237 else if ($staff_id > 0) {
238 $item_display = $first_name . " " . $last_name;
239 $item_url = "mailto: " . $staff_email;
240 }
241 // Subject
242 else if ($subject_id > 0) {
243 $item_display = $subject;
244 $item_url = $subjectURL;
245 }
246
247
248 // A "unique resource"
249 if (strlen($label) > 0 ) {
250 $item_url = $label_url;
251 $item_display = $label;
252 }
253
254 // Don't do this unless there's a valid element
255 if ($element_id > 0) {
256
257 // Cleanup
258 if (strlen($item_url) < 1) $item_url = "(no URL for this element)";
259 $item_display = strip_tags($item_display);
260
261 // New row
262 if ($row_num % 2 == 0) printf("<tr class =\"backLight\">\n");
263 else printf("<tr>\n");
264
265
266 printf("<td>%d</td>\n", $element_id);
267 printf("<td>%s</td>\n", $item_display);
268 printf("<td>%s</td>\n", $item_url);
269
270
271 // Don't track stats for staff mailto's.
272 if ($staff_id < 1) {
273
274 // Pull out the stats for this page
275 $stats_sql = "SELECT COUNT(*) as element_hits
276 FROM libstats.elementstats
277 WHERE page_id = "
278 . $page_id
279 . " AND element_id = "
280 . $element_id;
281
282 // Limit to
283 if (strlen($start_stamp) > 0) $stats_sql .= " AND visit_date >= '" . $start_stamp . "'";
284 if (strlen($end_stamp) > 0) $stats_sql .= " AND visit_date <= '" . $end_stamp . "'";
285
286 $stats_rs = xx_tryquery($stats_sql);
287 $stats_row = xx_fetch_array ($stats_rs, xx_ASSOC);
288 $element_hits = $stats_row["element_hits"];
289
290 // Cover the NULL value
291 if ($element_hits < 1) $element_hits = 0;
292
293 printf("<td>%s</td>\n", $element_hits);
294 }
295 else printf("<td>(N/A)</td>\n");
296
297
298
299 // Close row
300 printf("</tr>\n");
301
302 $row_num++;
303
304 }
305
306 $total_hits = $total_hits + $element_hits;
307
308 }
309
310 // Summary row
311 printf("<tr><td colspan=\"3\">&nbsp;</td>\n");
312 printf("<td><b>Total:</b> %d</td>\n", $total_hits);
313
314 printf("</table><br>\n");
315
316
317 // Link to return to admin console
318 adminReturn($sess_access_level);
319
320
321 printf("</center>\n");
322
323
324 } // logged in user
325
326 // No access page
327 else require_once ($GLOBAL_NO_ACCESS);
328
329
330 // Page footer
331 require_once ($GLOBAL_ADMIN_FOOTER);
332 ?>
333
334 </body>
335 </html>

  ViewVC Help
Powered by ViewVC 1.1.26