From 42c62cb041a2b2b95c9cda0c20fcf70334fd244c Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 1 Nov 2011 09:32:21 +0000 Subject: Rewl og krat... needs cleaning up - after port to GIT. --- forum/utils/addressbook.php | 279 ++++++++++++++++++++++--------------------- forum/utils/cache.php | 147 +++++++++++++++++++++++ forum/utils/calendar.php | 283 ++++++++++++++++++++++++-------------------- forum/utils/contacts.php | 90 ++++++++------ forum/utils/edit.php | 18 ++- forum/utils/editor.php | 236 +++++++++++++++--------------------- forum/utils/error.php | 3 +- forum/utils/events.php | 79 ++++++++++--- forum/utils/filehandler.php | 59 ++++----- forum/utils/files.php | 62 ++++++---- forum/utils/forums.php | 52 ++++++-- forum/utils/mimetypes.php | 2 +- forum/utils/notify.php | 1 + forum/utils/posts.php | 82 +++++++------ forum/utils/profile.php | 91 +++++++------- forum/utils/smileys.php | 1 + forum/utils/tasks.php | 145 ++++++++++++----------- forum/utils/threads.php | 32 +++-- forum/utils/view.php | 105 ++++++++-------- 19 files changed, 1036 insertions(+), 731 deletions(-) create mode 100644 forum/utils/cache.php (limited to 'forum/utils') diff --git a/forum/utils/addressbook.php b/forum/utils/addressbook.php index 20548ce..240831f 100644 --- a/forum/utils/addressbook.php +++ b/forum/utils/addressbook.php @@ -1,5 +1,4 @@ -
- - Name:
- c/o:
- Address:
- City:
- Country:
- Phone:
- Phone2:
- Email:
- Email2:
- URL:
- URL2:
- Essential: > (show on frontpage)
- Notes:
-
- -
-add($contactgroup); - $contacts->write(); - $gid = 0; -} - -elseif($action == "addcontact" && $gid && $cid) { - $contact = new Contact($cid, - $name, - $co, - $address, - $city, - $country, - $phone, - $phone2, - $email, - $email2, - $url, - $url2, - $essential, - $notes); - $contactgroup = $contacts->getContactGroup($gid); - $contactgroup->add($contact); - $contacts->write(); - $cid = 0; -} - -elseif($action =="editcontact" && $cid) { - $contact = $contacts->getContact($cid); - form($contact->cid, - "?mode=addressbook&action=updatecontact".$gid, - "Update contact", - $contact->name, - $contact->co, - $contact->address, - $contact->city, - $contact->country, - $contact->phone, - $contact->phone2, - $contact->email, - $contact->email2, - $contact->url, - $contact->url2, - $contact->essential, - $contact->notes); + $str = ""; + + $str .= "
\n"; + $str .= " \n"; + $str .= " Name:
\n"; + $str .= " c/o:
\n"; + $str .= " Address:
\n"; + $str .= " City:
\n"; + $str .= " Country:
\n"; + $str .= " Phone:
\n"; + $str .= " Phone2:
\n"; + $str .= " Email:
\n"; + $str .= " Email2:
\n"; + $str .= " URL:
\n"; + $str .= " URL2:
\n"; + $ess = ""; + if($essential == "on") $ess = " checked"; + $str .= " Essential: (show on frontpage)
\n"; + $str .= " Notes:
\n"; + $str .= "
\n"; + $str .= " \n"; + $str .= "
\n"; + + return $str; } -elseif($action == "updatecontact" && $cid) { - $contact = $contacts->getContact($cid); - - $contact->name = $name; - $contact->co = $co; - $contact->address = $address; - $contact->city = $city; - $contact->country = $country; - $contact->phone = $phone; - $contact->phone2 = $phone2; - $contact->email = $email; - $contact->email2 = $email2; - $contact->url = $url; - $contact->url2 = $url2; - $contact->essential = $essential; - $contact->notes = $notes; - - $contacts->write(); - - $contact->show(); -} - -elseif($cid) { - $contact = $contacts->getContact($cid); - $contact->show(); -} - -elseif($gid) { - $contactgroup = $contacts->getContactGroup($gid); - $contactgroup->show(); - - form($contacts->getNextCID(), - "?mode=addressbook&action=addcontact&gid=".$gid, - "Add contact"); - -} else { - $contacts->show(); - if($current_user->uid == 0) { -?> -
- - Name: - -
-add($contactgroup); + $contacts->write(); + $gid = 0; + } + + elseif($GLOBALS['action'] == "addcontact" && $gid && $cid) { + $contact = new Contact($cid, + $name, + $co, + $address, + $city, + $country, + $phone, + $phone2, + $email, + $email2, + $url, + $url2, + $essential, + $notes); + $contactgroup = $contacts->getContactGroup($gid); + $contactgroup->add($contact); + $contacts->write(); + $cid = 0; + } + + elseif($GLOBALS['action'] =="editcontact" && $cid) { + $contact = $contacts->getContact($cid); + $str .= form($contact->cid, + "?mode=addressbook&action=updatecontact".$gid, + "Update contact", + $contact->name, + $contact->co, + $contact->address, + $contact->city, + $contact->country, + $contact->phone, + $contact->phone2, + $contact->email, + $contact->email2, + $contact->url, + $contact->url2, + $contact->essential, + $contact->notes); + } + + elseif($GLOBALS['action'] == "updatecontact" && $cid) { + $contact = $contacts->getContact($cid); + + $contact->name = $name; + $contact->co = $co; + $contact->address = $address; + $contact->city = $city; + $contact->country = $country; + $contact->phone = $phone; + $contact->phone2 = $phone2; + $contact->email = $email; + $contact->email2 = $email2; + $contact->url = $url; + $contact->url2 = $url2; + $contact->essential = $essential; + $contact->notes = $notes; + + $contacts->write(); + + $str .= $contact->show(); + } + + elseif($cid) { + $contact = $contacts->getContact($cid); + $str .= $contact->show(); + } + + elseif($gid) { + $contactgroup = $contacts->getContactGroup($gid); + $str .= $contactgroup->show(); + + $str .= form($contacts->getNextCID(), + "?mode=addressbook&action=addcontact&gid=".$gid, + "Add contact"); + + } else { + $str .= $contacts->show(); + if($current_user->uid == 0) { + + $str .= "
\n"; + $str .= " getNextGID()) . "\">\n"; + $str .= " Name: \n"; + $str .= " \n"; + $str .= "
\n"; + + } + } + + return $str; } - ?> \ No newline at end of file diff --git a/forum/utils/cache.php b/forum/utils/cache.php new file mode 100644 index 0000000..42e4ca0 --- /dev/null +++ b/forum/utils/cache.php @@ -0,0 +1,147 @@ +id, ENT_QUOTES, "UTF-8") . "\">\n"); + + foreach($this->values as $key => $value) { + fwrite($fp, " "); + fwrite($fp, htmlspecialchars($value, ENT_QUOTES, "UTF-8")); + fwrite($fp, "\n"); + } + + fwrite($fp, " \n"); + } + + public function value($key) + { + if(!isset($this->values[$key])) return ""; + return $this->values[$key]; + } + + public function setValue($key, $value) + { + $this->values[$key] = $value; + } + + public function CacheEntry($id) + { + $this->id = $id; + } +} + +class Cache { + private $file; + public $entries = array(); + + public function rebuild($what = "all") + { + global $FORUMS_DIR, $users; + + + if($what == "all") $this->entries = array(); + + + if($what == "forum_numberofthreads" || $what == "all") { + $entry = new CacheEntry("forum_numberofthreads"); + + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + foreach($forums->forums as $forum) { + $threads = new Threads($FORUMS_DIR . "/" . $forum->fid); + $entry->setValue($forum->fid, sizeof($threads->threads)); + } + $this->add($entry); + } + + + if($what == "forum_lastpost" || $what == "all") { + $entry = new CacheEntry("forum_lastpost"); + + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + foreach($forums->forums as $forum) { + $threads = new Threads($FORUMS_DIR . "/" . $forum->fid); + + foreach($users->users as $user) { + + $unread = false; + foreach($threads->threads as $thread) { + if($thread->lastseen[$user->uid] < $thread->lastpost) { + $unread = true; + break; + } + } + + $entry->setValue($forum->fid . "-" . $user->uid, $unread); + } + + } + $this->add($entry); + } + + + $this->write(); + } + + public function add($entry) { + $key = $entry->id; + $this->entries[$key] = $entry; + } + + 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->entries as $entry) { + $entry->write($fp); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + public function get($id) + { + return $this->entries[$id]; + } + + private function read() + { + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $ces = $dom->getElementsByTagName('entry'); + + foreach($ces as $c) { + $entry = new CacheEntry($c->getAttribute('id')); + foreach($c->childNodes as $v) { + if($v->tagName != "value") continue; + $entry->setValue($v->getAttribute('key'), $v->textContent); + } + + $this->add($entry); + } + } + + public function Cache($file) + { + $this->file = $file; + if(file_exists($this->file)) $this->read(); + } + +} +?> diff --git a/forum/utils/calendar.php b/forum/utils/calendar.php index 318f458..0e7dba5 100644 --- a/forum/utils/calendar.php +++ b/forum/utils/calendar.php @@ -1,144 +1,173 @@ uid); - $events->add($event); - $events->write(); - - if($ZEND_DIR != "") googleCalendarEvent($event); - - if($DOKUWIKI_CALENDAR != "") { - $file = $DOKUWIKI_CALENDAR; - $fp = fopen($file, "w"); +function calendar() +{ + global $UTIL_DIR, $ZEND_DIR, $DOKUWIKI_CALENDAR, $GLOBALS, + $current_user, $DATA_DIR; + + include_once($UTIL_DIR . "/events.php"); + include_once($UTIL_DIR . "/notify.php"); + if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.php"); + + $str = ""; + + $events = new Events($DATA_DIR . "/calendar.xml"); + + foreach($events->events as $e) { + if($e->concert == "true") $str .= $e->show_simple(); + } + + if(!isset($GLOBALS['date'])) + $date = time() - (date("N", time()) - 1) * 24 * 60 * 60; + else + $date = $GLOBALS['date'] - (date("N", $GLOBALS['date'])-1) * 24 * 60 * 60; + + if($GLOBALS['action'] =="addentry") { + $title = stripslashes($GLOBALS['title']); + $description = stripslashes($GLOBALS['description']); + if($GLOBALS['concert'] == "on") $concert = "true"; + else $concert = "false"; + + $time = strtotime($GLOBALS['txtdate'] . " " . + $GLOBALS['txttimefrom'] . ":00"); + if($time !== FALSE) { + $duration = strtotime($GLOBALS['txtdate'] . " " . + $GLOBALS['txttimeto'] . ":00") - $time; + $eid = time(); + $event = new Event($eid, $title, $concert, $time, $duration, $description, + $current_user->uid); + $events->add($event); + $events->write(); + + if($ZEND_DIR != "") googleCalendarEvent($event); - fprintf($fp, "=====DIEs calendar=====\n"); - fprintf($fp, "Do not edit this file - it is automatically generated by the ExecutionRoom CMS.\n\n"); - fprintf($fp, "====Events====\n"); - foreach($events->events as $event) { - fprintf($fp, " * %s - %s %s: %s\n", - date("j.n.Y G:i", $event->starttime), - date("j.n.Y G:i", $event->starttime + $event->duration), - $event->title, $event->description); + if($DOKUWIKI_CALENDAR != "") { + $file = $DOKUWIKI_CALENDAR; + $fp = fopen($file, "w"); + + fprintf($fp, "=====DIEs calendar=====\n"); + fprintf($fp, "Do not edit this file - it is automatically generated " . + "by the ExecutionRoom CMS.\n\n"); + fprintf($fp, "====Events====\n"); + foreach($events->events as $event) { + fprintf($fp, " * %s - %s %s: %s\n", + date("j.n.Y G:i", $event->starttime), + date("j.n.Y G:i", $event->starttime + $event->duration), + $event->title, $event->description); + } + fclose($fp); } - fclose($fp); + + notify("calendar", "New calendar entry:\n" . $GLOBALS['title'] . "\n" . + date("r", $time) . "\n" . $GLOBALS['description'] . "\n" . + $FORUM_URL . "/?mode=calendar&date=" . $time); + + $str .= " \n"; + + } else { + $str .= "
ERROR: Date is not in the correct " . + "format! It was NOT posted. Please try again.
\n"; } + } - notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" . - $description . "\n" . - $FORUM_URL . "/?mode=calendar&date=" . $time); -?> - -delete($GLOBALS['eid']); + $events->write(); + } + + $str .= "

