Added discussion feature to site.
[Assignment-Trapper.git] / comment_feed.php
blob8d2714f195bebe56392eacc91560124e91128e92
1 <?php
3 date_default_timezone_set('America/Chicago');
5 include_once("auth_root.php");
7 $items = "";
9 //include_once("conn.php");
11 /* TODO: Lock out account if this user keeps hitting this page. */
13 //if($role != 0) { die("Account \"".$user_name."\" Is Not Authorized To View This Page.<br><br>This Event Will Be Logged And Reported."); }
15 if($role == 0) {
17 $sql = 'select txt, name, email, title, type_name, DATE_FORMAT(comments.timeposted,"%a, %d %b %Y %T CST") AS timeposted, comments.sub_id from comments, users, schedule, types where (schedule.assign_type = types.assign_type) and (schedule.sched_id = comments.sub_id) and (comments.user_id = users.user_id) order by timeposted limit 30';
19 } else {
20 $sql = 'select txt, name, email, title, type_name, DATE_FORMAT(comments.timeposted,"%a, %d %b %Y %T CST") AS timeposted, comments.sub_id from comments, users, schedule, types where (schedule.assign_type = types.assign_type) and (schedule.sched_id = comments.sub_id) and (comments.user_id = users.user_id) and users.user_id='.$user_id.' order by timeposted limit 30';
24 //echo $sql;
26 $result = mysql_query($sql);
28 $server_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
29 $server_url_base = "http://".$_SERVER['SERVER_NAME'];
30 //echo $server_url;
32 if (!$result) { die("SQL ERROR"); }
34 $i = 0;
35 while($row = mysql_fetch_array($result))
37 $row['txt'] = htmlspecialchars($row['txt']);
38 $items .= '
39 <item>
40 <title>'.$row['name'].' - '.$row['title'].' - '.$row['type_name'].'</title>
41 <description>'.$row['txt'].'</description>
42 <link>'.$server_url_base.'/at/detail_root.php?sched='.$row['sub_id'].'</link>
43 <author>'.$row['email'].' ('.$row['name'].')</author>
44 <category domain="comment feed">comments</category>
45 <guid>'.$server_url_base.'/at/detail_root.php?sched='.$row['sub_id'].'random='.$i.'</guid>
46 <pubDate>'.$row['timeposted'].'</pubDate>
47 </item>
50 $i++;
53 $now = date("D, d M Y H:i:s T");
55 //echo $now;
57 echo '<?xml version="1.0" encoding="UTF-8" ?>';
61 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
62 <channel>
63 <title>Assignment Trapper - Comment Feed</title>
64 <description>Latest comments listed by date.</description>
65 <link><?php echo $server_url; ?></link>
66 <lastBuildDate>Fri, 31 Dec 1999 23:59:59 EST</lastBuildDate>
67 <pubDate>Fri, 31 Dec 1999 23:59:59 EST</pubDate>
68 <language>en-US</language>
69 <copyright>Copyright 2011 Steven Schronk</copyright>
70 <managingEditor>steven@schronk.com (Steven Schronk)</managingEditor>
71 <webMaster>steven@schronk.com (Steven Schronk)</webMaster>
72 <ttl>10</ttl>
73 <atom:link href="http://www.opentextbook.info/at/comment_feed.php" rel="self" type="application/rss+xml" />
74 <image>
75 <title>Assignment Trapper - Comment Feed</title>
76 <url><?php echo $server_url_base; ?>/at/gfx/bricks.png</url>
77 <link><?php echo $server_url_base; ?>/at/comment_feed.php</link>
78 <width>32</width>
79 <height>32</height>
80 </image>
82 <?php echo $items; ?>
84 </channel>
85 </rss>