/[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 42 - (show annotations)
Thu Mar 4 22:43:50 2004 UTC (20 years, 1 month ago) by dpavlin
File size: 7852 byte(s)
rename all mysql_ functions to xx_ so that wrapper can be used

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

  ViewVC Help
Powered by ViewVC 1.1.26