From cce5e7710295021b41d9aaecc503a60fb99256be Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 4 Oct 2008 10:38:03 +0000 Subject: Initial revision --- forum/utils/calendar.php | 112 +++++++++++++++++++ forum/utils/clientinfo.php | 24 ++++ forum/utils/convert.php | 18 +++ forum/utils/edit.php | 89 +++++++++++++++ forum/utils/editor.php | 154 ++++++++++++++++++++++++++ forum/utils/editor_form.php | 127 ++++++++++++++++++++++ forum/utils/error.php | 6 + forum/utils/events.php | 141 ++++++++++++++++++++++++ forum/utils/filehandler.php | 33 ++++++ forum/utils/files.php | 134 +++++++++++++++++++++++ forum/utils/forums.php | 133 ++++++++++++++++++++++ forum/utils/log.php | 10 ++ forum/utils/login.php | 105 ++++++++++++++++++ forum/utils/mimetypes.php | 50 +++++++++ forum/utils/notify.php | 70 ++++++++++++ forum/utils/parser.php | 126 +++++++++++++++++++++ forum/utils/ping.php | 126 +++++++++++++++++++++ forum/utils/posts.php | 254 +++++++++++++++++++++++++++++++++++++++++++ forum/utils/profile.php | 39 +++++++ forum/utils/roadmap.php | 70 ++++++++++++ forum/utils/smileys.php | 38 +++++++ forum/utils/threads.php | 162 +++++++++++++++++++++++++++ forum/utils/users.php | 136 +++++++++++++++++++++++ forum/utils/view.php | 28 +++++ utils/admin_events.php | 85 +++++++++++++++ utils/admin_gallery.php | 108 ++++++++++++++++++ utils/admin_guestbook.php | 2 + utils/admin_news.php | 121 +++++++++++++++++++++ utils/admin_newsletter.php | 55 ++++++++++ utils/admin_pressrelease.php | 55 ++++++++++ utils/admin_user.php | 32 ++++++ utils/admin_users.php | 203 ++++++++++++++++++++++++++++++++++ utils/album.php | 137 +++++++++++++++++++++++ utils/convert.php | 11 ++ utils/events.php | 130 ++++++++++++++++++++++ utils/guestbook.php | 169 ++++++++++++++++++++++++++++ utils/links.php | 128 ++++++++++++++++++++++ utils/log.php | 15 +++ utils/login.php | 67 ++++++++++++ utils/news.php | 103 ++++++++++++++++++ utils/newsletter.php | 146 +++++++++++++++++++++++++ utils/pressrelease.php | 165 ++++++++++++++++++++++++++++ utils/rss.php | 112 +++++++++++++++++++ utils/thumbnail.php | 39 +++++++ utils/user.php | 151 +++++++++++++++++++++++++ utils/xml.php | 126 +++++++++++++++++++++ 46 files changed, 4345 insertions(+) create mode 100644 forum/utils/calendar.php create mode 100644 forum/utils/clientinfo.php create mode 100644 forum/utils/convert.php create mode 100644 forum/utils/edit.php create mode 100644 forum/utils/editor.php create mode 100644 forum/utils/editor_form.php create mode 100644 forum/utils/error.php create mode 100644 forum/utils/events.php create mode 100644 forum/utils/filehandler.php create mode 100644 forum/utils/files.php create mode 100644 forum/utils/forums.php create mode 100644 forum/utils/log.php create mode 100644 forum/utils/login.php create mode 100644 forum/utils/mimetypes.php create mode 100644 forum/utils/notify.php create mode 100644 forum/utils/parser.php create mode 100644 forum/utils/ping.php create mode 100644 forum/utils/posts.php create mode 100644 forum/utils/profile.php create mode 100644 forum/utils/roadmap.php create mode 100644 forum/utils/smileys.php create mode 100644 forum/utils/threads.php create mode 100644 forum/utils/users.php create mode 100644 forum/utils/view.php create mode 100644 utils/admin_events.php create mode 100644 utils/admin_gallery.php create mode 100644 utils/admin_guestbook.php create mode 100644 utils/admin_news.php create mode 100644 utils/admin_newsletter.php create mode 100644 utils/admin_pressrelease.php create mode 100644 utils/admin_user.php create mode 100644 utils/admin_users.php create mode 100644 utils/album.php create mode 100644 utils/convert.php create mode 100644 utils/events.php create mode 100644 utils/guestbook.php create mode 100644 utils/links.php create mode 100644 utils/log.php create mode 100644 utils/login.php create mode 100644 utils/news.php create mode 100644 utils/newsletter.php create mode 100644 utils/pressrelease.php create mode 100644 utils/rss.php create mode 100644 utils/thumbnail.php create mode 100644 utils/user.php create mode 100644 utils/xml.php 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 @@ +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(); + */ +} + +?> +

