2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../../include/');
\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
18 authenticate(AT_PRIV_CONTENT);
\r
20 function quote_csv($line) {
\r
21 $line = str_replace('"', '""', $line);
\r
23 $line = str_replace("\n", '\n', $line);
\r
24 $line = str_replace("\r", '\r', $line);
\r
25 $line = str_replace("\x00", '\0', $line);
\r
27 return '"'.$line.'"';
\r
30 $name = str_replace(" ", "_", $_SESSION['course_title']);
\r
31 $name = str_replace("'", "", $name);
\r
33 header('Content-Type: text/csv');
\r
34 header('Content-Disposition: inline; filename="'.$name.'_tracking.csv"');
\r
35 header('Expires: 0');
\r
36 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
\r
37 header('Pragma: public');
\r
39 $file_row = "page,member,visits,duration,timestamp";
\r
42 $sql = "SELECT C.title, M.login, MT.counter, SEC_TO_TIME(MT.duration) AS time, MT.last_accessed
\r
43 FROM ".TABLE_PREFIX."content C, ".TABLE_PREFIX."members M, ".TABLE_PREFIX."member_track MT
\r
44 WHERE M.member_id=MT.member_id AND C.content_id=MT.content_id AND C.course_id=$_SESSION[course_id]
\r
45 ORDER BY C.title, M.login ASC";
\r
47 $result = mysql_query($sql, $db);
\r
49 while ($row = mysql_fetch_assoc($result)) {
\r
50 $file_row .= quote_csv($row['title']) .",";
\r
51 $file_row .= quote_csv($row['login']) .",";
\r
52 $file_row .= quote_csv($row['counter']) .",";
\r
53 $file_row .= quote_csv($row['time']) .",";
\r
54 $file_row .= AT_date(_AT('forum_date_format'), $row['last_accessed']).",";
\r