remove old readme
[atutor.git] / docs / mods / _standard / farchive / forum_post.php
1 <?php
2 define('AT_INCLUDE_PATH', '../../../include/');
3
4
5 // Prints out an single formatted thread message
6 function print_entry2($row) {
7         global $page,$system_courses, $forum_info;
8         static $counter;
9         $counter++;
10
11         $reply_link = '<a href="forum/view.php?fid='.$row['forum_id'].SEP.'pid=';
12         if ($row['parent_id'] == 0) {
13                 $reply_link .= $row['post_id'];
14         } else {
15                 $reply_link .= $row['parent_id'];
16         }
17         $reply_link .= SEP.'reply='.$row['post_id'].SEP.'page='.$page.'#post" >'._AT('reply').'</a>';
18
19 ?>
20
21         <li class="<?php if ($counter %2) { echo 'odd'; } else { echo 'even'; } ?>">
22                 <a name="<?php echo $row['post_id']; ?>"></a>
23                 <div class="forum-post-author">
24                         <label class="title"><?php echo htmlspecialchars(get_display_name($row['member_id'])); ?></label><br />
25                 </div>
26
27                 <div class="forum-post-content">
28                         
29                         <div class="date">
30                 <p><?php echo AT_date(_AT('forum_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME); ?></p>
31             </div>
32             <div class="postheader"><h3><?php echo AT_Print($row['subject'], 'forums_threads.subject'); ?></h3></div>
33                                 
34                         <div class="body">
35                                 <p><?php echo AT_print($row['body'], 'forums_threads.body'); ?></p>
36                         </div>
37                 </div>
38         </li>
39 <?php
40 }
41
42 copy(getcwd()."/styles.css", AT_CONTENT_DIR."/styles.css");
43
44 $head = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
45         'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
46       <html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>";
47
48 $head .= "<head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><link rel=StyleSheet href='styles.css' type='text/css' media='screen'><title>Exported Forum</title></head><body>";
49
50 $tmpfile = AT_CONTENT_DIR."/exported_forum.html";
51 $main = fopen($tmpfile, "w");
52
53 //---- Header----
54 fwrite($main, $head);
55 fwrite($main, "<h1>".$forum_title."</h1><br />");
56 fwrite($main, "<div class='threadlist'>");
57
58 $filearr = array();  // will hold all the files that were created
59
60 $sql = "SELECT *, DATE_FORMAT(date, '%Y-%m-%d %H-%i:%s') AS date, UNIX_TIMESTAMP(date) AS udate FROM ".TABLE_PREFIX."forums_threads WHERE parent_id=0 AND forum_id=".$forum_id." ORDER BY date ASC LIMIT 0, 70";
61 $result = mysql_query($sql) or die(mysql_error());
62
63 // Print out each post for each thread
64 while ($row = mysql_fetch_array($result)) {
65
66
67     $handle = fopen(AT_CONTENT_DIR."/t-".$row['post_id'].".html", "w");
68     array_push($filearr, "t-".$row['post_id'].".html");
69
70     fwrite($main, "<a href='t-".$row['post_id'].".html'>".$row['subject']."</a><br />");
71     fwrite($handle, $head);
72     fwrite($handle, "<br /><div><a href='exported_forum.html' class='midtext'>Back to: Thread list</a></div><br />");
73     fwrite($handle, "<div><p><br /><h1>".$row['subject']."</h1></div><br />");
74     fwrite($handle, "<div><ul class='forum-thread'>");
75
76     $sql        = "SELECT *, DATE_FORMAT(date, '%Y-%m-%d %H-%i:%s') AS date, UNIX_TIMESTAMP(date) AS udate FROM ".TABLE_PREFIX."forums_threads WHERE parent_id=".$row['post_id']." AND forum_id=".$forum_id." ORDER BY date ASC LIMIT 0, 70";
77
78     $result_post = mysql_query($sql, $db);
79     ob_start();
80
81     print_entry2($row);
82     
83     while ($post_row = mysql_fetch_assoc($result_post)) {
84         print_entry2($post_row);
85     }
86     fwrite($handle, ob_get_contents());
87     ob_end_clean();
88     fwrite($handle, "</ul></div>");
89     fwrite($handle, "</body></html>");
90     fclose($handle);
91 }
92 fwrite($main, "<div></body></html>");
93
94 ?>