summaryrefslogtreecommitdiff
path: root/forum
diff options
context:
space:
mode:
Diffstat (limited to 'forum')
-rw-r--r--forum/utils/calendar.php112
-rw-r--r--forum/utils/clientinfo.php24
-rw-r--r--forum/utils/convert.php18
-rw-r--r--forum/utils/edit.php89
-rw-r--r--forum/utils/editor.php154
-rw-r--r--forum/utils/editor_form.php127
-rw-r--r--forum/utils/error.php6
-rw-r--r--forum/utils/events.php141
-rw-r--r--forum/utils/filehandler.php33
-rw-r--r--forum/utils/files.php134
-rw-r--r--forum/utils/forums.php133
-rw-r--r--forum/utils/log.php10
-rw-r--r--forum/utils/login.php105
-rw-r--r--forum/utils/mimetypes.php50
-rw-r--r--forum/utils/notify.php70
-rw-r--r--forum/utils/parser.php126
-rw-r--r--forum/utils/ping.php126
-rw-r--r--forum/utils/posts.php254
-rw-r--r--forum/utils/profile.php39
-rw-r--r--forum/utils/roadmap.php70
-rw-r--r--forum/utils/smileys.php38
-rw-r--r--forum/utils/threads.php162
-rw-r--r--forum/utils/users.php136
-rw-r--r--forum/utils/view.php28
24 files changed, 2185 insertions, 0 deletions
diff --git a/forum/utils/calendar.php b/forum/utils/calendar.php
new file mode 100644
index 0000000..1592195
--- /dev/null
+++ b/forum/utils/calendar.php
@@ -0,0 +1,112 @@
+<?php
+include_once($UTIL_DIR . "/events.php");
+include_once($UTIL_DIR . "/notify.php");
+
+$events = new Events($DATA_DIR . "/calendar.xml");
+
+if(!$date) $date = time() - (date("N", time()) - 1) * 24 * 60 * 60;
+else $date = $date - (date("N", $date) - 1) * 24 * 60 * 60;
+//echo $date;
+
+if($action=="addentry") {
+ $time = strtotime($txtdate . " " . $txttimefrom . ":00");
+ $duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time;
+ $eid = time();
+ $event = new Event($eid, $title, $time, $duration, $description, $current_user->uid);
+ $events->add($event);
+ $events->write();
+ notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" .
+ $description . "\n" .
+ "http://www.executionroom.com/forum/?mode=calendar&date=" . $time);
+}
+
+if($action=="edit") {
+ /*
+ $event = $events->getEvent($eid);
+ $event->duration += 2000;
+ $events->write();
+ */
+}
+
+?>
+<p style="text-align: center;">
+<a href="?mode=calendar&amp;date=<?php echo $date - 7 * 24 * 60 * 60 ?>">[&lt;]</a>
+&nbsp;&nbsp;
+<a href="?mode=calendar&amp;date=<?php echo $date - 31 * 24 * 60 * 60 ?>">[&lt;&lt;]</a>
+&nbsp;&nbsp;
+<?php echo date("F Y", $date); ?>
+&nbsp;&nbsp;
+<a href="?mode=calendar&amp;date=<?php echo $date + 31 * 24 * 60 * 60 ?>">[&gt;&gt;]</a>
+&nbsp;&nbsp;
+<a href="?mode=calendar&amp;date=<?php echo $date + 7 * 24 * 60 * 60 ?>">[&gt;]</a><br/>
+<a href="?mode=calendar">[Today]</a><br/>
+</p>
+<?php
+if($client_is_mobile_device) {
+ for($day = 0; $day < 7; $day++) {
+ echo " <div class=\"mobilecalentry\">\n";
+ echo " <div class=\"mobilecalheader\">\n";
+ $t = $date + $day * 24 * 60 * 60;
+ echo " " . date("l j/n", $t) . "\n";
+?>
+ <a style="text-decoration: none;" href="?mode=calendar&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">[+]</a>
+<?php
+ echo " </div>\n";
+
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
+ echo " <div class=\"mobilecalcontent\"";
+ if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\"";
+ elseif($day > 4) echo " style=\"background: #311;\"";
+ echo ">\n";
+
+ $events->show($t, $t + 24 * 60 * 60);
+
+ echo " </div>\n";
+ echo " </div>\n";
+
+ }
+} else {
+?>
+<table class="week">
+ <tr class="day">
+<?php
+for($day = 0; $day < 7; $day++) {
+ echo " <td class=\"header\">\n";
+ $t = $date + $day * 24 * 60 * 60;
+ echo " " . date("l j/n", $t) . "\n";
+ echo " </td>\n";
+}
+?>
+ </tr>
+ <tr class="day">
+<?php
+for($day = 0; $day < 7; $day++) {
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
+
+ echo " <td class=\"content\"";
+ if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\"";
+ elseif($day > 4) echo " style=\"background: #311;\"";
+ echo ">\n";
+?>
+ <a class="button" href="?mode=calendar&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">Add</a>
+<?php
+ $events->show($t, $t + 24 * 60 * 60);
+ echo " </td>\n";
+}
+?>
+ </tr>
+</table>
+<?php
+}
+?>
+<?php if($adddate != "") { ?>
+<form method="post" action="?mode=calendar&amp;action=addentry">
+Title: <input name="title" value=""><br/>
+Desription: <textarea name="description"></textarea><br/>
+Date: <input name="txtdate" value="<?php echo date("F j Y", $adddate); ?>"><br/>
+From-Time: <input name="txttimefrom" value="17:00"><br/>
+To-Time: <input name="txttimeto" value="20:00"><br/>
+<br/>
+<button type="submit">Add</button>
+</form>
+<?php } ?>
diff --git a/forum/utils/clientinfo.php b/forum/utils/clientinfo.php
new file mode 100644
index 0000000..cbb7a4d
--- /dev/null
+++ b/forum/utils/clientinfo.php
@@ -0,0 +1,24 @@
+<?php
+/*
+Jonas Mobil:
+"SonyEricssonW660i/R6BC Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
+
+Rasmus Mobil:
+"Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN81-3/11.0.045 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413"
+*/
+
+ //echo $_SERVER['HTTP_USER_AGENT'] . "<br/>";
+$client_is_mobile_device =
+ stripos($_SERVER['HTTP_USER_AGENT'], "MIDP") != FALSE
+ || stripos($_SERVER['HTTP_USER_AGENT'], "Nokia") != FALSE
+ || stripos($_SERVER['HTTP_USER_AGENT'], "Sony") != FALSE
+ || stripos($_SERVER['HTTP_USER_AGENT'], "Ericson") != FALSE
+ || $_GET['forcemobile'];
+
+//$client_is_mobile_device = !$client_is_mobile_device;
+/*
+echo "client_is_mobile_device = ";
+if($client_is_mobile_device) echo "yes";
+ else echo "no";
+*/
+?> \ No newline at end of file
diff --git a/forum/utils/convert.php b/forum/utils/convert.php
new file mode 100644
index 0000000..2ba0afe
--- /dev/null
+++ b/forum/utils/convert.php
@@ -0,0 +1,18 @@
+<?php
+
+function convert_xml($message)
+{
+ $message = htmlspecialchars($message, ENT_QUOTES, "UTF-8");
+ return $message;
+}
+
+function convert($message)
+{
+ $message = stripslashes($message);
+ $message = htmlspecialchars($message, ENT_QUOTES, "UTF-8");
+ //$message = htmlentities($message, ENT_QUOTES, "UTF-8");
+ // $message = utf8_encode($message);
+ return $message;
+}
+
+?> \ No newline at end of file
diff --git a/forum/utils/edit.php b/forum/utils/edit.php
new file mode 100644
index 0000000..0af361c
--- /dev/null
+++ b/forum/utils/edit.php
@@ -0,0 +1,89 @@
+<?php
+include_once($UTIL_DIR . "/error.php");
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/notify.php");
+
+$message = stripslashes($message);
+$title = stripslashes($title);
+
+switch($task) {
+ case "new":
+ if($fid) {
+ include_once("posts.php");
+ $tid = time();
+ $pid = time();
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $post = new Post($pid, $title, $current_user->uid, time(), $message);
+ $posts->add($post);
+ $posts->thread->name = $title;
+ $posts->thread->tid = $tid;
+ $posts->thread->lastpost = time();
+ $posts->write();
+ notify("forum", "New thread: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid);
+ } else {
+ error("No forum id supplied!");
+ }
+ break;
+
+case "reply":
+ if($fid && $tid && $pid) {
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $reply = $posts->getPost($pid);
+ if($reply) {
+ $post = new Post($posts->nextkey(), $title, $current_uid, time(), $message);
+ $reply->add($post);
+ $posts->thread->lastpost = time();
+ $posts->write();
+ notify("forum", "New reply: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid);
+ } else {
+ error("Message " . $pid . " not found!");
+ }
+ } else {
+ error("No message supplied!");
+ }
+ break;
+
+ case "edit":
+ if($fid && $tid && $pid) {
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $edit = $posts->getPost($pid);
+ if($edit) {
+ if($posts->thread->tid == $edit->pid) $posts->thread->name = $title;
+ $edit->title = $title;
+ $edit->message = $message . "\nEdited at: " . date("r", time());
+ $posts->thread->lastpost = time();
+ $posts->write();
+ notify("forum", "Message has been edited: http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid);
+ } else {
+ error("Message " . $pid . " not found!");
+ }
+ } else {
+ error("No message supplied!");
+ }
+ break;
+
+ case "quote":
+ if($fid && $tid && $pid) {
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $quote = $posts->getPost($pid);
+ if($quote) {
+ $post = new Post($posts->nextkey(), $title, $current_uid, time(), $message);
+ $quote->add($post);
+ $posts->thread->lastpost = time();
+ $posts->write();
+ notify("forum", "New reply (quote): http://www.executionroom.com/forum/?fid=". $fid . "&tid=" . $tid);
+ } else {
+ error("Message " . $pid . " not found!");
+ }
+ } else {
+ error("No message supplied!");
+ }
+ break;
+
+}
+echo "<p><a href=\"?fid=" . $fid . "&amp;tid=" . $tid . "\">Return to thread.</a></p>\n";
+
+?> \ No newline at end of file
diff --git a/forum/utils/editor.php b/forum/utils/editor.php
new file mode 100644
index 0000000..681b98d
--- /dev/null
+++ b/forum/utils/editor.php
@@ -0,0 +1,154 @@
+<script language="JavaScript">
+function addcontent(text) {
+ document.post_form.message.value += text;
+ document.post_form.message.focus();
+}
+</script>
+<?php
+include_once($UTIL_DIR . "/error.php");
+include_once($UTIL_DIR . "/convert.php");
+
+$title = "En titel";
+$message = "Something useful";
+
+if($fid && $tid && $pid) {
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ if($pid != -1) $post = $posts->getPost($pid);
+ if($post || $pid == -1) {
+
+ switch($task) {
+ case "new":
+ $title = "Title";
+ $message = "Message";
+ break;
+
+ case "reply":
+ $title = "Re: " . $post->title;
+ $message = "";
+ break;
+
+ case "edit":
+ $title = $post->title;
+ $message = $post->message;
+ break;
+
+ case "quote":
+ $title = "Re: " . $post->title;
+ $user = $users->getUser($post->user);
+ $message = "[quote title=" . $user->name . " wrote on " .date("r", $post->date) ."]" . $post->message . "[/quote]";
+ break;
+
+ default:
+ error("No mode supplied!");
+ break;
+ }
+?>
+<form style="clear: both;" name="post_form" method="post" action="?mode=edit&amp;task=<?php echo $task ?>&amp;fid=<?php echo $fid; ?>&amp;tid=<?php echo $tid; ?>&amp;pid=<?php echo $pid; ?>" onSubmit="javascript: document.post_form.btn_submit.disabled = true;">
+<?php /*
+<a href="javascript: insertTag(document.post_form.message, ';-)', '');"><img border="0" alt=";-)" src="gfx/smileys/wink.gif"/></a>
+<a href="javascript: insertTag(document.post_form.message, ';-D', '');"><img border="0" alt=";-)" src="gfx/smileys/biggrinn.gif"/></a>
+<a href="javascript: insertTag(document.post_form.message, '\\m/', '');"><img border="0" alt=";-)" src="gfx/smileys/headbanger.gif"/></a>
+<a href="javascript: insertTag(document.post_form.message, '>:O', '');"><img border="0" alt=";-)" src="gfx/smileys/growler.gif"/></a>
+<a href="javascript: insertTag(document.post_form.message, '[b]', '[/b]');"><strong>B</strong></a>
+<a href="javascript: insertTag(document.post_form.message, '[i]', '[/i]');"><em>I</em></a>
+<a href="javascript: insertTag(document.post_form.message, '[u]', '[/u]');"><u>U</u></a>
+<a href="javascript: insertTag(document.post_form.message, '[align=left]', '[/align]');">[L&nbsp;&nbsp;]</a>
+<a href="javascript: insertTag(document.post_form.message, '[align=center]', '[/align]');">[&nbsp;C&nbsp;]</a>
+<a href="javascript: insertTag(document.post_form.message, '[align=right]', '[/align]');">[&nbsp;&nbsp;R]</a>
+<a href="javascript: url_insert();">URL</a>
+<a href="javascript: email_insert();">E-Mail</a>
+<a href="javascript: image_insert();">Image</a>
+<a href="javascript: insertTag(document.post_form.message, '[quote]', '[/quote]');">"Q"</a>
+<a href="javascript: insertTag(document.post_form.message, '[code]', '[/code]');">c++</a>
+
+<select name="fnt_size" onchange="javascript:insertTag(document.post_form.message, '[size='+document.post_form.fnt_size.options[this.selectedIndex].value+']', '[/size]'); document.post_form.fnt_size.options[0].selected=true">
+<option value="" selected="selected">Size</option>
+<option value="1">1</option>
+<option value="2">2</option>
+<option value="3">3</option>
+<option value="4">4</option>
+<option value="5">5</option>
+<option value="6">6</option>
+<option value="7">7</option>
+</select>
+
+<select name="fnt_color" onchange="javascript:insertTag(document.post_form.message, '[color='+document.post_form.fnt_color.options[this.selectedIndex].value+']', '[/color]'); document.post_form.fnt_color.options[0].selected=true">
+<option value="">Color</option>
+<option value="skyblue" style="color: skyblue;">Sky Blue</option>
+<option value="royalblue" style="color: royalblue;">Royal Blue</option>
+<option value="blue" style="color: blue;">Blue</option>
+<option value="darkblue" style="color: darkblue;">Dark Blue</option>
+<option value="orange" style="color: orange;">Orange</option>
+<option value="orangered" style="color: orangered;">Orange Red</option>
+<option value="crimson" style="color: crimson;">Crimson</option>
+<option value="red" style="color: red;">Red</option>
+<option value="firebrick" style="color: firebrick;">Firebrick</option>
+<option value="darkred" style="color: darkred;">Dark Red</option>
+<option value="green" style="color: green;">Green</option>
+<option value="limegreen" style="color: limegreen;">Lime Green</option>
+<option value="seagreen" style="color: seagreen;">Sea Green</option>
+<option value="deeppink" style="color: deeppink;">Deep Pink</option>
+<option value="tomato" style="color: tomato;">Tomato</option>
+<option value="coral" style="color: coral;">Coral</option>
+<option value="purple" style="color: purple;">Purple</option>
+<option value="indigo" style="color: indigo;">Indigo</option>
+<option value="burlywood" style="color: burlywood;">Burly Wood</option>
+<option value="sandybrown" style="color: sandybrown;">Sandy Brown</option>
+<option value="sienna" style="color: sienna;">Sienna</option>
+<option value="chocolate" style="color: chocolate;">Chocolate</option>
+<option value="teal" style="color: teal;">Teal</option>
+<option value="silver" style="color: silver;">Silver</option>
+</select>
+
+<select name="fnt_face" onchange="javascript:insertTag(document.post_form.message, '[font='+document.post_form.fnt_face.options[this.selectedIndex].value+']', '[/font]'); document.post_form.fnt_face.options[0].selected=true">
+<option value="">Font</option>
+<option value="Arial" style="font-family: Arial;">Arial</option>
+<option value="Times" style="font-family: Times;">Times</option>
+<option value="Courier" style="font-family: Courier;">Courier</option>
+<option value="Century" style="font-family: Century;">Century</option>
+</select> */ ?>
+ <p>
+ Title:
+ <input name="title" style="width: 300px;" value="<?php echo convert_xml($title);?>"/>
+ </p>
+ <p>
+<?php
+include_once($UTIL_DIR . "/smileys.php");
+global $smileys;
+foreach($smileys as $smiley) {
+ $smile = $smiley[0][0];
+ if($smile == "\\m/") $smile = "\\\\m/";
+ echo " <a href=\"javascript:addcontent('" . $smile . "');\"><img style=\"border: 0px\" alt=\"\" src=\"gfx/smileys/" . $smiley[1] . "\"/></a>";
+}
+?>
+ </p>
+ <p>
+ <textarea rows="20" cols="65" name="message" onkeyup="storeCaret(this);" onclick="storeCaret(this);" onselect="storeCaret(this);"><?php echo convert_xml($message); ?></textarea>
+ </p>
+ <p>
+ <strong>To make a link, simply type the URL, and the system will
+ automagically transform it into an anchor (remember the
+ <em>http://</em> part)</strong>.<br/>
+ Example: http://www.executionroom.com<br/>
+ </p>
+ <p>
+ <strong>To insert an image, simply type the URL to that image, it will
+ automagically be transformed into an image, with a link to the
+ original image (again, remember the <em>http://</em> part).</strong><br/>
+ Example: http://www.executionroom.com/gfx/logos/die_logo_bloody.png
+ </p>
+ <p>
+ <button type="submit">Post</button>
+ </p>
+</form>
+<?php
+ if($pid != -1) $posts->show();
+ } else {
+ error("Message " . $pid . " not found!");
+ }
+} else {
+ error("No message supplied!");
+}
+
+?>
diff --git a/forum/utils/editor_form.php b/forum/utils/editor_form.php
new file mode 100644
index 0000000..6903ec9
--- /dev/null
+++ b/forum/utils/editor_form.php
@@ -0,0 +1,127 @@
+
+<form action="/egroupware/fudforum/1037711670/index.php?t=post" method="post" name="post_form" enctype="multipart/form-data" onSubmit="javascript: document.post_form.btn_submit.disabled = true;">
+<table border="0" cellspacing="1" cellpadding="2" class="ContentTable">
+<tr><th colspan=2><a name="ptop"> </a>Post Form</th></tr>
+<tr class="RowStyleB"><td nowrap class="GenText">Logged in user:</td><td class="GenText" width="100%">bent</td></tr><tr class="RowStyleB"><td class="GenText">Forum:</td><td class="GenText">Andet band relateret</td></tr>
+<tr class="RowStyleB"><td class="GenText">Title:</td><td class="GenText"><input type="text" maxLength=100 name="msg_subject" value="" size=50 tabindex="2"> </td></tr>
+<tr class="RowStyleB"><td class="GenText">Poll:</td><td class="GenText"><a class="GenLink" href="javascript://" onClick="javascript: window_open('/egroupware/fudforum/1037711670/index.php?t=poll&amp;&amp;frm_id=7', 'poll_creator', 400, 300);">[CREATE POLL]</a></td></tr><tr class="RowStyleA"><td valign=top class="GenText">Post Icon:</td><td>
+
+<table border=0 cellspacing=0 cellpadding=2>
+<tr><td class="GenText" colspan=9><input type="radio" name="msg_icon" value="" checked>No Icon</td></tr>
+<tr><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon1.gif"><img src="images/message_icons/icon1.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon10.gif"><img src="images/message_icons/icon10.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon11.gif"><img src="images/message_icons/icon11.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon12.gif"><img src="images/message_icons/icon12.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon13.gif"><img src="images/message_icons/icon13.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon14.gif"><img src="images/message_icons/icon14.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon2.gif"><img src="images/message_icons/icon2.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon3.gif"><img src="images/message_icons/icon3.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon4.gif"><img src="images/message_icons/icon4.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon5.gif"><img src="images/message_icons/icon5.gif" alt="" /></td></tr><tr><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon6.gif"><img src="images/message_icons/icon6.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon7.gif"><img src="images/message_icons/icon7.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon8.gif"><img src="images/message_icons/icon8.gif" alt="" /></td><td nowrap valign="middle"><input type="radio" name="msg_icon" value="icon9.gif"><img src="images/message_icons/icon9.gif" alt="" /></td></tr>
+</table>
+</td></tr><tr class="RowStyleA"><td nowrap valign=top class="GenText">Smiley Shortcuts:
+ <br /><font size="-1">[<a href="javascript://" onClick="javascript: window_open('/egroupware/fudforum/1037711670/index.php?t=smladd', 'sml_list', 220, 200);">list all smilies</a>]</font>
+</td>
+<td valign=top><table border=0 cellspacing=5 cellpadding=0><tr valign="bottom"><td><a href="javascript: insertTag(document.post_form.msg_body, '', ' :blush: ');"><img title="Embarassed" alt="Embarassed" src="images/smiley_icons/icon_redface.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :P ');"><img title="Razz" alt="Razz" src="images/smiley_icons/icon_razz.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :x ');"><img title="Mad" alt="Mad" src="images/smiley_icons/icon_mad.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :lol: ');"><img title="Laughing" alt="Laughing" src="images/smiley_icons/icon_lol.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' 8) ');"><img title="Cool" alt="Cool" src="images/smiley_icons/icon_cool.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :? ');"><img title="Confused" alt="Confused" src="images/smiley_icons/icon_confused.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' 8O ');"><img title="Shocked" alt="Shocked" src="images/smiley_icons/icon_eek.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :o ');"><img title="Surprised" alt="Surprised" src="images/smiley_icons/icon_surprised.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :( ');"><img title="Sad" alt="Sad" src="images/smiley_icons/icon_sad.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :) ');"><img title="Smile" alt="Smile" src="images/smiley_icons/icon_smile.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :D ');"><img title="Very Happy" alt="Very Happy" src="images/smiley_icons/icon_biggrin.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :cry: ');"><img title="Crying or Very Sad" alt="Crying or Very Sad" src="images/smiley_icons/icon_cry.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :evil: ');"><img title="Evil or Very Mad" alt="Evil or Very Mad" src="images/smiley_icons/icon_evil.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :twisted: ');"><img title="Twisted Evil" alt="Twisted Evil" src="images/smiley_icons/icon_twisted.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :roll: ');"><img title="Rolling Eyes" alt="Rolling Eyes" src="images/smiley_icons/icon_rolleyes.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' ;) ');"><img title="Wink" alt="Wink" src="images/smiley_icons/icon_wink.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :!: ');"><img title="Exclamation" alt="Exclamation" src="images/smiley_icons/icon_exclaim.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :?: ');"><img title="Question" alt="Question" src="images/smiley_icons/icon_question.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :idea: ');"><img title="Idea" alt="Idea" src="images/smiley_icons/icon_idea.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :arrow: ');"><img title="Arrow" alt="Arrow" src="images/smiley_icons/icon_arrow.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :| ');"><img title="Neutral" alt="Neutral" src="images/smiley_icons/icon_neutral.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :] ');"><img title="Grin" alt="Grin" src="images/smiley_icons/icon_mrgreen.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' x( ');"><img title="Dead" alt="Dead" src="images/smiley_icons/icon_dead.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :frown: ');"><img title="Frown" alt="Frown" src="images/smiley_icons/icon_frown.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :nod: ');"><img title="Nod" alt="Nod" src="images/smiley_icons/icon_nod.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :proud: ');"><img title="Proud" alt="Proud" src="images/smiley_icons/icon_proud.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :smug: ');"><img title="Smug" alt="Smug" src="images/smiley_icons/icon_smug.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :thumbup: ');"><img title="Thumbs Up" alt="Thumbs Up" src="images/smiley_icons/icon_thumbsup.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :thumbdown: ');"><img title="Thumbs Down" alt="Thumbs Down" src="images/smiley_icons/icon_thumbdown.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :uhoh: ');"><img title="Uh Oh" alt="Uh Oh" src="images/smiley_icons/icon_uhoh.gif" /></a>&nbsp;<a href="javascript: insertTag(document.post_form.msg_body, '', ' :yawn: ');"><img title="Bored" alt="Bored" src="images/smiley_icons/icon_yawn.gif" /></a>&nbsp;</td></tr></table></td></tr><tr class="RowStyleA"><td nowrap class="GenText">Formatting Tools:</td><td>
+<table border=0 cellspacing=0 cellpadding=0>
+<tr><td>
+<table border=0 cellspacing=1 cellpadding=2 class="FormattingToolsBG">
+<tr>
+
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[B]', '[/B]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_bold.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[I]', '[/I]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_italic.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[U]', '[/U]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_underline.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[ALIGN=left]', '[/ALIGN]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_aleft.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[ALIGN=center]', '[/ALIGN]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_acenter.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[ALIGN=right]', '[/ALIGN]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_aright.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: url_insert();"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_url.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: email_insert();"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_email.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: image_insert();"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_image.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: window_open('/egroupware/fudforum/1037711670/index.php?t=mklist&amp;&amp;tp=OL:1', 'listmaker', 350, 350);"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_numlist.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: window_open('/egroupware/fudforum/1037711670/index.php?t=mklist&amp;&amp;tp=UL:square', 'listmaker', 350, 350);"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_bulletlist.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[QUOTE]', '[/QUOTE]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_quote.gif" /></a></td>
+<td class="FormattingToolsCLR"><a href="javascript: insertTag(document.post_form.msg_body, '[CODE]', '[/CODE]');"><img alt="" src="/egroupware/fudforum/1037711670/theme/default/images/b_code.gif" /></a></td>
+</tr>
+</table>
+</td>
+<td>&nbsp;&nbsp;
+
+<select name="fnt_size" onChange="javascript:insertTag(document.post_form.msg_body, '[SIZE='+document.post_form.fnt_size.options[this.selectedIndex].value+']', '[/SIZE]'); document.post_form.fnt_size.options[0].selected=true">
+<option value="" selected>Size</option>
+<option value="1">1</option>
+<option value="2">2</option>
+<option value="3">3</option>
+<option value="4">4</option>
+<option value="5">5</option>
+<option value="6">6</option>
+<option value="7">7</option>
+
+</select>
+<select name="fnt_color" onChange="javascript:insertTag(document.post_form.msg_body, '[COLOR='+document.post_form.fnt_color.options[this.selectedIndex].value+']', '[/COLOR]'); document.post_form.fnt_color.options[0].selected=true">
+<option value="">Color</option>
+<option value="skyblue" style="color:skyblue">Sky Blue</option>
+<option value="royalblue" style="color:royalblue">Royal Blue</option>
+<option value="blue" style="color:blue">Blue</option>
+<option value="darkblue" style="color:darkblue">Dark Blue</option>
+<option value="orange" style="color:orange">Orange</option>
+<option value="orangered" style="color:orangered">Orange Red</option>
+<option value="crimson" style="color:crimson">Crimson</option>
+
+<option value="red" style="color:red">Red</option>
+<option value="firebrick" style="color:firebrick">Firebrick</option>
+<option value="darkred" style="color:darkred">Dark Red</option>
+<option value="green" style="color:green">Green</option>
+<option value="limegreen" style="color:limegreen">Lime Green</option>
+<option value="seagreen" style="color:seagreen">Sea Green</option>
+<option value="deeppink" style="color:deeppink">Deep Pink</option>
+<option value="tomato" style="color:tomato">Tomato</option>
+<option value="coral" style="color:coral">Coral</option>
+
+<option value="purple" style="color:purple">Purple</option>
+<option value="indigo" style="color:indigo">Indigo</option>
+<option value="burlywood" style="color:burlywood">Burly Wood</option>
+<option value="sandybrown" style="color:sandybrown">Sandy Brown</option>
+<option value="sienna" style="color:sienna">Sienna</option>
+<option value="chocolate" style="color:chocolate">Chocolate</option>
+<option value="teal" style="color:teal">Teal</option>
+<option value="silver" style="color:silver">Silver</option>
+</select>
+
+<select name="fnt_face" onChange="javascript:insertTag(document.post_form.msg_body, '[FONT='+document.post_form.fnt_face.options[this.selectedIndex].value+']', '[/FONT]'); document.post_form.fnt_face.options[0].selected=true">
+<option value="">Font</option>
+<option value="Arial" style="font-family:Arial">Arial</option>
+<option value="Times" style="font-family:Times">Times</option>
+<option value="Courier" style="font-family:Courier">Courier</option>
+<option value="Century" style="font-family:Century">Century</option>
+</select>
+</td></tr></table></td></tr>
+<tr class="RowStyleA"><td nowrap valign=top class="GenText">Body:<br /><br /><font class="SmallText"><b>Forum Options</b><br />
+<b>HTML</b> code is <b>OFF</b><br />
+
+<a href="/egroupware/fudforum/1037711670/index.php?section=readingposting&amp;t=help_index&amp;#style" target="_blank"><b>FUDcode</b> is <b>ON</b></a><br />
+<b>Images</b> are <b>ON</b><br />
+<a href="/egroupware/fudforum/1037711670/index.php?section=readingposting&amp;t=help_index&amp;#sml" target="_blank"><b>Smilies</b> are <b>ON</b></a><br><b>Editing Time Limit</b>: <b>Unlimited</b></font><br /></td><td><textarea rows="20" cols="65" tabindex="3" wrap="virtual" id="txtb" name="msg_body" onKeyUp="storeCaret(this);" onClick="storeCaret(this);" onSelect="storeCaret(this);"></textarea></td></tr>
+
+<tr class="RowStyleB"><td nowrap valign=top class="GenText">File Attachments:</td><td>
+
+
+<font class="SmallText"><b>Allowed File Extensions:</b> (unrestricted)<br /><b>Maximum File Size:</b> 10240Kb<br /><b>Maximum Files per Message:</b> 1
+
+</font><p>
+<input type="file" name="attach_control"> <input type="submit" class="button" name="attach_control_add" value="Upload File">
+
+</td></tr><tr class="RowStyleB" valign="top">
+<td class="GenText">Options:</td>
+<td>
+<table border=0 cellspacing=0 cellpadding=1>
+<tr><td><input type="checkbox" name="msg_poster_notif" value="Y" checked></td><td class="GenText"><b>Post Notification</b></td></tr>
+<tr><td>&nbsp;</td><td><font class="SmallText">Notify me when someone replies to this message.</font></td></tr>
+<tr><td><input type="checkbox" name="msg_show_sig" value="Y" checked></td><td class="GenText"><b>Include Signature</b></td></tr>
+<tr><td>&nbsp;</td><td><font class="SmallText">Include my profile signature.</font></td></tr>
+<tr><td><input type="checkbox" name="msg_smiley_disabled" value="Y"></td><td class="GenText"><b>Disable smilies in this message</b></td></tr></table>
+</td></tr>
+<tr class="RowStyleA"><td class="GenText" align="right" colspan=2>
+
+<input type="submit" class="button" value="Preview Message" tabindex="4" name="preview">&nbsp;<input type="submit" class="button" tabindex="5" name="btn_submit" value="Create Topic" onClick="javascript: document.post_form.submitted.value=1;"></td></tr>
+</table>
+<input type="hidden" name="submitted" value="">
+<input type="hidden" name="reply_to" value="0">
+<input type="hidden" name="th_id" value="">
+<input type="hidden" name="frm_id" value="7">
+<input type="hidden" name="start" value="">
+<input type="hidden" name="msg_id" value="0">
+<input type="hidden" name="pl_id" value="0">
+<input type="hidden" name="old_subject" value="">
+<input type="hidden" name="prev_loaded" value="1">
+</form>
diff --git a/forum/utils/error.php b/forum/utils/error.php
new file mode 100644
index 0000000..78128d2
--- /dev/null
+++ b/forum/utils/error.php
@@ -0,0 +1,6 @@
+<?php
+function error($msg) {
+ echo "<div class=\"error\">Error: " . $msg . "</div>\n";
+ // exit($msg);
+}
+?> \ No newline at end of file
diff --git a/forum/utils/events.php b/forum/utils/events.php
new file mode 100644
index 0000000..737c03c
--- /dev/null
+++ b/forum/utils/events.php
@@ -0,0 +1,141 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+
+class Event {
+ public $eid;
+ public $title;
+ public $starttime;
+ public $duration;
+ public $description;
+ public $user;
+
+ public function show()
+ {
+ global $users, $date, $client_is_mobile_device;
+
+ $user = $users->getUser($this->user);
+
+ echo " <div class=\"event\">\n";
+ echo " <div class=\"title\">". $this->title . "\n";
+ // echo " <a class=\"button\" href=\"\">Edit</a>\n";
+ echo " </div>\n";
+ echo " <div class=\"time\">" . date("G:i", $this->starttime) . " - " .
+ date("G:i", $this->starttime + $this->duration) . "</div>\n";
+ if(!$client_is_mobile_device) {
+ echo " <div class=\"description\">". $this->description . "</div>\n";
+ } else {
+ echo " <div class=\"mobiledescription\">". $this->description . "</div>\n";
+ }
+ echo " <div class=\"user\">By: ".$user->name . "</div>\n";
+ // echo " <a href=\"?mode=calendar&amp;date=" . $date . "&amp;eid=" . $this->eid . "&amp;action=edit\">Edit</a>";
+ echo " </div>\n";
+ }
+
+ public function Event($eid, $title, $starttime, $duration, $description, $user)
+ {
+ $this->eid = $eid;
+ $this->title = $title;
+ $this->starttime = $starttime;
+ $this->duration = $duration;
+ $this->description = $description;
+ $this->user = $user;
+ }
+}
+
+class Events {
+
+ private $file;
+ public $events = array();
+
+ public function add($event) {
+ $key = $event->eid;
+ $this->events[$key] = $event;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<events>\n");
+ foreach($this->events as $event) {
+ fwrite($fp, " <event eid=\"" .
+ htmlspecialchars($event->eid, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " title=\"" .
+ htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " starttime=\"" .
+ htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " duration=\"" .
+ htmlspecialchars($event->duration, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " user=\"" .
+ htmlspecialchars($event->user, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </event>\n");
+ }
+ fwrite($fp, "</events>\n");
+
+ fclose($fp);
+ }
+
+ /*
+ public function deleteForumUser($id)
+ {
+ if($this->members[$id]) {
+ unset($this->members[$id]);
+ // $this->write();
+ } else {
+ echo "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
+ return false;
+ }
+ return true;
+ }
+ */
+
+ public function show($starttime, $endtime)
+ {
+ foreach($this->events as $event) {
+ if($event->starttime > $starttime && $event->starttime < $endtime)
+ $event->show();
+ }
+ }
+
+ public function getEvent($eid)
+ {
+ $event = $this->events[$eid];
+ return $event;
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $events = $dom->getElementsByTagName('event');
+
+ foreach ($events as $e) {
+ $event = new Event($e->getAttribute('eid'),
+ $e->getAttribute('title'),
+ $e->getAttribute('starttime'),
+ $e->getAttribute('duration'),
+ $e->getAttribute('description'),
+ $e->getAttribute('user'));
+
+ $this->add($event);
+ }
+
+ }
+
+ public function Events($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+?>
diff --git a/forum/utils/filehandler.php b/forum/utils/filehandler.php
new file mode 100644
index 0000000..231ddd6
--- /dev/null
+++ b/forum/utils/filehandler.php
@@ -0,0 +1,33 @@
+<?php
+include_once($UTIL_DIR . "/files.php");
+
+$files = new Files($DATA_DIR . "/files.xml");
+
+if($task == "upload") {
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ $name = $filename;
+ if(!$filename) $name = $_FILES['userfile']['name'];
+ $files->newFile($_FILES['userfile']['tmp_name'], $name);
+ }
+}
+
+if($task == "delete" && $fid) {
+ $files->deleteFile($fid);
+}
+
+$files->show();
+
+
+?>
+<form enctype="multipart/form-data" action="?mode=files&amp;task=upload" method="post">
+ <p>
+ File: <input name="userfile" type="file">
+ </p>
+ <p>
+ Use alternative filename (leave empty to use original filename):
+ <input name="filename" value="<?php echo $description ?>"/>
+ </p>
+ <p>
+ <button type="submit">Add file</button>
+ </p>
+</form>
diff --git a/forum/utils/files.php b/forum/utils/files.php
new file mode 100644
index 0000000..d714ba2
--- /dev/null
+++ b/forum/utils/files.php
@@ -0,0 +1,134 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/mimetypes.php");
+
+class File {
+ public $fid;
+ public $name;
+ public $mimetype;
+
+ public function link()
+ {
+ global $PERMSTORE;
+ return "file.php?fid=" . $this->fid;
+ }
+
+ public function show()
+ {
+ global $PERMSTORE;
+ echo "<div class=\"file\">\n";
+ echo " <a class=\"delete\" href=\"?mode=files&amp;task=delete&amp;fid=" . $this->fid . "\">Delete</a>\n";
+ echo " <div class=\"filename\">Filename: <a href=\"" . $this->link() . "\">" . $this->name . "</a>(" . $this->mimetype. ")</div>\n";
+ echo " <div class=\"filesize\">Size: " . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb</div>\n";
+ echo "</div>\n";
+ }
+
+ public function File($fid, $name, $mimetype)
+ {
+ $this->fid = $fid;
+ $this->name = $name;
+ $this->mimetype = $mimetype;
+ }
+}
+
+class Files {
+
+ private $file;
+ public $files = array();
+
+ public function add($file) {
+ $key = $file->fid;
+ $this->files[$key] = $file;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<files>\n");
+ foreach($this->files as $file) {
+ fwrite($fp, " <file fid=\"" .
+ htmlspecialchars($file->fid, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " name=\"" .
+ htmlspecialchars($file->name, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " mimetype=\"" .
+ htmlspecialchars($file->mimetype, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </file>\n");
+ }
+ fwrite($fp, "</files>\n");
+
+ fclose($fp);
+ }
+
+ public function show()
+ {
+ foreach($this->files as $file) {
+ $file->show();
+ }
+ }
+
+ public function getFile($fid)
+ {
+ $file = $this->files[$fid];
+ return $file;
+ }
+
+ public function newFile($tempfile, $name)
+ {
+ global $PERMSTORE;
+ $fid = time();
+
+ // move tempfile to permstore and put it in db.
+ move_uploaded_file($tempfile, $PERMSTORE . "/" . $fid);
+
+ $f = new File($fid, $name, getMimeType($name)->name);
+ $this->add($f);
+
+ // We cannot wait to write the db, otherwise we'll get inconsistency!
+ $this->write();
+
+ // Return new file id.
+ return $fid;
+ }
+
+ public function deleteFile($fid)
+ {
+ global $PERMSTORE;
+ unlink($PERMSTORE . "/" . $fid);
+ unset($this->files[$fid]);
+
+ // We cannot wait to write the db, otherwise we'll get inconsitency!
+ $this->write();
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $files = $dom->getElementsByTagName('file');
+
+ foreach ($files as $f) {
+ $file = new File($f->getAttribute('fid'),
+ $f->getAttribute('name'),
+ $f->getAttribute('mimetype'));
+
+ $this->add($file);
+ }
+
+ }
+
+ public function Files($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/forum/utils/forums.php b/forum/utils/forums.php
new file mode 100644
index 0000000..9305623
--- /dev/null
+++ b/forum/utils/forums.php
@@ -0,0 +1,133 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/threads.php");
+
+
+class Forum {
+ public $fid;
+ public $readlist;
+ public $writelist;
+ public $name;
+ private $newStuff;
+
+ public function setNewStuff($newStuff)
+ {
+ $this->newStuff = $newStuff;
+ }
+
+ public function show()
+ {
+ echo "<div class=\"forum\">";
+ if($this->newStuff) echo "<div class=\"new\"></div>";
+ else echo "<div class=\"nonew\"></div>";
+ echo "<a href=\"?fid=" . $this->fid . "\">" . $this->name . "</a>";
+ echo "</div>";
+ }
+
+ public function Forum($fid, $readlist, $writelist, $name)
+ {
+ $this->fid = $fid;
+ $this->readlist = $readlist;
+ $this->writelist = $writelist;
+ $this->name = $name;
+ }
+}
+
+class Forums {
+
+ private $file;
+ public $forums = array();
+
+ public function add($forum) {
+ $key = $forum->fid;
+ $this->forums[$key] = $forum;
+ }
+
+ public function write()
+ {
+ /*
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<members>\n");
+ foreach($this->members as $member) {
+ fwrite($fp, " <member id=\"" .
+ htmlspecialchars($member->id, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " name=\"" .
+ htmlspecialchars($member->name, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($member->description, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " image=\"" .
+ htmlspecialchars($member->image, ENT_QUOTES, "UTF-8") . "\">\n");
+
+
+ fwrite($fp, " </member>\n");
+ }
+ fwrite($fp, "</members>\n");
+
+ fclose($fp);
+ */
+ }
+
+ /*
+ public function deleteForumUser($id)
+ {
+ if($this->members[$id]) {
+ unset($this->members[$id]);
+ // $this->write();
+ } else {
+ echo "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
+ return false;
+ }
+ return true;
+ }
+ */
+
+ public function getForum($fid)
+ {
+ $forum = $this->forums[$fid];
+ return $forum;
+ }
+
+ public function show()
+ {
+ foreach($this->forums as $forum) {
+ $forum->show();
+ }
+ }
+
+ private function read()
+ {
+ global $FORUMS_DIR;
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $forums = $dom->getElementsByTagName('forum');
+
+ foreach($forums as $f) {
+ $forum = new Forum($f->getAttribute('fid'),
+ $f->getAttribute('readlist'),
+ $f->getAttribute('writelist'),
+ $f->getAttribute('name'));
+
+ $this->add($forum);
+
+ $threads = new Threads($FORUMS_DIR . "/" . $f->getAttribute('fid'));
+ $forum->setNewStuff($threads->newStuff());
+ }
+ }
+
+ public function Forums($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/forum/utils/log.php b/forum/utils/log.php
new file mode 100644
index 0000000..e04c3bf
--- /dev/null
+++ b/forum/utils/log.php
@@ -0,0 +1,10 @@
+<?php
+
+function _log($user, $action) {
+ global $LOG_FILE;
+ $fp = fopen($LOG_FILE, "a");
+ fprintf($fp, "%s - %s - %s\n", date("r"), $user, $action);
+ fclose($fp);
+}
+
+?> \ No newline at end of file
diff --git a/forum/utils/login.php b/forum/utils/login.php
new file mode 100644
index 0000000..50d0da2
--- /dev/null
+++ b/forum/utils/login.php
@@ -0,0 +1,105 @@
+<?php
+
+include_once($UTIL_DIR . "/users.php");
+include_once($UTIL_DIR . "/log.php");
+
+$users = new Users($DATA_DIR . "/users.xml");
+
+function checklogin()
+{
+ // The cookies...
+ global $HTTP_COOKIE_VARS;
+
+ // User vars
+ global $users;
+ global $current_user;
+ global $current_username;
+ global $current_password;
+
+ // What are we doin'?
+ global $action;
+
+ // Config vars
+ global $DATA_DIR;
+ global $ADMIN_TIMEOUT;
+
+ if($action == "login") {
+ /**
+ * Login
+ */
+
+ $current_uid = $users->getUserID($current_username);
+ $u = $users->getUser($current_uid);
+
+ if($u && $u->checkPassword($current_password) ) {
+ $current_user = $u;
+ setcookie("current_uid", $current_uid, time()+$ADMIN_TIMEOUT);
+ setcookie("current_password", $current_password, time()+$ADMIN_TIMEOUT);
+
+ _log($u->username, "logged in");
+
+ if($current_user->notified > 0) {
+ $current_user->notified = 0;
+ $users->write();
+ }
+
+ } else {
+ // Remove cookies
+ setcookie("current_uid", "", time()-1);
+ setcookie("current_password", "", time()-1);
+ }
+
+ } else if($action == "logout") {
+
+ /**
+ * Logout
+ */
+ $u = $users->getUser($HTTP_COOKIE_VARS["current_uid"]);
+
+ // Remove cookies
+ setcookie("current_uid", "", time()-1);
+ setcookie("current_password", "", time()-1);
+
+ $current_uid = "";
+ $current_password = "";
+ $current_user = false;
+
+ _log($u->username, "logged out");
+
+ } else {
+
+ /**
+ * Usage
+ */
+
+ if($HTTP_COOKIE_VARS["current_uid"] == "") return;
+
+ $u = $users->getUser($HTTP_COOKIE_VARS["current_uid"]);
+ if($u->checkPassword($HTTP_COOKIE_VARS["current_password"]) ) {
+ setcookie("current_uid", $HTTP_COOKIE_VARS["current_uid"], time()+$ADMIN_TIMEOUT);
+ setcookie("current_password", $HTTP_COOKIE_VARS["current_password"], time()+$ADMIN_TIMEOUT);
+
+ $current_user = $u;
+
+ if($current_user->notified > 0) {
+ $current_user->notified = 0;
+ $users->write();
+ }
+
+ _log($u->username, "seen");
+
+ } else {
+ // Remove cookies
+ setcookie("current_uid", "", time()-1);
+ setcookie("current_password", "", time()-1);
+
+ $current_uid = "";
+ $current_password = "";
+ $current_user = false;
+
+ }
+ }
+
+}
+
+?>
diff --git a/forum/utils/mimetypes.php b/forum/utils/mimetypes.php
new file mode 100644
index 0000000..f9ecfea
--- /dev/null
+++ b/forum/utils/mimetypes.php
@@ -0,0 +1,50 @@
+<?php
+
+class MimeType {
+ public $name;
+ public $exts = array();
+ public $show;
+
+ public function MimeType($name, $exts, $show)
+ {
+ $this->name = $name;
+ $this->exts = $exts;
+ $this->show = $show;
+ }
+};
+
+
+$DEFAULT_MIME_TYPE = new MimeType("application/octet-stream", array(), false);
+
+// Know mimetypes
+$MIME_TYPES = array(new MimeType("image/jpeg",array("jpg","jpeg","jpe"),true),
+ new MimeType("image/gif",array("gif"),true),
+ new MimeType("image/png",array("png"),true),
+ new MimeType("audio/mpeg",array("mp3","mpga","mpega","mp2","m4a"),false),
+ new MimeType("application/ogg",array("ogg"),false),
+ new MimeType("application/pdf",array("pdf"),false),
+ new MimeType("application/msword",array("doc"),false),
+ new MimeType("text/plain", array("asc","txt","text","diff","pot"), true)
+ );
+
+
+// Get file extension.
+function extension($file) {
+ $fileExp = explode('.', $file); // make array off the periods
+ $filetype = $fileExp[count($fileExp) -1]; // file extension will be last index in array, -1 for 0-based indexes
+ return strtolower($filetype);
+}
+
+function getMimeType($file)
+{
+ global $DEFAULT_MIME_TYPE;
+ global $MIME_TYPES;
+
+ $ext = extension($file);
+ foreach($MIME_TYPES as $m) {
+ foreach($m->exts as $e) if($e == $ext) return $m;
+ }
+ return $DEFAULT_MIME_TYPE;
+}
+
+?> \ No newline at end of file
diff --git a/forum/utils/notify.php b/forum/utils/notify.php
new file mode 100644
index 0000000..f52d167
--- /dev/null
+++ b/forum/utils/notify.php
@@ -0,0 +1,70 @@
+<?php
+
+include_once($UTIL_DIR . "/error.php");
+include_once($UTIL_DIR . "/log.php");
+
+/**
+ * CONFIG
+ */
+$subject_prefix = "DIE CMS notifier";
+$sender = "DIE <info@executionroom.com>";
+$replyto = $sender;
+$footer = "
+
+Stay Brutal!
+// DIE
+http://www.executionroom.com
+info@executionroom.com
+";
+
+function send($email, $subject, $message)
+{
+ global $subject_prefix;
+ global $sender;
+ global $replyto;
+ global $footer;
+
+ $message .= $footer;
+ // $message .= "";
+ $headers = "From: " . $sender . "\r\n";
+ $headers .= "Reply-To: " . $replyto . "\r\n";
+ $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
+ $headers .= "X-Mailer: PHP/" . phpversion();
+ $subject = "[".$subject_prefix."] " . utf8_decode($subject);
+
+ $ret = mail($email, $subject, utf8_decode($message), $headers);
+ if(!$ret) echo error("The mail to " . $email . "could not be sent.");
+}
+
+function notify($module = "", $event = "")
+{
+ global $users;
+ global $current_user;
+ $users_changed = false;
+
+ foreach($users->users as $user) {
+ if($user->uid == 0) continue; // Don't notify the admin
+ if($user->enabled == false) continue; // Do not mail disabled accounts.
+
+ if($module == "calendar" || // Always mail calendar updates.
+ (
+ $module == "forum" &&
+ $user != $current_user && // Don't notify current user.
+ $user->notified < (time() - (60 * 60 * 24 * 7)) // Don't notify if already notified.
+ )
+ ) {
+ send($user->email, $module . " changed",
+ "There has been a change in the " . $module . " module by " .
+ $current_user->name . ":\n" . $event);
+
+ _log($user->username, "notified (" . $module . ")");
+
+ if($module != "calendar") {
+ $user->notified = time();
+ $users_changed = true;
+ }
+ }
+ }
+ if($users_changed == true) $users->write();
+}
+?>
diff --git a/forum/utils/parser.php b/forum/utils/parser.php
new file mode 100644
index 0000000..3c33a9b
--- /dev/null
+++ b/forum/utils/parser.php
@@ -0,0 +1,126 @@
+<?php
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/smileys.php");
+
+function parse($input, $indent = "")
+{
+ global $testing;
+ // Remove all tags from input (convert to xml)
+ $output = convert_xml($input);
+
+ // Replace newlines with '\n' and indent code.
+ $nls = array("\n\r", "\n\c", "\n");
+ $nls = str_replace($nls, "\n" . $indent, $indent . $output);
+ $output = $nls;
+
+ // Put in the smileys
+ global $smileys;
+ foreach($smileys as $smiley) {
+ $smile = $smiley[0];
+ $smile = str_replace($smile, "<img alt=\"\" src=\"gfx/smileys/" . $smiley[1] . "\"></img>", $output);
+ $output = $smile;
+ }
+
+ // Replace URLs with <a></a> tags
+ $urls = "";
+ while(($start = strpos($output, "http://"))) {
+ $pre = substr($output, 0, $start);
+ $url = substr($output, $start);
+ $end1 = strpos($url, " ");
+ $end2 = strpos($url, "\n");
+ if($end1 == 0) {
+ if($end2 == 0) $end = strlen($url);
+ else $end = $end2;
+ } else {
+ if($end2 == 0) $end = $end1;
+ else if($end1 < $end2) $end = $end1;
+ else $end = $end2;
+ }
+ $url = substr($url, 0, $end);
+ $post = substr($output, $start + $end);
+ if(strstr($url, ".jpg") || strstr($url, ".gif") || strstr($url, ".png")) {
+ $urls .= $pre . "<a href=\"" . $url . "\"><img alt=\"" . $url . "\" style=\"border: solid red 1px;\" src=\"imagecache.php?filename=" . urlencode($url) . "\"/></a>";
+ } else {
+ $urls .= $pre . "<a href=\"" . $url . "\">" . $url . "</a>";
+ }
+ $output = $post;
+ }
+ $urls .= $output;
+ $output = $urls;
+
+ // Replace [quote title=...]...[/quote]
+ $urls = "";
+ while(($start = strpos($output, "[quote"))) {
+ $pre = substr($output, 0, $start);
+ $url = substr($output, $start);
+ $end = strpos($url, "[/quote]") + strlen("[/quote]");
+ $url = substr($url, 0, $end - strlen("[/quote]"));
+ $post = substr($output, $start + $end + strlen("[/quote]") );
+
+ $header = substr($url, 0, strpos($url, "]") + 1);
+ $body = substr($url, strpos($url, "]") + 1);
+
+ $header = str_replace(array("title"), "", $header);
+ $header = str_replace(array("="), "<div class=\"title\">", $header);
+ $header = str_replace(array("[quote"), "<div class=\"quote\">", $header);
+ $header = str_replace(array("]"), " </div>", $header);
+
+ $urls .= $pre . $header . $body . "</div>";
+ $output = $post;
+ }
+ $urls .= $output;
+ $output = $urls;
+
+ //
+ // Hack to make quotes two levels deep.
+ //
+ // Replace [quote title=...]...[/quote]
+ $urls = "";
+ while(($start = strpos($output, "[quote"))) {
+ $pre = substr($output, 0, $start);
+ $url = substr($output, $start);
+ $end = strpos($url, "[/quote]") + strlen("[/quote]");
+ $url = substr($url, 0, $end - strlen("[/quote]"));
+ $post = substr($output, $start + $end + strlen("[/quote]") );
+
+ $header = substr($url, 0, strpos($url, "]") + 1);
+ $body = substr($url, strpos($url, "]") + 1);
+
+ $header = str_replace(array("title"), "", $header);
+ $header = str_replace(array("="), "<div class=\"title\">", $header);
+ $header = str_replace(array("[quote"), "<div class=\"quote\">", $header);
+ $header = str_replace(array("]"), " </div>", $header);
+
+ $urls .= $pre . $header . $body . "</div>";
+ $output = $post;
+ }
+ $urls .= $output;
+ $output = $urls;
+
+ // <b></b>
+ $b = array("[b]", "[B]");
+ $b = str_replace($b, "<strong>", $output);
+ $output = $b;
+
+ $b = array("[/b]", "[/B]");
+ $b = str_replace($b, "</strong>", $output);
+ $output = $b;
+
+ // <i></i>
+ $i = array("[i]", "[I]");
+ $i = str_replace($i, "<em>", $output);
+ $output = $i;
+
+ $i = array("[/i]", "[/i]");
+ $i = str_replace($i, "</em>", $output);
+ $output = $i;
+
+ // Replace newlines with <br/> tags
+ $nls = array("\n");
+ $nls = str_replace($nls, "<br/>\n", $output);
+ $output = $nls;
+
+ return $output;
+}
+
+?>
diff --git a/forum/utils/ping.php b/forum/utils/ping.php
new file mode 100644
index 0000000..8977df5
--- /dev/null
+++ b/forum/utils/ping.php
@@ -0,0 +1,126 @@
+<?php
+$g_icmp_error = "No Error";
+
+// timeout in ms
+function ping($host, $timeout)
+{
+ $port = 0;
+ $datasize = 64;
+ global $g_icmp_error;
+ $g_icmp_error = "No Error";
+ $ident = array(ord('J'), ord('C'));
+ $seq = array(rand(0, 255), rand(0, 255));
+
+ $packet = '';
+ $packet .= chr(8); // type = 8 : request
+ $packet .= chr(0); // code = 0
+
+ $packet .= chr(0); // checksum init
+ $packet .= chr(0); // checksum init
+
+ $packet .= chr($ident[0]); // identifier
+ $packet .= chr($ident[1]); // identifier
+
+ $packet .= chr($seq[0]); // seq
+ $packet .= chr($seq[1]); // seq
+
+ for ($i = 0; $i < $datasize; $i++)
+ $packet .= chr(0);
+
+ $chk = icmpChecksum($packet);
+
+ $packet[2] = $chk[0]; // checksum init
+ $packet[3] = $chk[1]; // checksum init
+
+ $sock = socket_create(AF_INET, SOCK_RAW, getprotobyname('icmp'));
+ $time_start = microtime();
+ socket_sendto($sock, $packet, strlen($packet), 0, $host, $port);
+
+
+ $read = array($sock);
+ $write = NULL;
+ $except = NULL;
+
+ $select = socket_select($read, $write, $except, 0, $timeout * 1000);
+ if ($select === NULL)
+ {
+ $g_icmp_error = "Select Error";
+ socket_close($sock);
+ return -1;
+ }
+ elseif ($select === 0)
+ {
+ $g_icmp_error = "Timeout";
+ socket_close($sock);
+ return -1;
+ }
+
+ $recv = '';
+ $time_stop = microtime();
+ socket_recvfrom($sock, $recv, 65535, 0, $host, $port);
+ $recv = unpack('C*', $recv);
+
+ if ($recv[10] !== 1) // ICMP proto = 1
+ {
+ $g_icmp_error = "Not ICMP packet";
+ socket_close($sock);
+ return -1;
+ }
+
+ if ($recv[21] !== 0) // ICMP response = 0
+ {
+ $g_icmp_error = "Not ICMP response";
+ socket_close($sock);
+ return -1;
+ }
+
+ if ($ident[0] !== $recv[25] || $ident[1] !== $recv[26])
+ {
+ $g_icmp_error = "Bad identification number";
+ socket_close($sock);
+ return -1;
+ }
+
+ if ($seq[0] !== $recv[27] || $seq[1] !== $recv[28])
+ {
+ $g_icmp_error = "Bad sequence number";
+ socket_close($sock);
+ return -1;
+ }
+
+ $ms = ($time_stop - $time_start) * 1000;
+
+ if ($ms < 0)
+ {
+ $g_icmp_error = "Response too long";
+ $ms = -1;
+ }
+
+ socket_close($sock);
+
+ return $ms;
+}
+
+function icmpChecksum($data)
+{
+ $bit = unpack('n*', $data);
+ $sum = array_sum($bit);
+
+ if (strlen($data) % 2) {
+ $temp = unpack('C*', $data[strlen($data) - 1]);
+ $sum += $temp[1];
+ }
+
+ $sum = ($sum >> 16) + ($sum & 0xffff);
+ $sum += ($sum >> 16);
+
+ return pack('n*', ~$sum);
+}
+
+function getLastIcmpError()
+{
+ global $g_icmp_error;
+ return $g_icmp_error;
+}
+
+?> \ No newline at end of file
diff --git a/forum/utils/posts.php b/forum/utils/posts.php
new file mode 100644
index 0000000..c301852
--- /dev/null
+++ b/forum/utils/posts.php
@@ -0,0 +1,254 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+include_once($UTIL_DIR . "/threads.php");
+include_once($UTIL_DIR . "/parser.php");
+
+class Post {
+ public $pid;
+ public $user;
+ public $title;
+ public $date;
+ public $message;
+ public $replies = array();
+
+ public function write($fp, $indent)
+ {
+ fwrite($fp, $indent . "<post pid=\"" . $this->pid . "\"\n");
+ fwrite($fp, $indent . " user=\"" . $this->user . "\"\n");
+ fwrite($fp, $indent . " title=\"" . convert_xml($this->title) . "\"\n");
+ fwrite($fp, $indent . " date=\"" . $this->date . "\">\n");
+ fwrite($fp, $indent . " <message>" . convert_xml($this->message) . "</message>\n");
+
+ foreach($this->replies as $reply) {
+ $reply->write($fp, $indent . " ");
+ }
+
+ fwrite($fp, $indent . "</post>\n");
+ }
+
+ public function add($post) {
+ $key = $post->pid;
+ $this->replies[$key] = $post;
+ }
+
+ public function getPost($pid)
+ {
+ $result = false;
+
+ foreach($this->replies as $post) {
+ if($post->pid == $pid) return $post;
+ $result = $post->getPost($pid);
+ if($result) return $result;
+ }
+
+ return $result;
+ }
+
+ public function show($indent = "", $recurse = true)
+ {
+ global $users, $fid, $tid, $current_user, $client_is_mobile_device;
+ $user = $users->getUser($this->user);
+
+ echo $indent . "<div class=\"post\">\n";
+ if($client_is_mobile_device) {
+ $avatar = "mobileavatar.gif";
+ } else {
+ if($user->avatar) $avatar = $user->avatar;
+ else $avatar = "default.gif";
+ }
+ echo $indent . " <img class=\"avatar\" alt=\"avatar\" src=\"gfx/avatars/" . $avatar . "\"/>\n";
+ if(!$client_is_mobile_device) {
+ echo $indent . " <div class=\"id\">ID: " . $this->pid . "</div>\n";
+ echo $indent . " <div class=\"title\">Title: " . convert_xml($this->title) . "</div>\n";
+ }
+ echo $indent . " <div class=\"user\">";
+ if(!$client_is_mobile_device) echo "UserID: ";
+ echo $user->name . "</div>\n";
+ echo $indent . " <div class=\"date\">";
+ if(!$client_is_mobile_device) echo "Date: ";
+ echo date("j. M Y - G:i", $this->date) . "</div>\n";
+ echo $indent . " <div class=\"message\">\n";
+ echo parse($this->message, $indent . " ") . "\n";
+ echo $indent . " </div>\n";
+ echo $indent . " <div class=\"buttons\">\n";
+
+ if($current_user->uid == $this->user) {
+ echo $indent .
+ " <a href=\"?mode=editor&amp;task=edit&amp;fid=".$fid.
+ "&amp;tid=".$tid.
+ "&amp;pid=".$this->pid."\">";
+ echo "<img alt=\"edit\" src=\"gfx/btn_edit.gif\"/></a>\n";
+ }
+
+ echo $indent .
+ " <a href=\"?mode=editor&amp;task=quote&amp;fid=".$fid.
+ "&amp;tid=".$tid.
+ "&amp;pid=".$this->pid."\">";
+ echo "<img alt=\"quote\" src=\"gfx/btn_quote.gif\"/></a>\n";
+
+ echo $indent .
+ " <a href=\"?mode=editor&amp;task=reply&amp;fid=".$fid.
+ "&amp;tid=".$tid.
+ "&amp;pid=".$this->pid."\">";
+ echo "<img alt=\"reply\" src=\"gfx/btn_reply.gif\"/></a>\n";
+
+ echo $indent . " </div>\n";
+ echo $indent . " <div class=\"replies\">\n";
+
+ if($recurse) {
+ foreach($this->replies as $reply) {
+ $reply->show($indent . " ");
+ }
+ }
+
+ echo $indent . " </div>\n";
+ echo $indent . "</div>\n";
+ }
+
+ public function Post($pid, $title, $user, $date, $message = "")
+ {
+ $this->pid = $pid;
+ $this->title = $title;
+ $this->user = $user;
+ $this->date = $date;
+ $this->message = $message;
+ }
+}
+
+class Posts {
+ private $file;
+ private $posts = array();
+ public $thread;
+ private $posts_linear = array();
+ private $maxkey = 0;
+
+ public function nextkey() {
+ $this->maxkey++;
+ return $this->maxkey;
+ }
+
+ public function add($post) {
+ $key = $post->pid;
+ $this->posts[$key] = $post;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ if($this->thread->lastseen) {
+ foreach($this->thread->lastseen as $key => $value) {
+ if($lastseenstr != "") $lastseenstr .= ",";
+ $lastseenstr .= $key . "=" . $value;
+ }
+ }
+
+ fwrite($fp, "<thread tid=\"" . $this->thread->tid . "\"\n");
+ fwrite($fp, " name=\"" . convert_xml($this->thread->name) . "\"\n");
+ fwrite($fp, " lastpost=\"" . $this->thread->lastpost . "\"\n");
+ fwrite($fp, " lastseen=\"" . $lastseenstr . "\">\n");
+
+ foreach($this->posts as $post) {
+ $post->write($fp, " ");
+ }
+
+ fwrite($fp, "</thread>\n");
+
+ fclose($fp);
+ }
+
+ public function getPost($pid)
+ {
+ $result = false;
+
+ foreach($this->posts as $post) {
+ if($post->pid == $pid) return $post;
+ $result = $post->getPost($pid);
+ if($result) return $result;
+ }
+
+ return $result;
+ }
+
+ public function show()
+ {
+ global $current_user;
+ echo "<h1 id=\"top\">" . $this->thread->name . "</h1>";
+
+ /* // Recursive
+ foreach($this->posts as $post) {
+ $post->show();
+ }
+ */
+
+ // Linear
+ foreach($this->posts_linear as $post) {
+ $post->show("", false);
+ }
+
+ $this->thread->lastseen[$current_user->uid] = time();
+
+ $this->write();
+
+ echo "<p><a href=\"#top\">Back to the top</a></p>";
+ }
+
+ private function recurser($parentpost, $element)
+ {
+ if($element->tagName != "post") return;
+
+ $post = new Post($element->getAttribute('pid'),
+ $element->getAttribute('title'),
+ $element->getAttribute('user'),
+ $element->getAttribute('date'));
+
+ $this->posts_linear[$post->date . "-" . $post->pid] = $post;
+
+ if($post->pid > $this->maxkey) $this->maxkey = $post->pid;
+
+ if($parentpost) $parentpost->add($post);
+ else $this->add($post);
+
+ foreach($element->childNodes as $child) {
+ if($child->tagName == "post")
+ $this->recurser($post, $child);
+ if($child->tagName == "message")
+ $post->message = $child->textContent;
+ }
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->resolveExternals = FALSE;
+ $dom->substituteEntities = FALSE;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+
+ $thread = $dom->documentElement;
+ $this->thread = new Thread($thread->getAttribute('tid'),
+ $thread->getAttribute('name'),
+ $thread->getAttribute('lastpost'),
+ $thread->getAttribute('lastseen'));
+ foreach($thread->childNodes as $child) {
+ $this->recurser(false, $child);
+ }
+
+ // The linear list should be sorted.
+ sort($this->posts_linear);
+ }
+
+ public function Posts($file)
+ {
+ $this->file = $file;
+ if(file_exists($this->file)) $this->read();
+ }
+
+}
+?>
diff --git a/forum/utils/profile.php b/forum/utils/profile.php
new file mode 100644
index 0000000..ee47cb0
--- /dev/null
+++ b/forum/utils/profile.php
@@ -0,0 +1,39 @@
+<?php
+include_once($UTIL_DIR . "/error.php");
+
+if($action == "update") {
+// $current_user->username = $username;
+ $current_user->name = $name;
+ $current_user->email = $email;
+ $current_user->avatar = $avatar;
+ if($password != "") {
+ if($password == $password_confirm) {
+ $current_user->password = sha1(md5($password));
+ } else {
+ error("Passwords do not match - thus not changed!");
+ }
+ }
+ $users->write();
+}
+?>
+
+<form method="post" action="?mode=profile&amp;action=update">
+<?php /*Username: <input name="username" value="<?php echo $current_user->username; ?>"><br/> */ ?>
+Name: <input name="name" value="<?php echo $current_user->name; ?>"><br/>
+New password: <input type="password" name="password" value=""><br/>
+Confirm password: <input type="password" name="password_confirm" value=""><br/>
+E-Mail: <input name="email" value="<?php echo $current_user->email; ?>"><br/>
+Avatar: <select name="avatar">
+<?php
+$dir = opendir("gfx/avatars");
+while($avatar = readdir($dir)) {
+ if($avatar != "." && $avatar != "..") {
+?> <option value="<?php echo $avatar ?>" <?php if($current_user->avatar == $avatar) echo selected; ?>><?php echo $avatar ?></option>
+<?php
+ }
+}
+?>
+</select><br/>
+<br/>
+<button type="submit">Update</button>
+</form>
diff --git a/forum/utils/roadmap.php b/forum/utils/roadmap.php
new file mode 100644
index 0000000..f3e85ca
--- /dev/null
+++ b/forum/utils/roadmap.php
@@ -0,0 +1,70 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+
+class Roadmap {
+ private $file;
+ private $groups = array(array());
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<roadmap tid=\"" . $this-> . "\"\n");
+ fwrite($fp, " abc=\"" . . "\">\n");
+
+ // for each group
+ for($gid = 0; $gid < length($groups); $gid++) {
+ fwrite($fp, " <group id=\"" . $gid . "\"\n");
+ fwrite($fp, " name=\"" . $name . "\">\n");
+
+ for($iid = 0; $iid < length($groups[$gid]); $iid++) {
+ fwrite($fp, " <item id=\"" . $id . "\"\n");
+ fwrite($fp, " name=\"" . $name . "\"/>\n");
+ }
+
+ fwrite($fp, " </group>\n");
+ }
+
+ fwrite($fp, "</thread>\n");
+
+ fclose($fp);
+ }
+
+ public function show()
+ {
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->resolveExternals = FALSE;
+ $dom->substituteEntities = FALSE;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+
+
+ $roadmap = $dom->documentElement;
+ foreach($roadmap->childNodes as $group) {
+ echo $group->getAttribute('id');
+ echo $group->getAttribute('name');
+ foreach($group->childNodes as $item) {
+ echo $item->getAttribute('id');
+ echo $item->getAttribute('name');
+ }
+ }
+ }
+
+ public function Roadmap($file)
+ {
+ $this->file = $file;
+ if(file_exists($this->file)) $this->read();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/forum/utils/smileys.php b/forum/utils/smileys.php
new file mode 100644
index 0000000..e0a2d1a
--- /dev/null
+++ b/forum/utils/smileys.php
@@ -0,0 +1,38 @@
+<?php
+
+$smileys = array(
+ array(array(":-)", ":)"), "smile.gif"),
+ array(array(":-D", ":D"), "biggrinn.gif"),
+ array(array("X-D", "x-D"), "grinn.gif"),
+ array(array(";-)", ";)"), "wink.gif"),
+ array(array(";(", ";-("), "cry.gif"),
+ array(array(":(", ":-("), "mad.gif"),
+ array(array(":smoke:"), "smoke.gif"),
+ array(array(":vom:"), "vommit.gif"),
+ array(array(":nod:"), "nod.gif"),
+ array(array(":butt:"), "butt.gif"),
+ array(array(":eek:"), "eek.gif"),
+ array(array(":razz:"), "razz.gif"),
+ array(array(":roll:"), "roll.gif"),
+ array(array(":evil:"), "evil.gif"),
+ array(array(":lol:"), "lol.gif"),
+ array(array(":cool:"), "cool.gif"),
+// array(array(":thumbsup:"), "thumbsup.gif"),
+ array(array(":-p", ":p", ":-P", ":P"), "tongue.png"),
+ array(array("(R)"), "redface.gif"),
+ array(array("\\m/"), "headbanger.gif"),
+ array(array("&gt;:O"), "growler.gif"),
+ array(array(":thumbsup:"), "thumbsup.gif"),
+ array(array(":thumbsdown:"), "thumbsdown.gif"),
+ array(array("=>", "->"), "arrow.gif"),
+ array(array(":smug:"), "smug.gif"),
+ array(array(":idea:"), "idea.gif"),
+ array(array(":-K", ":-k", ":k", ":K"), "think.gif"),
+ array(array(":-O", ":O"), "surprised.gif"),
+ array(array(":S", ":-S"), "confused.gif"),
+ array(array(":drinker:"), "drinker.gif"),
+ array(array(":drinkers:"), "party.gif")
+ );
+
+
+?>
diff --git a/forum/utils/threads.php b/forum/utils/threads.php
new file mode 100644
index 0000000..e3f0996
--- /dev/null
+++ b/forum/utils/threads.php
@@ -0,0 +1,162 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+
+/**
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <thread tid="1" name="Thread1">
+ * .
+ * .
+ * .
+ * </thread>
+ */
+
+class Thread {
+ public $tid;
+ public $name;
+ public $lastseen = array();
+ public $lastpost;
+
+ public function show()
+ {
+ global $fid, $current_user;
+ echo "<div class=\"thread\">";
+ if($this->lastseen[$current_user->uid] < $this->lastpost) echo "<div class=\"new\"></div>";
+ else echo "<div class=\"nonew\"></div>";
+ echo "<a href=\"?fid=" . $fid . "&amp;tid=" . $this->tid . "\">" . $this->name . "</a>";
+ echo "</div>";
+ }
+
+ private function loadLastSeen($lastseen)
+ {
+ if($lastseen == "") return;
+ $list = explode(",", $lastseen);
+ foreach($list as $l) {
+ $pair = explode("=", $l);
+ if($pair[0] != "" && $pair[1] != "") {
+ $this->lastseen[$pair[0]] = $pair[1];
+ }
+ }
+ }
+
+ public function Thread($tid, $name, $lastpost, $lastseen)
+ {
+ $this->tid = $tid;
+ $this->name = $name;
+ $this->lastpost = $lastpost;
+ $this->loadLastSeen($lastseen);
+ }
+}
+
+class Threads {
+
+ private $dir;
+ public $threads = array();
+
+ public function add($thread) {
+ // $key = $thread->name;
+ // $key = sprintf("%d-%d", $thread->lastpost, $thread->tid);
+ // $key = sprintf("%d", $thread->lastpost);
+ $key = $thread->lastpost . "-" . $thread->tid;//name;
+ // echo "[" . $key . "]";
+ $this->threads[$key] = $thread;
+ }
+
+ public function write()
+ {
+ /*
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<members>\n");
+ foreach($this->members as $member) {
+ fwrite($fp, " <member id=\"" .
+ htmlspecialchars($member->id, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " name=\"" .
+ htmlspecialchars($member->name, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($member->description, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " image=\"" .
+ htmlspecialchars($member->image, ENT_QUOTES, "UTF-8") . "\">\n");
+
+
+ fwrite($fp, " </member>\n");
+ }
+ fwrite($fp, "</members>\n");
+
+ fclose($fp);
+ */
+ }
+
+ /*
+ public function deleteForumUser($id)
+ {
+ if($this->members[$id]) {
+ unset($this->members[$id]);
+ // $this->write();
+ } else {
+ echo "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
+ return false;
+ }
+ return true;
+ }
+ */
+
+ public function getThread($tid)
+ {
+ $thread = $this->threads[$tid];
+ return $thread;
+ }
+
+ public function show()
+ {
+ foreach($this->threads as $thread) {
+ $thread->show();
+ }
+ }
+
+ public function newStuff()
+ {
+ global $current_user;
+
+ foreach($this->threads as $thread) {
+ if($thread->lastseen[$current_user->uid] < $thread->lastpost) return true;
+ }
+
+ return false;
+ }
+
+ private function read()
+ {
+ $dh = opendir($this->dir);
+ while($file = readdir($dh)) {
+ if($file == "." || $file == "..") continue;
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->dir . "/" . $file);
+ $threads = $dom->getElementsByTagName('thread');
+
+ foreach($threads as $f) {
+ $thread = new Thread($f->getAttribute('tid'),
+ $f->getAttribute('name'),
+ $f->getAttribute('lastpost'),
+ $f->getAttribute('lastseen'));
+
+ $this->add($thread);
+ }
+ }
+ }
+
+ public function Threads($dir)
+ {
+ $this->dir = $dir;
+ $this->read();
+ krsort($this->threads);
+ }
+
+}
+?> \ No newline at end of file
diff --git a/forum/utils/users.php b/forum/utils/users.php
new file mode 100644
index 0000000..99aaffc
--- /dev/null
+++ b/forum/utils/users.php
@@ -0,0 +1,136 @@
+<?php
+
+include_once($UTIL_DIR . "/convert.php");
+
+class User {
+ public $uid;
+ public $gid;
+ public $enabled;
+ public $username;
+ public $password;
+ public $name;
+ public $avatar;
+ public $email;
+ public $notified;
+
+ public function checkPassword($password)
+ {
+ return $this->password == sha1(md5($password));
+ }
+
+ public function write($fp)
+ {
+ fwrite($fp, " <user enabled=\"" . $this->enabled . "\"\n");
+ fwrite($fp, " uid=\"" . $this->uid . "\"\n");
+ fwrite($fp, " gid=\"" . $this->gid . "\"\n");
+ fwrite($fp, " notified=\"" . $this->notified . "\"\n");
+ fwrite($fp, " username=\"" . htmlspecialchars($this->username, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " password=\"" . $this->password . "\"\n");
+ fwrite($fp, " name=\"" . htmlspecialchars($this->name, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " avatar=\"" . htmlspecialchars($this->avatar, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " email=\"" . htmlspecialchars($this->email, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </user>\n");
+ }
+
+ public function User($enabled, $uid, $gid, $username, $password, $name, $email, $avatar, $notified)
+ {
+ $this->enabled = $enabled;
+ $this->gid = $gid;
+ $this->uid = $uid;
+ $this->username = $username;
+ $this->password = $password;
+ $this->email = $email;
+ $this->name = $name;
+ $this->avatar = $avatar;
+ if($notified == "") $notified = 0;
+ $this->notified = $notified;
+ }
+}
+
+class Users {
+
+ private $file;
+ public $users = array();
+
+ public function add($user) {
+ $key = $user->uid;
+ $this->users[$key] = $user;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<users>\n");
+ foreach($this->users as $user) {
+ $user->write($fp);
+ }
+ fwrite($fp, "</users>\n");
+
+ fclose($fp);
+ }
+
+ /*
+ public function deleteForumUser($id)
+ {
+ if($this->members[$id]) {
+ unset($this->members[$id]);
+ // $this->write();
+ } else {
+ echo "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
+ return false;
+ }
+ return true;
+ }
+ */
+
+ public function getUserID($username)
+ {
+ foreach($this->users as $user) {
+ if($user->username == $username) return $user->uid;
+ }
+ return false;
+ }
+
+ public function getUser($uid)
+ {
+ $user = $this->users[$uid];
+ return $user;
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $users = $dom->getElementsByTagName('user');
+
+ foreach ($users as $u) {
+ $user = new User($u->getAttribute('enabled'),
+ $u->getAttribute('uid'),
+ $u->getAttribute('gid'),
+ $u->getAttribute('username'),
+ $u->getAttribute('password'),
+ $u->getAttribute('name'),
+ $u->getAttribute('email'),
+ $u->getAttribute('avatar'),
+ $u->getAttribute('notified'));
+
+ $this->add($user);
+ }
+
+ }
+
+ public function Users($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/forum/utils/view.php b/forum/utils/view.php
new file mode 100644
index 0000000..0adb1a0
--- /dev/null
+++ b/forum/utils/view.php
@@ -0,0 +1,28 @@
+<?php
+echo "<div class=\"navigation\">";
+if($fid) echo "<a href=\"?\">forums</a>";
+if($tid) echo ":: <a href=\"?fid=" . $fid . "\">threads</a>";
+if($pid) echo ":: <a href=\"?fid=" . $fid . "&amp;tid=" . $tid . "\">posts</a>";
+echo "</div>\n";
+
+
+ if($fid && $tid) {
+ // echo "<h1>Posts</h1>";
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $posts->show();
+ } else if($fid) {
+ echo "<h1>Threads</h1>";
+ echo "<a href=\"?mode=editor&amp;task=new&amp;fid=".$fid.
+ "&amp;tid=".time()."&amp;pid=-1\">New thread</a>";
+
+ include_once("threads.php");
+ $threads = new Threads($FORUMS_DIR . "/" . $fid);
+ $threads->show();
+ } else {
+ echo "<h1>Forums</h1>";
+ include_once("forums.php");
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ $forums->show();
+ }
+?> \ No newline at end of file