diff options
author | deva <deva> | 2011-11-01 09:32:21 +0000 |
---|---|---|
committer | deva <deva> | 2011-11-01 09:32:21 +0000 |
commit | 42c62cb041a2b2b95c9cda0c20fcf70334fd244c (patch) | |
tree | 38371eb37ff7348585ee84438b326c25055e2cbe /forum | |
parent | 208e3b642149a9ac701a43397d31990f9b27ca79 (diff) |
Rewl og krat... needs cleaning up - after port to GIT.origin
Diffstat (limited to 'forum')
-rw-r--r-- | forum/htdocs/index.php | 79 | ||||
-rw-r--r-- | forum/utils/addressbook.php | 279 | ||||
-rw-r--r-- | forum/utils/cache.php | 147 | ||||
-rw-r--r-- | forum/utils/calendar.php | 283 | ||||
-rw-r--r-- | forum/utils/contacts.php | 90 | ||||
-rw-r--r-- | forum/utils/edit.php | 18 | ||||
-rw-r--r-- | forum/utils/editor.php | 236 | ||||
-rw-r--r-- | forum/utils/error.php | 3 | ||||
-rw-r--r-- | forum/utils/events.php | 79 | ||||
-rw-r--r-- | forum/utils/filehandler.php | 59 | ||||
-rw-r--r-- | forum/utils/files.php | 62 | ||||
-rw-r--r-- | forum/utils/forums.php | 52 | ||||
-rw-r--r-- | forum/utils/mimetypes.php | 2 | ||||
-rw-r--r-- | forum/utils/notify.php | 1 | ||||
-rw-r--r-- | forum/utils/posts.php | 82 | ||||
-rw-r--r-- | forum/utils/profile.php | 91 | ||||
-rw-r--r-- | forum/utils/smileys.php | 1 | ||||
-rw-r--r-- | forum/utils/tasks.php | 145 | ||||
-rw-r--r-- | forum/utils/threads.php | 32 | ||||
-rw-r--r-- | forum/utils/view.php | 105 |
20 files changed, 1093 insertions, 753 deletions
diff --git a/forum/htdocs/index.php b/forum/htdocs/index.php index c4e0570..0608f93 100644 --- a/forum/htdocs/index.php +++ b/forum/htdocs/index.php @@ -8,6 +8,12 @@ include_once("config.php"); include_once($UTIL_DIR . "/login.php"); checklogin(); +if($yeah) { +include_once($UTIL_DIR . "/cache.php"); +$cache = new Cache($DATA_DIR . "/cache.xml"); +$cache->rebuild(); +} + // Catch the modes that must not output any html. if($current_user) { switch($mode) { @@ -40,16 +46,26 @@ include_once($UTIL_DIR . "/clientinfo.php"); <?php if($mode == "editor") {?> <script language="javascript" src="lib.js" type="text/javascript"></script><?php } ?> </head> <body> - <div id="menu_top" class="menu"> - <a href="?mode=forum">Forum</a> - <a href="?mode=filehandler">Filehandler</a> - <a href="?mode=calendar">Calendar</a> - <a href="?mode=addressbook">Addressbook</a> - <a href="?mode=profile">Profile</a> - <a href="?mode=tasks">Tasks</a> -<?php if($current_user->uid == 0) {?> <a href="?mode=diagnostics">Diagnostics</a><?php } ?> - </div> <?php + function menu($pos, $unread) +{ + global $current_user; + + if($unread) $newposts = "newposts"; + else $newposts = "nonewposts"; + + $str .=" <div id=\"menu_".$pos."\" class=\"menu\">\n"; + $str .=" <a href=\"?mode=forum\"><span class=\"".$newposts."\"> </span>Forum</a>\n"; + $str .=" <a href=\"?mode=filehandler\">Filehandler</a>\n"; + $str .=" <a href=\"?mode=calendar\">Calendar</a>\n"; + $str .=" <a href=\"?mode=addressbook\">Addressbook</a>\n"; + $str .=" <a href=\"?mode=profile\">Profile</a>\n"; + $str .=" <a href=\"?mode=tasks\">Tasks</a>\n"; + if($current_user->uid == 0) + $str .=" <a href=\"?mode=diagnostics\">Diagnostics</a>\n"; + $str .=" </div>\n"; + return $str; +} // Globals: // $fid @@ -58,57 +74,76 @@ include_once($UTIL_DIR . "/clientinfo.php"); // $task if($current_user) { - echo " <p>Logged in as: " . $current_user->name . " - <a href=\"?action=logout\">Logout</a></p>\n"; + $str = ""; + + $str .= " <p>Logged in as: " . $current_user->name . " - <a href=\"?action=logout\">Logout</a></p>\n"; switch($mode) { case "profile": include_once($UTIL_DIR. "/profile.php"); + $str .= profile(); break; case "tasks": include_once($UTIL_DIR. "/tasks.php"); + $str .= tasks(); break; case "calendar": include_once($UTIL_DIR. "/calendar.php"); + $str .= calendar(); break; case "addressbook": include_once($UTIL_DIR. "/addressbook.php"); + $str .= addressbook(); break; case "editor": include_once($UTIL_DIR. "/editor.php"); + $str .= editor(); break; case "edit": include_once($UTIL_DIR. "/edit.php"); + $str .= ""; break; case "filehandler": include_once($UTIL_DIR. "/filehandler.php"); + $str .= filehandler(); break; case "diagnostics": include_once($UTIL_DIR. "/diagnostics.php"); + $str .= ""; break; - case "view": default: + case "view": include_once($UTIL_DIR. "/view.php"); -?> - <div id="menu_bottom" class="menu"> - <a href="?mode=forum">Forum</a> - <a href="?mode=filehandler">Filehandler</a> - <a href="?mode=calendar">Calendar</a> - <a href="?mode=addressbook">Addressbook</a> - <a href="?mode=profile">Profile</a> - <a href="?mode=tasks">Tasks</a> -<?php if($current_user->uid == 0) {?> <a href="?mode=diagnostics">Diagnostics</a><?php } ?> - </div> -<?php + $str .= viewForum(); + if(!isset($GLOBALS['fid'])) { + include_once($UTIL_DIR. "/calendar.php"); + $str .= calendar(); + } break; } + if($mode != "edit") { + include_once($UTIL_DIR . "/forums.php"); + + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + + $unreadPosts = false; + foreach($forums->forums as $forum) { + $unreadPosts |= $forum->newStuff; + } + + echo menu("top", $unreadPosts). $str. menu("bottom", $unreadPosts); + } else { + echo $str; + } + } else { ?> <form action="?action=login" method="post"> 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 @@ <?php -include_once($UTIL_DIR . "/contacts.php"); function form($cid, $posturl, @@ -18,138 +17,154 @@ function form($cid, $essential = "on", $notes = "") { -?> -<form method="post" action="<?php echo $posturl; ?>"> - <input type="hidden" name="cid" value="<?php echo $cid;?>"> - Name: <input name="name" value="<?php echo $name;?>"><br/> - c/o: <input name="co" value="<?php echo $co;?>"><br/> - Address: <input name="address" value="<?php echo $address;?>"><br/> - City: <input name="city" value="<?php echo $city;?>"><br/> - Country: <input name="country" value="<?php echo $country;?>"><br/> - Phone: <input name="phone" value="<?php echo $phone;?>"><br/> - Phone2: <input name="phone2" value="<?php echo $phone2;?>"><br/> - Email: <input name="email" value="<?php echo $email;?>"><br/> - Email2: <input name="email2" value="<?php echo $email2;?>"><br/> - URL: <input name="url" value="<?php echo $url;?>"><br/> - URL2: <input name="url2" value="<?php echo $url2;?>"><br/> - Essential: <input type="checkbox" name="essential"<?php if($essential == "on") echo " checked";?>> (show on frontpage)<br/> - Notes:<br/> - <textarea name="notes" cols="60" rows="10"><?php echo $notes;?></textarea><br/> - <button type="submit"><?php echo $buttontext; ?></button> -</form> -<?php -} - - -$name = stripslashes($name); -$co = stripslashes($co); -$address = stripslashes($address); -$city = stripslashes($city); -$country = stripslashes($country); -$phone = stripslashes($phone); -$phone2 = stripslashes($phone2); -$email = stripslashes($email); -$email2 = stripslashes($email2); -$url = stripslashes($url); -$url2 = stripslashes($url2); -$notes = stripslashes($notes); - -$contacts = new Contacts($DATA_DIR . "/contacts.xml"); - -if($action == "addgroup" && $gid) { - $contactgroup = new ContactGroup($gid, $name); - $contacts->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 .= "<form method=\"post\" action=\"" . $posturl . "\">\n"; + $str .= " <input type=\"hidden\" name=\"cid\" value=\"". $cid . "\">\n"; + $str .= " Name: <input name=\"name\" value=\"" . $name . "\"><br/>\n"; + $str .= " c/o: <input name=\"co\" value=\"" . $co . "\"><br/>\n"; + $str .= " Address: <input name=\"address\" value=\"" . $address . "\"><br/>\n"; + $str .= " City: <input name=\"city\" value=\"" . $city . "\"><br/>\n"; + $str .= " Country: <input name=\"country\" value=\"" . $country . "\"><br/>\n"; + $str .= " Phone: <input name=\"phone\" value=\"" . $phone . "\"><br/>\n"; + $str .= " Phone2: <input name=\"phone2\" value=\"" . $phone2 . "\"><br/>\n"; + $str .= " Email: <input name=\"email\" value=\"" . $email . "\"><br/>\n"; + $str .= " Email2: <input name=\"email2\" value=\"" . $email2 . "\"><br/>\n"; + $str .= " URL: <input name=\"url\" value=\"" . $url . "\"><br/>\n"; + $str .= " URL2: <input name=\"url2\" value=\"" . $url2 . "\"><br/>\n"; + $ess = ""; + if($essential == "on") $ess = " checked"; + $str .= " Essential: <input type=\"checkbox\" name=\"essential\"" . + $ess . "> (show on frontpage)<br/>\n"; + $str .= " Notes:<br/>\n"; + $str .= " <textarea name=\"notes\" cols=\"60\" rows=\"10\">" . + $notes . "</textarea><br/>\n"; + $str .= " <button type=\"submit\">" . $buttontext . "</button>\n"; + $str .= "</form>\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) { -?> -<form method="post" action="?mode=addressbook&action=addgroup"> - <input type="hidden" name="gid" value="<?php echo $contacts->getNextGID();?>"> - Name: <input name="name" value=""> - <button type="submit">Add group</button> -</form> -<?php - } +function addressbook() +{ + global $UTIL_DIR, $DATA_DIR, $GLOBALS, $gid, $cid, $smileys; + + include_once($UTIL_DIR . "/contacts.php"); + + $str = ""; + + $name = stripslashes($GLOBALS['name']); + $co = stripslashes($GLOBALS['co']); + $address = stripslashes($GLOBALS['address']); + $city = stripslashes($GLOBALS['city']); + $country = stripslashes($GLOBALS['country']); + $phone = stripslashes($GLOBALS['phone']); + $phone2 = stripslashes($GLOBALS['phone2']); + $email = stripslashes($GLOBALS['email']); + $email2 = stripslashes($GLOBALS['email2']); + $url = stripslashes($GLOBALS['url']); + $url2 = stripslashes($GLOBALS['url2']); + $notes = stripslashes($GLOBALS['notes']); + + $contacts = new Contacts($DATA_DIR . "/contacts.xml"); + + if($GLOBALS['action'] == "addgroup" && $gid) { + $contactgroup = new ContactGroup($gid, $name); + $contacts->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 .= "<form method=\"post\" action=\"?mode=addressbook&action=addgroup\">\n"; + $str .= " <input type=\"hidden\" name=\"gid\" value=\"" . + sprintf("%d", $contacts->getNextGID()) . "\">\n"; + $str .= " Name: <input name=\"name\" value=\"\">\n"; + $str .= " <button type=\"submit\">Add group</button>\n"; + $str .= "</form>\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 @@ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +include_once($UTIL_DIR . "/convert.php"); +include_once($UTIL_DIR . "/forums.php"); + +class CacheEntry { + public $values = array(); + public $id; + + public function write($fp) + { + fwrite($fp, " <entry id=\"" . + htmlspecialchars($this->id, ENT_QUOTES, "UTF-8") . "\">\n"); + + foreach($this->values as $key => $value) { + fwrite($fp, " <value key=\"" . + htmlspecialchars($key, ENT_QUOTES, "UTF-8") . "\">"); + fwrite($fp, htmlspecialchars($value, ENT_QUOTES, "UTF-8")); + fwrite($fp, "</value>\n"); + } + + fwrite($fp, " </entry>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<cache>\n"); + foreach($this->entries as $entry) { + $entry->write($fp); + } + fwrite($fp, "</cache>\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 @@ <?php -include_once($UTIL_DIR . "/events.php"); -include_once($UTIL_DIR . "/notify.php"); -if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.php"); - -$events = new Events($DATA_DIR . "/calendar.xml"); - -if(!$date) $date = time() - (date("N", time()) - 1) * 24 * 60 * 60; -else $date = $date - (date("N", $date) - 1) * 24 * 60 * 60; -//echo $date; - -if($action=="addentry") { - $title = stripslashes($title); - $description = stripslashes($description); - - $time = strtotime($txtdate . " " . $txttimefrom . ":00"); - if($time !== FALSE) { - $duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time; - $eid = time(); - $event = new Event($eid, $title, $time, $duration, $description, $current_user->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 .= " <meta http-equiv=\"refresh\" content=\"0; " . + "URL=?mode=calendar&date=" . $time . "\"/>\n"; + + } else { + $str .= "<div class=\"error\">ERROR: Date is not in the correct " . + "format! It was NOT posted. Please try again.</div>\n"; } + } - notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" . - $description . "\n" . - $FORUM_URL . "/?mode=calendar&date=" . $time); -?> - <meta http-equiv="refresh" content="0; URL=?mode=calendar&date=<?php echo $time; ?>" /> -<?php + if($GLOBALS['action'] =="delete") { + $events->delete($GLOBALS['eid']); + $events->write(); + } + + $str .= "<p style=\"text-align: center;\">\n"; + $str .= "<a href=\"?mode=calendar&date=" . + sprintf("%d", $date - 7 * 24 * 60 * 60) . "\">[<]</a>\n"; + $str .= " \n"; + $str .= "<a href=\"?mode=calendar&date=" . + sprintf("%d", $date - 31 * 24 * 60 * 60) . "\">[<<]</a>\n"; + $str .= " \n"; + $str .= date("F Y", $date) . "\n"; + $str .= " \n"; + $str .= "<a href=\"?mode=calendar&date=" . + sprintf("%d", $date + 31 * 24 * 60 * 60) . "\">[>>]</a> \n"; + $str .= " \n"; + $str .= "<a href=\"?mode=calendar&date=" . + sprintf("%d", $date + 7 * 24 * 60 * 60) . "\">[>]</a><br/>\n"; + $str .= "<a href=\"?mode=calendar\">[Today]</a><br/>\n"; + $str .= "</p>\n"; + + if($client_is_mobile_device) { + for($day = 0; $day < 7; $day++) { + $str .= " <div class=\"mobilecalentry\">\n"; + $str .= " <div class=\"mobilecalheader\">\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= "<a style=\"text-decoration: none;\" " . + "href=\"?mode=calendar&date=". + sprintf("%d", $date) . "&adddate=". $t . + "&action=add\">[+]</a>\n"; + $str .= " </div>\n"; + $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + $str .= " <div class=\"mobilecalcontent\""; + if($t == strtotime(date("F j Y", time()))) + $str .= " style=\"background: #113;\""; + elseif($day > 4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; + + $str .= $events->show($t, $t + 24 * 60 * 60); + + $str .= " </div>\n"; + $str .= " </div>\n"; + + } } else { - echo "<div class=\"error\">ERROR: Date is not in the correct format! It was NOT posted. Please try again.</div>\n"; - } -} + $str .= "<table class=\"week\">\n"; + $str .= " <tr class=\"day\">\n"; -if($action=="edit") { - /* - $event = $events->getEvent($eid); - $event->duration += 2000; - $events->write(); - */ -} + for($day = 0; $day < 7; $day++) { + $str .= " <td class=\"header\">\n"; + $t = $date + $day * 24 * 60 * 60; + $str .= " " . date("l j/n", $t) . "\n"; + $str .= " </td>\n"; + } -?> -<p style="text-align: center;"> -<a href="?mode=calendar&date=<?php echo $date - 7 * 24 * 60 * 60 ?>">[<]</a> - -<a href="?mode=calendar&date=<?php echo $date - 31 * 24 * 60 * 60 ?>">[<<]</a> - -<?php echo date("F Y", $date); ?> - -<a href="?mode=calendar&date=<?php echo $date + 31 * 24 * 60 * 60 ?>">[>>]</a> - -<a href="?mode=calendar&date=<?php echo $date + 7 * 24 * 60 * 60 ?>">[>]</a><br/> -<a href="?mode=calendar">[Today]</a><br/> -</p> -<?php -if($client_is_mobile_device) { - for($day = 0; $day < 7; $day++) { - echo " <div class=\"mobilecalentry\">\n"; - echo " <div class=\"mobilecalheader\">\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; -?> - <a style="text-decoration: none;" href="?mode=calendar&date=<?php echo $date; ?>&adddate=<?php echo $t; ?>&action=add">[+]</a> -<?php - echo " </div>\n"; + $str .= " </tr>\n"; + $str .= " <tr class=\"day\">\n"; - $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); - echo " <div class=\"mobilecalcontent\""; - if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\""; - elseif($day > 4) echo " style=\"background: #311;\""; - echo ">\n"; + 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 .= " <td class=\"content\""; + if($t == strtotime(date("F j Y", time()))) + $str .= " style=\"background: #113;\""; + elseif($day > 4) $str .= " style=\"background: #311;\""; + $str .= ">\n"; - echo " </div>\n"; - echo " </div>\n"; + $str .= " <a class=\"button\" href=\"?mode=calendar&date=" . + sprintf("%d", $date) . "&adddate=". $t . + "&action=add\">Add</a>\n"; - } -} else { -?> -<table class="week"> - <tr class="day"> -<?php -for($day = 0; $day < 7; $day++) { - echo " <td class=\"header\">\n"; - $t = $date + $day * 24 * 60 * 60; - echo " " . date("l j/n", $t) . "\n"; - echo " </td>\n"; -} -?> - </tr> - <tr class="day"> -<?php -for($day = 0; $day < 7; $day++) { - $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60)); + $str .= $events->show($t, $t + 24 * 60 * 60); + $str .= " </td>\n"; + } - echo " <td class=\"content\""; - if($t == strtotime(date("F j Y", time()))) echo " style=\"background: #113;\""; - elseif($day > 4) echo " style=\"background: #311;\""; - echo ">\n"; -?> - <a class="button" href="?mode=calendar&date=<?php echo $date; ?>&adddate=<?php echo $t; ?>&action=add">Add</a> -<?php - $events->show($t, $t + 24 * 60 * 60); - echo " </td>\n"; -} -?> - </tr> -</table> -<?php + $str .= " </tr>\n"; + $str .= "</table>\n"; + } + + if($GLOBALS['adddate'] != "") { + $str .= "<form method=\"post\" action=\"?mode=calendar&action=" . + "addentry\">\n"; + $str .= "Title: <input name=\"title\" value=\"\"><br/>\n"; + $str .= "Concert: <input type=\"checkbox\" name=\"concert\"/><br/>\n"; + $str .= "Desription: <textarea name=\"description\"></textarea><br/>\n"; + $str .= "Date: <input name=\"txtdate\" value=\"". + date("F j Y", $GLOBALS['adddate']) . "\"><br/>\n"; + $str .= "From-Time: <input name=\"txttimefrom\" value=\"19:00\"><br/>\n"; + $str .= "To-Time: <input name=\"txttimeto\" value=\"22:00\"><br/>\n"; + $str .= "<br/>\n"; + $str .= "<button type=\"submit\">Add</button>\n"; + $str .= "</form>\n"; + } + + return $str; } ?> -<?php if($adddate != "") { ?> -<form method="post" action="?mode=calendar&action=addentry"> -Title: <input name="title" value=""><br/> -Desription: <textarea name="description"></textarea><br/> -Date: <input name="txtdate" value="<?php echo date("F j Y", $adddate); ?>"><br/> -From-Time: <input name="txttimefrom" value="17:00"><br/> -To-Time: <input name="txttimeto" value="20:00"><br/> -<br/> -<button type="submit">Add</button> -</form> -<?php } ?> diff --git a/forum/utils/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 "<p>\n"; - // echo "\tcid: " . $this->cid . "<br/>\n"; - echo "\tName: " . $this->name . "<br/>\n"; - if($this->co) echo "\tc/o: " . $this->co . "<br/>\n"; - if($this->address) echo "\tAddress: " . $this->address . "<br/>\n"; - if($this->city) echo "\tCity: " . $this->city . "<br/>\n"; - if($this->country) echo "\tCountry: " . $this->country . "<br/>\n"; - if($this->phone) echo "\tPhone: " . $this->phone . "<br/>\n"; - if($this->phone2) echo "\tPhone2: " . $this->phone2 . "<br/>\n"; - if($this->email) echo "\tEmail: <a href=\"mailto:" . $this->email . "\">" . $this->email . "</a><br/>\n"; - if($this->email2) echo "\tEmail2: <a href=\"mailto:" . $this->email2 . "\">" . $this->email2 . "</a><br/>\n"; - if($this->url) echo "\tURL: <a href=\"" . $this->url . "\">" . $this->url . "</a><br/>\n"; - if($this->url2) echo "\tURL2: <a href=\"" . $this->url2 . "\">" . $this->url2 . "</a><br/>\n"; - if($this->notes) echo "\tNotes: <br/>\n" . parse($this->notes) . "<br/>\n"; - echo "\t<a href=\"?mode=addressbook&action=editcontact&cid=" . $this->cid . "\">Edit</a>\n"; - echo "</p>\n"; + $str = ""; + + $str .= "<p>\n"; + // $str .= "\tcid: " . $this->cid . "<br/>\n"; + $str .= "\tName: " . $this->name . "<br/>\n"; + if($this->co) $str .= "\tc/o: " . $this->co . "<br/>\n"; + if($this->address) $str .= "\tAddress: " . $this->address . "<br/>\n"; + if($this->city) $str .= "\tCity: " . $this->city . "<br/>\n"; + if($this->country) $str .= "\tCountry: " . $this->country . "<br/>\n"; + if($this->phone) $str .= "\tPhone: " . $this->phone . "<br/>\n"; + if($this->phone2) $str .= "\tPhone2: " . $this->phone2 . "<br/>\n"; + if($this->email) $str .= "\tEmail: <a href=\"mailto:" . $this->email . "\">" . $this->email . "</a><br/>\n"; + if($this->email2) $str .= "\tEmail2: <a href=\"mailto:" . $this->email2 . "\">" . $this->email2 . "</a><br/>\n"; + if($this->url) $str .= "\tURL: <a href=\"" . $this->url . "\">" . $this->url . "</a><br/>\n"; + if($this->url2) $str .= "\tURL2: <a href=\"" . $this->url2 . "\">" . $this->url2 . "</a><br/>\n"; + if($this->notes) $str .= "\tNotes: <br/>\n" . parse($this->notes) . "<br/>\n"; + $str .= "\t<a href=\"?mode=addressbook&action=editcontact&cid=" . $this->cid . "\">Edit</a>\n"; + $str .= "</p>\n"; + + return $str; } public function showshort() { - echo "<div class=\"contact\"><a href=\"?mode=addressbook&cid=" . $this->cid . "\">" . $this->name . "</a></div>"; + $str = ""; + + $str .= "<div class=\"contact\"><a href=\"?mode=addressbook&cid=" . + $this->cid . "\">" . $this->name . "</a></div>"; + + 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 " <div class=\"contactgroup\">\n"; - echo " <div class=\"title\">" . $this->name . "</div>\n"; - echo " <div class=\"contacts\">\n"; + $str = ""; + + $str .= " <div class=\"contactgroup\">\n"; + $str .= " <div class=\"title\">" . $this->name . "</div>\n"; + $str .= " <div class=\"contacts\">\n"; foreach($this->contacts as $contact) { - $contact->showshort(); + $str .= $contact->showshort(); } - echo " </div>\n"; - echo " </div>\n"; + $str .= " </div>\n"; + $str .= " </div>\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 " <div class=\"contactgroup\">\n"; - echo " <div class=\"title\"><a href=\"?mode=addressbook&gid=" . $this->gid . "\">" . $this->name . "</a>"; + $str .= " <div class=\"contactgroup\">\n"; + $str .= " <div class=\"title\"><a href=\"?mode=addressbook&gid=" . $this->gid . "\">" . $this->name . "</a>"; if(!$client_is_mobile_device) - echo " - ".sizeof($this->contacts)." contacts (". sprintf("%d", sizeof($this->contacts) - $ness)." hidden)"; - echo "</div>\n"; - echo " <div class=\"contacts\">\n"; + $str .= " - ".sizeof($this->contacts)." contacts (". sprintf("%d", sizeof($this->contacts) - $ness)." hidden)"; + $str .= "</div>\n"; + $str .= " <div class=\"contacts\">\n"; foreach($this->contacts as $contact) { - if($contact->essential) $contact->showshort(); + if($contact->essential) $str .= $contact->showshort(); } - echo " </div>\n"; - echo " </div>\n"; + $str .= " </div>\n"; + $str .= " </div>\n"; + + return $str; } function ContactGroup($gid, @@ -164,11 +182,15 @@ class Contacts { public function show() { - echo "<div class=\"contactlist\">\n"; + $str = ""; + + $str .= "<div class=\"contactlist\">\n"; foreach($this->contactgroups as $contactgroup) { - $contactgroup->showshort(); + $str .= $contactgroup->showshort(); } - echo "</div>\n"; + $str .= "</div>\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 "<p><a href=\"?fid=" . $fid . "&tid=" . $tid . "\">Return to thread.</a></p>\n"; ?> -<meta http-equiv="refresh" content="0; URL=?fid=<?php echo $fid; ?>&tid=<?php echo $tid; ?>" /> +<meta http-equiv="refresh" content="0; URL=?fid=<?php echo $fid; ?>&tid=<?php echo $tid; ?>#firstunread" /> 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 @@ -<script language="JavaScript"> -function addcontent(text) { - document.post_form.message.value += text; - document.post_form.message.focus(); -} -</script> <?php -include_once($UTIL_DIR . "/error.php"); -include_once($UTIL_DIR . "/convert.php"); -$title = "En titel"; -$message = "Something useful"; +function editor() +{ + global $UTIL_DIR, $FORUMS_DIR, $users, $fid, $tid, $pid, $smileys, $task; + + include_once($UTIL_DIR . "/error.php"); + include_once($UTIL_DIR . "/convert.php"); + + $str = ""; + + $str .= "<script language=\"JavaScript\">\n"; + $str .= "function addcontent(text) {\n"; + $str .= " document.post_form.message.value += text;\n"; + $str .= " document.post_form.message.focus();\n"; + $str .= "}\n"; + $str .= "</script>\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; - } -?> -<form style="clear: both;" name="post_form" method="post" action="?mode=edit&task=<?php echo $task ?>&fid=<?php echo $fid; ?>&tid=<?php echo $tid; ?>&pid=<?php echo $pid; ?>" onSubmit="javascript: document.post_form.btn_submit.disabled = true;"> -<?php /* -<a href="javascript: insertTag(document.post_form.message, ';-)', '');"><img border="0" alt=";-)" src="gfx/smileys/wink.gif"/></a> -<a href="javascript: insertTag(document.post_form.message, ';-D', '');"><img border="0" alt=";-)" src="gfx/smileys/biggrinn.gif"/></a> -<a href="javascript: insertTag(document.post_form.message, '\\m/', '');"><img border="0" alt=";-)" src="gfx/smileys/headbanger.gif"/></a> -<a href="javascript: insertTag(document.post_form.message, '>:O', '');"><img border="0" alt=";-)" src="gfx/smileys/growler.gif"/></a> -<a href="javascript: insertTag(document.post_form.message, '[b]', '[/b]');"><strong>B</strong></a> -<a href="javascript: insertTag(document.post_form.message, '[i]', '[/i]');"><em>I</em></a> -<a href="javascript: insertTag(document.post_form.message, '[u]', '[/u]');"><u>U</u></a> -<a href="javascript: insertTag(document.post_form.message, '[align=left]', '[/align]');">[L ]</a> -<a href="javascript: insertTag(document.post_form.message, '[align=center]', '[/align]');">[ C ]</a> -<a href="javascript: insertTag(document.post_form.message, '[align=right]', '[/align]');">[ R]</a> -<a href="javascript: url_insert();">URL</a> -<a href="javascript: email_insert();">E-Mail</a> -<a href="javascript: image_insert();">Image</a> -<a href="javascript: insertTag(document.post_form.message, '[quote]', '[/quote]');">"Q"</a> -<a href="javascript: insertTag(document.post_form.message, '[code]', '[/code]');">c++</a> + 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; -<select name="fnt_size" onchange="javascript:insertTag(document.post_form.message, '[size='+document.post_form.fnt_size.options[this.selectedIndex].value+']', '[/size]'); document.post_form.fnt_size.options[0].selected=true"> -<option value="" selected="selected">Size</option> -<option value="1">1</option> -<option value="2">2</option> -<option value="3">3</option> -<option value="4">4</option> -<option value="5">5</option> -<option value="6">6</option> -<option value="7">7</option> -</select> + default: + $str .= error("No mode supplied!"); + return $str; + break; + } -<select name="fnt_color" onchange="javascript:insertTag(document.post_form.message, '[color='+document.post_form.fnt_color.options[this.selectedIndex].value+']', '[/color]'); document.post_form.fnt_color.options[0].selected=true"> -<option value="">Color</option> -<option value="skyblue" style="color: skyblue;">Sky Blue</option> -<option value="royalblue" style="color: royalblue;">Royal Blue</option> -<option value="blue" style="color: blue;">Blue</option> -<option value="darkblue" style="color: darkblue;">Dark Blue</option> -<option value="orange" style="color: orange;">Orange</option> -<option value="orangered" style="color: orangered;">Orange Red</option> -<option value="crimson" style="color: crimson;">Crimson</option> -<option value="red" style="color: red;">Red</option> -<option value="firebrick" style="color: firebrick;">Firebrick</option> -<option value="darkred" style="color: darkred;">Dark Red</option> -<option value="green" style="color: green;">Green</option> -<option value="limegreen" style="color: limegreen;">Lime Green</option> -<option value="seagreen" style="color: seagreen;">Sea Green</option> -<option value="deeppink" style="color: deeppink;">Deep Pink</option> -<option value="tomato" style="color: tomato;">Tomato</option> -<option value="coral" style="color: coral;">Coral</option> -<option value="purple" style="color: purple;">Purple</option> -<option value="indigo" style="color: indigo;">Indigo</option> -<option value="burlywood" style="color: burlywood;">Burly Wood</option> -<option value="sandybrown" style="color: sandybrown;">Sandy Brown</option> -<option value="sienna" style="color: sienna;">Sienna</option> -<option value="chocolate" style="color: chocolate;">Chocolate</option> -<option value="teal" style="color: teal;">Teal</option> -<option value="silver" style="color: silver;">Silver</option> -</select> + $str .= "<form style=\"clear: both;\" name=\"post_form\" method=\"post\" action=\"?mode=edit&task=" . + $task . "&fid=" . $fid . "&tid=" . $tid . "&pid=" . $pid . + "\" onSubmit=\"javascript: document.post_form.btn_submit.disabled = true;\">\n"; + $str .= " <p> Title: <input name=\"title\" style=\"width: 300px;\" value=\"" . + convert_xml($title) . "\"/></p>\n"; + $str .= " <p>\n"; -<select name="fnt_face" onchange="javascript:insertTag(document.post_form.message, '[font='+document.post_form.fnt_face.options[this.selectedIndex].value+']', '[/font]'); document.post_form.fnt_face.options[0].selected=true"> -<option value="">Font</option> -<option value="Arial" style="font-family: Arial;">Arial</option> -<option value="Times" style="font-family: Times;">Times</option> -<option value="Courier" style="font-family: Courier;">Courier</option> -<option value="Century" style="font-family: Century;">Century</option> -</select> */ ?> - <p> - Title: - <input name="title" style="width: 300px;" value="<?php echo convert_xml($title);?>"/> - </p> - <p> -<?php -include_once($UTIL_DIR . "/smileys.php"); -global $smileys; -foreach($smileys as $smiley) { - $smile = $smiley[0][0]; - if($smile == "\\m/") $smile = "\\\\m/"; - echo " <a href=\"javascript:addcontent('" . $smile . "');\"><img style=\"border: 0px\" alt=\"\" src=\"gfx/smileys/" . $smiley[1] . "\"/></a>"; -} -?> - </p> - <p> - <textarea rows="20" cols="65" name="message" onkeyup="storeCaret(this);" onclick="storeCaret(this);" onselect="storeCaret(this);"><?php echo convert_xml($message); ?></textarea> - </p> - <p> - <strong>To make a link, simply type the URL, and the system will - automagically transform it into an anchor (remember the - <em>http://</em> part)</strong>.<br/> - Example: http://www.example.com<br/> - </p> - <p> - <strong>To insert an image, simply type the URL to that image, it will - automagically be transformed into an image, with a link to the - original image (again, remember the <em>http://</em> part).</strong><br/> - Example: http://www.example.com/image.jpg - </p> - <p> - <button type="submit">Post</button> - </p> -</form> -<?php - if($pid != -1) $posts->show(); + include_once($UTIL_DIR . "/smileys.php"); + foreach($smileys as $smiley) { + $smile = $smiley[0][0]; + if($smile == "\\m/") $smile = "\\\\m/"; + $str .= " <a href=\"javascript:addcontent('" . $smile . + "');\"><img style=\"border: 0px\" alt=\"\" src=\"gfx/smileys/" . + $smiley[1] . "\"/></a>"; + } + $str .= " </p>\n"; + $str .= " <p>\n"; + $str .= " <textarea rows=\"20\" cols=\"65\" name=\"message\" onkeyup=\"storeCaret(this);\"". + " onclick=\"storeCaret(this);\" onselect=\"storeCaret(this);\">". + convert_xml($message) . "</textarea>\n"; + $str .= " </p>\n"; + $str .= " <p>\n"; + $str .= " <strong>To make a link, simply type the URL, and the system will\n"; + $str .= " automagically transform it into an anchor (remember the\n"; + $str .= " <em>http://</em> part)</strong>.<br/>\n"; + $str .= " Example: http://www.example.com<br/>\n"; + $str .= " </p>\n"; + $str .= " <p>\n"; + $str .= " <strong>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 <em>http://</em> part).</strong><br/>\n"; + $str .= " Example: http://www.example.com/image.jpg\n"; + $str .= " </p>\n"; + $str .= " <p>\n"; + $str .= " <button type=\"submit\">Post</button>\n"; + $str .= " </p>\n"; + $str .= "</form>\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 @@ <?php function error($msg) { - echo "<div class=\"error\">Error: " . $msg . "</div>\n"; - // exit($msg); + return "<div class=\"error\">Error: " . $msg . "</div>\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 " <div class=\"event\">\n"; - echo " <div class=\"title\">". $this->title . "\n"; - // echo " <a class=\"button\" href=\"\">Edit</a>\n"; - echo " </div>\n"; - echo " <div class=\"time\">" . date("G:i", $this->starttime) . " - " . - date("G:i", $this->starttime + $this->duration) . "</div>\n"; + $user = $users->getUser($this->user); + $str .= " <div class=\"event"; + if($this->concert == "true") $str .= " concert"; + $str .= "\">\n"; + $str .= " <div class=\"title\">". $this->title . "\n"; + // $str .= " <a class=\"button\" href=\"\">Edit</a>\n"; + $str .= " </div>\n"; + $str .= " <div class=\"time\">" . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "</div>\n"; if(!$client_is_mobile_device) { - echo " <div class=\"description\">". $this->description . "</div>\n"; + $str .= " <div class=\"description\">". $this->description . + "</div>\n"; } else { - echo " <div class=\"mobiledescription\">". $this->description . "</div>\n"; + $str .= " <div class=\"mobiledescription\">" . + $this->description . "</div>\n"; } - echo " <div class=\"user\">By: ".$user->name . "</div>\n"; - // echo " <a href=\"?mode=calendar&date=" . $date . "&eid=" . $this->eid . "&action=edit\">Edit</a>"; - echo " </div>\n"; + $str .= " <div class=\"user\">By: ".$user->name . "</div>\n"; + + $datestr = ""; + if(isset($GLOBALS['date'])) $datestr = "&date=". $GLOBALS['date']; + + $str .= " <a href=\"?mode=calendar" . $datestr . + "&eid=" . $this->eid . "&action=delete\">Delete</a>"; + $str .= " </div>\n"; + + return $str; + } + + public function show_simple() + { + global $users, $GLOBALS, $client_is_mobile_device; + + $str = ""; + + $str .= " <div class=\"event_simple\">\n"; + $str .= " <span class=\"date\">" . date("D d M Y", $this->starttime) . "</span>\n"; + $str .= " <span class=\"title\">". $this->title . "\n"; + $str .= " </span>\n"; + $str .= " <span class=\"time\">" . date("G:i", $this->starttime) . + " - " . date("G:i", $this->starttime + $this->duration) . "</span>\n"; + $str .= " </div>\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 "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n"; + $str .= "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\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 @@ <?php -include_once($UTIL_DIR . "/files.php"); +function filehandler() +{ + global $UTIL_DIR, $task, $_FILES, $FILE_MAX_SIZE, $DATA_DIR; + global $DEFAULT_MIME_TYPE, $MIME_TYPES; + + include_once($UTIL_DIR . "/files.php"); -$files = new Files($DATA_DIR . "/files.xml"); + $str = ""; -if($task == "upload") { + $files = new Files($DATA_DIR . "/files.xml"); - 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 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 .= "<form class=\"files\" enctype=\"multipart/form-data\" action=\"?mode=filehandler&task=upload\" method=\"post\">"; + $str .= "<p>File: <input name=\"userfile\" type=\"file\"></p>\n"; + $str .= "<p>Use alternative filename (leave empty to use original filename):<input name=\"filename\" value=\"".$description."\"/></p>\n"; + $str .= "<p><button type=\"submit\">Add file</button></p>"; + $str .= "</form>"; -$files->show(); + $str .= $files->show(); -?> -<form class="files" enctype="multipart/form-data" action="?mode=filehandler&task=upload" method="post"> - <p> - File: <input name="userfile" type="file"> - </p> - <p> - Use alternative filename (leave empty to use original filename): - <input name="filename" value="<?php echo $description ?>"/> - </p> - <p> - <button type="submit">Add file</button> - </p> -</form> + 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 " <div class=\"file\">\n"; + + $str = ""; + + $str .= " <div class=\"file\">\n"; if($current_user->uid == 0) { - echo " <a class=\"delete\" onclick=\"return confirm('Really delete?')\" onkeypress=\"return confirm('Really delete?')\" href=\"?mode=filehandler&task=delete&fid=" . $this->fid . "\">X</a>\n"; + $str .= " <a class=\"delete\" onclick=\"return confirm('Really delete?')\" onkeypress=\"return confirm('Really delete?')\" href=\"?mode=filehandler&task=delete&fid=" . $this->fid . "\">X</a>\n"; } - echo " <div class=\"preview\"><a href=\"" . $this->link() . "\"><img src=\"?mode=file&preview=1&fid=" . $this->fid . "\"/></a></div>\n"; - echo " <div class=\"insertcommand\">{{" . $this->fid . "}}</div>\n"; - echo " <div class=\"filename\"><a href=\"" . $this->link() . "\">" . $this->name . "</a></div>\n"; - echo " <div class=\"mimetype\">" . $this->mimetype. "</div>\n"; - echo " <div class=\"fileuser\">" . $users->getUser($this->uid)->name . "</div>\n"; - echo " <div class=\"filesize\">" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb</div>\n"; - echo " <div class=\"filedate\">" . date("M jS Y - G:i", $this->date) . "</div>\n"; - echo " </div>\n"; + $str .= " <div class=\"preview\"><a href=\"" . $this->link() . "\"><img src=\"?mode=file&preview=1&fid=" . $this->fid . "\"/></a></div>\n"; + $str .= " <div class=\"insertcommand\">{{" . $this->fid . "}}</div>\n"; + $str .= " <div class=\"filename\"><a href=\"" . $this->link() . "\">" . $this->name . "</a></div>\n"; + $str .= " <div class=\"mimetype\">" . $this->mimetype. "</div>\n"; + $str .= " <div class=\"fileuser\">" . $users->getUser($this->uid)->name . "</div>\n"; + $str .= " <div class=\"filesize\">" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb</div>\n"; + $str .= " <div class=\"filedate\">" . date("M jS Y - G:i", $this->date) . "</div>\n"; + $str .= " </div>\n"; + + return $str; } public function File($fid, $uid, $name, $date, $mimetype) @@ -83,25 +88,30 @@ class Files { public function show() { global $current_user; - echo "<div class=\"files\">\n"; - echo " <div class=\"file\">\n"; - echo " <div class=\"fileheader\">\n"; + + $str = ""; + + $str .= "<div class=\"files\">\n"; + $str .= " <div class=\"file\">\n"; + $str .= " <div class=\"fileheader\">\n"; if($current_user->uid == 0) { - echo " <div class=\"delete\"></div>\n"; + $str .= " <div class=\"delete\"></div>\n"; } - echo " <div class=\"preview\">Preview</div>\n"; - echo " <div class=\"insertcommand\">Command</div>\n"; - echo " <div class=\"filename\">Filename</div>\n"; - echo " <div class=\"mimetype\">Mimetype</div>\n"; - echo " <div class=\"fileuser\">User</div>\n"; - echo " <div class=\"filesize\">Size</div>\n"; - echo " <div class=\"filedate\">Date</div>\n"; - echo " </div>\n"; - echo " </div>\n"; + $str .= " <div class=\"preview\">Preview</div>\n"; + $str .= " <div class=\"insertcommand\">Command</div>\n"; + $str .= " <div class=\"filename\">Filename</div>\n"; + $str .= " <div class=\"mimetype\">Mimetype</div>\n"; + $str .= " <div class=\"fileuser\">User</div>\n"; + $str .= " <div class=\"filesize\">Size</div>\n"; + $str .= " <div class=\"filedate\">Date</div>\n"; + $str .= " </div>\n"; + $str .= " </div>\n"; foreach($this->files as $file) { - $file->show(); + $str .= $file->show(); } - echo "</div>\n"; + $str .= "</div>\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 " <div class=\"forum\">\n"; - echo " <span class=\"forum_icon".$newcls."\"></span>\n"; - echo " <a class=\"forum_title\" href=\"?fid=" . $this->fid . "\">" . $this->name . "</a>\n"; - echo " <span class=\"forum_latestpost\">".$this->latestPost."</span>\n"; - echo " <span class=\"forum_numberofthreads\">".sprintf("%d", $this->numPosts)." threads</span>\n"; - echo " </div>\n"; + if($yeah) { + $lp = $cache->get("forum_lastpost"); + if($lp->value($this->fid)) $newcls = " forum_new"; + } else { + if($this->newStuff) $newcls = " forum_new"; + } + + $str .= " <div class=\"forum\">\n"; + $str .= " <span class=\"forum_icon".$newcls."\"></span>\n"; + $str .= " <a class=\"forum_title\" href=\"?fid=" . + $this->fid . "\">" . $this->name . "</a>\n"; + $str .= " <span class=\"forum_latestpost\">". + $this->latestPost . "</span>\n"; + if($yeah) { + $fc = $cache->get("forum_numberofthreads"); + + $str .= " <span class=\"forum_numberofthreads\">" . + $fc->value($this->fid) . " threads</span>\n"; + } else { + $str .= " <span class=\"forum_numberofthreads\">" + . sprintf("%d", $this->numPosts)." threads</span>\n"; + } + $str .= " </div>\n"; + + return $str; } public function Forum($fid, $name) @@ -84,11 +106,15 @@ class Forums { public function show() { - echo "<div class=\"forums\">\n"; + $str = ""; + + $str .= "<div class=\"forums\">\n"; foreach($this->forums as $forum) { - $forum->show(); + $str .= $forum->show(); } - echo "</div>\n"; + $str .= "</div>\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 . "<div class=\"post\">\n"; + $str .= $indent . "<div class=\"post\">\n"; if($client_is_mobile_device) { $avatar = "mobileavatar.gif"; } else { if($user->avatar) $avatar = $user->avatar; else $avatar = "default.gif"; } - echo $indent . " <img class=\"avatar\" alt=\"avatar\" src=\"gfx/avatars/" . $avatar . "\"/>\n"; + $str .= $indent . " <img class=\"avatar\" alt=\"avatar\" src=\"gfx/avatars/" . $avatar . "\"/>\n"; if(!$client_is_mobile_device) { - echo $indent . " <div class=\"id\">ID: " . $this->pid . "</div>\n"; - echo $indent . " <div class=\"title\">Title: " . convert_xml($this->title) . "</div>\n"; + $str .= $indent . " <div class=\"id\">ID: " . $this->pid . "</div>\n"; + $str .= $indent . " <div class=\"title\">Title: " . convert_xml($this->title) . "</div>\n"; } - echo $indent . " <div class=\"user\">"; - if(!$client_is_mobile_device) echo "UserID: "; - echo $user->name . "</div>\n"; - echo $indent . " <div class=\"date\">"; - if(!$client_is_mobile_device) echo "Date: "; - echo date("j. M Y - G:i", $this->date) . "</div>\n"; - echo $indent . " <div class=\"message\">\n"; - echo parse($this->message, $indent . " ") . "\n"; + $str .= $indent . " <div class=\"user\">"; + if(!$client_is_mobile_device) $str .= "UserID: "; + $str .= $user->name . "</div>\n"; + $str .= $indent . " <div class=\"date\">"; + if(!$client_is_mobile_device) $str .= "Date: "; + $str .= date("j. M Y - G:i", $this->date) . "</div>\n"; + $str .= $indent . " <div class=\"message\">\n"; + $str .= parse($this->message, $indent . " ") . "\n"; if(trim($user->signature) != "") { - echo $indent . " <div class=\"signature\">\n"; - echo parse("--------------------------\n" . $user->signature, $indent . " ") . "\n"; - echo $indent . " </div>\n"; + $str .= $indent . " <div class=\"signature\">\n"; + $str .= parse("--------------------------\n" . $user->signature, $indent . " ") . "\n"; + $str .= $indent . " </div>\n"; } - echo $indent . " </div>\n"; - echo $indent . " <div class=\"buttons\">\n"; + $str .= $indent . " </div>\n"; + $str .= $indent . " <div class=\"buttons\">\n"; if($current_user->uid == $this->user) { - echo $indent . + $str .= $indent . " <a href=\"?mode=editor&task=edit&fid=".$fid. "&tid=".$tid. "&pid=".$this->pid."\">"; - echo "<img alt=\"edit\" src=\"gfx/btn_edit.gif\"/></a>\n"; + $str .= "<img alt=\"edit\" src=\"gfx/btn_edit.gif\"/></a>\n"; } - echo $indent . + $str .= $indent . " <a href=\"?mode=editor&task=quote&fid=".$fid. "&tid=".$tid. "&pid=".$this->pid."\">"; - echo "<img alt=\"quote\" src=\"gfx/btn_quote.gif\"/></a>\n"; + $str .= "<img alt=\"quote\" src=\"gfx/btn_quote.gif\"/></a>\n"; - echo $indent . + $str .= $indent . " <a href=\"?mode=editor&task=reply&fid=".$fid. "&tid=".$tid. "&pid=".$this->pid."\">"; - echo "<img alt=\"reply\" src=\"gfx/btn_reply.gif\"/></a>\n"; + $str .= "<img alt=\"reply\" src=\"gfx/btn_reply.gif\"/></a>\n"; - echo $indent . " </div>\n"; - echo $indent . " <div class=\"replies\">\n"; + $str .= $indent . " </div>\n"; + $str .= $indent . " <div class=\"replies\">\n"; if($recurse) { foreach($this->replies as $reply) { - $reply->show($indent . " "); + $str .= $reply->show($indent . " "); } } - echo $indent . " </div>\n"; - echo $indent . "</div>\n"; + $str .= $indent . " </div>\n"; + $str .= $indent . "</div>\n"; + + return $str; } public function Post($pid, $title, $user, $date, $message = "") @@ -185,15 +189,17 @@ class Posts { { global $current_user; - echo " <p><a href=\"#menu_bottom\">Down to the bottom</a>"; + $str = ""; + + $str .= " <p><a href=\"#menu_bottom\">Down to the bottom</a>"; foreach($this->posts_linear as $post) { if($post->date > $this->thread->lastseen[$current_user->uid]) { - echo " <a href=\"#firstunread\">Down to first unread</a>\n"; + $str .= " <a href=\"#firstunread\">Down to first unread</a>\n"; break; } } - echo "</p>\n"; - echo " <h1>" . $this->thread->name . "</h1>\n"; + $str .= "</p>\n"; + $str .= " <h1>" . $this->thread->name . "</h1>\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 " <div id=\"firstunread\"></div>\n"; - echo " <div class=\"unread\">\n"; + $str .= " <div id=\"firstunread\"></div>\n"; + $str .= " <div class=\"unread\">\n"; } - $post->show(" ", false); + $str .= $post->show(" ", false); } if($firstunread == true) { - echo " </div>\n"; + $str .= " </div>\n"; } $this->thread->lastseen[$current_user->uid] = time(); $this->write(); - echo " <p><a href=\"#menu_top\">Up to the top</a></p>\n"; + $str .= " <p><a href=\"#menu_top\">Up to the top</a></p>\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 @@ <?php -include_once($UTIL_DIR . "/error.php"); +function profile() +{ + global $action, $_FILES, $current_user, $UTIL_DIR; + include_once($UTIL_DIR . "/error.php"); + + $str = ""; -if($action == "update") { -// $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($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(); -} -?> - -<form method="post" enctype="multipart/form-data" action="?mode=profile&action=update"><?php - /*Username: <input name="username" value="<?php echo $current_user->username; ?>"><br/> */ ?> - Name: <input name="name" value="<?php echo $current_user->name; ?>"><br/> - New password: <input type="password" name="password" value=""><br/> - Confirm password: <input type="password" name="password_confirm" value=""><br/> - E-Mail: <input name="email" value="<?php echo $current_user->email; ?>"><br/> - Avatar:<br/> - <img alt="Avatar" src="gfx/avatars/<?php echo $current_user->avatar; ?>"/><br/> - <input name="userfile" type="file"><br/> - Signature:<br/> - <textarea name="signature" cols="60" rows="2"><?php echo $current_user->signature ?></textarea><br/> - <br/> - <button type="submit">Update</button> -</form> + $str .= "<form method=\"post\" enctype=\"multipart/form-data\" action=\"?mode=profile&action=update\">"; + //$str .= " Username: <input name=\"username\" value=\"" . $current_user->username . "\"<br/>"; + $str .= " Name: <input name=\"name\" value=\"" . $current_user->name . "\"><br/>"; + $str .= " New password: <input type=\"password\" name=\"password\" value=\"\"><br/>"; + $str .= " Confirm password: <input type=\"password\" name=\"password_confirm\" value=\"\"><br/>"; + $str .= " E-Mail: <input name=\"email\" value=\"" . $current_user->email . "\"><br/>"; + $str .= " Avatar:<br/>"; + $str .= " <img alt=\"Avatar\" src=\"gfx/avatars/" . $current_user->avatar . "\"/><br/>"; + $str .= " <input name=\"userfile\" type=\"file\"><br/>"; + $str .= " Signature:<br/>"; + $str .= " <textarea name=\"signature\" cols=\"60\" rows=\"2\">". $current_user->signature . "</textarea><br/>"; + $str .= " <br/>"; + $str .= " <button type=\"submit\">Update</button>"; + $str .= "</form>"; + + 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 .= "<form method=\"post\" enctype=\"multipart/form-data\" action=\"?mode=tasks&action=add\">\n"; + $str .= " Title: <input name=\"title\" value=\"\"> - User: " . userList($current_user->uid) . " -"; + $str .= " Deadline: D<input placeholder=\"day\" name=\"deadline_day\" style=\"width: 2em\" value=\"\">\n"; + $str .= " M<input placeholder=\"month\" name=\"deadline_month\" style=\"width: 2em\" value=\"\">\n"; + $str .= " Y<input placeholder=\"year\" name=\"deadline_year\" style=\"width: 4em\" value=\"\"><br/>\n"; + $str .= " Reassignable: <input name=\"reassignable\" type=\"checkbox\" checked><br/>\n"; + $str .= " <textarea name=\"description\" cols=\"80\" rows=\"2\"></textarea><br/>\n"; + $str .= " <button style=\"width: 120px\" type=\"submit\">Add Task</button>\n"; + $str .= "</form>\n"; + $str .= "<hr/>\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; } - ?> -<form method="post" enctype="multipart/form-data" action="?mode=tasks&action=add"> - Title: <input name="title" value=""> - User: <?php echo userList($current_user->uid); ?> - Deadline: D<input placeholder="day" name="deadline_day" style="width: 2em" value=""> - M<input placeholder="month" name="deadline_month" style="width: 2em" value=""> - Y<input placeholder="year" name="deadline_year" style="width: 4em" value=""><br/> - Reassignable: <input name="reassignable" type="checkbox" checked><br/> - <textarea name="description" cols="80" rows="2"></textarea><br/> - <button style="width: 120px" type="submit">Add Task</button> -</form> -<hr/> -<?php -echo $tasks->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 " <div class=\"thread\">\n"; - echo " <span class=\"thread_icon".$newcls."\"> </span>\n"; - echo " <a class=\"thread_title\" href=\"?fid=" . $fid . - "&tid=" . $this->tid . $jumptonew."\">" . $this->name . "</a>\n"; - echo " <span class=\"thread_numposts\">".$this->numposts." posts"; + $str .= " <div class=\"thread\">\n"; + $str .= " <span class=\"thread_icon".$newcls."\"> </span>\n"; + $str .= " <span class=\"thread_title\"><a href=\"?fid=" . $fid . + "&tid=" . $this->tid . $jumptonew."\">" . $this->name . "</a></span>\n"; + $str .= " <span class=\"thread_numposts\">".$this->numposts." posts"; if($this->numunread != 0) { - echo " <strong>(".$this->numunread." unread)</strong>"; + $str .= " <strong>(".$this->numunread." unread)</strong>"; } - echo "</span>\n"; - echo " <span class=\"thread_lastpost\">Last post: ". + $str .= "</span>\n"; + $str .= " <span class=\"thread_lastpost\">Last post: ". date("j. M Y - G:i", $this->lastpost)."</span>\n"; $user = $users->getUser($this->first_user); - echo " <span class=\"thread_createdby\">By ".$user->name; - echo " at ". date("j. M Y - G:i", $this->first_date)."</span>\n"; - echo " </div>\n"; + $str .= " <span class=\"thread_createdby\">By ".$user->name; + $str .= " at ". date("j. M Y - G:i", $this->first_date)."</span>\n"; + $str .= " </div>\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 @@ <?php -echo " <div class=\"navigation\">"; -if($fid) { - echo "Legend: <a href=\"?\">Forums</a>"; - if($tid) { - include_once("forums.php"); - $forums = new Forums($FORUMS_DIR . "/forums.xml"); - $forum = $forums->getForum($fid); - echo " :: <a href=\"?fid=" . $fid . "\">".$forum->name."</a>"; - - 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 " <h1>Threads in '".$forum->name."'</h1>\n"; - echo " <a href=\"?mode=editor&task=new&fid=".$fid. - "&tid=".time()."&pid=-1\">New thread</a>\n"; + +function viewForum() +{ + global $fid, $tid, $action, $current_user, $UTIL_DIR, + $FORUMS_DIR, $smileys; + + $legend = " <div class=\"navigation\">"; + $f_str = ""; + if($fid) { + $legend .= "Legend: <a href=\"?\">Forums</a>"; + if($tid) { + include_once($UTIL_DIR . "/forums.php"); + $forums = new Forums($FORUMS_DIR . "/forums.xml"); + $forum = $forums->getForum($fid); + $legend .= " :: <a href=\"?fid=" . $fid . "\">".$forum->name."</a>"; + + 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 .= " <h1>Threads in '".$forum->name."'</h1>\n"; + $f_str .= " <a href=\"?mode=editor&task=new&fid=".$fid. + "&tid=".time()."&pid=-1\">New thread</a>\n"; - include_once("threads.php"); - $threads = new Threads($FORUMS_DIR . "/" . $fid); - $threads->show(); - } -} else { - echo "Legend: Forums"; - echo " <h1>Forums</h1>\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 .= " <h1>Forums</h1>\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) { -?> -<form method="post" action="?mode=forum&action=addforum"> -Add new forum: <input name="title" value=""><button type="submit">Add</button> -</form> -<?php - } + if($current_user->uid == 0) { + $f_str .= "<form method=\"post\" action=\"?mode=forum&action=addforum\">\n"; + $f_str .= "Add new forum: <input name=\"title\" value=\"\"><button type=\"submit\">Add</button>\n"; + $f_str .= "</form>\n"; + } + } + + $legend .= "</div>\n"; + + return $legend . $f_str; } -echo "</div>\n"; ?>
\ No newline at end of file |