\n"; + $str .= "[<]\n"; + $str .= "  \n"; + $str .= "[<<]\n"; + $str .= "  \n"; + $str .= date("F Y", $date) . "\n"; + $str .= "  \n"; + $str .= "[>>] \n"; + $str .= "  \n"; + $str .= "[>]
\n"; + $str .= "[Today]
\n"; + $str .= "

\n"; + + if($client_is_mobile_device) { + for($day = 0; $day < 7; $day++) { + $str .= "
\n"; + $str .= "
\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= "[+]\n"; + $str .= "
\n"; + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + $str .= "
4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; + + $str .= $events->show($t, $t + 24 * 60 * 60); + + $str .= "
\n"; + $str .= "
\n"; + + } } else { - echo "
ERROR: Date is not in the correct format! It was NOT posted. Please try again.
\n"; - } -} + $str .= "\n"; + $str .= " \n"; -if($action=="edit") { - /* - $event = $events->getEvent($eid); - $event->duration += 2000; - $events->write(); - */ -} + for($day = 0; $day < 7; $day++) { + $str .= " \n"; + } -?> -

-[<] -   -[<<] -   - -   -[>>] -   -[>]
-[Today]
-

-\n"; - echo "
\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; -?> - [+] -\n"; + $str .= "
\n"; + $str .= " \n"; - $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); - echo "
4) echo " style=\"background: #311;\""; - echo ">\n"; + for($day = 0; $day < 7; $day++) { + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); - $events->show($t, $t + 24 * 60 * 60); + $str .= "
\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= "
4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; - echo " \n"; - echo " \n"; + $str .= " Add\n"; - } -} else { -?> - - -\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; - echo " \n"; -} -?> - - -show($t, $t + 24 * 60 * 60); + $str .= " \n"; + } - echo " \n"; -} -?> - -
4) echo " style=\"background: #311;\""; - echo ">\n"; -?> - Add -show($t, $t + 24 * 60 * 60); - echo "
-\n"; + $str .= "
\n"; + } + + if($GLOBALS['adddate'] != "") { + $str .= "
\n"; + $str .= "Title:
\n"; + $str .= "Concert:
\n"; + $str .= "Desription:
\n"; + $str .= "Date:
\n"; + $str .= "From-Time:
\n"; + $str .= "To-Time:
\n"; + $str .= "
\n"; + $str .= "\n"; + $str .= "
\n"; + } + + return $str; } ?> - -
-Title:
-Desription:
-Date: ">
-From-Time:
-To-Time:
-
- -
- diff --git a/forum/utils/contacts.php b/forum/utils/contacts.php index 7458108..7c67f92 100644 --- a/forum/utils/contacts.php +++ b/forum/utils/contacts.php @@ -39,27 +39,36 @@ class Contact { public function show() { - echo "

\n"; - // echo "\tcid: " . $this->cid . "
\n"; - echo "\tName: " . $this->name . "
\n"; - if($this->co) echo "\tc/o: " . $this->co . "
\n"; - if($this->address) echo "\tAddress: " . $this->address . "
\n"; - if($this->city) echo "\tCity: " . $this->city . "
\n"; - if($this->country) echo "\tCountry: " . $this->country . "
\n"; - if($this->phone) echo "\tPhone: " . $this->phone . "
\n"; - if($this->phone2) echo "\tPhone2: " . $this->phone2 . "
\n"; - if($this->email) echo "\tEmail: email . "\">" . $this->email . "
\n"; - if($this->email2) echo "\tEmail2: email2 . "\">" . $this->email2 . "
\n"; - if($this->url) echo "\tURL: url . "\">" . $this->url . "
\n"; - if($this->url2) echo "\tURL2: url2 . "\">" . $this->url2 . "
\n"; - if($this->notes) echo "\tNotes:
\n" . parse($this->notes) . "
\n"; - echo "\tcid . "\">Edit\n"; - echo "

\n"; + $str = ""; + + $str .= "

\n"; + // $str .= "\tcid: " . $this->cid . "
\n"; + $str .= "\tName: " . $this->name . "
\n"; + if($this->co) $str .= "\tc/o: " . $this->co . "
\n"; + if($this->address) $str .= "\tAddress: " . $this->address . "
\n"; + if($this->city) $str .= "\tCity: " . $this->city . "
\n"; + if($this->country) $str .= "\tCountry: " . $this->country . "
\n"; + if($this->phone) $str .= "\tPhone: " . $this->phone . "
\n"; + if($this->phone2) $str .= "\tPhone2: " . $this->phone2 . "
\n"; + if($this->email) $str .= "\tEmail: email . "\">" . $this->email . "
\n"; + if($this->email2) $str .= "\tEmail2: email2 . "\">" . $this->email2 . "
\n"; + if($this->url) $str .= "\tURL: url . "\">" . $this->url . "
\n"; + if($this->url2) $str .= "\tURL2: url2 . "\">" . $this->url2 . "
\n"; + if($this->notes) $str .= "\tNotes:
\n" . parse($this->notes) . "
\n"; + $str .= "\tcid . "\">Edit\n"; + $str .= "

\n"; + + return $str; } public function showshort() { - echo "
cid . "\">" . $this->name . "
"; + $str = ""; + + $str .= "
cid . "\">" . $this->name . "
"; + + return $str; } function Contact($cid, $name, $co, $address, $city, $country, $phone, $phone2, $email, $email2, $url, $url2, $essential, $notes) @@ -118,35 +127,44 @@ class ContactGroup { public function show() { - echo "
\n"; - echo "
" . $this->name . "
\n"; - echo "
\n"; + $str = ""; + + $str .= "
\n"; + $str .= "
" . $this->name . "
\n"; + $str .= "
\n"; foreach($this->contacts as $contact) { - $contact->showshort(); + $str .= $contact->showshort(); } - echo "
\n"; - echo "
\n"; + $str .= "
\n"; + $str .= "
\n"; + + return $str; } public function showshort() { global $client_is_mobile_device; + + $str = ""; + $ness = 0; foreach($this->contacts as $contact) { if($contact->essential) $ness += 1; } - echo "
\n"; - echo "
gid . "\">" . $this->name . ""; + $str .= "
\n"; + $str .= "
gid . "\">" . $this->name . ""; if(!$client_is_mobile_device) - echo " - ".sizeof($this->contacts)." contacts (". sprintf("%d", sizeof($this->contacts) - $ness)." hidden)"; - echo "
\n"; - echo "
\n"; + $str .= " - ".sizeof($this->contacts)." contacts (". sprintf("%d", sizeof($this->contacts) - $ness)." hidden)"; + $str .= "
\n"; + $str .= "
\n"; foreach($this->contacts as $contact) { - if($contact->essential) $contact->showshort(); + if($contact->essential) $str .= $contact->showshort(); } - echo "
\n"; - echo "
\n"; + $str .= "
\n"; + $str .= "
\n"; + + return $str; } function ContactGroup($gid, @@ -164,11 +182,15 @@ class Contacts { public function show() { - echo "
\n"; + $str = ""; + + $str .= "
\n"; foreach($this->contactgroups as $contactgroup) { - $contactgroup->showshort(); + $str .= $contactgroup->showshort(); } - echo "
\n"; + $str .= "
\n"; + + return $str; } public function getNextCID() diff --git a/forum/utils/edit.php b/forum/utils/edit.php index 20b5336..92c306a 100644 --- a/forum/utils/edit.php +++ b/forum/utils/edit.php @@ -19,7 +19,9 @@ switch($task) { $posts->thread->tid = $tid; $posts->thread->lastpost = time(); $posts->write(); - notify("forum", "New thread \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid); + $m = "New thread \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n"; + $m .= $message; + notify("forum", $m); } else { error("No forum id supplied!"); } @@ -35,7 +37,9 @@ case "reply": $reply->add($post); $posts->thread->lastpost = time(); $posts->write(); - notify("forum", "New reply \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid); + $m = "New reply \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n"; + $m .= $message; + notify("forum", $m); } else { error("Message " . $pid . " not found!"); } @@ -55,7 +59,9 @@ case "reply": $edit->message = $message . "\nEdited at: " . date("r", time()); $posts->thread->lastpost = time(); $posts->write(); - notify("forum", "Message \"" . $title . "\" has been edited: " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid); + $m = "Message \"" . $title . "\" has been edited: " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n"; + $m .= $message; + notify("forum", $m); } else { error("Message " . $pid . " not found!"); } @@ -74,7 +80,9 @@ case "reply": $quote->add($post); $posts->thread->lastpost = time(); $posts->write(); - notify("forum", "New reply (quote) \"" . $title . "\": " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid); + $m = "New reply (quote) \"" . $title . "\": " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n"; + $m .= $message; + notify("forum", $m); } else { error("Message " . $pid . " not found!"); } @@ -87,7 +95,7 @@ case "reply": echo "

