diff options
36 files changed, 2058 insertions, 1019 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 diff --git a/htdocs/admin.css b/htdocs/admin.css index d81f420..d3f1e1e 100644 --- a/htdocs/admin.css +++ b/htdocs/admin.css @@ -25,7 +25,7 @@ border-radius: 6px; } -.admin .header { +.admin .mainheader { display: inline-block; text-align: center; background-image: none; @@ -64,7 +64,7 @@ display: box; } -.admin .menu, +.admin .adminmenu, .admin .submenu, .admin .form { background-color: #fff; @@ -85,7 +85,7 @@ border-radius: 6px; } -.admin .menu, +.admin .adminmenu, .admin .submenu { width: 704px; } @@ -95,18 +95,18 @@ padding: 10px; } -.admin .menu { +.admin .adminmenu { margin-top: 0px; min-height: 12px; } -.admin .menu .entry, +.admin .adminmenu .entry, .admin .submenu .entry { + border-color: #eee; color: #000; background-color: #eee; text-align: center; - border-color: inherit; border-width: inherit; border-style: outset; font-size: 10px; @@ -126,7 +126,7 @@ min-height: 12px; } -.admin .menu .active, +.admin .adminmenu .active, .admin .submenu .active { border-style: inset; background-color: #ffc; diff --git a/htdocs/index.php b/htdocs/index.php index d389e6d..f20f0af 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,4 +1,5 @@ <?php + $start_time = microtime(true); if(file_exists("config.php")) include_once("config.php"); @@ -39,7 +40,8 @@ include_once($MODULES_DIR . "/pages.php"); $pages = new Pages($DATA_DIR . "/pages.xml"); -if($config->value('splash') == "true") { +// Skip splash if site is entered deep (page != ""). +if($page == "" && $config->value('splash') == "true") { if($_GET["skipsplash"]) { setcookie("skipsplash", "true", time()+$config->value('splashreshow')); } diff --git a/utils/admin.php b/utils/admin.php index df3a9df..6b8b8e0 100644 --- a/utils/admin.php +++ b/utils/admin.php @@ -1,6 +1,6 @@ <?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ ?> <div class="admin" id="admin"> - <span class="header windowtitle">Admin</span> + <span class="mainheader windowtitle">Admin</span> <div class="button close"><a href="?page=">X</a></div> <?php global $loggedin; @@ -15,7 +15,7 @@ global $DATA_DIR; $user = $users->findUser($UID); ?> <a class="logout" href="?page=admin&action=logout">Logout <span class="user"><?php echo $UID;?></span></a> -<div class="menu"> +<div class="adminmenu"> <?php include_once($UTIL_DIR . "/modules.php"); diff --git a/utils/forms.php b/utils/forms.php index 39e1a4c..d6fdada 100644 --- a/utils/forms.php +++ b/utils/forms.php @@ -89,14 +89,19 @@ class CheckBox { { $this->label = $label; $this->name = $name; - $this->value = $value; + if($value == true || $value == "on" || $value == "true" || $value == "yes") + $this->value = "checked "; + else + $this->value = ""; } public function render($indent = "") { $str = $indent . "<div class=\"input\">\n"; - $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n"; - $str .= $indent . " <div class=\"widget\"><input type=\"checkbox\" name=\"vars[".$this->name."]\" value=\"".xmlenc($this->value)."\"/></div>\n"; + $str .= $indent . " <div class=\"label\">". xmlenc($this->label) ."</div>\n"; + $str .= $indent . " <div class=\"widget\">". + "<input type=\"checkbox\" name=\"vars[".$this->name."]\" ".$this->value."value=\"on\"/>". + "</div>\n"; $str .= $indent . "</div>\n"; return $str; } @@ -132,7 +137,7 @@ class ComboBox { class Hidden { public $values; - + public function Hidden($values) { $this->values = $values; @@ -280,13 +285,14 @@ class ImageComboBox { class ListEditor { public $label, $name, $namewidget, $valuewidget, $values; - public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array()) + public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array(), $commalist = false) { $this->label = $label; $this->name = $name; $this->namewidget = $namewidget; $this->valuewidget = $valuewidget; $this->values = $values; + $this->commalist = $commalist; } public function render($indent = "") @@ -354,11 +360,17 @@ class ListEditor { $str .= $indent . "}\n"; $str .= $indent . "//-->\n"; $str .= $indent . "</script>\n"; - $str .= $indent . "<select multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n"; - if(sizeof($this->values)) { - foreach($this->values as $key => $val) { - $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n"; - } + $str .= $indent . "<select style=\"min-width: 200px;\" multiple size=\"8\" id=\"items\" name=\"".$this->name."[]\">\n"; + if($this->values) { + if($this->commalist) { + foreach($this->values as $val) { + $str .= $indent . " <option value=\"".$val."\">".$val."</option>\n"; + } + } else { + foreach($this->values as $key => $val) { + $str .= $indent . " <option value=\"".$key.":".$val."\">".$key.":".$val."</option>\n"; + } + } } $str .= $indent . "</select><br/>\n"; $str .= $indent . "<div class=\"button\" button onclick=\"moveUp()\">/\</div><br/>\n"; @@ -373,12 +385,38 @@ class ListEditor { public function splitValues($values) { $out = array(); - foreach($values as $value) { - $vals = explode(":", $value); - $out[$vals[0]]=$vals[1]; - } + if($values) { + foreach($values as $value) { + $vals = explode(":", $value); + + /* + $out[$vals[0]]=$vals[1]; + */ + + $_keys = array_keys($out); + $_vals = array_values($out); + + array_push($_keys, $vals[0]); + array_push($_vals, $vals[1]); + + $out = array_combine($_keys, $_vals); + } + } return $out; } + + function combineValues($values) + { + $out = array(); + if($values) { + foreach($values as $k => $v) { + $value = $k.":".$v; + array_push($out, $value); + } + } + return $out; + } + } class MultiList { diff --git a/utils/imagecache.php b/utils/imagecache.php index 3f91d79..5adf54c 100644 --- a/utils/imagecache.php +++ b/utils/imagecache.php @@ -7,16 +7,38 @@ include_once($UTIL_DIR . "/modules.php"); class ImageSize { public $width; public $height; + public $cut; - public function ImageSize($w, $h) + public function ImageSize($w, $h, $c) { $this->width = $w; $this->height = $h; + $this->cut = $c; } }; -function rescale($image, $width, $height) +function rescale_nocut($image, $maxwidth, $maxheight) { + $width = imagesx($image); + $height = imagesy($image); + + if($width <= $maxwidth && $height <= $maxheight) return $image; + + $scale = 1; + if($width > $maxwidth) $scale = $width / $maxwidth; + if($height / $scale > $maxheight) $scale = $height / $maxheight; + + $image_p = imagecreatetruecolor($width / $scale, $height / $scale); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width / $scale, + $height / $scale, $width, $height); + + return $image_p; +} + +function rescale($image, $width, $height, $cut) +{ + if($cut == false) return rescale_nocut($image, $width, $height); + $aspect = $width / $height; $w = imagesx($image); @@ -60,27 +82,19 @@ function errorImage($message) function getCachedImage($filename, $mod, $cat) { - global $modules; - loadModule($mod); - if(!$modules[$mod]) die(404); - if(!method_exists($modules[$mod], "getImageSize")) die(404); + $module = loadModule($mod); + if(!$module) die(404); + if(!method_exists($module, "getImageSize")) die(404); - $size = $modules[$mod]->getImageSize($cat); + $size = $module->getImageSize($cat); $maxwidth = $size->width; $maxheight = $size->height; + $cut = $size->cut; - /* - if($mod == "discography") { - if($cat == "cover") { $maxwidth = 100; $maxheight = 100; } - } - if($mod == "gallery") { - if($cat == "randomimage") { $maxwidth = 100; $maxheight = 100; } - if($cat == "photo") { $maxwidth = 100; $maxheight = 100; } - if($cat == "albumicon") { $maxwidth = 100; $maxheight = 100; } - } - */ global $IMAGECACHE, $JPEG_CACHE_QUALITY; - $fullfilename = $IMAGECACHE . "/" . $maxwidth . ":" . $maxheight . ":". urlencode($filename); + $cutstr = "uncut"; + if($cut) $cutstr = "cut"; + $fullfilename = $IMAGECACHE . "/" . $maxwidth . ":" . $maxheight . ":" . $cutstr . ":" . urlencode($filename); // Test the storage dir if(!file_exists($IMAGECACHE)) { @@ -106,21 +120,21 @@ function getCachedImage($filename, $mod, $cat) case ".jpg": $image = imagecreatefromjpeg(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagejpeg($image, $fullfilename, $JPEG_CACHE_QUALITY); break; case ".gif": $image = imagecreatefromgif(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagegif($image, $fullfilename); break; case ".png": $image = imagecreatefrompng(urldecode($filename)); if(!$image) errorImage("Could not read: ". $filename); - $image = rescale($image, $maxwidth, $maxheight); + $image = rescale($image, $maxwidth, $maxheight, $cut); imagepng($image, $fullfilename); break; diff --git a/utils/mail.php b/utils/mail.php index 02d1b7f..f0d46ac 100644 --- a/utils/mail.php +++ b/utils/mail.php @@ -16,8 +16,8 @@ class Email { $headers = "From: " . $sender . "\r\n"; $headers .= "Reply-To: " . $replyto . "\r\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; - $headers .= "X-Mailer: PHP/" . phpversion(); - + // $headers .= "X-Mailer: PHP/" . phpversion(); + $headers .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7"; return mail($this->email, utf8_decode($subject), utf8_decode($message), $headers); } } diff --git a/utils/modules.php b/utils/modules.php index c363e6d..4718f95 100644 --- a/utils/modules.php +++ b/utils/modules.php @@ -26,16 +26,18 @@ function loadModule($modulename) global $MODULES_DIR; global $modules; - $modulefile = $MODULES_DIR . "/" . $modulename . ".php"; if(!$modules[$modulename]) { + $modulefile = $MODULES_DIR . "/" . $modulename . ".php"; if(file_exists($modulefile)) { include_once($modulefile); $module = call_user_func($modulename . "_init"); $modules[$modulename] = $module; } else { // Module does not exist. + return; } } + return $modules[$modulename]; } function loadAllModules() diff --git a/utils/modules/config.php b/utils/modules/config.php index 13cdda1..dcdedda 100644 --- a/utils/modules/config.php +++ b/utils/modules/config.php @@ -43,12 +43,32 @@ class Config { echo "The stylesheet has now been changed to \"". $this->value("css") . "\""; $this->write(); break; - + /* + case "css_test_start": + setCookie("testcss", $vars["css"]); + break; + + case "css_test_stop": + deleteCookie("testcss"); + break; + */ default: $form = new Form("update"); $form->addWidget(new LineEdit("CSS file:", "css", $this->value("css", "CSS not yet set"))); $form->addWidget(new Button("Update")); $form->render(); + /* + if(!$testcss) { + $form = new Form("css_test_start"); + $form->addWidget(new LineEdit("Test CSS file:", "css", "")); + $form->addWidget(new Button("Start CSS test")); + $form->render(); + } else { + $form = new Form("css_test_stop"); + $form->addWidget(new Button("Stop CSS test")); + $form->render(); + } + */ break; } } @@ -173,6 +193,7 @@ class Config { public function value($name, $default = "") { + if($GLOBALS["test"] == "1" && $name == "css") return "design/rotr/style.css"; if(isset($this->configs[$name])) return $this->configs[$name]; return $default; } diff --git a/utils/modules/discography.php b/utils/modules/discography.php index 3bbce99..d390a3b 100644 --- a/utils/modules/discography.php +++ b/utils/modules/discography.php @@ -1,92 +1,100 @@ -<?php -/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ global $UTIL_DIR; include_once($UTIL_DIR . "/convert.php"); include_once($UTIL_DIR . "/markdown.php"); +include_once($UTIL_DIR . "/refs.php"); function time2str($t) { - $min = sprintf("%d", floor($t / 60)); - $sec = $t % 60; - return sprintf("%d:%02d", $min ,$sec); + $min = sprintf("%d", floor($t / 60)); + $sec = $t % 60; + return sprintf("%d:%02d", $min ,$sec); } function createNewlines($in) { - $str = ""; - $head = substr($in, 0, strpos($in, "\n")); - $tail = substr($in, strpos($in, "\n")+1); - $str .= "<div class=\"header\"><h2 class=\"lyrics_header\"><div class=\"header_text\">".$head."</div></h2></div>\n"; - $str .= str_replace("\n", "<br/>\n", $tail); - return $str; + $str = ""; + $head = substr($in, 0, strpos($in, "\n")); + $tail = substr($in, strpos($in, "\n")+1); + $str .= "<div class=\"header\"><h2 class=\"lyrics_header\">". + "<div class=\"header_text\">".$head."</div></h2></div>\n"; + $str .= str_replace("\n", "<br/>\n", $tail); + return $str; } class Track { - public $title; - public $number; - public $playtime; - public $previewurl; - public $lyrics; - - public function write($fp) - { - fwrite($fp, " <track title=\"" . - htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " number=\"" . $this->number . "\"\n"); - fwrite($fp, " playtime=\"" . $this->playtime . "\"\n"); - fwrite($fp, " previewurl=\"" . $this->previewurl . "\">\n"); - fwrite($fp, " <lyrics>".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n"); - fwrite($fp, " </track>\n"); - } + public $title; + public $number; + public $playtime; + public $previewurl; + public $lyrics; - public function showLyrics() - { - $str = ""; - if($this->lyrics) { - $str .= createNewlines(htmlspecialchars_decode($this->lyrics)); - } - return $str; - } + public function write($fp) + { + fwrite($fp, " <track title=\"" . + htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " number=\"" . $this->number . "\"\n"); + fwrite($fp, " playtime=\"" . $this->playtime . "\"\n"); + fwrite($fp, " previewurl=\"" . $this->previewurl . "\">\n"); + fwrite($fp, " <lyrics>". + htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n"); + fwrite($fp, " </track>\n"); + } - public function show($disc) - { - global $GLOBALS; - - $page = $GLOBALS["page"]; - $str = ""; - $str .= " <div class=\"track\">\n"; - - $str .= " <span class=\"preview\">\n"; - if($this->previewurl) { - $str .= " <object type=\"application/x-shockwave-flash\" data=\"player_mp3_maxi.swf\" width=\"25\" height=\"12\">\n"; - $str .= " <param name=\"movie\" value=\"player_mp3_maxi.swf\"/>\n"; - $str .= " <param name=\"FlashVars\" value=\"mp3=".$this->previewurl."&showslider=0&width=25&height=12&skin=design/mors/chicken.jpg\"/>\n"; - $str .= " </object>\n"; - } else { - } - $str .= " </span>\n"; - - $str .= " <span class=\"number\">".$this->number.". </span>\n"; - $str .= " <span class=\"title\">".$this->title."</span>\n"; - $str .= " <span class=\"playtime\">".time2str($this->playtime)."</span>\n"; - if($this->lyrics) { - $str .= " <a href=\"?page=".$page."&lyrics=".$disc."&track=".$this->number."\">Lyrics</a>\n"; - } - $str .= " </div>\n"; - - return $str; - } + public function showLyrics() + { + $str = ""; + if($this->lyrics) { + $str .= createNewlines(htmlspecialchars_decode($this->lyrics)); + } + return $str; + } - public function Track($title, $number, $playtime, $previewurl, $lyrics) - { - $this->title = $title; - $this->number = $number; - $this->playtime = $playtime; - $this->previewurl = $previewurl; - $this->lyrics = $lyrics; - } + public function show($disc) + { + global $GLOBALS; + + $page = $GLOBALS["page"]; + $str = ""; + $str .= " <div class=\"track\">\n"; + + $str .= " <span class=\"preview\">\n"; + if($this->previewurl) { + $str .= " <object type=\"application/x-shockwave-flash\" ". + "data=\"player_mp3_maxi.swf\" width=\"25\" height=\"12\">\n"; + $str .= " <param name=\"movie\" ". + "value=\"player_mp3_maxi.swf\"/>\n"; + $str .= " <param name=\"FlashVars\" value=\"mp3=". + $this->previewurl."&showslider=0&width=25&height=12&". + "skin=design/rotr/chicken.jpg\"/>\n"; + $str .= " </object>\n"; + } else { + } + $str .= " </span>\n"; + + $str .= " <span class=\"number\">".$this->number.". </span>\n"; + $str .= " <span class=\"title\">".$this->title."</span>\n"; + $str .= " <span class=\"playtime\">".time2str($this->playtime). + "</span>\n"; + if($this->lyrics) { + $str .= " <a href=\"?page=".$page."&lyrics=".$disc. + "&track=".$this->number."\">Lyrics</a>\n"; + } + $str .= " </div>\n"; + + return $str; + } + + public function Track($title, $number, $playtime, $previewurl, $lyrics) + { + $this->title = $title; + $this->number = $number; + $this->playtime = $playtime; + $this->previewurl = $previewurl; + $this->lyrics = $lyrics; + } } class Disc { @@ -94,88 +102,137 @@ class Disc { public $releasetime; public $description; public $cover; - public $releaser; - public $tracks = array(); - - public function write($fp) - { - fwrite($fp, " <disc title=\"" . - htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " releasetime=\"" . $this->releasetime . "\"\n"); - fwrite($fp, " description=\"" . - htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " cover=\"" . $this->cover . "\"\n"); - fwrite($fp, " releaser=\"" . $this->releaser . "\">\n"); - fwrite($fp, " <tracks>\n"); - if($this->tracks) { - foreach($this->tracks as $track) { - $track->write($fp); - } - } - fwrite($fp, " </tracks>\n"); - fwrite($fp, " </disc>\n"); - } + public $releaser; + public $tracks = array(); + // public $reviews = array(); + public $refs; - public function showLyrics($number) - { - $str = ""; - if($this->tracks) { - foreach($this->tracks as $track) { - if($track->number == $number) { - $str .= $track->showLyrics(); - break; - } - } - } - return $str; + public function write($fp) + { + fwrite($fp, " <disc title=\"" . + htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " releasetime=\"" . $this->releasetime . "\"\n"); + fwrite($fp, " description=\"" . + htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " cover=\"" . $this->cover . "\"\n"); + fwrite($fp, " releaser=\"" . $this->releaser . "\">\n"); + fwrite($fp, " <tracks>\n"); + if($this->tracks) { + foreach($this->tracks as $track) { + $track->write($fp); + } + } + fwrite($fp, " </tracks>\n"); + if($this->refs) $this->refs->write($fp, " "); + fwrite($fp, " </disc>\n"); + } + + public function showLyrics($number) + { + $str = ""; + if($this->tracks) { + foreach($this->tracks as $track) { + if($track->number == $number) { + $str .= $track->showLyrics(); + break; } + } + } + return $str; + } - public function show() - { - $str = ""; - - $str .= " <div class=\"disc\">\n"; - $str .= " <span class=\"record_title\">".$this->title." (".date("Y", $this->releasetime).")</span>\n"; - $str .= " <div class=\"cover\">\n"; - $str .= " <a href=\"".$this->cover."\">\n"; - $str .= " <img alt=\"".$this->title." cover\"\n"; - $str .= " src=\"?mode=imagecache&uri=" . $this->cover . "&mod=discography&cat=cover\"/>\n"; - $str .= " </a>\n"; - $str .= " </div>\n"; - $str .= " <span class=\"label\">"; - if($this->releasetime > time()) $str .= "To be"; - else $str .= "Was"; - $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ".date("F jS Y", $this->releasetime)."</span>\n"; - $str .= " <span class=\"tracklist_header\">"; - if($this->tracks && sizeof($this->tracks) > 1) { - $str .= "Tracks:"; - } else { - $str .= "Track:"; - } - $str .= "</span>\n"; - $str .= " <div class=\"tracklist\">\n"; - $total = 0; - if($this->tracks) { - foreach($this->tracks as $track) { + public function show() + { + $str = ""; + + $str .= " <div class=\"disc\">\n"; + $str .= " <span class=\"record_title\">".$this->title." (". + date("Y", $this->releasetime).")</span>\n"; + $str .= " <div class=\"cover\">\n"; + $str .= " <a href=\"".$this->cover."\">\n"; + $str .= " <img alt=\"".$this->title." cover\"\n"; + $str .= " src=\"?mode=imagecache&uri=" . + $this->cover . "&mod=discography&cat=cover\"/>\n"; + $str .= " </a>\n"; + $str .= " </div>\n"; + $str .= " <span class=\"label\">"; + if($this->releasetime > time()) $str .= "To be"; + else $str .= "Was"; + $str .= " released by ".htmlspecialchars_decode($this->releaser)." on ". + date("F jS Y", $this->releasetime)."</span>\n"; + $str .= " <span class=\"tracklist_header\">"; + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= "Tracks:"; + } else { + $str .= "Track:"; + } + $str .= "</span>\n"; + $str .= " <div class=\"tracklist\">\n"; + $total = 0; + if($this->tracks) { + foreach($this->tracks as $track) { $str .= $track->show($this->releasetime); $total += $track->playtime; - } - } - if($this->tracks && sizeof($this->tracks) > 1) { - $str .= " <span class=\"total_playtime\">Total playtime: ".time2str($total)."</span>\n"; - } - $str .= " </div>\n"; - $str .= " <span class=\"description\">".Markdown(htmlspecialchars_decode($this->description))."</span>\n"; - $str .= " </div>\n"; - - return $str; + } + } + if($this->tracks && sizeof($this->tracks) > 1) { + $str .= " <span class=\"total_playtime\">Total playtime: ". + time2str($total)."</span>\n"; + } + $str .= " </div>\n"; + $str .= " <span class=\"description\">". + Markdown(htmlspecialchars_decode($this->description))."</span>\n"; + + if($this->refs) $str .= $this->refs->show(); + + $str .= " </div>\n"; + + return $str; + } + + public function showCompact() + { + $str = ""; + + $str .= " <div class=\"disc\">\n"; + /* + $str .= " <span class=\"record_title\">".$this->title." (". + date("Y", $this->releasetime).")</span>\n"; + */ + $str .= " <div class=\"cover\">\n"; + $str .= " <a href=\"?page=discography\">\n"; + $str .= " <img alt=\"".$this->title." cover\"\n"; + $str .= " src=\"?mode=imagecache&uri=" . + $this->cover . "&mod=discography&cat=compactcover\"/>\n"; + $str .= " </a>\n"; + $str .= " </div>\n"; + $str .= " <span class=\"label\">"; + if($this->releasetime > time()) $str .= "Coming ".date("F jS Y", $this->releasetime); + else $str .= "Out now!"; + $str .= "</span>\n"; + $str .= " </div>\n"; + $str .= "</div>\n"; + + return $str; } - public function addTrack($track) - { - $key = $track->number; - $this->tracks[$key] = $track; - } + public function addTrack($track) + { + $key = $track->number; + $this->tracks[$key] = $track; + } + /* + public function addReview($review) + { + $key = $review->id; + $this->reviews[$key] = $review; + } + */ + + public function addRefs($refs) + { + $this->refs = $refs; + } public function Disc($title, $releasetime, $description, $cover, $releaser) { @@ -195,8 +252,8 @@ class Discography { // Admin config public $admin_title = "Discography"; public $admin_submodules = array("Add Disc" => "add", - "Edit Disc" => "edit", - "Delete Disc" => "delete"); + "Edit Disc" => "edit", + "Delete Disc" => "delete"); public function admin($sub, $action, $vars) { switch($sub) { @@ -211,36 +268,55 @@ class Discography { public function run($params) { - global $GLOBALS; + global $GLOBALS; - $str = "<div class=\"discography\">\n"; + $str = "<div class=\"discography\">\n"; - $lyrics = $GLOBALS["lyrics"]; - $number = $GLOBALS["track"]; + foreach($params as $param => $value) { + switch($param) { + case "latest": + $id = -1; + foreach($this->discs as $disc) { + if($disc->releasetime > $id) $id = $disc->releasetime; + } + if($id != -1) { + $disc = $this->discs[$id]; + return $str .= $disc->showCompact(); + } + break; + + default: + $lyrics = $GLOBALS["lyrics"]; + $number = $GLOBALS["track"]; + + //foreach($params as $param => $value) {} + + if($lyrics && $number) { + if($this->discs) { + foreach($this->discs as $disc) { + if($disc->releasetime == $lyrics) { + $str .= $disc->showLyrics($number); + break; + } + } + } + } else { + if($this->discs) { + foreach($this->discs as $disc) { + $str .= $disc->show(); + } + } + } - //foreach($params as $param => $value) {} + break; + } + } - if($lyrics && $number) { - if($this->discs) { - foreach($this->discs as $disc) { - if($disc->releasetime == $lyrics) { - $str .= $disc->showLyrics($number); - break; - } - } - } - } else { - if($this->discs) { - foreach($this->discs as $disc) { - $str .= $disc->show(); - } - } - } - $str .= "</div>\n"; + $str .= "</div>\n"; - return $str; + return $str; } public function add($disc) { @@ -248,15 +324,18 @@ class Discography { $this->discs[$key] = $disc; } - public function getImageSize($cat) - { - switch($cat) { - case "cover": - return new ImageSize($this->coverwidth, $this->coverheight); - default: - die(404); - } - } + public function getImageSize($cat) + { + switch($cat) { + case "cover": + return new ImageSize($this->coverwidth, $this->coverheight, true); + case "compactcover": + // return new ImageSize($this->compactcoverwidth, $this->compactcoverheight, true); + return new ImageSize(150, 150, true); + default: + die(404); + } + } public function write() { @@ -265,7 +344,7 @@ class Discography { fwrite($fp, "<discography>\n"); foreach($this->discs as $disc) { - $disc->write($fp); + $disc->write($fp); } fwrite($fp, "</discography>\n"); @@ -274,32 +353,34 @@ class Discography { private function read() { + $reviews = loadModule("reviews"); + $dom = new DomDocument; $dom->preserveWhiteSpace = FALSE; $dom->load($this->file); - $discography = $dom->documentElement; + $discography = $dom->documentElement; - $this->coverwidth = $discography->getAttribute('coverwidth'); - $this->coverheight = $discography->getAttribute('coverheight'); + $this->coverwidth = $discography->getAttribute('coverwidth'); + $this->coverheight = $discography->getAttribute('coverheight'); $discs = $dom->getElementsByTagName('disc'); foreach($discs as $d) { - $description = ""; - $dess = $d->getElementsByTagName('description'); - foreach($dess as $des) { + $description = ""; + $dess = $d->getElementsByTagName('description'); + foreach($dess as $des) { $description = $des->textContent; - } + } $disc = new Disc($d->getAttribute('title'), - $d->getAttribute('releasetime'), - $description, - $d->getAttribute('cover'), - $d->getAttribute('releaser')); + $d->getAttribute('releasetime'), + $description, + $d->getAttribute('cover'), + $d->getAttribute('releaser')); - $tracks = $d->getElementsByTagName('track'); - foreach($tracks as $t) { + $tracks = $d->getElementsByTagName('track'); + foreach($tracks as $t) { $lyrics = ""; $ls = $t->getElementsByTagName('lyrics'); foreach($ls as $l) { @@ -311,9 +392,16 @@ class Discography { $t->getAttribute('playtime'), $t->getAttribute('previewurl'), $lyrics); - + $disc->addTrack($track); - } + } + + $rs = $d->getElementsByTagName('refs'); + foreach($rs as $r) { + $refs = new Refs($r); + $disc->addRefs($refs); + break; + } $this->add($disc); } diff --git a/utils/modules/downloads.php b/utils/modules/downloads.php index 99e9962..52c6736 100644 --- a/utils/modules/downloads.php +++ b/utils/modules/downloads.php @@ -68,6 +68,21 @@ class DownloadItem { */ } + public function showRef() + { + $str = ""; + + if($this->type == "youtube") { + $str .= "<a href=\"http://www.youtube.com/watch?v=".$this->value."\">Video: " . $this->title."</a>"; + } + + if($this->type == "vimeo") { + $str .= "<a href=\"http://www.vimeo.com/".$this->value."\">Video: " . $this->title."</a>"; + } + + return $str; + } + public function show() { global $VIDEO_WIDTH; @@ -254,6 +269,20 @@ class Downloads { */ } + public function showRef($id) + { + $bleh = explode(",", $id); + $gid = $bleh[0]; + $iid = $bleh[1]; + + $str = ""; + if($this->groups[$gid] && $this->groups[$gid]->items[$iid]) { + $str .= $this->groups[$gid]->items[$iid]->showRef(); + } + + return $str; + } + private function read() { $dom = new DomDocument; @@ -284,12 +313,12 @@ class Downloads { } } - ksort($item->sources); + // ksort($item->sources); $group->addItem($item); } } - ksort($group->items); + // ksort($group->items); $this->add($group); } } diff --git a/utils/modules/events.php b/utils/modules/events.php index 3bccce6..1bfcd5c 100644 --- a/utils/modules/events.php +++ b/utils/modules/events.php @@ -5,20 +5,23 @@ global $UTIL_DIR, $MODULES_DIR; include_once($UTIL_DIR . "/convert.php"); include_once($UTIL_DIR . "/markdown.php"); include_once($MODULES_DIR . "/icons.php"); +include_once($UTIL_DIR . "/refs.php"); class Event { public $title; public $time; public $description; public $flyer; + public $refs; public function write($fp) { fwrite($fp, " <event title=\"" .xmlenc($this->title) . "\"\n"); fwrite($fp, " time=\"" . xmlenc($this->time) . "\"\n"); - fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">"); - fwrite($fp, xmlenc($this->description)); - fwrite($fp, "</event>\n"); + fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">\n"); + fwrite($fp, " <description>".xmlenc($this->description)."</description>\n"); + if($this->refs) $this->refs->write($fp, " "); + fwrite($fp, " </event>\n"); } public function show($eventpage) @@ -40,10 +43,17 @@ class Event { $str .= " <img class=\"event_flyer\" alt=\"flyer\" src=\"".$icon->prefix.$icon->file."\"/>\n"; } */ + if($this->refs) $str .= $this->refs->show(); + $str .= "</div>\n"; return $str; } + public function addRefs($refs) + { + $this->refs = $refs; + } + public function Event($title, $time, $description, $flyer = "") { $this->title = $title; @@ -144,6 +154,8 @@ class Events { $this->events[$vars["eventid"]]->time = DateTimeEdit::toTimestamp($vars, "time"); $this->events[$vars["eventid"]]->description = $vars["description"]; $this->events[$vars["eventid"]]->flyer = $vars["icon"]; + $refs = refsGetRefsFromHidden($vars); + $this->events[$vars["eventid"]]->refs = $refs; $this->write(); echo "\"" . $this->events[$vars["eventid"]]->title . "\" has now been edited."; break; @@ -151,6 +163,9 @@ class Events { case "preview": $event = new Event($vars["title"], DatetimeEdit::toTimestamp($vars, "time"), $vars["description"], $vars["icon"]); + $refs = refsGetRefsFromWidget(); + $event->addRefs($refs); + echo "<div class=\"preview\">\n"; echo "<div class=\"content\">\n"; echo $event->show($this->eventpage); @@ -159,11 +174,13 @@ class Events { echo "<p>Looking ok?</p>"; $form = new Form("add"); $form->addWidget(new Hidden($vars)); + refsAddHiddenWidget($form, $refs); $form->addWidget(new Button("yes")); $form->render(); $form = new Form("retry"); $form->addWidget(new Hidden($vars)); + refsAddHiddenWidget($form, $refs); $form->addWidget(new Button("no")); $form->render(); break; @@ -178,13 +195,18 @@ class Events { else $description = $this->events[$vars["eventid"]]->description; if(isset($vars["icon"])) $icon = $vars["icon"]; else $icon = $this->events[$vars["eventid"]]->flyer; - + if(isset($vars["refslist_hidden"])) $refs = refsGetFromHidden($vars); + else { + $refs = refsGetCommaListFromRefs($this->events[$vars["eventid"]]->refs); + } + $form = new Form("preview"); $form->addWidget(new Hidden($vars)); $form->addWidget(new LineEdit("Title", "title", $title)); $form->addWidget(new DateTimeEdit("Time", "time", $time)); $form->addWidget(new TextEdit("Description", "description", $description)); $form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/"))); + refsAddWidget($form, $refs); $form->addWidget(new Button("Update event")); $form->render(); break; @@ -415,10 +437,25 @@ class Events { $this->eventpage = $events->getAttribute('eventpage'); foreach ($params as $param) { + + $description = ""; + $dess = $param->getElementsByTagName('description'); + foreach($dess as $des) { + $description = $des->textContent; + } + $event = new Event($param->getAttribute('title'), $param->getAttribute('time'), - $param->textContent, + $description, $param->getAttribute('flyer')); + + $rs = $param->getElementsByTagName('refs'); + foreach($rs as $r) { + $refs = new Refs($r); + $event->addRefs($refs); + break; + } + $this->add($event); } } diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php index 3915a90..396cfd7 100644 --- a/utils/modules/gallery.php +++ b/utils/modules/gallery.php @@ -58,6 +58,15 @@ class Photo { return $str; } + public function showRef() + { + $str = ""; + $str .= " <img style=\"vertical-align: middle;\" alt=\"".$this->title."\"\n"; + $str .= " src=\"?mode=imagecache&uri=" + . $this->path . "/" . $this->image . "&mod=gallery&cat=reficon\"/>\n"; + return $str; + } + public function Photo($path, $id, $title, $image) { $this->path = $path; @@ -103,16 +112,33 @@ class Album { { global $page; + if(!$this->enabled) return ""; + $str = ""; $str .= $indent."<span class=\"album\">\n"; + // $str .= $indent." <a style=\"position: relative; top: -32px; text-decoration: none;\" class=\"album_back\" href=\"?page=".$page."\"> ← Back to albums</a>\n"; $str .= $indent." <span class=\"album_title\">" . $this->title . "</span>\n"; + $str .= $indent." <span class=\"album_copyright\">Copyright: " . $this->copyright . "</span>\n"; foreach($this->photos as $photo) { $str .= $indent." <a class=\"photo_icon\" href=\"?page=".$page."&a=".$this->id."&p=".$photo->id."\">\n"; $str .= $photo->show($indent." ", "albumicon"); $str .= $indent." </a>\n"; } - $str .= $indent."</span>\n"; + $str .= $indent." <br/><a style=\"clear: both; text-decoration: none;\" class=\"album_back\" href=\"?page=".$page."\"> ← Back to albums</a>\n"; + // Back to gallery + /* + $str .= $indent." <a class=\"photo_icon\" href=\"?page=".$page."\">\n"; + $str .= $indent."<span class=\"photo\">\n"; + $str .= $indent." <span class=\"photo_image\">\n"; + $str .= $indent." <img alt=\"Back to gallery\"\n"; + $str .= $indent." src=\"?mode=imagecache&uri=design/mors/home.png&mod=gallery&cat=albumicon\"/>\n"; + $str .= $indent." </span>\n"; + $str .= $indent." <span class=\"photo_caption\">" . $this->title . "</span>\n"; + $str .= $indent."</span>\n"; + $str .= $indent." </a>\n"; + $str .= $indent."</span>\n"; + */ return $str; } @@ -132,6 +158,20 @@ class Album { return $str; } + public function showRef() + { + global $page; + + $str = ""; + + $str .= $indent."<a class=\"album\" href=\"?page=gallery&a=".$this->id."\">\n"; + $str .= $this->photos[$this->icon]->showRef() . + " " .$this->title . "\n"; + $str .= $indent."</a>\n"; + + return $str; + } + public function showPhoto($indent, $photo) { global $GLOBALS; @@ -192,7 +232,7 @@ class Album { $this->title = $title; $this->copyright = $copyright; $this->icon = $icon; - $this->enabled = $enabled == 'on'; + $this->enabled = $enabled == "true" || $enabled == "on" || $enabled == "yes"; } } @@ -266,11 +306,20 @@ class Gallery { global $ALBUMS_DIR; switch($action) { case "create": - $album = new Album($this->getNextID(), $vars['title'], $vars['copyright'], "1", $vars['enabled']); + $baseid = $vars['id']; + $id = $baseid; + $idcnt = 1; + while(!$this->checkUniqueID($id)) { + $id = $baseid . "-" . $idcnt; + $idcnt++; + } + + $album = new Album($id, $vars['title'], $vars['copyright'], "1", $vars['enabled']); unpackImages($_FILES['images'], $album); - $this->add($album); + $this->add($album); $this->write(); echo $album->show("", "albumicon"); + break; case "select": @@ -278,7 +327,8 @@ class Gallery { $form = new Form("create"); $form->addWidget(new LineEdit("Album title:", "title")); $form->addWidget(new LineEdit("Album copyright:", "copyright")); - $form->addWidget(new CheckBox("Album enabled:", "enabled")); + $form->addWidget(new LineEdit("Album ID:", "id", $this->getNextID())); + $form->addWidget(new CheckBox("Album enabled:", "enabled")); $form->addWidget(new FileUpload("Select image archive:", "images", "application/zip")); $form->addWidget(new Button("Create")); $form->render(); @@ -286,6 +336,48 @@ class Gallery { } } + public function admin_edit($action, $vars) + { + global $ALBUMS_DIR; + switch($action) { + case "update": + $album = $this->albums[$vars["id"]]; + + $album->title = $vars["title"]; + $album->copyright = $vars["copyright"]; + $album->enabled = $vars["enabled"] == "on"; + + $this->write(); + break; + + case "edit": + $album = $this->albums[$vars["id"]]; + + $form = new Form("update"); + $form->addWidget(new LineEdit("Album title:", "title", $album->title)); + $form->addWidget(new LineEdit("Album copyright:", "copyright", $album->copyright)); + $form->addWidget(new LineEdit("Album ID:", "id", $album->id)); + $form->addWidget(new CheckBox("Album enabled:", "enabled", $album->enabled)); + $form->addWidget(new Button("Update")); + $form->render(); + break; + + case "select": + default: + $albumlist = array(); + foreach($this->albums as $album) { + $albumlist[$album->title . " (".$album->id.")"] = $album->id; + } + krsort($albumlist); + + $form = new Form("edit"); + $form->addWidget(new ComboBox("Select album:", "id", "", $albumlist)); + $form->addWidget(new Button("Edit")); + $form->render(); + break; + } + } + public function admin_options($action, $vars) { switch($action) { @@ -325,7 +417,7 @@ class Gallery { $this->admin_new($action, $vars); break; case "edit": - $this->admin_new($action, $vars); + $this->admin_edit($action, $vars); break; case "delete": $this->admin_new($action, $vars); @@ -356,7 +448,7 @@ class Gallery { $str .= "\n<span class=\"albums\">\n"; foreach($this->albums as $album) { - $str .= $album->showIcon(" "); + if($album->enabled) $str .= $album->showIcon(" "); } $str .= "</span>\n"; @@ -374,6 +466,12 @@ class Gallery { return $str; } + public function showRef($id) + { + if(!$this->albums[$id]) return ""; + return $this->albums[$id]->showRef(); + } + public function run($params) { global $a, $p; @@ -413,17 +511,28 @@ class Gallery { return $maxid + 1; } + public function checkUniqueID($id) + { + foreach($this->albums as $album) { + if($album->id == $id) return false; + } + return true; + } + public function getImageSize($cat) { switch($cat) { case "photo": - return new ImageSize($this->maxwidth, $this->maxheight); + return new ImageSize($this->maxwidth, $this->maxheight, false); case "randomimage": - return new ImageSize($this->maxwidth_rand, $this->maxheight_rand); + return new ImageSize($this->maxwidth_rand, $this->maxheight_rand, true); case "navicon": - return new ImageSize($this->maxwidth_navicon, $this->maxheight_navicon); + return new ImageSize($this->maxwidth_navicon, $this->maxheight_navicon, true); case "albumicon": - return new ImageSize($this->maxwidth_icon, $this->maxheight_icon); + return new ImageSize($this->maxwidth_icon, $this->maxheight_icon, true); + case "reficon": + // return new ImageSize($this->maxwidth_reficon, $this->maxheight_reficon, true); + return new ImageSize(32, 24, true); default: die(404); } diff --git a/utils/modules/guestbook.php b/utils/modules/guestbook.php index 92fe732..039cd2c 100644 --- a/utils/modules/guestbook.php +++ b/utils/modules/guestbook.php @@ -339,7 +339,7 @@ class Guestbook { default: if($show == "all") $showposts = -1; - else $showposts = 7; + else $showposts = 12; break; } } diff --git a/utils/modules/members.php b/utils/modules/members.php index 670de53..41f1979 100644 --- a/utils/modules/members.php +++ b/utils/modules/members.php @@ -1,5 +1,4 @@ -<?php -/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ global $UTIL_DIR; diff --git a/utils/modules/reviews.php b/utils/modules/reviews.php new file mode 100644 index 0000000..8fa97b5 --- /dev/null +++ b/utils/modules/reviews.php @@ -0,0 +1,221 @@ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +global $UTIL_DIR; + +include_once($UTIL_DIR . "/convert.php"); +include_once($UTIL_DIR . "/markdown.php"); + +// See: http://www.loc.gov/standards/iso639-2/php/code_list.php +function lang2text($lang) +{ + + if(function_exists('locale_get_display_language')) + return locale_get_display_language($lang, 'en'); + + switch($lang) { + case "en": return "english"; + case "da": return "danish"; + case "nl": return "dutch"; + case "bul": return "bulgarian"; + case "fr": return "french"; + case "it": return "italian"; + default: return "unknown"; + } +} + +class Text { + public $text; + public $lang; + public $original; + + public function show() + { + $str = ""; + + $prefix = "Original"; + if(!$this->original) $prefix = "Translated"; + + $str .= "<div class=\"header\"><h3>".$prefix." ".lang2text($this->lang)." text</h3></div>\n"; + $str .= markdown($this->text) . "\n"; + return $str; + } + + public function Text($text, $lang, $original) + { + $this->text = $text; + $this->lang = $lang; + $this->original = $original; + } +} + +class Review { + public $title; + public $id; + public $src; + public $url; + public $texts = array(); + + public function write($fp) + { +/* + fwrite($fp, " <track title=\"" . + htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " number=\"" . $this->number . "\"\n"); + fwrite($fp, " playtime=\"" . $this->playtime . "\"\n"); + fwrite($fp, " previewurl=\"" . $this->previewurl . "\">\n"); + fwrite($fp, " <lyrics>".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")."</lyrics>\n"); + fwrite($fp, " </track>\n"); +*/ + } + + public function show() + { + $str = ""; + + // $str .= $this->id . "\n"; + $str .= "<div class=\"header\"><h2>".$this->title."</h2></div>\n"; + $str .= "<p>Origin: <em>".$this->src."</em> <a href=\"".$this->url."\">".$this->url."</a></p>\n"; + + foreach($this->texts as $text) { + if($text->original) { + $str .= $text->show(); + break; + } + } + + foreach($this->texts as $text) { + if(!$text->original) { + $str .= $text->show(); + } + } + + return $str; + } + + public function showRef() + { + $str = ""; + $str .= "<a href=\"?page=reviews&rid=". + $this->id."\">".$this->title." from ".$this->src."</a>\n"; + return $str; + } + + public function add($text) + { + array_push($this->texts, $text); + } + + public function Review($id, $title, $src, $url) + { + $this->id = $id; + $this->title = $title; + $this->src = $src; + $this->url = $url; + } +} + +class Reviews { + + private $file; + private $reviews = array(); + + // Admin config + public $admin_title = "Reviews"; + public $admin_submodules = array(); + + public function admin($sub, $action, $vars) + { + switch($sub) { + case "delete": + break; + } + } + + public function run($params) + { + global $GLOBALS; + $str = ""; + foreach($this->reviews as $review) { + if($GLOBALS['rid'] == $review->id) { + $str .= $review->show(); + } + } + + return $str; + } + + public function get($id) + { + return $this->reviews[$id]; + } + + public function showRef($id) + { + if(!$this->reviews[$id]) return ""; + return $this->reviews[$id]->showRef(); + } + + public function add($review) { + $key = $review->id; + $this->reviews[$key] = $review; + } + + public function write() + { + /* + $fp = fopen($this->file, "w"); + fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<discography>\n"); + foreach($this->discs as $disc) { + $disc->write($fp); + } + fwrite($fp, "</discography>\n"); + + fclose($fp); + */ + } + + private function read() + { + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + + $discography = $dom->documentElement; + + $revs = $dom->getElementsByTagName('review'); + + foreach($revs as $rev) { + $review = new Review($rev->getAttribute('id'), + $rev->getAttribute('title'), + $rev->getAttribute('src'), + $rev->getAttribute('url')); + + $ts = $rev->getElementsByTagName('text'); + foreach($ts as $t) { + $text = new Text($t->textContent, + $t->getAttribute('lang'), + $t->getAttribute('original')); + $review->add($text); + } + + $this->add($review); + } + } + + public function Reviews($file) + { + $this->file = $file; + if(file_exists($file)) $this->read(); + } + +} + +function reviews_init() +{ + global $DATA_DIR; + return new Reviews($DATA_DIR . "/reviews.xml"); +} + +?> diff --git a/utils/refs.php b/utils/refs.php new file mode 100644 index 0000000..0589cff --- /dev/null +++ b/utils/refs.php @@ -0,0 +1,139 @@ +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +include_once($UTIL_DIR . "/modules.php"); + +class Ref { + public $mod; + public $id; + + function show() + { + $str = ""; + $module = loadModule($this->mod); + if($module && method_exists($module, "showRef")) { + $str .= "<div class=\"ref\">\n"; + $str .= /*"[".$this->mod."] - ".*/$module->showRef($this->id); + $str .= "</div>\n"; + } + return $str; + } + + function Ref($mod, $id) + { + $this->mod = $mod; + $this->id = $id; + } +} + +class Refs { + public $refs = array(); + + function show() + { + $str = ""; + $str .= "<div class=\"refs\">\n"; + $str .= " <div class=\"refs_header\">References:</div>\n"; + foreach($this->refs as $ref) { + $str .= $ref->show(); + } + $str .= "</div>"; + return $str; + } + + public function write($fp, $indent) + { + if($this->refs) { + fwrite($fp, $indent."<refs>\n"); + foreach($this->refs as $ref) { + fwrite($fp, $indent." <ref mod=\"".$ref->mod."\" id=\"".$ref->id."\"/>\n"); + } + fwrite($fp, $indent."</refs>\n"); + } + } + + public function add($ref) + { + array_push($this->refs, $ref); + } + + public function Refs($refsnode = NULL) + { + if(!$refsnode) return; + + $refs = $refsnode->getElementsByTagName('ref'); + foreach($refs as $r) { + $ref = new Ref($r->getAttribute('mod'), + $r->getAttribute('id')); + $this->add($ref); + } + + } + +} + +function refsAddWidget($form, $refslist) +{ + $form->addWidget(new ListEditor("References:", "refslist", + new LineEdit("ID", "ref_id"), + new LineEdit("Module", "ref_mod"), + $refslist, true)); +} + +function refsAddHiddenWidget($form, $lst) +{ + $vallst = array(); + $vallst["refslist_hidden"] = serialize(refsGetCommaListFromRefs($lst)); + $form->addWidget(new Hidden($vallst)); +} + +function refsGetFromHidden($vals) +{ + $refslist = unserialize($vals["refslist_hidden"]); + return $refslist; +} + +function refsGetCommaListFromRefs($refs) +{ + $lst = array(); + foreach($refs->refs as $ref) { + array_push($lst, $ref->mod.":".$ref->id); + } + return $lst; +} + +function refsGetRefsFromHidden($vals) +{ + $r = refsGetFromHidden($vals); + + $refs = new Refs(); + foreach($r as $k => $val) { + $v = explode(":", $val); + $refmod = $v[0]; + $refid = $v[1]; + $ref = new Ref($refmod, $refid); + $refs->add($ref); + } + + return $refs; +} + +function refsGetRefsFromWidget() +{ + $lst = refsGetValuesFromWidget(); + $refs = new Refs(); + foreach($lst as $val) { + $v = explode(":", $val); + $refmod = $v[0]; + $refid = $v[1]; + $ref = new Ref($refmod, $refid); + $refs->add($ref); + } + return $refs; +} + +function refsGetValuesFromWidget() +{ + global $GLOBALS; + return $GLOBALS["refslist"]; +} +?>
\ No newline at end of file |