+[<] +   +[<<] +   + +   +[>>] +   +[>]
+[Today]
+

+\n"; + echo "
\n"; + $t = $date + $day * 24 * 60 * 60; + echo " " . date("l j/n", $t) . "\n"; +?> + [+] +\n"; + + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + echo "
4) echo " style=\"background: #311;\""; + echo ">\n"; + + $events->show($t, $t + 24 * 60 * 60); + + echo "
\n"; + echo "
\n"; + + } +} else { +?> + + +\n"; + $t = $date + $day * 24 * 60 * 60; + echo " " . date("l j/n", $t) . "\n"; + echo " \n"; +} +?> + + + 4) echo " style=\"background: #311;\""; + echo ">\n"; +?> + Add +show($t, $t + 24 * 60 * 60); + echo " \n"; +} +?> + +
+ + +
+Title:
+Desription:
+Date: ">
+From-Time:
+To-Time:
+
+ +
+ 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 @@ +"; +$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 @@ + \ 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 @@ +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 "

Return to thread.

\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 @@ + +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; + } +?> +
+;-) +;-) +;-) +;-) +B +I +U +[L  ] +[ C ] +[  R] +URL +E-Mail +Image +"Q" +c++ + + + + + + */ ?> +

+ Title: + +

+

+\"\""; +} +?> +

+

+ +

+

