summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2008-10-04 10:38:03 +0000
committerdeva <deva>2008-10-04 10:38:03 +0000
commitcce5e7710295021b41d9aaecc503a60fb99256be (patch)
tree660235be91fb821e976c7ae62347eb368ce87524
Initial revision
-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
-rw-r--r--utils/admin_events.php85
-rw-r--r--utils/admin_gallery.php108
-rw-r--r--utils/admin_guestbook.php2
-rw-r--r--utils/admin_news.php121
-rw-r--r--utils/admin_newsletter.php55
-rw-r--r--utils/admin_pressrelease.php55
-rw-r--r--utils/admin_user.php32
-rw-r--r--utils/admin_users.php203
-rw-r--r--utils/album.php137
-rw-r--r--utils/convert.php11
-rw-r--r--utils/events.php130
-rw-r--r--utils/guestbook.php169
-rw-r--r--utils/links.php128
-rw-r--r--utils/log.php15
-rw-r--r--utils/login.php67
-rw-r--r--utils/news.php103
-rw-r--r--utils/newsletter.php146
-rw-r--r--utils/pressrelease.php165
-rw-r--r--utils/rss.php112
-rw-r--r--utils/thumbnail.php39
-rw-r--r--utils/user.php151
-rw-r--r--utils/xml.php126
46 files changed, 4345 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
diff --git a/utils/admin_events.php b/utils/admin_events.php
new file mode 100644
index 0000000..058b9de
--- /dev/null
+++ b/utils/admin_events.php
@@ -0,0 +1,85 @@
+<h2>Events</h2>
+<?php
+include_once($UTIL_DIR."/events.php");
+include_once($UTIL_DIR."/convert.php");
+
+if($task == "confirmevent") {
+ $time = strtotime($month."/" .$day . "/" . $year);// . " " . $hour . ":" . $minute);
+
+ $title = convert($title);
+ $description = convert($description);
+
+ $event = new Event($title, $time, $description);
+ $event->show();
+?>
+Is this correct?<br/>
+<form method="post" action="?page=admin&amp;module=events&amp;task=postevent">
+ <input name="title" type="hidden" value="<?php echo $title ?>"/>
+ <input name="day" type="hidden" value="<?php echo $day ?>"/>
+ <input name="month" type="hidden" value="<?php echo $month ?>"/>
+ <input name="year" type="hidden" value="<?php echo $year ?>"/>
+ <input name="description" type="hidden" value="<?php echo $description ?>"/>
+ <button type="submit">Yes</button>
+</form>
+<form method="post" action="?page=admin&amp;module=events">
+ <input name="title" type="hidden" value="<?php echo $title ?>"/>
+ <input name="day" type="hidden" value="<?php echo $day ?>"/>
+ <input name="month" type="hidden" value="<?php echo $month ?>"/>
+ <input name="year" type="hidden" value="<?php echo $year ?>"/>
+ <input name="description" type="hidden" value="<?php echo $description ?>"/>
+ <button type="submit">No</button>
+</form>
+<?php
+ $title = "";
+ $day = "";
+ $month = "";
+ $year = "";
+ $hour = "";
+ $minute = "";
+ $description = "";
+}
+?>
+
+<?php
+if($task == "postevent") {
+ $time = strtotime($month."/" .$day . "/" . $year . " 23:59:00");// . " " . $hour . ":" . $minute);
+
+ $title = convert($title);
+ $description = convert($description);
+
+ $events = new Events($DATA_DIR."/events.xml");
+ $event = new Event($title, $time, $description);
+ $events->add($event);
+ $events->write();
+
+ echo "<p>Event posted successfully.</p>";
+ $title = "";
+ $day = "";
+ $month = "";
+ $year = "";
+ $description = "";
+}
+?>
+
+<?php
+$now = time();
+if($day == "") $day = date("j", $now);
+if($month =="") $month = date("n", $now);
+if($year == "") $year = date("Y", $now);
+?>
+<div class="small_header">Post event</div>
+<form method="post" action="?page=admin&amp;module=events&amp;task=confirmevent">
+ <p>
+ Title: <input name="title" value="<?php echo convert($title) ?>"/>
+ </p>
+ <p>
+ Date: <input name="day" style="width: 20px;" value="<?php echo $day ?>"/>/
+ <input name="month" style="width: 20px;" value="<?php echo $month ?>"/>-
+ <input name="year" style="width: 40px;" value="<?php echo $year ?>"/>
+ </p>
+ <p>
+ Description:<br/>
+ <textarea name="description"><?php echo convert($description) ?></textarea>
+ </p>
+ <button type="submit">Post event</button>
+</form>
diff --git a/utils/admin_gallery.php b/utils/admin_gallery.php
new file mode 100644
index 0000000..b584229
--- /dev/null
+++ b/utils/admin_gallery.php
@@ -0,0 +1,108 @@
+<h2>Gallery</h2>
+
+<?php include_once($UTIL_DIR."/album.php"); ?>
+
+<?php
+if($task == "newalbum") {
+ $albumdir = $ALBUMS_DIR . "/" . time();
+ echo "New album " . $albumname . "<br/>";
+ echo $albumcopyright . "<br/>";
+ echo $albumdir . "<br/>";
+ mkdir($albumdir);
+ $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ $xml .= "<album title=\"". $albumname . "\" icon=\"\" copyright=\"" . $albumcopyright . "\">\n";
+ $xml .= "</album>\n";
+ $fp = fopen($albumdir . "/album.xml", "w");
+ fprintf($fp, $xml);
+ fclose($fp);
+}
+?>
+
+<?php
+if($task == "uploadimage") {
+
+ echo $album . "<br/>";
+ echo $description . "<br/>";
+ echo $_FILES['userfile']['tmp_name'] . "<br/>";
+
+ if($_FILES['userfile']['tmp_name'] != "") {
+ echo "Filename [". $_FILES['userfile']['tmp_name'] . "]";
+ if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.\n";
+
+ $outputfile = time() . ".jpg";
+
+ $image = imagecreatefromjpeg($_FILES["userfile"]["tmp_name"]);
+ list($w, $h) = getimagesize($_FILES["userfile"]["tmp_name"]);
+
+ // output size and quality
+ $quality = 80;
+
+ $max = 530;
+
+ $width = 530;;
+ $height = 380;
+
+ if($w > $h) {
+ $width = 530;
+ $height = 530 / $w * $h;
+ } else {
+ $height = 530;
+ $width = 530 / $h * $w;
+ }
+ $image_p = imagecreatetruecolor($width, $height);
+ imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $w, $h);
+ imagejpeg($image_p, $ALBUMS_DIR ."/" .$album ."/" .$outputfile, $quality);
+
+ $photo = new Photo($outputfile, $description);
+ $album = new Album($album);
+ $album->add($photo);
+ $album->write();
+
+ } else {
+ echo "Possible file upload attack: ";
+ echo "filename '". $_FILES['userfile']['tmp_name'] . "'.";
+ }
+ }
+}
+?>
+
+<div class="small_header">New album</div>
+<form method="post" action="?page=admin&amp;module=gallery&amp;task=newalbum">
+ <p>
+ Title: <input name="albumname" value="<?php echo $albumname ?>"/>
+ </p>
+ <p>
+ Copyright: <input name="albumcopyright" value="<?php echo $albumcopyright ?>"/>
+ </p>
+ <p>
+ <button type="submit">Create album</button>
+ </p>
+</form>
+
+<div class="small_header">Upload image</div>
+<form enctype="multipart/form-data" action="?page=admin&amp;module=gallery&amp;task=uploadimage" method="post">
+ <p>
+ Album:
+ <select name="album">
+<?php
+$albums = getAllAlbums();
+foreach($albums as $album)
+{
+ echo " <option value=\"" . $album->album . "\">" . $album->title . "</option>\n";
+}
+?>
+ </select>
+ </p>
+ <p>
+ Description:
+ <input name="description" value="<?php echo $description ?>"/>
+ </p>
+ <p>
+ Upload this image:
+ <input name="userfile" type="file">
+ </p>
+ <p>
+ <button type="submit">Add Image</button>
+ </p>
+</form>
diff --git a/utils/admin_guestbook.php b/utils/admin_guestbook.php
new file mode 100644
index 0000000..ebdefbf
--- /dev/null
+++ b/utils/admin_guestbook.php
@@ -0,0 +1,2 @@
+<h2>Guestbook</h2>
+... nothing to see here ... yet! \ No newline at end of file
diff --git a/utils/admin_news.php b/utils/admin_news.php
new file mode 100644
index 0000000..b27cf31
--- /dev/null
+++ b/utils/admin_news.php
@@ -0,0 +1,121 @@
+<h2>News</h2>
+<?php
+include_once($UTIL_DIR."/news.php");
+include_once($UTIL_DIR."/convert.php");
+include_once($UTIL_DIR."/newsletter.php");
+include_once($UTIL_DIR."/rss.php");
+
+if($task == "confirmnews") {
+ $time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second);
+
+ $title = convert($title);
+ $description = convert($description);
+
+ $newsentry = new NewsEntry($title, $time, $category, $description);
+ $newsentry->show();
+
+ echo "<p>Category: " . $category . "</p>\n";
+ if($newsletter) echo "<p><strong>WARNING:</strong> This news will be sent out a newsletter if <em>yes</em> is pressed.</p>\n";
+?>
+Is this news correct?<br/>
+<form method="post" action="?page=admin&amp;module=news&amp;task=postnews">
+ <input name="title" type="hidden" value="<?php echo $title ?>"/>
+ <input name="category" type="hidden" value="<?php echo $category ?>"/>
+ <input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/>
+ <input name="day" type="hidden" value="<?php echo $day ?>"/>
+ <input name="month" type="hidden" value="<?php echo $month ?>"/>
+ <input name="year" type="hidden" value="<?php echo $year ?>"/>
+ <input name="hour" type="hidden" value="<?php echo $hour ?>"/>
+ <input name="minute" type="hidden" value="<?php echo $minute ?>"/>
+ <input name="second" type="hidden" value="<?php echo $second ?>"/>
+ <input name="description" type="hidden" value="<?php echo $description ?>"/>
+ <button type="submit">Yes</button>
+</form>
+<form method="post" action="?page=admin&amp;module=news">
+ <input name="title" type="hidden" value="<?php echo $title ?>"/>
+ <input name="category" type="hidden" value="<?php echo $category ?>"/>
+ <input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/>
+ <input name="day" type="hidden" value="<?php echo $day ?>"/>
+ <input name="month" type="hidden" value="<?php echo $month ?>"/>
+ <input name="year" type="hidden" value="<?php echo $year ?>"/>
+ <input name="hour" type="hidden" value="<?php echo $hour ?>"/>
+ <input name="minute" type="hidden" value="<?php echo $minute ?>"/>
+ <input name="second" type="hidden" value="<?php echo $second ?>"/>
+ <input name="description" type="hidden" value="<?php echo $description ?>"/>
+ <button type="submit">No</button>
+</form>
+<?php
+
+ $title = "";
+ $category = "";
+ $newsletter = "";
+ $day = "";
+ $month = "";
+ $year = "";
+ $hour = "";
+ $minute = "";
+ $second = "";
+ $description = "";
+}
+?>
+
+<?php
+if($task == "postnews") {
+ $time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second);
+
+ $title = convert($title);
+ $description = convert($description);
+
+ $news = new News($DATA_DIR."/news.xml");
+ $newsentry = new NewsEntry($title, $time, $category, $description);
+ $news->add($newsentry);
+ $news->write();
+
+ // Now update the RSS feed.
+ $rss = new RSS($DATA_DIR."/news.xml", "rss.xml");
+ $rss->write();
+
+ echo "<p>News posted successfully.</p>";
+
+ // if($newsletter == "on") sendNewsLetter($title, $description);
+
+ $title = "";
+ $category = "";
+ $newsletter = "";
+ $day = "";
+ $month = "";
+ $year = "";
+ $hour = "";
+ $minute = "";
+ $second = "";
+ $description = "";
+}
+?>
+
+<?php
+$now = time();
+if($day == "") $day = date("j", $now);
+if($month =="") $month = date("n", $now);
+if($year == "") $year = date("Y", $now);
+if($hour == "") $hour = date("G", $now);
+if($minute == "") $minute = date("i", $now);
+if($second == "") $second = date("s", $now);
+?>
+
+<div class="small_header">Post news</div>
+<form method="post" action="?page=admin&amp;module=news&amp;task=confirmnews">
+ Title: <input name="title" width="40" value="<?php echo convert($title) ?>"/><br/>
+ Category:
+ <select name="category">
+ <option value="main" <?php if($category == "main") echo "selected"; ?>>main</option>
+ <option value="site" <?php if($category == "site") echo "selected"; ?>>site</option>
+ </select><br/>
+ Date: <input name="day" maxlength="2" style="width: 20px;" value="<?php echo $day ?>"/>/
+ <input name="month" maxlength="2" style="width: 20px;" value="<?php echo $month ?>"/>-
+ <input name="year" maxlength="4" style="width: 40px;" value="<?php echo $year ?>"/><br/>
+ Time: <input name="hour" maxlength="2" style="width: 20px;" value="<?php echo $hour ?>"/>:
+ <input name="minute" maxlength="2" style="width: 20px;" value="<?php echo $minute ?>"/>:
+ <input name="second" maxlength="2" style="width: 20px;" value="<?php echo $second ?>"/><br/>
+ Description: <textarea name="description"><?php echo convert($description) ?></textarea><br/>
+ <button type="submit">Post news</button>
+</form>
diff --git a/utils/admin_newsletter.php b/utils/admin_newsletter.php
new file mode 100644
index 0000000..29275ab
--- /dev/null
+++ b/utils/admin_newsletter.php
@@ -0,0 +1,55 @@
+<h2>Newsletter</h2>
+<?php
+include_once($UTIL_DIR . "/newsletter.php");
+include_once($UTIL_DIR . "/convert.php");
+
+if($task == "confirm") {
+ $testmail = new Email($testaddr, time());
+ $testmail->send(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message)));
+ echo "A testmail has been sent to " . $testaddr . ". Check this email to berify the correctness of the contents.";
+
+?>
+Is the newsmail correct?<br/>
+<form method="post" action="?page=admin&amp;module=newsletter&amp;task=send">
+ <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/>
+ <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/>
+ <input name="message" type="hidden" value="<?php echo convert($message) ?>"/>
+ <button type="submit">Yes</button>
+</form>
+<form method="post" action="?page=admin&amp;module=newsletter">
+ <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/>
+ <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/>
+ <input name="message" type="hidden" value="<?php echo convert($message) ?>"/>
+ <button type="submit">No</button>
+</form>
+<?php
+ $subject = "";
+ $message = "";
+}
+?>
+
+<?php
+if($task == "send") {
+ $list = new Mailinglist($DATA_DIR . "/mailinglist.xml");
+ $list->post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message)));
+}
+?>
+
+<div class="small_header">Post newsletter</div>
+<form method="post" action="?page=admin&amp;module=newsletter&amp;task=confirm">
+ <p>
+ Test address:
+ <input name="testaddr" value="<?php echo convert($testaddr) ?>"/>
+ </p>
+ <p>
+ Subject:
+ <input name="subject" value="<?php echo convert($subject) ?>"/>
+ </p>
+ <p>
+ Message:<br/>
+ <textarea name="message"><?php echo convert($message) ?></textarea>
+ </p>
+ <p>
+ <button type="submit">Post news</button>
+ </p>
+</form>
diff --git a/utils/admin_pressrelease.php b/utils/admin_pressrelease.php
new file mode 100644
index 0000000..65ba35a
--- /dev/null
+++ b/utils/admin_pressrelease.php
@@ -0,0 +1,55 @@
+<h2>Pressrelease</h2>
+<?php
+include_once($UTIL_DIR . "/pressrelease.php");
+include_once($UTIL_DIR . "/convert.php");
+
+if($task == "confirm") {
+ $testmail = new Email("Testname", "http://www.example.com", $testaddr);
+ $testmail->send(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message)));
+ echo "A testmail has been sent to " . $testaddr . ". Check this email to berify the correctness of the contents.";
+
+?>
+Is the press mail correct?<br/>
+<form method="post" action="?page=admin&amp;module=pressrelease&amp;task=send">
+ <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/>
+ <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/>
+ <input name="message" type="hidden" value="<?php echo convert($message) ?>"/>
+ <button type="submit">Yes</button>
+</form>
+<form method="post" action="?page=admin&amp;module=pressrelease">
+ <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/>
+ <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/>
+ <input name="message" type="hidden" value="<?php echo convert($message) ?>"/>
+ <button type="submit">No</button>
+</form>
+<?php
+ $subject = "";
+ $message = "";
+}
+?>
+
+<?php
+if($task == "send") {
+ $list = new PressRelease($DATA_DIR . "/pressrelease.xml");
+ $list->post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message)));
+}
+?>
+
+<div class="small_header">Post pressrelease</div>
+<form method="post" action="?page=admin&amp;module=pressrelease&amp;task=confirm">
+ <p>
+ Test address:
+ <input name="testaddr" value="<?php echo convert($testaddr) ?>"/>
+ </p>
+ <p>
+ Subject:
+ <input name="subject" value="<?php echo convert($subject) ?>"/>
+ </p>
+ <p>
+ Message:<br/>
+ <textarea name="message"><?php echo convert($message) ?></textarea>
+ </p>
+ <p>
+ <button type="submit">Post news</button>
+ </p>
+</form>
diff --git a/utils/admin_user.php b/utils/admin_user.php
new file mode 100644
index 0000000..42ed784
--- /dev/null
+++ b/utils/admin_user.php
@@ -0,0 +1,32 @@
+<h2>Password</h2>
+<?php
+include_once($UTIL_DIR."/user.php");
+include_once($UTIL_DIR."/convert.php");
+
+if($task == "setpassword") {
+ $users = new Users($DATA_DIR . "/users.xml");
+ $user = $users->findUser($HTTP_COOKIE_VARS["UserID"]);
+ $user->setPassword($oldpassword, $password1, $password2);
+ $users->add($user); // We need to update the user after changing the password!
+ $users->write();
+}
+?>
+
+<div class="small_header">Change password</div>
+<form method="post" action="?page=admin&amp;module=user&amp;task=setpassword">
+ <p>
+ Old password:
+ <input type="password" name="oldpassword" style="width: 100px;" value=""/
+ </p>
+ <p>
+ New password:
+ <input type="password" name="password1" style="width: 100px;" value=""/>
+ </p>
+ <p>
+ Confirm password:
+ <input type="password" name="password2" style="width: 100px;" value=""/>
+ </p>
+ <p>
+ <button type="submit">Change password</button>
+ </p>
+</form>
diff --git a/utils/admin_users.php b/utils/admin_users.php
new file mode 100644
index 0000000..c2e742f
--- /dev/null
+++ b/utils/admin_users.php
@@ -0,0 +1,203 @@
+<h2>Users</h2>
+<?php
+include_once($UTIL_DIR . "/user.php");
+$users = new Users($DATA_DIR. "/users.xml");
+?>
+
+
+<div class="small_header">Add user</div>
+<?php
+if($task == "adduser") {
+ if($password1 == $password2) {
+ if(!$users->findUser($newuserid)) {
+ $user = new User($newuserid,
+ sha1(md5($newpassword1)),
+ $newmodule_users,
+ $newmodule_news,
+ $newmodule_events,
+ $newmodule_guestbook,
+ $newmodule_gallery,
+ $newmodule_user,
+ $newmodule_newsletter);
+ $users->add($user);
+ $users->write();
+ echo "<p>User <em>" . $newuserid . "</em> added successfully.</p>\n";
+ } else {
+ echo "<p>ERROR: User <em>" . $newuserid . "</em> already exists.</p>\n";
+ }
+ } else {
+ echo "<p>ERROR: Passwords do not match.</p>\n";
+ }
+}
+?>
+<form method="post" action="?page=admin&amp;module=users&amp;task=adduser">
+ <p>
+ UserID: <input name="newuserid" value="<?php echo $newuserid; ?>"/>
+ </p>
+ <p>
+ <input name="newmodule_users"
+ type="checkbox" <?php if($newmodule_users == "on") echo "checked"; ?>/>
+ Add/edit.delete users:<br/>
+ <input name="newmodule_user"
+ type="checkbox" <?php if($newmodule_user == "on") echo "checked"; ?>/>
+ Change password:<br/>
+ <input name="newmodule_news"
+ type="checkbox" <?php if($newmodule_news == "on") echo "checked"; ?>/>
+ Add news:<br/>
+ <input name="newmodule_events"
+ type="checkbox" <?php if($newmodule_events == "on") echo "checked"; ?>/>
+ Add events:<br/>
+ <input name="newmodule_gallery"
+ type="checkbox" <?php if($newmodule_gallery == "on") echo "checked"; ?>/>
+ Add images in gallery:<br/>
+ <input name="newmodule_newsletter"
+ type="checkbox" <?php if($newmodule_newsletter == "on") echo "checked"; ?>/>
+ Send newsletter:<br/>
+ <input name="newmodule_guestbook"
+ type="checkbox" <?php if($newmodule_guestbook == "on") echo "checked"; ?>/>
+ Modify guestbook
+ </p>
+ <p>
+ New password:
+ <input type="password" name="newpassword1" style="width: 100px;" value="<?php echo $newpassword1; ?>"/>
+ </p>
+ <p>
+ Confirm password:
+ <input type="password" name="newpassword2" style="width: 100px;" value="<?php echo $newpassword2; ?>"/>
+ </p>
+ <p>
+ <button type="submit">Add user</button>
+ </p>
+</form>
+
+<div class="small_header">Edit user</div>
+<?php
+if($task == "updateuser") {
+ $user = $users->findUser($edituserid);
+ $user->users = $module_users;
+ $user->user = $module_user;
+ $user->news = $module_news;
+ $user->events = $module_events;
+ $user->gallery = $module_gallery;
+ $user->newsletter = $module_newsletter;
+ $user->guestbook = $module_guestbook;
+ if($password1 != "") {
+ if($password1 == $password2) {
+ $user->password = sha1(md5($password1));
+ $users->add($user);
+ $users->write();
+ echo "<p>User <em>" . $edituserid . "</em> successfully updated.</p>\n";
+ } else {
+ echo "<p>ERROR: Passwords do not match</p>\n";
+ $task = "edituser";
+ }
+ } else {
+ $users->add($user);
+ $users->write();
+ echo "<p>User <em>" . $edituserid . "</em> successfully updated. Password left untouched.</p>\n";
+ }
+}
+?>
+<?php
+if($task == "edituser") {
+ $user = $users->findUser($edituserid);
+?>
+<form method="post" action="?page=admin&amp;module=users&amp;task=updateuser">
+ <p>
+ UserID: <input name="edituserid" readonly value="<?php echo $user->userid; ?>"/>
+ </p>
+ <p>
+ <input name="module_users"
+ type="checkbox" <?php if($user->users == "on") echo "checked"; ?>/>
+ Add/edit.delete users:<br/>
+ <input name="module_user"
+ type="checkbox" <?php if($user->user == "on") echo "checked"; ?>/>
+ Change password:<br/>
+ <input name="module_news"
+ type="checkbox" <?php if($user->news == "on") echo "checked"; ?>/>
+ Add news:<br/>
+ <input name="module_events"
+ type="checkbox" <?php if($user->events == "on") echo "checked"; ?>/>
+ Add events:<br/>
+ <input name="module_gallery"
+ type="checkbox" <?php if($user->gallery == "on") echo "checked"; ?>/>
+ Add images in gallery:<br/>
+ <input name="module_newsletter"
+ type="checkbox" <?php if($user->newsletter == "on") echo "checked"; ?>/>
+ Send newsletter:<br/>
+ <input name="module_guestbook"
+ type="checkbox" <?php if($user->guestbook == "on") echo "checked"; ?>/>
+ Modify guestbook
+ </p>
+ <p>
+ New password:
+ <input type="password" name="password1" style="width: 100px;" value=""/>
+ </p>
+ <p>
+ Confirm password:
+ <input type="password" name="password2" style="width: 100px;" value=""/>
+ </p>
+ <p>
+ <button type="submit">Submit changes</button>
+ </p>
+</form>
+<?php
+}
+?>
+<form method="post" action="?page=admin&amp;module=users&amp;task=edituser">
+ <p>
+ Select the user you want to edit:<br/>
+ <select name="edituserid">
+<?php
+$uids = $users->useridList();
+foreach($uids as $uid) {
+?>
+ <option value="<?php echo $uid;?>"><?php echo $uid;?></option>
+<?php
+}
+?>
+ </select>
+ <button type="submit">Edit</button>
+ </p>
+</form>
+
+<div class="small_header">Delete user</div>
+<?php
+if($task == "deleteconfirm") {
+?>
+Are you sure you want to delete the <em><?php echo $deleteuserid; ?></em> user?<br/>
+<form method="post" action="?page=admin&amp;module=users&amp;task=delete">
+ <input name="deleteuserid" type="hidden" value="<?php echo $deleteuserid ?>"/>
+ <button type="submit">Yes</button>
+</form>
+<form method="post" action="?page=admin&amp;module=users">
+ <input name="deleteuserid" type="hidden" value="<?php echo $deleteuderid; ?>"/>
+ <button type="submit">No</button>
+</form>
+<?php
+}
+?>
+
+<?php
+if($task == "delete") {
+ if($users->deleteUser($deleteuserid)) {
+ echo "<p>User <em>".$deleteuserid."</em> deleted successfully.</p>\n";
+ }
+}
+?>
+<form method="post" action="?page=admin&amp;module=users&amp;task=deleteconfirm">
+ <p>
+ Select the user you want to delete:<br/>
+ <select name="deleteuserid">
+<?php
+$uids = $users->useridList();
+foreach($uids as $uid) {
+?>
+ <option value="<?php echo $uid;?>"><?php echo $uid;?></option>
+<?php
+}
+?>
+ </select>
+ <button type="submit">Delete</button>
+ </p>
+</form>
diff --git a/utils/album.php b/utils/album.php
new file mode 100644
index 0000000..1b6b662
--- /dev/null
+++ b/utils/album.php
@@ -0,0 +1,137 @@
+<?php
+include_once("thumbnail.php");
+
+class Photo {
+ public $file;
+ public $text;
+
+ function Photo($file, $text) {
+ $this->file = $file;
+ $this->text = $text;
+ }
+}
+
+class Album {
+ // Album directory (and identifier)
+ public $album;
+
+ // Photo array
+ public $photos;
+
+ // Album data
+ public $title;
+ public $icon;
+ public $copyright;
+
+ public function add($photo) {
+ // First added image is automatically made album icon.
+ if($this->icon == "") $this->icon = $photo->file;
+
+ $key = $photo->file;
+ $this->photos[$key] = $photo;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<album title=\"". $this->title . "\" icon=\"".$this->icon."\" copyright=\"" . $this->copyright . "\">\n");
+ foreach($this->photos as $photo) {
+ fwrite($fp, " <photo file=\"" . $photo->file . "\"\n");
+ fwrite($fp, " text=\"" . $photo->text . "\">\n");
+ fwrite($fp, " </photo>\n");
+ }
+ fwrite($fp, "</album>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+
+ $params = $dom->getElementsByTagName('album');
+ foreach ($params as $param) {
+ $this->title = $param->getAttribute('title');
+ $this->icon = $param->getAttribute('icon');
+ $this->copyright = $param->getAttribute('copyright');
+ }
+
+ $params = $dom->getElementsByTagName('photo');
+ foreach ($params as $param) {
+ $photo = new Photo($param->getAttribute('file'), $param->getAttribute('text'));
+ $this->add($photo);
+ }
+
+ // Key sort
+ if(sizeof($this->photos) > 0) ksort($this->photos);
+ }
+
+ public function Album($album)
+ {
+ global $ALBUMS_DIR;
+ $this->album = $album;
+ $this->file = $ALBUMS_DIR ."/". $album . "/album.xml";
+ $this->read();
+ }
+
+}
+
+
+function getAllAlbums()
+{
+ global $ALBUMS_DIR;
+ $albums = array();
+
+ $handle = opendir($ALBUMS_DIR . "/");
+ $albumdirs = array();
+ while($albumdir = readdir($handle)) {
+ array_push($albumdirs, $albumdir);
+ }
+
+ rsort($albumdirs);
+
+ foreach($albumdirs as $albumdir) {
+ if(!strstr($albumdir, ".") && !strstr($albumdir, "..")) {
+ $album = new Album($albumdir);
+ array_push($albums, $album);
+ }
+ }
+
+ return $albums;
+}
+
+function getRandomPhoto()
+{
+ $album;
+ $photo;
+
+ $albums = getAllAlbums();
+
+ $numalbums = sizeof($albums);
+ $ralbum = rand(0, sizeof($albums)-1);
+ foreach($albums as $a) {
+ $album = $a;
+ $ralbum--;
+ if(!$ralbum) break;
+ }
+
+ $numphotos = sizeof($album->photos);
+ $rphoto = rand(0, $numphotos-1);
+ foreach($album->photos as $p) {
+ $photo = $p;
+ $rphoto--;
+ if(!$rphoto) break;
+ }
+
+ // echo "<p>".$numalbums . " " .$ralbum . " ".$numphotos . " ".$rphoto . "</p>";
+
+ return array($album, $photo);
+}
+
+
+?> \ No newline at end of file
diff --git a/utils/convert.php b/utils/convert.php
new file mode 100644
index 0000000..6ba1964
--- /dev/null
+++ b/utils/convert.php
@@ -0,0 +1,11 @@
+<?php
+
+function convert($message)
+{
+ $message = stripslashes($message);
+ $message = htmlspecialchars($message, ENT_QUOTES, "UTF-8");
+ // $message = utf8_encode($message);
+ return $message;
+}
+
+?> \ No newline at end of file
diff --git a/utils/events.php b/utils/events.php
new file mode 100644
index 0000000..27ec873
--- /dev/null
+++ b/utils/events.php
@@ -0,0 +1,130 @@
+<?php
+
+include_once("convert.php");
+
+class Event {
+ public $title;
+ public $time;
+ public $description;
+ public $flyer;
+
+ public function show()
+ {
+ echo "<div class=\"event\">\n";
+ echo " <div class=\"event_title\">" .
+ htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ echo " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n";
+ echo " <div class=\"event_description\">" .
+ htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
+ if($this->flyer) {
+ echo " <img class=\"event_flyer\" alt=\"flyer\" src=\"gfx/flyers/" . $this->flyer . "\"/>\n";
+ }
+ echo "</div>\n";
+ }
+
+ public function Event($title, $time, $description, $flyer = "")
+ {
+ $this->title = $title;
+ $this->time = $time;
+ $this->description = $description;
+ $this->flyer = $flyer;
+ }
+}
+
+class Events {
+
+ private $file;
+ private $events = array();
+
+ public function showcoming($number)
+ {
+ $foundany = false;
+
+ // Key sort
+ ksort($this->events);
+
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->events as $event) {
+ if($event->time >= time()) {
+ $foundany = true;
+ $event->show();
+ $number--;
+ }
+ if(!$number) return;
+ }
+
+ if($foundany == false) echo "No shows available at the moment.";
+ }
+
+ public function showold($number)
+ {
+ // Key sort
+ krsort($this->events);
+
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->events as $event) {
+ if($event->time <= time()) {
+ $event->show();
+ $number--;
+ }
+ if(!$number) return;
+ }
+ }
+
+ public function add($event) {
+ $key = $event->time;
+ // array_push($this->events, $event);
+ $this->events[$key] = $event;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<events>\n");
+ foreach($this->events as $event) {
+ fwrite($fp, " <event title=\"" .
+ htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " time=\"" . $event->time . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " flyer=\"" . $event->flyer . "\">\n");
+ fwrite($fp, " </event>\n");
+ }
+ fwrite($fp, "</events>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('event');
+
+ foreach ($params as $param) {
+ $event = new Event($param->getAttribute('title'),
+ $param->getAttribute('time'),
+ $param->getAttribute('description'),
+ $param->getAttribute('flyer'));
+ $this->add($event);
+ }
+
+ }
+
+ public function Events($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/utils/guestbook.php b/utils/guestbook.php
new file mode 100644
index 0000000..ca9cd81
--- /dev/null
+++ b/utils/guestbook.php
@@ -0,0 +1,169 @@
+<?php
+class GuestbookEntry {
+ public $remoteaddr;
+ public $title;
+ public $email;
+ public $time;
+ public $text;
+
+ public function GuestbookEntry($title, $email, $time, $remoteaddr, $text) {
+ $this->title = $title;
+ $this->email = $email;
+ $this->time = $time;
+ $this->remoteaddr = $remoteaddr;
+ $this->text = $text;
+ }
+
+ public function show()
+ {
+ echo "<div class=\"guestbook_entry\">\n";
+ echo " <div class=\"guestbook_name\">" . $this->title . "</div>\n";
+ echo " <div class=\"guestbook_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ echo " <div class=\"guestbook_email\">" . str_replace("@", "(A)", $this->email) . "</div>\n";
+ echo " <div class=\"guestbook_text\">" . $this->text . "</div>\n";
+ echo "</div>\n";
+ }
+}
+
+class Guestbook {
+ private $file;
+ private $guestbook = array();
+
+ public function add($entry) {
+ $key = $entry->time;
+ $this->guestbook[$key] = $entry;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<guestbook>\n");
+ foreach($this->guestbook as $entry) {
+ fwrite($fp, " <entry name=\"" .
+ htmlspecialchars($entry->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " time=\"" . $entry->time . "\"\n");
+ fwrite($fp, " email=\"" .
+ htmlspecialchars($entry->email, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " remoteaddr=\"" .
+ htmlspecialchars($entry->remoteaddr, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " text=\"" .
+ htmlspecialchars($entry->text, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </entry>\n");
+ }
+ fwrite($fp, "</guestbook>\n");
+
+ fclose($fp);
+ }
+
+ public function show($number)
+ {
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->guestbook as $entry) {
+ $entry->show();
+ $number--;
+ if(!$number) return;
+ }
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('entry');
+
+ foreach ($params as $param) {
+ $entry = new GuestbookEntry($param->getAttribute('name'),
+ $param->getAttribute('email'),
+ $param->getAttribute('time'),
+ $param->getAttribute('remoteaddr'),
+ $param->getAttribute('text'));
+
+ $this->add($entry);
+ }
+
+ // Key sort
+ krsort($this->guestbook);
+ }
+
+ public function Guestbook($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+}
+
+function filtermessage($name, $email, $message, $name_hidden, $email_hidden, $message_hidden)
+{
+ global $_SERVER;
+
+ // First filter known bad IPs
+ $spammers = array("85.255.118.10",
+ "216.32.84.82",
+ "220.226.63.254");
+ $ip = $_SERVER['REMOTE_ADDR'];
+ foreach($spammers as $spamip) {
+ if($ip == $spamip) {
+ // echo "Go away evil spammer!!!!";
+ return false;//die(1);
+ }
+ }
+
+ // Bot catcher!
+ if($name || $email || $message) return false;//$spam .= "BOTCatch\n";
+
+ $name = strip_tags($name_hidden);
+ $email = strip_tags($email_hidden);
+ if($name == "" && $email == "") return false;//$spam .= "Empty name and mail\n";
+ if($name == "") $name = "Name unknown";
+ if($email == "") $email = "Email unknown";
+
+ $message = strip_tags($message_hidden);
+
+ // Banned words
+ if(stristr($message, "incest")) return false;//$spam .= "Contained word 'incest'\n";
+ if(stristr($message, "estate")) return false;//$spam .= "Contained word 'estate'\n";
+ if(stristr($message, "phentermine")) return false;//$spam .= "Contained word 'phentermine'\n";
+ if(stristr($message, "viagra")) return false;//$spam .= "Contained word 'viagra'\n";
+ if(stristr($message, "ringtones")) return false;//$spam .= "Contained word 'ringtones'\n";
+ //if(stristr($message, "vaginal")) return false;//$spam .= "Contained word 'vaginal'\n";
+ if(stristr($message, "messed up in the email of mine")) return false;//$spam .= "Contained words 'messed up in the email of mine'\n";
+ if(stristr($message, "ambien")) return false;//$spam .= "Contained word 'ambien'\n";
+ if(stristr($message, "dating")) return false;//$spam .= "Contained word 'dating'\n";
+ if(stristr($message, "levitra")) return false;//$spam .= "Contained word 'levitra'\n";
+ //if(stristr($message, "myspace")) return false;//$spam .= "Contained word 'myspace'\n";
+
+ if($message == "") return false;//$spam .= "Empty message\n";
+ $date = date("r");
+ //if(strstr($message, "http://")) return false;//$spam .= "Contains URL\n";
+
+ // Message is not SPAM
+ return true;
+}
+
+//
+// INIT CODE:
+//
+if($page == "guestbook" && $action == "post" &&
+ !filtermessage($name, $email, $message, $name_hidden, $email_hidden, $message_hidden)) {
+//!strstr($_SERVER['HTTP_REFERER'], "guestbook")) {
+ header("HTTP/1.0 404 Not Found");
+?>
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html><head>
+<title>404 Not Found</title>
+</head><body>
+<h1>Not Found</h1>
+<p>The requested URL /?page=guestbook was not found on this server.</p>
+<hr>
+<address>Apache/2.0.58 (Gentoo) mod_ssl/2.0.58 OpenSSL/0.9.7j PHP/5.1.6-pl6-gentoo Server at www.executionroom.com Port 80</address>
+</body></html>
+<?php
+ exit(404);
+}
+?> \ No newline at end of file
diff --git a/utils/links.php b/utils/links.php
new file mode 100644
index 0000000..e093eb2
--- /dev/null
+++ b/utils/links.php
@@ -0,0 +1,128 @@
+<?php
+
+class Link {
+ public $title;
+ public $href;
+ public $icon;
+
+ public function Link($title, $href, $icon) {
+ $this->title = $title;
+ $this->href = $href;
+ $this->icon = $icon;
+ }
+
+ public function show()
+ {
+ echo "<div class=\"link\">\n";
+ if($this->icon != "") {
+ echo " <a class=\"link_icon\" rel=\"external\" href=\"" . $this->href . "\">\n";
+ echo " <img alt=\"" . $this->title . "\" src=\"" . $this->icon . "\"/>\n";
+ echo " </a>\n";
+ }
+ echo " <a class=\"link_title\" rel=\"external\" href=\"" . $this->href . "\">\n";
+ echo " " . htmlspecialchars_decode($this->title, ENT_QUOTES) . "\n";
+ echo " </a>\n";
+ echo "</div>\n";
+ }
+}
+
+class LinkGroup {
+ public $title;
+ public $id;
+ private $links = array();
+
+ public function LinkGroup($title, $id) {
+ $this->title = $title;
+ $this->id = $id;
+ }
+
+ public function add($link) {
+ $key = $link->title;
+ $this->links[$key] = $link;
+ }
+
+ public function show()
+ {
+ echo "<div class=\"linkgroup\">\n";
+ echo " <div class=\"linkgroup_title\">". htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ foreach($this->links as $link) {
+ $link->show();
+ }
+ echo "</div>\n";
+ }
+}
+
+class Links {
+ private $file;
+ private $groups = array();
+
+ public function add($group) {
+ $key = $group->title;
+ $this->groups[$key] = $group;
+ }
+ /*
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<links>\n");
+ foreach($this->links as $link) {
+ fwrite($fp, " <link title=\"" .
+ htmlspecialchars($link->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " href=\"" .
+ htmlspecialchars($link->href, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " icon=\"" .
+ htmlspecialchars($link->icon, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </link>\n");
+ }
+ fwrite($fp, "</links>\n");
+
+ fclose($fp);
+ }
+ */
+ public function show($groupid)
+ {
+ foreach($this->groups as $group) {
+ if($groupid == $group->id || $groupid == "all") $group->show();
+ }
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+
+ $xmlgroups = $dom->getElementsByTagName('group');
+
+ foreach ($xmlgroups as $xmlgroup) {
+
+ $group = new LinkGroup($xmlgroup->getAttribute('name'),
+ $xmlgroup->getAttribute('id'));
+ $xmllinks = $xmlgroup->getElementsByTagName('link');
+
+ foreach ($xmllinks as $xmllink) {
+ $link = new Link($xmllink->getAttribute('title'),
+ $xmllink->getAttribute('href'),
+ $xmllink->getAttribute('icon'));
+
+ $group->add($link);
+ }
+
+ $this->add($group);
+ }
+
+ // Key sort
+ // ksort($this->events);
+ }
+
+ public function Links($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/utils/log.php b/utils/log.php
new file mode 100644
index 0000000..e6f2789
--- /dev/null
+++ b/utils/log.php
@@ -0,0 +1,15 @@
+<?php
+
+function _log($action, $username)
+{
+ global $DATA_DIR;
+
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $time = date("D M jS Y G:i", time());
+
+ $fp = fopen($DATA_DIR . "/admin.log", "a");
+ fprintf($fp, "%s - %s: User %s from %s\n", $time, $action, $username, $ip);
+ fclose($fp);
+}
+
+?> \ No newline at end of file
diff --git a/utils/login.php b/utils/login.php
new file mode 100644
index 0000000..950476e
--- /dev/null
+++ b/utils/login.php
@@ -0,0 +1,67 @@
+<?php
+
+$loggedin = false;
+
+include_once($UTIL_DIR . "/user.php");
+include_once($UTIL_DIR . "/log.php");
+
+function checklogin()
+{
+ global $HTTP_COOKIE_VARS;
+ global $userid;
+ global $password;
+ global $loggedin;
+ global $action;
+ global $DATA_DIR;
+
+ $users = new Users($DATA_DIR . "/users.xml");
+
+ if($action == "login") {
+ $user = $users->findUser($userid);
+ if($user) {
+ if($user->checkPassword($password)) {
+ $loggedin = true;
+ _log("Logged in", $userid);
+ } else {
+ _log("Wrong password", $userid);
+ }
+ setcookie("UserID", $userid, time()+600); // expire in 10 minutes
+ setcookie("Password", $password, time()+600); // expire in 10 minutes
+ return;
+ } else {
+ _log("Failed", $userid);
+ return;
+ }
+ }
+
+ if($action == "logout") {
+ _log("Logged out", $HTTP_COOKIE_VARS["UserID"]);
+ setcookie("UserID", "", time()-1); // remove cookie
+ setcookie("Password", "", time()-1); // remove cookie
+ $userid = "";
+ $password = "";
+ $loggedin = false;
+ return;
+ }
+
+ if($HTTP_COOKIE_VARS["UserID"] == "") {
+ _log("Failed", $UserID);
+ return;
+ }
+
+ $user = $users->findUser($HTTP_COOKIE_VARS["UserID"]);
+ if($user) {
+ if($user->checkPassword($HTTP_COOKIE_VARS["Password"])) {
+ setcookie("UserID", $HTTP_COOKIE_VARS["UserID"], time()+600); // expire in 10 minutes
+ setcookie("Password", $HTTP_COOKIE_VARS["Password"], time()+600); // expire in 10 minutes
+ $loggedin = true;
+ return;
+ } else {
+ _log("Wrong password", $HTTP_COOKIE_VARS["UserID"]);
+ }
+ } else {
+ _log("Failed", $UserID);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/utils/news.php b/utils/news.php
new file mode 100644
index 0000000..809e8dc
--- /dev/null
+++ b/utils/news.php
@@ -0,0 +1,103 @@
+<?php
+
+include_once("convert.php");
+
+class NewsEntry {
+ public $title;
+ public $time;
+ public $description;
+ public $category;
+
+ public function show()
+ {
+ echo "<div class=\"news_entry\">\n";
+ echo " <div class=\"news_title\">" .
+ htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ echo " <div class=\"news_description\">" .
+ htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
+ echo "</div>\n";
+ }
+
+ public function NewsEntry($title, $time, $category, $description)
+ {
+ $this->title = $title;
+ $this->time = $time;
+ $this->category = $category;
+ $this->description = $description;
+ }
+}
+
+class News {
+
+ private $file;
+ private $news = array();
+
+ public function show($number, $category)
+ {
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->news as $newsentry) {
+ if($newsentry->category == $category || $category == "all") {
+ $newsentry->show();
+ $number--;
+ }
+ if(!$number) return;
+ }
+ }
+
+ public function add($newsentry) {
+ $key = $newsentry->time;
+ $this->news[$key] = $newsentry;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<news>\n");
+ foreach($this->news as $newsentry) {
+ fwrite($fp, " <newsentry title=\"" .
+ htmlspecialchars($newsentry->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " time=\"" . $newsentry->time . "\"\n");
+ fwrite($fp, " category=\"" . $newsentry->category . "\"\n");
+ fwrite($fp, " description=\"" .
+ htmlspecialchars($newsentry->description, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </newsentry>\n");
+ }
+ fwrite($fp, "</news>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('newsentry');
+
+ foreach ($params as $param) {
+ $newsentry = new NewsEntry($param->getAttribute('title'),
+ $param->getAttribute('time'),
+ $param->getAttribute('category'),
+ $param->getAttribute('description'));
+ $this->add($newsentry);
+ }
+
+ // Key sort
+ krsort($this->news);
+ }
+
+ public function News($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+
+?>
diff --git a/utils/newsletter.php b/utils/newsletter.php
new file mode 100644
index 0000000..049e3f5
--- /dev/null
+++ b/utils/newsletter.php
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * CONFIG
+ */
+$subject_prefix = "DIE Newsletter";
+$sender = "DIE <info@executionroom.com>";
+$replyto = $sender;
+$footer = "
+
+Stay Brutal!
+// DIE
+http://www.executionroom.com
+info@executionroom.com
+";
+
+class Email {
+ public $timestamp;
+ public $email;
+
+ public function Email($email, $timestamp)
+ {
+ $this->email = $email;
+ $this->timestamp = $timestamp;
+ }
+
+ function send($subject, $message) {
+ global $subject_prefix;
+ global $sender;
+ global $replyto;
+ global $footer;
+
+ $message .= $footer;
+ $message .= "\nTo stop receiving this newsletter, click the following link: http://www.executionroom.com/?page=news&action=unsubscribe&email=". $this->email . "\n";
+ $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."] " . $subject;
+
+ $ret = mail($this->email, $subject, $message, $headers);
+ if(!$ret) echo "Fail(".$this->email.")";
+
+ //usleep(100000);
+ }
+}
+
+class Mailinglist {
+ private $file;
+ private $mailinglist = array();
+
+ public function add($email) {
+ $key = $email->email;
+ $this->mailinglist[$key] = $email;
+ }
+
+ public function remove($email) {
+ if(array_key_exists($email, $this->mailinglist)) {
+ unset($this->mailinglist[$email]);
+ }
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<mailinglist>\n");
+ foreach($this->mailinglist as $email) {
+ fwrite($fp, " <email email=\"" .
+ htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n");
+ fwrite($fp, " </email>\n");
+ }
+ fwrite($fp, "</mailinglist>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('email');
+
+ foreach ($params as $param) {
+ $email = new Email($param->getAttribute('email'),
+ $param->getAttribute('timestamp'));
+ $this->add($email);
+ }
+ }
+
+ public function subscribe($email)
+ {
+ $email = new EMail($email, time());
+ $this->add($email);
+ $this->write();
+ }
+
+ public function unsubscribe($email)
+ {
+ $this->remove($email);
+ $this->write();
+ }
+
+ public function post($subject, $message)
+ {
+ $sz = sizeof($this->mailinglist);
+
+ echo "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\n&lt;";
+ ob_flush();
+ flush();
+
+ $num = 0;
+ $lvl = 0;
+ $steps = floor($sz / 10) + 1;
+
+ foreach($this->mailinglist as $email) {
+ $email->send($subject, $message);
+ $pct = $num / $sz * 100;
+ if($pct >= $lvl) {
+ printf("<font style=\"font-size: 9px;\">%.0f%%</font>", $lvl);
+ $lvl += 100/$steps;
+ } else {
+ echo ".";
+ }
+ ob_flush();
+ flush();
+ $num++;
+ }
+ echo "<font style=\"font-size: 9px;\">[100%]</font>&gt;\n<br/>done<br/>\n";
+ echo "<a style=\"font-size: 20px; font-weight: bold;\" href=\"?page=admin&amp;module=newsletter\">[CLOSE]</a>";
+ echo "</div>\n";
+ ob_flush();
+ flush();
+ }
+
+ public function Mailinglist($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/utils/pressrelease.php b/utils/pressrelease.php
new file mode 100644
index 0000000..3ae25b4
--- /dev/null
+++ b/utils/pressrelease.php
@@ -0,0 +1,165 @@
+<?php
+/**
+<?xml version="1.0" encoding="UTF-8"?>
+<mailinglist>
+ <email name="HeavyMetal.dk" url="http://www.heavymetal.dk/" email="info@heavymetal.dk"/>
+ <email name="Blabbermouth.net" url="http://www.blabbermouth.net" email="bmouth@bellatlantic.net"/>
+ <email name="Power Metal.dk" url="http://www.powermetal.dk/" email="kenn@powermetal.dk"/>
+ <email name="Revolution Music" url="http://www.revolution-music.dk" email="heavybear@revolution-music.dk "/>
+ <email name="Antenna" url="http://www.antenna.nu" email="lolk@antenna.nu"/>
+ <email name="Supreme Brutality" url="http://www.supremebrutality.net" email="contact@supremebrutality.net"/>
+ <email name="Vampire Magazine" url="http://www.vampire-magazine.com" email="Ricardo@vampire-magazine.com"/>
+ <email name="Danish Metal" url="http://www.danishmetal.dk" email="martin@danishmetal.dk"/>
+ <email name="Revelationz" url="http://www.revelationz.net" email="mail@revelationz.net"/>
+</mailinglist>
+ **/
+
+
+/**
+ * CONFIG
+ */
+$subject_prefix = "DIE Pressrelease";
+$sender = "DIE <info@executionroom.com>";
+$replyto = $sender;
+$footer = "
+
+Stay Brutal!
+// DIE
+http://www.executionroom.com
+info@executionroom.com
+";
+
+class Email {
+ public $name;
+ public $url;
+ public $email;
+
+ public function Email($name, $url, $email)
+ {
+ $this->name = $name;
+ $this->url = $url;
+ $this->email = $email;
+ }
+
+ function send($subject, $message) {
+ global $subject_prefix;
+ global $sender;
+ global $replyto;
+ global $footer;
+
+ $message .= $footer;
+ $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."] " . $subject;
+
+ $ret = mail($this->email, $subject, $message, $headers);
+ if(!$ret) echo "Fail(".$this->email.")";
+
+ //usleep(100000);
+ }
+}
+
+class PressRelease {
+ private $file;
+ private $mailinglist = array();
+
+ public function add($email) {
+ $key = $email->email;
+ $this->mailinglist[$key] = $email;
+ }
+
+ public function remove($email) {
+ if(array_key_exists($email, $this->mailinglist)) {
+ unset($this->mailinglist[$email]);
+ }
+ }
+
+ public function write()
+ {
+ /*
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<mailinglist>\n");
+ foreach($this->mailinglist as $email) {
+ fwrite($fp, " <email email=\"" .
+ htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n");
+ fwrite($fp, " </email>\n");
+ }
+ fwrite($fp, "</mailinglist>\n");
+
+ fclose($fp);
+ */
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('email');
+
+ foreach ($params as $param) {
+ $email = new Email($param->getAttribute('name'),
+ $param->getAttribute('url'),
+ $param->getAttribute('email'));
+ $this->add($email);
+ }
+ }
+ /*
+ public function subscribe($email)
+ {
+ $email = new EMail($email, time());
+ $this->add($email);
+ $this->write();
+ }
+
+ public function unsubscribe($email)
+ {
+ $this->remove($email);
+ $this->write();
+ }
+ */
+ public function post($subject, $message)
+ {
+ $sz = sizeof($this->mailinglist);
+
+ echo "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\n&lt;";
+ ob_flush();
+ flush();
+
+ $num = 0;
+ $lvl = 0;
+ $steps = floor($sz / 10) + 1;
+
+ foreach($this->mailinglist as $email) {
+ $email->send($subject, $message);
+ $pct = $num / $sz * 100;
+ if($pct >= $lvl) {
+ printf("<font style=\"font-size: 9px;\">%.0f%%</font>", $lvl);
+ $lvl += 100/$steps;
+ } else {
+ echo ".";
+ }
+ ob_flush();
+ flush();
+ $num++;
+ }
+ echo "<font style=\"font-size: 9px;\">[100%]</font>&gt;\n<br/>done<br/>\n";
+ echo "<a style=\"font-size: 20px; font-weight: bold;\" href=\"?page=admin&amp;module=pressrelease\">[CLOSE]</a>";
+ echo "</div>\n";
+ ob_flush();
+ flush();
+ }
+
+ public function PressRelease($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/utils/rss.php b/utils/rss.php
new file mode 100644
index 0000000..e6aa83f
--- /dev/null
+++ b/utils/rss.php
@@ -0,0 +1,112 @@
+<?php
+
+include_once("convert.php");
+
+class RSSEntry {
+ public $title;
+ public $time;
+ public $description;
+ public $category;
+
+ /*
+ public function show()
+ {
+ echo "<div class=\"news_entry\">\n";
+ echo " <div class=\"news_title\">" .
+ htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n";
+ echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ echo " <div class=\"news_description\">" .
+ htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n";
+ echo "</div>\n";
+ }
+ */
+ public function RSSEntry($title, $time, $category, $description)
+ {
+ $this->title = $title;
+ $this->time = $time;
+ $this->category = $category;
+ $this->description = $description;
+ }
+}
+
+class RSS {
+
+ private $newsfile;
+ private $rssfile;
+ private $news = array();
+
+ public function add($newsentry) {
+ $key = $newsentry->time;
+ $this->news[$key] = $newsentry;
+ }
+
+ private function date($time) {
+ return date("r", $time);
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->rssfile, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ fwrite($fp, "<rss version=\"2.0\">\n");
+ fwrite($fp, " <channel>\n");
+ fwrite($fp, " <title>DIE News</title>\n");
+ fwrite($fp, " <link>http://www.executionroom.com</link>\n");
+ fwrite($fp, " <description>DIE - News from ExecutionRoom.com</description>\n");
+ fwrite($fp, " <language>en-us</language>\n");
+ fwrite($fp, " <pubDate>".$this->date(time())."</pubDate>\n");
+ fwrite($fp, " <lastBuildDate>".$this->date(time())."</lastBuildDate>\n");
+ fwrite($fp, " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n");
+ fwrite($fp, " <generator>ExecutionRoom CMS</generator>\n");
+ fwrite($fp, " <managingEditor>info@executionroom.com</managingEditor>\n");
+ fwrite($fp, " <webMaster>info@executionroom.com</webMaster>\n");
+
+ $i = 0;
+ foreach($this->news as $newsentry) {
+ fwrite($fp, " <item>\n");
+ fwrite($fp, " <title>".$newsentry->title."</title>\n");
+ fwrite($fp, " <link>http://www.executionroom.com/?page=news&amp;id=".$newsentry->time."</link>\n");
+ fwrite($fp, " <description>".$newsentry->description."</description>\n");
+ fwrite($fp, " <pubDate>".$this->date($newsentry->time)."</pubDate>\n");
+ fwrite($fp, " <guid>http://www.executionroom.com/?page=news&amp;id=".$newsentry->time."</guid>\n");
+ fwrite($fp, " </item>\n");
+ $i++;
+ if($i > 6) break;
+ }
+
+ fwrite($fp, " </channel>\n");
+ fwrite($fp, "</rss>\n");
+
+ fclose($fp);
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->newsfile);
+ $params = $dom->getElementsByTagName('newsentry');
+
+ foreach ($params as $param) {
+ $rssentry = new RSSEntry($param->getAttribute('title'),
+ $param->getAttribute('time'),
+ $param->getAttribute('category'),
+ $param->getAttribute('description'));
+ $this->add($rssentry);
+ }
+
+ // Key sort
+ krsort($this->news);
+ }
+
+ public function RSS($newsfile, $rssfile)
+ {
+ $this->newsfile = $newsfile;
+ $this->rssfile = $rssfile;
+ $this->read();
+ }
+
+}
+
+?>
diff --git a/utils/thumbnail.php b/utils/thumbnail.php
new file mode 100644
index 0000000..f1f4b38
--- /dev/null
+++ b/utils/thumbnail.php
@@ -0,0 +1,39 @@
+<?php
+function thumbnail($album, $file, $maxwidth, $maxheight) {
+ global $ALBUMS_DIR;
+
+ if($file =="") return "No such image";
+
+ // Config
+ $quality = 70;
+ $width = $maxwidth;
+ $height = $maxheight;
+
+ // Filenames
+ $thumbnaildir = $ALBUMS_DIR . "/" . $album . "/thumbnails/";
+ $thumbnail = $thumbnaildir . $maxwidth . "x" . $maxheight . "_" . $file;
+ $original = $ALBUMS_DIR . "/" . $album . "/" . $file;
+
+ if(!file_exists($thumbnaildir)) {
+ // The thumbnaildir doesn't exist, create it.
+ mkdir($thumbnaildir, 0755);
+ }
+
+ // Create thumbnail
+ if(!file_exists($thumbnail)) {
+ list($width_orig, $height_orig) = getimagesize($original);
+ if ($width && ($width_orig < $height_orig)) {
+ $width = ($height / $height_orig) * $width_orig;
+ } else {
+ $height = ($width / $width_orig) * $height_orig;
+ }
+ $image_p = imagecreatetruecolor($width, $height);
+ $image = imagecreatefromjpeg($original);
+ imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
+ imagejpeg($image_p, $thumbnail, $quality);
+ }
+
+ // Return thumbnail filename
+ return $thumbnail;
+}
+?> \ No newline at end of file
diff --git a/utils/user.php b/utils/user.php
new file mode 100644
index 0000000..508f83d
--- /dev/null
+++ b/utils/user.php
@@ -0,0 +1,151 @@
+<?php
+
+include_once("convert.php");
+
+class User {
+ public $userid;
+ public $password;
+ public $users;
+ public $news;
+ public $events;
+ public $guestbook;
+ public $gallery;
+ public $user;
+ public $newsletter;
+ public $pressrelease;
+
+ public function checkPassword($password) {
+ return $this->password == sha1(md5($password));
+ }
+
+ public function setPassword($oldpassword, $password1, $password2) {
+ if($this->checkPassword($oldpassword) == false) { // Doublecheck the validity of the user.
+ echo "<p>Current password is incorrect!</p>\n";
+ return 1;
+ }
+
+ if($password1 != $password2) { // Check if passowrds match.
+ echo "<p>Passwords do not match!</p>\n";
+ return 1;
+ }
+
+ echo "<p>Password updated successfully!</p>\n";
+
+ $this->password = sha1(md5($password1));
+ return 0;
+ }
+
+ public function User($userid, $password, $users, $news, $events, $guestbook, $gallery, $user, $newsletter, $pressrelease)
+ {
+ $this->userid = $userid;
+ $this->password = $password;
+ $this->users = $users;
+ $this->news = $news;
+ $this->events = $events;
+ $this->guestbook = $guestbook;
+ $this->gallery = $gallery;
+ $this->user = $user;
+ $this->newsletter = $newsletter;
+ $this->pressrelease = $pressrelease;
+ }
+}
+
+class Users {
+
+ private $file;
+ private $users = array();
+
+ public function add($user) {
+ $key = $user->userid;
+ $this->users[$key] = $user;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+ fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+
+ fwrite($fp, "<users>\n");
+ foreach($this->users as $user) {
+ fwrite($fp, " <user userid=\"" .
+ htmlspecialchars($user->userid, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " password=\"" . $user->password . "\"\n");
+ fwrite($fp, " users=\"" . $user->users . "\"\n");
+ fwrite($fp, " news=\"" . $user->news . "\"\n");
+ fwrite($fp, " events=\"" . $user->events . "\"\n");
+ fwrite($fp, " guestbook=\"" . $user->guestbook . "\"\n");
+ fwrite($fp, " gallery=\"" . $user->gallery . "\"\n");
+ fwrite($fp, " user=\"" . $user->user . "\"\n");
+ fwrite($fp, " newsletter=\"" . $user->newsletter . "\"\n");
+ fwrite($fp, " pressrelease=\"" . $user->pressrelease . "\">\n");
+ fwrite($fp, " </user>\n");
+ }
+ fwrite($fp, "</users>\n");
+
+ fclose($fp);
+ }
+
+ public function deleteUser($userid)
+ {
+ if($userid != "admin") {
+ if($this->users[$userid]) {
+ unset($this->users[$userid]);
+ $this->write();
+ } else {
+ echo "<p>ERROR: User! <em>".$userid."</em> does not exist!</p>\n";
+ return false;
+ }
+ } else {
+ echo "<p>ERROR: You cannot delete the admin user!</p>\n";
+ return false;
+ }
+ return true;
+ }
+
+ public function findUser($userid)
+ {
+ $user = $this->users[$userid];
+ return $user;
+ }
+
+ public function useridList()
+ {
+ $useridlist = array();
+ foreach($this->users as $user) {
+ array_push($useridlist, $user->userid);
+ }
+ return $useridlist;
+ }
+
+ private function read()
+ {
+
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $params = $dom->getElementsByTagName('user');
+
+ foreach ($params as $param) {
+ $user = new User($param->getAttribute('userid'),
+ $param->getAttribute('password'),
+ $param->getAttribute('users'),
+ $param->getAttribute('news'),
+ $param->getAttribute('events'),
+ $param->getAttribute('guestbook'),
+ $param->getAttribute('gallery'),
+ $param->getAttribute('user'),
+ $param->getAttribute('newsletter'),
+ $param->getAttribute('pressrelease'));
+ $this->add($user);
+ }
+
+ }
+
+ public function Users($file)
+ {
+ $this->file = $file;
+ $this->read();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/utils/xml.php b/utils/xml.php
new file mode 100644
index 0000000..69059b0
--- /dev/null
+++ b/utils/xml.php
@@ -0,0 +1,126 @@
+<?php
+
+class XMLDOMAttribute
+{
+ public $name;
+ public $value;
+}
+
+class XMLDOMNode
+{
+ public $parentnode;
+ public $name;
+ public $contents;
+ public $attributes = array();
+ public $children = array();
+
+ public function XMLDOMNode(&$parentnode)
+ {
+ $this->parentnode = &$parentnode;
+ }
+
+ public function addNode(&$node)
+ {
+ echo "<p>" . $this->name . "::addNode(" . $node->name . ")</p>";
+ // $node->parent = &$this;
+ array_push($this->children, &$node);
+ }
+
+ public function addAttribute($name, $value)
+ {
+ // echo "<p>" . $this->name . "::addAttribute(" . $name . ", ". $value . ")</p>";
+ $attribute = new XMLDOMAttribute();
+ $attribute->name = strtolower($name);
+ $attribute->value = $value;
+ array_push($this->attributes, &$attribute);
+ }
+
+}
+
+class XMLDOMReader
+{
+ private $parent;
+ private $curnode;
+ public $root;
+
+ private function startThreadElement($parser, $name, $attribs)
+ {
+ $this->parent = &$this->curnode;
+
+ $this->curnode = new XMLDOMNode(&$this->parent);
+ $this->curnode->name = $name;
+
+ while (list($name, $value) = each($attribs)) {
+ $this->curnode->addAttribute($name, $value);
+ }
+
+ $this->parent->addNode(&$this->curnode);
+ }
+
+ private function dataThreadElement($parser, $data)
+ {
+ $this->curnode->contents = $data;
+ }
+
+ private function endThreadElement($parser, $name)
+ {
+ $this->curnode = &$this->parent;
+ }
+
+ public function XMLDOMReader($file)
+ {
+ $doc = new DOMDocument();
+ $doc->load('book.xml');
+ echo $doc->saveXML();
+
+ /*
+ $this->root = new XMLDOMNode(&$this->root);
+ $this->root->name = "root";
+ $this->parent = &$this->root;
+
+ // parse the xml file
+ $xml_parser = xml_parser_create("ISO-8859-1");
+ xml_set_element_handler($xml_parser, "startThreadElement", "endThreadElement");
+ xml_set_character_data_handler($xml_parser, "dataThreadElement");
+ xml_set_object ( $xml_parser, $this );
+
+ $data = file_get_contents($file);
+
+ if (!xml_parse($xml_parser, $data, true)) {
+ die(sprintf("XML error: %s at line %d",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+ }
+ xml_parser_free($xml_parser);
+ */
+
+ // $parent;
+ /*
+ $this->root = new XMLDOMNode(&$this->root);
+ $this->root->name = "Root";
+
+ $node0 = new XMLDOMNode(&$this->root);
+ $node0->name = "Node1";
+ array_push($this->root->children, &$node0);
+ // $this->root->addNode(&$node0);
+
+ $node1 = new XMLDOMNode(&$node0);
+ $node1->name = "Node1.1";
+ array_push($node0->children, &$node1);
+ // $node0->addNode(&$node1);
+
+ $node2 = new XMLDOMNode(&$node0);
+ $node2->name = "Node1.2";
+ array_push($node0->children, &$node2);
+ // $node0->addNode(&$node2);
+
+ echo "\n<pre>";
+ echo $this->root . " - " . $node0 . " - " . $node1 . " - " . $node2 . "\n";
+ print_r($this->root);
+ echo "</pre>\n";
+ */
+ }
+}
+
+
+?> \ No newline at end of file