Return to thread.

\n"; ?> - + diff --git a/forum/utils/editor.php b/forum/utils/editor.php index 36fb39d..768bce9 100644 --- a/forum/utils/editor.php +++ b/forum/utils/editor.php @@ -1,154 +1,112 @@ - \n"; + $str .= "function addcontent(text) {\n"; + $str .= " document.post_form.message.value += text;\n"; + $str .= " document.post_form.message.focus();\n"; + $str .= "}\n"; + $str .= "\n"; -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; + $title = "En titel"; + $message = "Something useful"; - case "reply": - $title = "Re: " . $post->title; + 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) { + + $title = ""; $message = ""; - break; + + switch($task) { + case "new": + $title = "Title"; + $message = "Message"; + break; - case "edit": - $title = $post->title; - $message = $post->message; - break; + case "reply": + if(substr($post->title, 0, 4) != "Re: ") + $title = "Re: " . $post->title; + else $title = $post->title; + $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; + case "edit": + $title = $post->title; + $message = $post->message; + break; - default: - error("No mode supplied!"); - break; - } -?> -
-;-) -;-) -;-) -;-) -B -I -U -[L  ] -[ C ] -[  R] -URL -E-Mail -Image -"Q" -c++ + case "quote": + if(substr($post->title, 0, 4) != "Re: ") + $title = "Re: " . $post->title; + else $title = $post->title; + $user = $users->getUser($post->user); + $message = "[quote title=" . $user->name . " wrote on " . + date("r", $post->date) ."]" . $post->message . "[/quote]"; + break; - + default: + $str .= error("No mode supplied!"); + return $str; + break; + } - + $str .= "\n"; + $str .= "