+ To make a link, simply type the URL, and the system will + automagically transform it into an anchor (remember the + http:// part).
+ Example: http://www.executionroom.com
+

+

+ 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 http:// part).
+ Example: http://www.executionroom.com/gfx/logos/die_logo_bloody.png +

+

+ +

+
+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 @@ + +
+ + + + + + + + + + + + +
Post Form
Logged in user:bent
Forum:Andet band relateret
Title:
Poll:[CREATE POLL]
Post Icon: + + + + +
No Icon
+
Smiley Shortcuts: +
[list all smilies] +
Embarassed Razz Mad Laughing Cool Confused Shocked Surprised Sad Smile Very Happy Crying or Very Sad Evil or Very Mad Twisted Evil Rolling Eyes Wink Exclamation Question Idea Arrow Neutral Grin Dead Frown Nod Proud Smug Thumbs Up Thumbs Down Uh Oh Bored 
Formatting Tools: + + +
+ + + + + + + + + + + + + + + + + +
+
   + + + + + +
Body:

Forum Options
+HTML code is OFF
+ +FUDcode is ON
+Images are ON
+Smilies are ON
Editing Time Limit: Unlimited

File Attachments: + + +Allowed File Extensions: (unrestricted)
Maximum File Size: 10240Kb
Maximum Files per Message: 1 + +

+ + +

Options: + + + + + +
Post Notification
 Notify me when someone replies to this message.
Include Signature
 Include my profile signature.
Disable smilies in this message
+
+ + 
+ + + + + + + + + +
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 @@ +Error: " . $msg . "\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 @@ +getUser($this->user); + + echo "
\n"; + echo "
". $this->title . "\n"; + // echo " Edit\n"; + echo "
\n"; + echo "
" . date("G:i", $this->starttime) . " - " . + date("G:i", $this->starttime + $this->duration) . "
\n"; + if(!$client_is_mobile_device) { + echo "
". $this->description . "
\n"; + } else { + echo "
". $this->description . "
\n"; + } + echo "
By: ".$user->name . "
\n"; + // echo " Edit"; + echo "
\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->events as $event) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + /* + public function deleteForumUser($id) + { + if($this->members[$id]) { + unset($this->members[$id]); + // $this->write(); + } else { + echo "

ERROR: User! ".$id." does not exist!

\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 @@ +newFile($_FILES['userfile']['tmp_name'], $name); + } +} + +if($task == "delete" && $fid) { + $files->deleteFile($fid); +} + +$files->show(); + + +?> +
+

+ File: +

+

+ Use alternative filename (leave empty to use original filename): + +

+

+ +

+
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 @@ +fid; + } + + public function show() + { + global $PERMSTORE; + echo "
\n"; + echo " fid . "\">Delete\n"; + echo "
Filename: link() . "\">" . $this->name . "(" . $this->mimetype. ")
\n"; + echo "
Size: " . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb
\n"; + echo "
\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->files as $file) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\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 @@ +newStuff = $newStuff; + } + + public function show() + { + echo "
"; + if($this->newStuff) echo "
"; + else echo "
"; + echo "fid . "\">" . $this->name . ""; + echo "
"; + } + + 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, "\n"); + + fwrite($fp, "\n"); + foreach($this->members as $member) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + */ + } + + /* + public function deleteForumUser($id) + { + if($this->members[$id]) { + unset($this->members[$id]); + // $this->write(); + } else { + echo "

ERROR: User! ".$id." does not exist!

\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 @@ + \ 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 @@ +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 @@ +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 @@ +"; +$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 @@ +", $output); + $output = $smile; + } + + // Replace URLs with 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 . "\"""; + } else { + $urls .= $pre . "" . $url . ""; + } + $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("="), "
", $header); + $header = str_replace(array("[quote"), "
", $header); + $header = str_replace(array("]"), "
", $header); + + $urls .= $pre . $header . $body . "
"; + $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("="), "
", $header); + $header = str_replace(array("[quote"), "
", $header); + $header = str_replace(array("]"), "
", $header); + + $urls .= $pre . $header . $body . "
"; + $output = $post; + } + $urls .= $output; + $output = $urls; + + // + $b = array("[b]", "[B]"); + $b = str_replace($b, "", $output); + $output = $b; + + $b = array("[/b]", "[/B]"); + $b = str_replace($b, "", $output); + $output = $b; + + // + $i = array("[i]", "[I]"); + $i = str_replace($i, "", $output); + $output = $i; + + $i = array("[/i]", "[/i]"); + $i = str_replace($i, "", $output); + $output = $i; + + // Replace newlines with
tags + $nls = array("\n"); + $nls = str_replace($nls, "
\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 @@ +> 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 @@ +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 . " " . convert_xml($this->message) . "\n"); + + foreach($this->replies as $reply) { + $reply->write($fp, $indent . " "); + } + + fwrite($fp, $indent . "\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 . "
\n"; + if($client_is_mobile_device) { + $avatar = "mobileavatar.gif"; + } else { + if($user->avatar) $avatar = $user->avatar; + else $avatar = "default.gif"; + } + echo $indent . " \"avatar\"\n"; + if(!$client_is_mobile_device) { + echo $indent . "
ID: " . $this->pid . "
\n"; + echo $indent . "
Title: " . convert_xml($this->title) . "
\n"; + } + echo $indent . "
"; + if(!$client_is_mobile_device) echo "UserID: "; + echo $user->name . "
\n"; + echo $indent . "
"; + if(!$client_is_mobile_device) echo "Date: "; + echo date("j. M Y - G:i", $this->date) . "
\n"; + echo $indent . "
\n"; + echo parse($this->message, $indent . " ") . "\n"; + echo $indent . "
\n"; + echo $indent . "
\n"; + + if($current_user->uid == $this->user) { + echo $indent . + " "; + echo "\"edit\"\n"; + } + + echo $indent . + " "; + echo "\"quote\"\n"; + + echo $indent . + " "; + echo "\"reply\"\n"; + + echo $indent . "
\n"; + echo $indent . "
\n"; + + if($recurse) { + foreach($this->replies as $reply) { + $reply->show($indent . " "); + } + } + + echo $indent . "
\n"; + echo $indent . "
\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, "\n"); + + if($this->thread->lastseen) { + foreach($this->thread->lastseen as $key => $value) { + if($lastseenstr != "") $lastseenstr .= ","; + $lastseenstr .= $key . "=" . $value; + } + } + + fwrite($fp, "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, "\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 "

" . $this->thread->name . "

"; + + /* // 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 "

Back to the top

"; + } + + 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 @@ +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(); +} +?> + +
+username; ?>">
*/ ?> +Name:
+New password:
+Confirm password:
+E-Mail:
+Avatar:
+
+ +
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 @@ +file, "w"); + + $block = TRUE; + flock($fp, LOCK_EX, $block); // do an exclusive lock + + fwrite($fp, "\n"); + + fwrite($fp, " . "\"\n"); + fwrite($fp, " abc=\"" . . "\">\n"); + + // for each group + for($gid = 0; $gid < length($groups); $gid++) { + fwrite($fp, " \n"); + + for($iid = 0; $iid < length($groups[$gid]); $iid++) { + fwrite($fp, " \n"); + } + + fwrite($fp, " \n"); + } + + fwrite($fp, "\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 @@ +", "->"), "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 @@ + + * + * . + * . + * . + * + */ + +class Thread { + public $tid; + public $name; + public $lastseen = array(); + public $lastpost; + + public function show() + { + global $fid, $current_user; + echo "
"; + if($this->lastseen[$current_user->uid] < $this->lastpost) echo "
"; + else echo "
"; + echo "" . $this->name . ""; + echo "
"; + } + + 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, "\n"); + + fwrite($fp, "\n"); + foreach($this->members as $member) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + */ + } + + /* + public function deleteForumUser($id) + { + if($this->members[$id]) { + unset($this->members[$id]); + // $this->write(); + } else { + echo "

ERROR: User! ".$id." does not exist!

\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 @@ +password == sha1(md5($password)); + } + + public function write($fp) + { + fwrite($fp, " 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, " \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, "\n"); + + fwrite($fp, "\n"); + foreach($this->users as $user) { + $user->write($fp); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + /* + public function deleteForumUser($id) + { + if($this->members[$id]) { + unset($this->members[$id]); + // $this->write(); + } else { + echo "

ERROR: User! ".$id." does not exist!

\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 @@ +"; +if($fid) echo "forums"; +if($tid) echo ":: threads"; +if($pid) echo ":: posts"; +echo "\n"; + + + if($fid && $tid) { + // echo "

Posts

"; + include_once("posts.php"); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $posts->show(); + } else if($fid) { + echo "

Threads

"; + echo "New thread"; + + include_once("threads.php"); + $threads = new Threads($FORUMS_DIR . "/" . $fid); + $threads->show(); + } else { + echo "

Forums

"; + 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 @@ +

Events

+show(); +?> +Is this correct?
+
+ + + + + + +
+
+ + + + + + +
+ + +add($event); + $events->write(); + + echo "

Event posted successfully.

"; + $title = ""; + $day = ""; + $month = ""; + $year = ""; + $description = ""; +} +?> + + +
Post event
+
+

+ Title: +

+

+ Date: / + - + +

+

+ Description:
+ +

+ +
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 @@ +

Gallery

+ + + +"; + echo $albumcopyright . "
"; + echo $albumdir . "
"; + mkdir($albumdir); + $xml = "\n"; + $xml .= "\n"; + $xml .= "\n"; + $fp = fopen($albumdir . "/album.xml", "w"); + fprintf($fp, $xml); + fclose($fp); +} +?> + +"; + echo $description . "
"; + echo $_FILES['userfile']['tmp_name'] . "
"; + + 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'] . "'."; + } + } +} +?> + +
New album
+
+

+ Title: +

+

+ Copyright: +

+

+ +

+
+ +
Upload image
+
+

+ Album: + +

+

+ Description: + +

+

+ Upload this image: + +

+

+ +

+
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 @@ +

Guestbook

+... 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 @@ +

News

+show(); + + echo "

Category: " . $category . "

\n"; + if($newsletter) echo "

WARNING: This news will be sent out a newsletter if yes is pressed.

\n"; +?> +Is this news correct?
+
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
+ + +add($newsentry); + $news->write(); + + // Now update the RSS feed. + $rss = new RSS($DATA_DIR."/news.xml", "rss.xml"); + $rss->write(); + + echo "

News posted successfully.

"; + + // if($newsletter == "on") sendNewsLetter($title, $description); + + $title = ""; + $category = ""; + $newsletter = ""; + $day = ""; + $month = ""; + $year = ""; + $hour = ""; + $minute = ""; + $second = ""; + $description = ""; +} +?> + + + +
Post news
+
+ Title:
+ Category: +
+ Date: / + - +
+ Time: : + : +
+ Description:
+ +
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 @@ +

Newsletter

+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?
+
+ + + + +
+
+ + + + +
+ + +post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +
Post newsletter
+
+

+ Test address: + +

+

+ Subject: + +

+

+ Message:
+ +

+

+ +

+
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 @@ +

Pressrelease

+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?
+
+ + + + +
+
+ + + + +
+ + +post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +
Post pressrelease
+
+

+ Test address: + +

+

+ Subject: + +

+

+ Message:
+ +

+

+ +

+
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 @@ +

Password

+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(); +} +?> + +
Change password
+
+

+ Old password: + +

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
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 @@ +

Users

+ + + +
Add user
+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 "

User " . $newuserid . " added successfully.

\n"; + } else { + echo "

ERROR: User " . $newuserid . " already exists.

\n"; + } + } else { + echo "

ERROR: Passwords do not match.

\n"; + } +} +?> +
+

+ UserID: +

+

+ /> + Add/edit.delete users:
+ /> + Change password:
+ /> + Add news:
+ /> + Add events:
+ /> + Add images in gallery:
+ /> + Send newsletter:
+ /> + Modify guestbook +

+

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
+ +
Edit user
+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 "

User " . $edituserid . " successfully updated.

\n"; + } else { + echo "

ERROR: Passwords do not match

\n"; + $task = "edituser"; + } + } else { + $users->add($user); + $users->write(); + echo "

User " . $edituserid . " successfully updated. Password left untouched.

\n"; + } +} +?> +findUser($edituserid); +?> +
+

+ UserID: +

+

+ users == "on") echo "checked"; ?>/> + Add/edit.delete users:
+ user == "on") echo "checked"; ?>/> + Change password:
+ news == "on") echo "checked"; ?>/> + Add news:
+ events == "on") echo "checked"; ?>/> + Add events:
+ gallery == "on") echo "checked"; ?>/> + Add images in gallery:
+ newsletter == "on") echo "checked"; ?>/> + Send newsletter:
+ guestbook == "on") echo "checked"; ?>/> + Modify guestbook +

+

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
+ +
+

+ Select the user you want to edit:
+ + +

+
+ +
Delete user
+ +Are you sure you want to delete the user?
+
+ + +
+
+ + +
+ + +deleteUser($deleteuserid)) { + echo "

User ".$deleteuserid." deleted successfully.

\n"; + } +} +?> +
+

+ Select the user you want to delete:
+ + +

+
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 @@ +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, "\n"); + + fwrite($fp, "title . "\" icon=\"".$this->icon."\" copyright=\"" . $this->copyright . "\">\n"); + foreach($this->photos as $photo) { + fwrite($fp, " file . "\"\n"); + fwrite($fp, " text=\"" . $photo->text . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\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 "

".$numalbums . " " .$ralbum . " ".$numphotos . " ".$rphoto . "

"; + + 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 @@ + \ 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 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + if($this->flyer) { + echo " \"flyer\"flyer . "\"/>\n"; + } + echo "\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->events as $event) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\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 @@ +title = $title; + $this->email = $email; + $this->time = $time; + $this->remoteaddr = $remoteaddr; + $this->text = $text; + } + + public function show() + { + echo "
\n"; + echo "
" . $this->title . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . str_replace("@", "(A)", $this->email) . "
\n"; + echo "
" . $this->text . "
\n"; + echo "
\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->guestbook as $entry) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\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"); +?> + + +404 Not Found + +

Not Found

+

The requested URL /?page=guestbook was not found on this server.

+
+
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
+ + \ 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 @@ +title = $title; + $this->href = $href; + $this->icon = $icon; + } + + public function show() + { + echo "\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 "
\n"; + echo "
". htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + foreach($this->links as $link) { + $link->show(); + } + echo "
\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->links as $link) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\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 @@ + \ 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 @@ +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 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + echo "\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->news as $newsentry) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\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 @@ +"; +$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, "\n"); + + fwrite($fp, "\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\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 "
Sending ". $sz ." mails
\n<"; + 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("%.0f%%", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "[100%]>\n
done
\n"; + echo "[CLOSE]"; + echo "
\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 @@ + + + + + + + + + + + + + **/ + + +/** + * CONFIG + */ +$subject_prefix = "DIE Pressrelease"; +$sender = "DIE "; +$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, "\n"); + + fwrite($fp, "\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\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 "
Sending ". $sz ." mails
\n<"; + 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("%.0f%%", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "[100%]>\n
done
\n"; + echo "[CLOSE]"; + echo "
\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 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + echo "\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, "\n"); + fwrite($fp, "\n"); + fwrite($fp, " \n"); + fwrite($fp, " DIE News\n"); + fwrite($fp, " http://www.executionroom.com\n"); + fwrite($fp, " DIE - News from ExecutionRoom.com\n"); + fwrite($fp, " en-us\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " http://blogs.law.harvard.edu/tech/rss\n"); + fwrite($fp, " ExecutionRoom CMS\n"); + fwrite($fp, " info@executionroom.com\n"); + fwrite($fp, " info@executionroom.com\n"); + + $i = 0; + foreach($this->news as $newsentry) { + fwrite($fp, " \n"); + fwrite($fp, " ".$newsentry->title."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " ".$newsentry->description."\n"); + fwrite($fp, " ".$this->date($newsentry->time)."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " \n"); + $i++; + if($i > 6) break; + } + + fwrite($fp, " \n"); + fwrite($fp, "\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 @@ + \ 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 @@ +password == sha1(md5($password)); + } + + public function setPassword($oldpassword, $password1, $password2) { + if($this->checkPassword($oldpassword) == false) { // Doublecheck the validity of the user. + echo "

Current password is incorrect!

\n"; + return 1; + } + + if($password1 != $password2) { // Check if passowrds match. + echo "

Passwords do not match!

\n"; + return 1; + } + + echo "

Password updated successfully!

\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, "\n"); + + fwrite($fp, "\n"); + foreach($this->users as $user) { + fwrite($fp, " 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, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + public function deleteUser($userid) + { + if($userid != "admin") { + if($this->users[$userid]) { + unset($this->users[$userid]); + $this->write(); + } else { + echo "

ERROR: User! ".$userid." does not exist!

\n"; + return false; + } + } else { + echo "

ERROR: You cannot delete the admin user!

\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 @@ +parentnode = &$parentnode; + } + + public function addNode(&$node) + { + echo "

" . $this->name . "::addNode(" . $node->name . ")

"; + // $node->parent = &$this; + array_push($this->children, &$node); + } + + public function addAttribute($name, $value) + { + // echo "

" . $this->name . "::addAttribute(" . $name . ", ". $value . ")

"; + $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
";
+		echo $this->root . " - " . $node0 . " - " . $node1 . " - " . $node2 . "\n";
+		print_r($this->root);
+		echo "
\n"; + */ + } +} + + +?> \ No newline at end of file -- cgit v1.2.3