Title:

\n"; + $str .= "

\n"; - */ ?> -

- 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.example.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.example.com/image.jpg -

-

- -

-
-show(); + include_once($UTIL_DIR . "/smileys.php"); + foreach($smileys as $smiley) { + $smile = $smiley[0][0]; + if($smile == "\\m/") $smile = "\\\\m/"; + $str .= " \"\""; + } + $str .= "

\n"; + $str .= "

\n"; + $str .= " \n"; + $str .= "

\n"; + $str .= "

\n"; + $str .= " To make a link, simply type the URL, and the system will\n"; + $str .= " automagically transform it into an anchor (remember the\n"; + $str .= " http:// part).
\n"; + $str .= " Example: http://www.example.com
\n"; + $str .= "

\n"; + $str .= "

\n"; + $str .= " To insert an image, simply type the URL to that image, it will\n"; + $str .= " automagically be transformed into an image, with a link to the\n"; + $str .= " original image (again, remember the http:// part).
\n"; + $str .= " Example: http://www.example.com/image.jpg\n"; + $str .= "

\n"; + $str .= "

\n"; + $str .= " \n"; + $str .= "

\n"; + $str .= "\n"; + + if($pid != -1) $str .= $posts->show(); + } else { + $str .= error("Message " . $pid . " not found!"); + } } else { - error("Message " . $pid . " not found!"); + $str .= error("No message supplied!"); } -} else { - error("No message supplied!"); -} + return $str; +} ?> diff --git a/forum/utils/error.php b/forum/utils/error.php index 78128d2..bc2cadb 100644 --- a/forum/utils/error.php +++ b/forum/utils/error.php @@ -1,6 +1,5 @@ Error: " . $msg . "\n"; - // exit($msg); + return "
Error: " . $msg . "
\n"; } ?> \ No newline at end of file diff --git a/forum/utils/events.php b/forum/utils/events.php index 9f521b8..2f46f14 100644 --- a/forum/utils/events.php +++ b/forum/utils/events.php @@ -8,31 +8,62 @@ class Event { public $starttime; public $duration; public $description; + public $concert; public $user; public function show() { - global $users, $date, $client_is_mobile_device; + global $users, $GLOBALS, $client_is_mobile_device; - $user = $users->getUser($this->user); + $str = ""; - 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"; + $user = $users->getUser($this->user); + $str .= "
concert == "true") $str .= " concert"; + $str .= "\">\n"; + $str .= "
". $this->title . "\n"; + // $str .= " Edit\n"; + $str .= "
\n"; + $str .= "
" . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "
\n"; if(!$client_is_mobile_device) { - echo "
". $this->description . "
\n"; + $str .= "
". $this->description . + "
\n"; } else { - echo "
". $this->description . "
\n"; + $str .= "
" . + $this->description . "
\n"; } - echo "
By: ".$user->name . "
\n"; - // echo " Edit"; - echo "
\n"; + $str .= "
By: ".$user->name . "
\n"; + + $datestr = ""; + if(isset($GLOBALS['date'])) $datestr = "&date=". $GLOBALS['date']; + + $str .= " Delete"; + $str .= "
\n"; + + return $str; + } + + public function show_simple() + { + global $users, $GLOBALS, $client_is_mobile_device; + + $str = ""; + + $str .= "
\n"; + $str .= " " . date("D d M Y", $this->starttime) . "\n"; + $str .= " ". $this->title . "\n"; + $str .= " \n"; + $str .= " " . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "\n"; + $str .= "
\n"; + + return $str; } - public function Event($eid, $title, $starttime, $duration, $description, $user) + public function Event($eid, $title, $concert, $starttime, $duration, + $description, $user) { $this->eid = $eid; $this->title = $title; @@ -40,6 +71,7 @@ class Event { $this->duration = $duration; $this->description = $description; $this->user = $user; + $this->concert = $concert; } } @@ -53,6 +85,13 @@ class Events { $this->events[$key] = $event; } + public function delete($eid) { + if(isset($this->events[$eid])) { + unset($this->events[$eid]); + echo "DELETE"; + } + } + public function write() { $fp = fopen($this->file, "w"); @@ -68,6 +107,11 @@ class Events { htmlspecialchars($event->eid, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " title=\"" . htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n"); + + if($event->concert == "true") $concert = "true"; + else $concert = "false"; + fwrite($fp, " concert=\"" . $concert . "\"\n"); + fwrite($fp, " starttime=\"" . htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " duration=\"" . @@ -90,7 +134,7 @@ class Events { unset($this->members[$id]); // $this->write(); } else { - echo "

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

\n"; + $str .= "

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

\n"; return false; } return true; @@ -99,10 +143,12 @@ class Events { public function show($starttime, $endtime) { + $str = ""; foreach($this->events as $event) { if($event->starttime > $starttime && $event->starttime < $endtime) - $event->show(); + $str .= $event->show(); } + return $str; } public function getEvent($eid) @@ -121,6 +167,7 @@ class Events { foreach ($events as $e) { $event = new Event($e->getAttribute('eid'), $e->getAttribute('title'), + $e->getAttribute('concert') == "true", $e->getAttribute('starttime'), $e->getAttribute('duration'), $e->getAttribute('description'), diff --git a/forum/utils/filehandler.php b/forum/utils/filehandler.php index af1c305..4c18c38 100644 --- a/forum/utils/filehandler.php +++ b/forum/utils/filehandler.php @@ -1,36 +1,39 @@ newFile($_FILES['userfile']['tmp_name'], $name); - else echo "File is too big " . sprintf("%.0f", filesize($_FILES['userfile']['tmp_name'])/1024). - "kb, max file size: " . sprintf("%.0f", $FILE_MAX_SIZE/1024) . "kb."; - } -} + if($task == "upload") { -if($task == "delete" && $fid) { - $files->deleteFile($fid); -} + if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { + $name = $filename; + if(!$filename) $name = $_FILES['userfile']['name']; + if(filesize($_FILES['userfile']['tmp_name']) <= $FILE_MAX_SIZE) $files->newFile($_FILES['userfile']['tmp_name'], $name); + else $str .= "File is too big " . sprintf("%.0f", filesize($_FILES['userfile']['tmp_name'])/1024). + "kb, max file size: " . sprintf("%.0f", $FILE_MAX_SIZE/1024) . "kb."; + krsort($files->files); + } + } + + if($task == "delete" && $fid) { + $files->deleteFile($fid); + } + + $str .= "
"; + $str .= "

File:

\n"; + $str .= "

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

\n"; + $str .= "

"; + $str .= "
"; -$files->show(); + $str .= $files->show(); -?> -
-

- File: -

-

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

-

- -

-
+ return $str; +} \ No newline at end of file diff --git a/forum/utils/files.php b/forum/utils/files.php index 7356ff8..2fa3ec4 100644 --- a/forum/utils/files.php +++ b/forum/utils/files.php @@ -18,18 +18,23 @@ class File { public function show() { global $PERMSTORE, $current_user, $users; - echo "
\n"; + + $str = ""; + + $str .= "
\n"; if($current_user->uid == 0) { - echo " fid . "\">X\n"; + $str .= " fid . "\">X\n"; } - echo " \n"; - echo "
{{" . $this->fid . "}}
\n"; - echo " \n"; - echo "
" . $this->mimetype. "
\n"; - echo "
" . $users->getUser($this->uid)->name . "
\n"; - echo "
" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb
\n"; - echo "
" . date("M jS Y - G:i", $this->date) . "
\n"; - echo "
\n"; + $str .= " \n"; + $str .= "
{{" . $this->fid . "}}
\n"; + $str .= " \n"; + $str .= "
" . $this->mimetype. "
\n"; + $str .= "
" . $users->getUser($this->uid)->name . "
\n"; + $str .= "
" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb
\n"; + $str .= "
" . date("M jS Y - G:i", $this->date) . "
\n"; + $str .= "
\n"; + + return $str; } public function File($fid, $uid, $name, $date, $mimetype) @@ -83,25 +88,30 @@ class Files { public function show() { global $current_user; - echo "
\n"; - echo "
\n"; - echo "
\n"; + + $str = ""; + + $str .= "
\n"; + $str .= "
\n"; + $str .= "
\n"; if($current_user->uid == 0) { - echo "
\n"; + $str .= "
\n"; } - echo "
Preview
\n"; - echo "
Command
\n"; - echo "
Filename
\n"; - echo "
Mimetype
\n"; - echo "
User
\n"; - echo "
Size
\n"; - echo "
Date
\n"; - echo "
\n"; - echo "
\n"; + $str .= "
Preview
\n"; + $str .= "
Command
\n"; + $str .= "
Filename
\n"; + $str .= "
Mimetype
\n"; + $str .= "
User
\n"; + $str .= "
Size
\n"; + $str .= "
Date
\n"; + $str .= "
\n"; + $str .= "
\n"; foreach($this->files as $file) { - $file->show(); + $str .= $file->show(); } - echo "
\n"; + $str .= "
\n"; + + return $str; } public function getFile($fid) @@ -154,7 +164,7 @@ class Files { $this->add($file); } - + krsort($this->files); } public function Files($file) diff --git a/forum/utils/forums.php b/forum/utils/forums.php index c9c48b5..c93cafb 100644 --- a/forum/utils/forums.php +++ b/forum/utils/forums.php @@ -7,8 +7,8 @@ include_once($UTIL_DIR . "/threads.php"); class Forum { public $fid; public $name; - private $newStuff; - private $numPosts; + public $newStuff; + public $numPosts; private $latestPost; public function setNewStuff($newStuff, $threads) @@ -25,15 +25,37 @@ class Forum { public function show() { + global $cache; + global $yeah; + + $str = ""; + $newcls = " forum_nonew"; - if($this->newStuff) $newcls = " forum_new"; - - echo "
\n"; - echo " \n"; - echo " fid . "\">" . $this->name . "\n"; - echo " ".$this->latestPost."\n"; - echo " ".sprintf("%d", $this->numPosts)." threads\n"; - echo "
\n"; + if($yeah) { + $lp = $cache->get("forum_lastpost"); + if($lp->value($this->fid)) $newcls = " forum_new"; + } else { + if($this->newStuff) $newcls = " forum_new"; + } + + $str .= "
\n"; + $str .= " \n"; + $str .= " fid . "\">" . $this->name . "\n"; + $str .= " ". + $this->latestPost . "\n"; + if($yeah) { + $fc = $cache->get("forum_numberofthreads"); + + $str .= " " . + $fc->value($this->fid) . " threads\n"; + } else { + $str .= " " + . sprintf("%d", $this->numPosts)." threads\n"; + } + $str .= "
\n"; + + return $str; } public function Forum($fid, $name) @@ -84,11 +106,15 @@ class Forums { public function show() { - echo "
\n"; + $str = ""; + + $str .= "
\n"; foreach($this->forums as $forum) { - $forum->show(); + $str .= $forum->show(); } - echo "
\n"; + $str .= "
\n"; + + return $str; } private function read() diff --git a/forum/utils/mimetypes.php b/forum/utils/mimetypes.php index f9ecfea..96aab15 100644 --- a/forum/utils/mimetypes.php +++ b/forum/utils/mimetypes.php @@ -23,7 +23,7 @@ $MIME_TYPES = array(new MimeType("image/jpeg",array("jpg","jpeg","jpe"),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("application/msword",array("doc", "docx"),false), new MimeType("text/plain", array("asc","txt","text","diff","pot"), true) ); diff --git a/forum/utils/notify.php b/forum/utils/notify.php index 8ddbbd0..81a8734 100644 --- a/forum/utils/notify.php +++ b/forum/utils/notify.php @@ -34,6 +34,7 @@ function notify($module = "", $event = "") if($user->enabled == false) continue; // Do not mail disabled accounts. if($module == "calendar" || // Always mail calendar updates. + $user->username == "rasmus" || // Always send mails to Rasmus. ( $module == "forum" && $user != $current_user && // Don't notify current user. diff --git a/forum/utils/posts.php b/forum/utils/posts.php index f29354e..32e48e2 100644 --- a/forum/utils/posts.php +++ b/forum/utils/posts.php @@ -47,68 +47,72 @@ class Post { public function show($indent = " ", $recurse = true) { + $str = ""; + global $users, $fid, $tid, $current_user, $client_is_mobile_device; $user = $users->getUser($this->user); - echo $indent . "
\n"; + $str .= $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"; + $str .= $indent . " \"avatar\"\n"; if(!$client_is_mobile_device) { - echo $indent . "
ID: " . $this->pid . "
\n"; - echo $indent . "
Title: " . convert_xml($this->title) . "
\n"; + $str .= $indent . "
ID: " . $this->pid . "
\n"; + $str .= $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"; + $str .= $indent . "
"; + if(!$client_is_mobile_device) $str .= "UserID: "; + $str .= $user->name . "
\n"; + $str .= $indent . "
"; + if(!$client_is_mobile_device) $str .= "Date: "; + $str .= date("j. M Y - G:i", $this->date) . "
\n"; + $str .= $indent . "
\n"; + $str .= parse($this->message, $indent . " ") . "\n"; if(trim($user->signature) != "") { - echo $indent . "
\n"; - echo parse("--------------------------\n" . $user->signature, $indent . " ") . "\n"; - echo $indent . "
\n"; + $str .= $indent . "
\n"; + $str .= parse("--------------------------\n" . $user->signature, $indent . " ") . "\n"; + $str .= $indent . "
\n"; } - echo $indent . "
\n"; - echo $indent . "
\n"; + $str .= $indent . "
\n"; + $str .= $indent . "
\n"; if($current_user->uid == $this->user) { - echo $indent . + $str .= $indent . " "; - echo "\"edit\"\n"; + $str .= "\"edit\"\n"; } - echo $indent . + $str .= $indent . " "; - echo "\"quote\"\n"; + $str .= "\"quote\"\n"; - echo $indent . + $str .= $indent . " "; - echo "\"reply\"\n"; + $str .= "\"reply\"\n"; - echo $indent . "
\n"; - echo $indent . "
\n"; + $str .= $indent . "
\n"; + $str .= $indent . "
\n"; if($recurse) { foreach($this->replies as $reply) { - $reply->show($indent . " "); + $str .= $reply->show($indent . " "); } } - echo $indent . "
\n"; - echo $indent . "
\n"; + $str .= $indent . "
\n"; + $str .= $indent . "
\n"; + + return $str; } public function Post($pid, $title, $user, $date, $message = "") @@ -185,15 +189,17 @@ class Posts { { global $current_user; - echo "

Down to the bottom"; + $str = ""; + + $str .= "

Down to the bottom"; foreach($this->posts_linear as $post) { if($post->date > $this->thread->lastseen[$current_user->uid]) { - echo " Down to first unread\n"; + $str .= " Down to first unread\n"; break; } } - echo "

\n"; - echo "

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

\n"; + $str .= "

\n"; + $str .= "

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

\n"; /* // Recursive foreach($this->posts as $post) { @@ -206,21 +212,23 @@ class Posts { foreach($this->posts_linear as $post) { if($post->date > $this->thread->lastseen[$current_user->uid] && $firstunread == false) { $firstunread = true; - echo "
\n"; - echo "
\n"; + $str .= "
\n"; + $str .= "
\n"; } - $post->show(" ", false); + $str .= $post->show(" ", false); } if($firstunread == true) { - echo "
\n"; + $str .= "
\n"; } $this->thread->lastseen[$current_user->uid] = time(); $this->write(); - echo "

Up to the top

\n"; + $str .= "

Up to the top

\n"; + + return $str; } private function recurser($parentpost, $element) diff --git a/forum/utils/profile.php b/forum/utils/profile.php index f7595ed..d96b8c2 100644 --- a/forum/utils/profile.php +++ b/forum/utils/profile.php @@ -1,45 +1,52 @@ username = $username; - $current_user->name = $name; - $current_user->email = $email; - // $current_user->avatar = $avatar; - $current_user->signature = stripslashes($signature); - if($password != "") { - if($password == $password_confirm) { - $current_user->password = sha1(md5($password)); - } else { - error("Passwords do not match - thus not changed!"); - } - } + if($action == "update") { + global $name, $email, $signature, $password, $password_confirm, $users; + // $current_user->username = $username; + $current_user->name = $name; + $current_user->email = $email; + // $current_user->avatar = $avatar; + $current_user->signature = stripslashes($signature); + if($password != "") { + if($password == $password_confirm) { + $current_user->password = sha1(md5($password)); + } else { + error("Passwords do not match - thus not changed!"); + } + } + + if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { + if(!file_exists("gfx/avatars")) mkdir("gfx/avatars"); + // Prepend username to prevent overwriting of other users avatars. + $filename = $current_user->username . "_" . $_FILES['userfile']['name']; + if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar); + move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename); + $current_user->avatar = $filename; + } + + $users->write(); + } - if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { - if(!file_exists("gfx/avatars")) mkdir("gfx/avatars"); - // Prepend username to prevent overwriting of other users avatars. - $filename = $current_user->username . "_" . $_FILES['userfile']['name']; - if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar); - move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename); - $current_user->avatar = $filename; - } - - - $users->write(); -} -?> - -
username; ?>">
*/ ?> - Name:
- New password:
- Confirm password:
- E-Mail:
- Avatar:
- Avatar
-
- Signature:
-
-
- -
+ $str .= "
"; + //$str .= " Username: username . "\"
"; + $str .= " Name: name . "\">
"; + $str .= " New password:
"; + $str .= " Confirm password:
"; + $str .= " E-Mail: email . "\">
"; + $str .= " Avatar:
"; + $str .= " \"Avatar\"avatar . "\"/>
"; + $str .= "
"; + $str .= " Signature:
"; + $str .= "
"; + $str .= "
"; + $str .= " "; + $str .= "
"; + + return $str; +} \ No newline at end of file diff --git a/forum/utils/smileys.php b/forum/utils/smileys.php index 805ad69..5ee43f8 100644 --- a/forum/utils/smileys.php +++ b/forum/utils/smileys.php @@ -15,6 +15,7 @@ $smileys = array( array(array(":razz:"), "razz.gif"), array(array(":roll:"), "roll.gif"), array(array(":evil:"), "evil.gif"), + array(array(":jawdrop:"), "jawdrop.gif"), array(array(":evilgrin:"), "evilgrin.gif"), array(array(":lol:"), "lol.gif"), array(array(":cool:"), "cool.gif"), diff --git a/forum/utils/tasks.php b/forum/utils/tasks.php index 91f5409..fe66327 100644 --- a/forum/utils/tasks.php +++ b/forum/utils/tasks.php @@ -226,79 +226,86 @@ function sendMail($id, $new, $reassigned) send($email, $subject, $body); } -$tasks = tasks_init(); - -if($action == "tick") { - $now = time(); - - $h = (60 * 60); - $d = ($h * 24); - - $mininterval = $d - $h * 4; - $maxinterval = $d * 7 - $h * 4; - $overdueinterval = $h * 7; - - foreach($tasks->tasks as $task) { - - if($task->completed) continue; // no need for reminding - - if(($now > $task->deadline) && (($now - $task->lastreminder) > $overdueinterval)) { - // Deadline is overdue, and it has been more than $overdueinterval since last reminder. - sendMail($task->id, false, false); - } elseif((($task->deadline - $now) > $maxinterval) && (($now - $task->lastreminder) > $maxinterval)) { - // Deadline is a long way off, but it has been $maxinterval since last reminder. - sendMail($task->id, false, false); - } elseif((($task->deadline - $now) > $mininterval) && (($now - $task->lastreminder) > $mininterval)) { - // Deadline is near, and it has been $mininterval since last reminder. - sendMail($task->id, false, false); - } +function tasks() +{ + global $action, $GLOBALS; + + $tasks = tasks_init(); + + if($action == "tick") { + $now = time(); + + $h = (60 * 60); + $d = ($h * 24); + + $mininterval = $d - $h * 4; + $maxinterval = $d * 7 - $h * 4; + $overdueinterval = $h * 7; + + foreach($tasks->tasks as $task) { + + if($task->completed) continue; // no need for reminding + + if(($now > $task->deadline) && (($now - $task->lastreminder) > $overdueinterval)) { + // Deadline is overdue, and it has been more than $overdueinterval since last reminder. + sendMail($task->id, false, false); + } elseif((($task->deadline - $now) > $maxinterval) && (($now - $task->lastreminder) > $maxinterval)) { + // Deadline is a long way off, but it has been $maxinterval since last reminder. + sendMail($task->id, false, false); + } elseif((($task->deadline - $now) > $mininterval) && (($now - $task->lastreminder) > $mininterval)) { + // Deadline is near, and it has been $mininterval since last reminder. + sendMail($task->id, false, false); + } } -} + } -if($action == "update") { - $reassigned = false; - $id = $GLOBALS['id']; - $task = $tasks->tasks[$id]; - if(isset($GLOBALS['completed'])) $task->completed = $GLOBALS['completed'] == "on"; - if(isset($GLOBALS['userid'])) { - $reassigned = $task->userid != $GLOBALS['userid']; - $task->userid = $GLOBALS['userid']; - } - $tasks->write(); + if($action == "update") { + $reassigned = false; + $id = $GLOBALS['id']; + $task = $tasks->tasks[$id]; + if(isset($GLOBALS['completed'])) $task->completed = $GLOBALS['completed'] == "on"; + if(isset($GLOBALS['userid'])) { + $reassigned = $task->userid != $GLOBALS['userid']; + $task->userid = $GLOBALS['userid']; + } + $tasks->write(); + + if($reassigned) sendMail($id, false, true); + } + + if($action == "add") { + + $deadline = strtotime($GLOBALS['deadline_year']."-". + $GLOBALS['deadline_month']."-". + $GLOBALS['deadline_day']); + + $task = new Task($tasks->getNextID(), + stripslashes($GLOBALS['title']), + $deadline, + stripslashes($GLOBALS['description']), + 0, + $GLOBALS['reassignable'] == "on", + $GLOBALS['userid'], + false); + $tasks->add($task); + $tasks->write(); + + sendMail($task->id, true, false); + } - if($reassigned) sendMail($id, false, true); -} + $str .= "
\n"; + $str .= " Title: - User: " . userList($current_user->uid) . " -"; + $str .= " Deadline: D\n"; + $str .= " M\n"; + $str .= " Y
\n"; + $str .= " Reassignable:
\n"; + $str .= "
\n"; + $str .= " \n"; + $str .= "
\n"; + $str .= "
\n"; -if($action == "add") { - - $deadline = strtotime($GLOBALS['deadline_year']."-". - $GLOBALS['deadline_month']."-". - $GLOBALS['deadline_day']); - - $task = new Task($tasks->getNextID(), - stripslashes($GLOBALS['title']), - $deadline, - stripslashes($GLOBALS['description']), - 0, - $GLOBALS['reassignable'] == "on", - $GLOBALS['userid'], - false); - $tasks->add($task); - $tasks->write(); + $str .= $tasks->show(); - sendMail($task->id, true, false); + return $str; } - ?> -
- Title: - User: uid); ?> - Deadline: D - M - Y
- Reassignable:
-
- -
-
-show(); -?> \ No newline at end of file diff --git a/forum/utils/threads.php b/forum/utils/threads.php index 52dda06..a30bf5c 100644 --- a/forum/utils/threads.php +++ b/forum/utils/threads.php @@ -35,6 +35,8 @@ class Thread { global $fid, $current_user; global $users; + $str = ""; + $jumptonew = ""; $newcls = " thread_nonew"; if($this->lastseen[$current_user->uid] < $this->lastpost) { @@ -42,21 +44,23 @@ class Thread { $jumptonew = "#firstunread"; } - echo "
\n"; - echo "  \n"; - echo " " . $this->name . "\n"; - echo " ".$this->numposts." posts"; + $str .= "
\n"; + $str .= "  \n"; + $str .= " " . $this->name . "\n"; + $str .= " ".$this->numposts." posts"; if($this->numunread != 0) { - echo " (".$this->numunread." unread)"; + $str .= " (".$this->numunread." unread)"; } - echo "\n"; - echo " Last post: ". + $str .= "\n"; + $str .= " Last post: ". date("j. M Y - G:i", $this->lastpost)."\n"; $user = $users->getUser($this->first_user); - echo " By ".$user->name; - echo " at ". date("j. M Y - G:i", $this->first_date)."\n"; - echo "
\n"; + $str .= " By ".$user->name; + $str .= " at ". date("j. M Y - G:i", $this->first_date)."\n"; + $str .= "
\n"; + + return $str; } public function processPost($pid, $title, $user, $date) @@ -190,9 +194,13 @@ class Threads { public function show() { + $str = ""; + foreach($this->threads as $thread) { - $thread->show(); + $str .= $thread->show(); } + + return $str; } public function newStuff() diff --git a/forum/utils/view.php b/forum/utils/view.php index 2673394..1e9812a 100644 --- a/forum/utils/view.php +++ b/forum/utils/view.php @@ -1,56 +1,65 @@ "; -if($fid) { - echo "Legend: Forums"; - if($tid) { - include_once("forums.php"); - $forums = new Forums($FORUMS_DIR . "/forums.xml"); - $forum = $forums->getForum($fid); - echo " :: ".$forum->name.""; - - include_once("posts.php"); - $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); - echo " :: ".$posts->thread->name; - - $posts->show(); - - } else { - include_once("forums.php"); - $forums = new Forums($FORUMS_DIR . "/forums.xml"); - $forum = $forums->getForum($fid); - echo " :: ".$forum->name; - - echo "

Threads in '".$forum->name."'

\n"; - echo " New thread\n"; + +function viewForum() +{ + global $fid, $tid, $action, $current_user, $UTIL_DIR, + $FORUMS_DIR, $smileys; + + $legend = "
"; + $f_str = ""; + if($fid) { + $legend .= "Legend: Forums"; + if($tid) { + include_once($UTIL_DIR . "/forums.php"); + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + $forum = $forums->getForum($fid); + $legend .= " :: ".$forum->name.""; + + include_once($UTIL_DIR . "/posts.php"); + $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); + $legend .= " :: ".$posts->thread->name; + + $f_str .= $posts->show(); + + } else { + include_once($UTIL_DIR . "/forums.php"); + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + $forum = $forums->getForum($fid); + $legend .= " :: ".$forum->name; + + $f_str .= "

Threads in '".$forum->name."'

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

Forums

\n"; - include_once("forums.php"); - $forums = new Forums($FORUMS_DIR . "/forums.xml"); + include_once($UTIL_DIR . "/threads.php"); + $threads = new Threads($FORUMS_DIR . "/" . $fid); + $f_str .= $threads->show(); + } + } else { + $legend .= "Legend: Forums"; + $f_str .= "

Forums

\n"; + include_once("forums.php"); + $forums = new Forums($FORUMS_DIR . "/forums.xml"); - if($action == "addforum") { - $newfid = 1; - while($forums->getForum($newfid)) $newfid++; + if($action == "addforum") { + $newfid = 1; + while($forums->getForum($newfid)) $newfid++; - $forums->add(new Forum($newfid, $title)); - $forums->write(); - } + $forums->add(new Forum($newfid, $title)); + $forums->write(); + } - $forums->show(); + $f_str .= $forums->show(); - if($current_user->uid == 0) { -?> -
-Add new forum: -
-uid == 0) { + $f_str .= "
\n"; + $f_str .= "Add new forum: \n"; + $f_str .= "
\n"; + } + } + + $legend .= "
\n"; + + return $legend . $f_str; } -echo "\n"; ?> \ No newline at end of file -- cgit v1.2.3