From 42c62cb041a2b2b95c9cda0c20fcf70334fd244c Mon Sep 17 00:00:00 2001
From: deva
Date: Tue, 1 Nov 2011 09:32:21 +0000
Subject: Rewl og krat... needs cleaning up - after port to GIT.
---
forum/htdocs/index.php | 79 +++++--
forum/utils/addressbook.php | 279 ++++++++++++------------
forum/utils/cache.php | 147 +++++++++++++
forum/utils/calendar.php | 283 ++++++++++++++-----------
forum/utils/contacts.php | 90 +++++---
forum/utils/edit.php | 18 +-
forum/utils/editor.php | 236 +++++++++------------
forum/utils/error.php | 3 +-
forum/utils/events.php | 79 +++++--
forum/utils/filehandler.php | 59 +++---
forum/utils/files.php | 62 +++---
forum/utils/forums.php | 52 +++--
forum/utils/mimetypes.php | 2 +-
forum/utils/notify.php | 1 +
forum/utils/posts.php | 82 ++++----
forum/utils/profile.php | 91 ++++----
forum/utils/smileys.php | 1 +
forum/utils/tasks.php | 145 +++++++------
forum/utils/threads.php | 32 +--
forum/utils/view.php | 105 ++++-----
htdocs/admin.css | 14 +-
htdocs/index.php | 4 +-
utils/admin.php | 4 +-
utils/forms.php | 66 ++++--
utils/imagecache.php | 56 +++--
utils/mail.php | 4 +-
utils/modules.php | 4 +-
utils/modules/config.php | 23 +-
utils/modules/discography.php | 480 +++++++++++++++++++++++++-----------------
utils/modules/downloads.php | 33 ++-
utils/modules/events.php | 47 ++++-
utils/modules/gallery.php | 131 +++++++++++-
utils/modules/guestbook.php | 2 +-
utils/modules/members.php | 3 +-
utils/modules/reviews.php | 221 +++++++++++++++++++
utils/refs.php | 139 ++++++++++++
36 files changed, 2058 insertions(+), 1019 deletions(-)
create mode 100644 forum/utils/cache.php
create mode 100644 utils/modules/reviews.php
create mode 100644 utils/refs.php
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");
-
\n";
+ $str .=" Forum \n";
+ $str .=" Filehandler \n";
+ $str .=" Calendar \n";
+ $str .=" Addressbook \n";
+ $str .=" Profile \n";
+ $str .=" Tasks \n";
+ if($current_user->uid == 0)
+ $str .=" Diagnostics \n";
+ $str .=" \n";
+ return $str;
+}
// Globals:
// $fid
@@ -58,57 +74,76 @@ include_once($UTIL_DIR . "/clientinfo.php");
// $task
if($current_user) {
- echo " Logged in as: " . $current_user->name . " - Logout
\n";
+ $str = "";
+
+ $str .= " Logged in as: " . $current_user->name . " - Logout
\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");
-?>
-
-forums as $forum) {
+ $unreadPosts |= $forum->newStuff;
+ }
+
+ echo menu("top", $unreadPosts). $str. menu("bottom", $unreadPosts);
+ } else {
+ echo $str;
+ }
+
} else {
?>
-add($contactgroup);
- $contacts->write();
- $gid = 0;
-}
-
-elseif($action == "addcontact" && $gid && $cid) {
- $contact = new Contact($cid,
- $name,
- $co,
- $address,
- $city,
- $country,
- $phone,
- $phone2,
- $email,
- $email2,
- $url,
- $url2,
- $essential,
- $notes);
- $contactgroup = $contacts->getContactGroup($gid);
- $contactgroup->add($contact);
- $contacts->write();
- $cid = 0;
-}
-
-elseif($action =="editcontact" && $cid) {
- $contact = $contacts->getContact($cid);
- form($contact->cid,
- "?mode=addressbook&action=updatecontact".$gid,
- "Update contact",
- $contact->name,
- $contact->co,
- $contact->address,
- $contact->city,
- $contact->country,
- $contact->phone,
- $contact->phone2,
- $contact->email,
- $contact->email2,
- $contact->url,
- $contact->url2,
- $contact->essential,
- $contact->notes);
+ $str = "";
+
+ $str .= "\n";
+ $str .= " \n";
+ $str .= " Name: \n";
+ $str .= " c/o: \n";
+ $str .= " Address: \n";
+ $str .= " City: \n";
+ $str .= " Country: \n";
+ $str .= " Phone: \n";
+ $str .= " Phone2: \n";
+ $str .= " Email: \n";
+ $str .= " Email2: \n";
+ $str .= " URL: \n";
+ $str .= " URL2: \n";
+ $ess = "";
+ if($essential == "on") $ess = " checked";
+ $str .= " Essential: (show on frontpage) \n";
+ $str .= " Notes: \n";
+ $str .= " " .
+ $notes . " \n";
+ $str .= " " . $buttontext . " \n";
+ $str .= " \n";
+
+ return $str;
}
-elseif($action == "updatecontact" && $cid) {
- $contact = $contacts->getContact($cid);
-
- $contact->name = $name;
- $contact->co = $co;
- $contact->address = $address;
- $contact->city = $city;
- $contact->country = $country;
- $contact->phone = $phone;
- $contact->phone2 = $phone2;
- $contact->email = $email;
- $contact->email2 = $email2;
- $contact->url = $url;
- $contact->url2 = $url2;
- $contact->essential = $essential;
- $contact->notes = $notes;
-
- $contacts->write();
-
- $contact->show();
-}
-
-elseif($cid) {
- $contact = $contacts->getContact($cid);
- $contact->show();
-}
-
-elseif($gid) {
- $contactgroup = $contacts->getContactGroup($gid);
- $contactgroup->show();
-
- form($contacts->getNextCID(),
- "?mode=addressbook&action=addcontact&gid=".$gid,
- "Add contact");
-
-} else {
- $contacts->show();
- if($current_user->uid == 0) {
-?>
-
-
- Name:
- Add group
-
-add($contactgroup);
+ $contacts->write();
+ $gid = 0;
+ }
+
+ elseif($GLOBALS['action'] == "addcontact" && $gid && $cid) {
+ $contact = new Contact($cid,
+ $name,
+ $co,
+ $address,
+ $city,
+ $country,
+ $phone,
+ $phone2,
+ $email,
+ $email2,
+ $url,
+ $url2,
+ $essential,
+ $notes);
+ $contactgroup = $contacts->getContactGroup($gid);
+ $contactgroup->add($contact);
+ $contacts->write();
+ $cid = 0;
+ }
+
+ elseif($GLOBALS['action'] =="editcontact" && $cid) {
+ $contact = $contacts->getContact($cid);
+ $str .= form($contact->cid,
+ "?mode=addressbook&action=updatecontact".$gid,
+ "Update contact",
+ $contact->name,
+ $contact->co,
+ $contact->address,
+ $contact->city,
+ $contact->country,
+ $contact->phone,
+ $contact->phone2,
+ $contact->email,
+ $contact->email2,
+ $contact->url,
+ $contact->url2,
+ $contact->essential,
+ $contact->notes);
+ }
+
+ elseif($GLOBALS['action'] == "updatecontact" && $cid) {
+ $contact = $contacts->getContact($cid);
+
+ $contact->name = $name;
+ $contact->co = $co;
+ $contact->address = $address;
+ $contact->city = $city;
+ $contact->country = $country;
+ $contact->phone = $phone;
+ $contact->phone2 = $phone2;
+ $contact->email = $email;
+ $contact->email2 = $email2;
+ $contact->url = $url;
+ $contact->url2 = $url2;
+ $contact->essential = $essential;
+ $contact->notes = $notes;
+
+ $contacts->write();
+
+ $str .= $contact->show();
+ }
+
+ elseif($cid) {
+ $contact = $contacts->getContact($cid);
+ $str .= $contact->show();
+ }
+
+ elseif($gid) {
+ $contactgroup = $contacts->getContactGroup($gid);
+ $str .= $contactgroup->show();
+
+ $str .= form($contacts->getNextCID(),
+ "?mode=addressbook&action=addcontact&gid=".$gid,
+ "Add contact");
+
+ } else {
+ $str .= $contacts->show();
+ if($current_user->uid == 0) {
+
+ $str .= "\n";
+ $str .= " getNextGID()) . "\">\n";
+ $str .= " Name: \n";
+ $str .= " Add group \n";
+ $str .= " \n";
+
+ }
+ }
+
+ return $str;
}
-
?>
\ No newline at end of file
diff --git a/forum/utils/cache.php b/forum/utils/cache.php
new file mode 100644
index 0000000..42e4ca0
--- /dev/null
+++ b/forum/utils/cache.php
@@ -0,0 +1,147 @@
+id, ENT_QUOTES, "UTF-8") . "\">\n");
+
+ foreach($this->values as $key => $value) {
+ fwrite($fp, " ");
+ fwrite($fp, htmlspecialchars($value, ENT_QUOTES, "UTF-8"));
+ fwrite($fp, " \n");
+ }
+
+ fwrite($fp, " \n");
+ }
+
+ public function value($key)
+ {
+ if(!isset($this->values[$key])) return "";
+ return $this->values[$key];
+ }
+
+ public function setValue($key, $value)
+ {
+ $this->values[$key] = $value;
+ }
+
+ public function CacheEntry($id)
+ {
+ $this->id = $id;
+ }
+}
+
+class Cache {
+ private $file;
+ public $entries = array();
+
+ public function rebuild($what = "all")
+ {
+ global $FORUMS_DIR, $users;
+
+
+ if($what == "all") $this->entries = array();
+
+
+ if($what == "forum_numberofthreads" || $what == "all") {
+ $entry = new CacheEntry("forum_numberofthreads");
+
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ foreach($forums->forums as $forum) {
+ $threads = new Threads($FORUMS_DIR . "/" . $forum->fid);
+ $entry->setValue($forum->fid, sizeof($threads->threads));
+ }
+ $this->add($entry);
+ }
+
+
+ if($what == "forum_lastpost" || $what == "all") {
+ $entry = new CacheEntry("forum_lastpost");
+
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ foreach($forums->forums as $forum) {
+ $threads = new Threads($FORUMS_DIR . "/" . $forum->fid);
+
+ foreach($users->users as $user) {
+
+ $unread = false;
+ foreach($threads->threads as $thread) {
+ if($thread->lastseen[$user->uid] < $thread->lastpost) {
+ $unread = true;
+ break;
+ }
+ }
+
+ $entry->setValue($forum->fid . "-" . $user->uid, $unread);
+ }
+
+ }
+ $this->add($entry);
+ }
+
+
+ $this->write();
+ }
+
+ public function add($entry) {
+ $key = $entry->id;
+ $this->entries[$key] = $entry;
+ }
+
+ public function write()
+ {
+ $fp = fopen($this->file, "w");
+
+ $block = TRUE;
+ flock($fp, LOCK_EX, $block); // do an exclusive lock
+
+ fwrite($fp, "\n");
+
+ fwrite($fp, "\n");
+ foreach($this->entries as $entry) {
+ $entry->write($fp);
+ }
+ fwrite($fp, " \n");
+
+ fclose($fp);
+ }
+
+ public function get($id)
+ {
+ return $this->entries[$id];
+ }
+
+ private function read()
+ {
+ $dom = new DomDocument;
+ $dom->preserveWhiteSpace = FALSE;
+ $dom->load($this->file);
+ $ces = $dom->getElementsByTagName('entry');
+
+ foreach($ces as $c) {
+ $entry = new CacheEntry($c->getAttribute('id'));
+ foreach($c->childNodes as $v) {
+ if($v->tagName != "value") continue;
+ $entry->setValue($v->getAttribute('key'), $v->textContent);
+ }
+
+ $this->add($entry);
+ }
+ }
+
+ public function Cache($file)
+ {
+ $this->file = $file;
+ if(file_exists($this->file)) $this->read();
+ }
+
+}
+?>
diff --git a/forum/utils/calendar.php b/forum/utils/calendar.php
index 318f458..0e7dba5 100644
--- a/forum/utils/calendar.php
+++ b/forum/utils/calendar.php
@@ -1,144 +1,173 @@
uid);
- $events->add($event);
- $events->write();
-
- if($ZEND_DIR != "") googleCalendarEvent($event);
-
- if($DOKUWIKI_CALENDAR != "") {
- $file = $DOKUWIKI_CALENDAR;
- $fp = fopen($file, "w");
+function calendar()
+{
+ global $UTIL_DIR, $ZEND_DIR, $DOKUWIKI_CALENDAR, $GLOBALS,
+ $current_user, $DATA_DIR;
+
+ include_once($UTIL_DIR . "/events.php");
+ include_once($UTIL_DIR . "/notify.php");
+ if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.php");
+
+ $str = "";
+
+ $events = new Events($DATA_DIR . "/calendar.xml");
+
+ foreach($events->events as $e) {
+ if($e->concert == "true") $str .= $e->show_simple();
+ }
+
+ if(!isset($GLOBALS['date']))
+ $date = time() - (date("N", time()) - 1) * 24 * 60 * 60;
+ else
+ $date = $GLOBALS['date'] - (date("N", $GLOBALS['date'])-1) * 24 * 60 * 60;
+
+ if($GLOBALS['action'] =="addentry") {
+ $title = stripslashes($GLOBALS['title']);
+ $description = stripslashes($GLOBALS['description']);
+ if($GLOBALS['concert'] == "on") $concert = "true";
+ else $concert = "false";
+
+ $time = strtotime($GLOBALS['txtdate'] . " " .
+ $GLOBALS['txttimefrom'] . ":00");
+ if($time !== FALSE) {
+ $duration = strtotime($GLOBALS['txtdate'] . " " .
+ $GLOBALS['txttimeto'] . ":00") - $time;
+ $eid = time();
+ $event = new Event($eid, $title, $concert, $time, $duration, $description,
+ $current_user->uid);
+ $events->add($event);
+ $events->write();
+
+ if($ZEND_DIR != "") googleCalendarEvent($event);
- fprintf($fp, "=====DIEs calendar=====\n");
- fprintf($fp, "Do not edit this file - it is automatically generated by the ExecutionRoom CMS.\n\n");
- fprintf($fp, "====Events====\n");
- foreach($events->events as $event) {
- fprintf($fp, " * %s - %s %s: %s\n",
- date("j.n.Y G:i", $event->starttime),
- date("j.n.Y G:i", $event->starttime + $event->duration),
- $event->title, $event->description);
+ if($DOKUWIKI_CALENDAR != "") {
+ $file = $DOKUWIKI_CALENDAR;
+ $fp = fopen($file, "w");
+
+ fprintf($fp, "=====DIEs calendar=====\n");
+ fprintf($fp, "Do not edit this file - it is automatically generated " .
+ "by the ExecutionRoom CMS.\n\n");
+ fprintf($fp, "====Events====\n");
+ foreach($events->events as $event) {
+ fprintf($fp, " * %s - %s %s: %s\n",
+ date("j.n.Y G:i", $event->starttime),
+ date("j.n.Y G:i", $event->starttime + $event->duration),
+ $event->title, $event->description);
+ }
+ fclose($fp);
}
- fclose($fp);
+
+ notify("calendar", "New calendar entry:\n" . $GLOBALS['title'] . "\n" .
+ date("r", $time) . "\n" . $GLOBALS['description'] . "\n" .
+ $FORUM_URL . "/?mode=calendar&date=" . $time);
+
+ $str .= " \n";
+
+ } else {
+ $str .= "ERROR: Date is not in the correct " .
+ "format! It was NOT posted. Please try again.
\n";
}
+ }
- notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" .
- $description . "\n" .
- $FORUM_URL . "/?mode=calendar&date=" . $time);
-?>
-
-delete($GLOBALS['eid']);
+ $events->write();
+ }
+
+ $str .= "\n";
+ $str .= "[<] \n";
+ $str .= " \n";
+ $str .= "[<<] \n";
+ $str .= " \n";
+ $str .= date("F Y", $date) . "\n";
+ $str .= " \n";
+ $str .= "[>>] \n";
+ $str .= " \n";
+ $str .= "[>] \n";
+ $str .= "[Today] \n";
+ $str .= "
\n";
+
+ if($client_is_mobile_device) {
+ for($day = 0; $day < 7; $day++) {
+ $str .= " \n";
+ $str .= " \n";
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
+ $str .= "
4) $str .= " style=\"background: #311;\"";
+ $str .= ">\n";
+
+ $str .= $events->show($t, $t + 24 * 60 * 60);
+
+ $str .= "
\n";
+ $str .= "
\n";
+
+ }
} else {
- echo "ERROR: Date is not in the correct format! It was NOT posted. Please try again.
\n";
- }
-}
+ $str .= "\n";
+ $str .= " \n";
-if($action=="edit") {
- /*
- $event = $events->getEvent($eid);
- $event->duration += 2000;
- $events->write();
- */
-}
+ for($day = 0; $day < 7; $day++) {
+ $str .= " \n";
+ }
-?>
-
-[<]
-
-[<<]
-
-
-
-[>>]
-
-[>]
-[Today]
-
-\n";
- echo " \n";
+ $str .= " \n";
- $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
- echo " 4) echo " style=\"background: #311;\"";
- echo ">\n";
+ for($day = 0; $day < 7; $day++) {
+ $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
- $events->show($t, $t + 24 * 60 * 60);
+ $str .= "
4) $str .= " style=\"background: #311;\"";
+ $str .= ">\n";
- echo " \n";
- echo " \n";
+ $str .= " Add \n";
- }
-} else {
-?>
-
-
-\n";
- $t = $date + $day * 24 * 60 * 60;
- echo " " . date("l j/n", $t) . "\n";
- echo " \n";
-}
-?>
-
-
-show($t, $t + 24 * 60 * 60);
+ $str .= " \n";
+ }
- echo " 4) echo " style=\"background: #311;\"";
- echo ">\n";
-?>
- Add
-show($t, $t + 24 * 60 * 60);
- echo " \n";
-}
-?>
-
-
-\n";
+ $str .= "
\n";
+ }
+
+ if($GLOBALS['adddate'] != "") {
+ $str .= "\n";
+ $str .= "Title: \n";
+ $str .= "Concert: \n";
+ $str .= "Desription: \n";
+ $str .= "Date: \n";
+ $str .= "From-Time: \n";
+ $str .= "To-Time: \n";
+ $str .= " \n";
+ $str .= "Add \n";
+ $str .= " \n";
+ }
+
+ return $str;
}
?>
-
-
-Title:
-Desription:
-Date: ">
-From-Time:
-To-Time:
-
-Add
-
-
diff --git a/forum/utils/contacts.php b/forum/utils/contacts.php
index 7458108..7c67f92 100644
--- a/forum/utils/contacts.php
+++ b/forum/utils/contacts.php
@@ -39,27 +39,36 @@ class Contact {
public function show()
{
- echo "\n";
- // echo "\tcid: " . $this->cid . " \n";
- echo "\tName: " . $this->name . " \n";
- if($this->co) echo "\tc/o: " . $this->co . " \n";
- if($this->address) echo "\tAddress: " . $this->address . " \n";
- if($this->city) echo "\tCity: " . $this->city . " \n";
- if($this->country) echo "\tCountry: " . $this->country . " \n";
- if($this->phone) echo "\tPhone: " . $this->phone . " \n";
- if($this->phone2) echo "\tPhone2: " . $this->phone2 . " \n";
- if($this->email) echo "\tEmail: email . "\">" . $this->email . " \n";
- if($this->email2) echo "\tEmail2: email2 . "\">" . $this->email2 . " \n";
- if($this->url) echo "\tURL: url . "\">" . $this->url . " \n";
- if($this->url2) echo "\tURL2: url2 . "\">" . $this->url2 . " \n";
- if($this->notes) echo "\tNotes: \n" . parse($this->notes) . " \n";
- echo "\tcid . "\">Edit \n";
- echo "
\n";
+ $str = "";
+
+ $str .= "\n";
+ // $str .= "\tcid: " . $this->cid . " \n";
+ $str .= "\tName: " . $this->name . " \n";
+ if($this->co) $str .= "\tc/o: " . $this->co . " \n";
+ if($this->address) $str .= "\tAddress: " . $this->address . " \n";
+ if($this->city) $str .= "\tCity: " . $this->city . " \n";
+ if($this->country) $str .= "\tCountry: " . $this->country . " \n";
+ if($this->phone) $str .= "\tPhone: " . $this->phone . " \n";
+ if($this->phone2) $str .= "\tPhone2: " . $this->phone2 . " \n";
+ if($this->email) $str .= "\tEmail: email . "\">" . $this->email . " \n";
+ if($this->email2) $str .= "\tEmail2: email2 . "\">" . $this->email2 . " \n";
+ if($this->url) $str .= "\tURL: url . "\">" . $this->url . " \n";
+ if($this->url2) $str .= "\tURL2: url2 . "\">" . $this->url2 . " \n";
+ if($this->notes) $str .= "\tNotes: \n" . parse($this->notes) . " \n";
+ $str .= "\tcid . "\">Edit \n";
+ $str .= "
\n";
+
+ return $str;
}
public function showshort()
{
- echo "";
+ $str = "";
+
+ $str .= "";
+
+ return $str;
}
function Contact($cid, $name, $co, $address, $city, $country, $phone, $phone2, $email, $email2, $url, $url2, $essential, $notes)
@@ -118,35 +127,44 @@ class ContactGroup {
public function show()
{
- echo " \n";
+
+ return $str;
}
public function showshort()
{
global $client_is_mobile_device;
+
+ $str = "";
+
$ness = 0;
foreach($this->contacts as $contact) {
if($contact->essential) $ness += 1;
}
- echo " \n";
+
+ return $str;
}
function ContactGroup($gid,
@@ -164,11 +182,15 @@ class Contacts {
public function show()
{
- echo "\n";
+
+ return $str;
}
public function getNextCID()
diff --git a/forum/utils/edit.php b/forum/utils/edit.php
index 20b5336..92c306a 100644
--- a/forum/utils/edit.php
+++ b/forum/utils/edit.php
@@ -19,7 +19,9 @@ switch($task) {
$posts->thread->tid = $tid;
$posts->thread->lastpost = time();
$posts->write();
- notify("forum", "New thread \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid);
+ $m = "New thread \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n";
+ $m .= $message;
+ notify("forum", $m);
} else {
error("No forum id supplied!");
}
@@ -35,7 +37,9 @@ case "reply":
$reply->add($post);
$posts->thread->lastpost = time();
$posts->write();
- notify("forum", "New reply \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid);
+ $m = "New reply \"" . $title . "\" at " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n";
+ $m .= $message;
+ notify("forum", $m);
} else {
error("Message " . $pid . " not found!");
}
@@ -55,7 +59,9 @@ case "reply":
$edit->message = $message . "\nEdited at: " . date("r", time());
$posts->thread->lastpost = time();
$posts->write();
- notify("forum", "Message \"" . $title . "\" has been edited: " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid);
+ $m = "Message \"" . $title . "\" has been edited: " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n";
+ $m .= $message;
+ notify("forum", $m);
} else {
error("Message " . $pid . " not found!");
}
@@ -74,7 +80,9 @@ case "reply":
$quote->add($post);
$posts->thread->lastpost = time();
$posts->write();
- notify("forum", "New reply (quote) \"" . $title . "\": " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid);
+ $m = "New reply (quote) \"" . $title . "\": " . $FORUM_URL . "/?fid=". $fid . "&tid=" . $tid. "#firstunread\n";
+ $m .= $message;
+ notify("forum", $m);
} else {
error("Message " . $pid . " not found!");
}
@@ -87,7 +95,7 @@ case "reply":
echo "Return to thread.
\n";
?>
-
+
diff --git a/forum/utils/editor.php b/forum/utils/editor.php
index 36fb39d..768bce9 100644
--- a/forum/utils/editor.php
+++ b/forum/utils/editor.php
@@ -1,154 +1,112 @@
-
\n";
+ $str .= "function addcontent(text) {\n";
+ $str .= " document.post_form.message.value += text;\n";
+ $str .= " document.post_form.message.focus();\n";
+ $str .= "}\n";
+ $str .= "\n";
-if($fid && $tid && $pid) {
- include_once("posts.php");
- $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
- if($pid != -1) $post = $posts->getPost($pid);
- if($post || $pid == -1) {
-
- switch($task) {
- case "new":
- $title = "Title";
- $message = "Message";
- break;
+ $title = "En titel";
+ $message = "Something useful";
- case "reply":
- $title = "Re: " . $post->title;
+ if($fid && $tid && $pid) {
+ include_once("posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ if($pid != -1) $post = $posts->getPost($pid);
+ if($post || $pid == -1) {
+
+ $title = "";
$message = "";
- break;
+
+ switch($task) {
+ case "new":
+ $title = "Title";
+ $message = "Message";
+ break;
- case "edit":
- $title = $post->title;
- $message = $post->message;
- break;
+ case "reply":
+ if(substr($post->title, 0, 4) != "Re: ")
+ $title = "Re: " . $post->title;
+ else $title = $post->title;
+ $message = "";
+ break;
- case "quote":
- $title = "Re: " . $post->title;
- $user = $users->getUser($post->user);
- $message = "[quote title=" . $user->name . " wrote on " .date("r", $post->date) ."]" . $post->message . "[/quote]";
- break;
+ case "edit":
+ $title = $post->title;
+ $message = $post->message;
+ break;
- default:
- error("No mode supplied!");
- break;
- }
-?>
-
-
-
-
-
-B
-I
-U
-[L ]
-[ C ]
-[ R]
-URL
-E-Mail
-Image
-"Q"
-c++
+ case "quote":
+ if(substr($post->title, 0, 4) != "Re: ")
+ $title = "Re: " . $post->title;
+ else $title = $post->title;
+ $user = $users->getUser($post->user);
+ $message = "[quote title=" . $user->name . " wrote on " .
+ date("r", $post->date) ."]" . $post->message . "[/quote]";
+ break;
-
-Size
-1
-2
-3
-4
-5
-6
-7
-
+ default:
+ $str .= error("No mode supplied!");
+ return $str;
+ break;
+ }
-
-Color
-Sky Blue
-Royal Blue
-Blue
-Dark Blue
-Orange
-Orange Red
-Crimson
-Red
-Firebrick
-Dark Red
-Green
-Lime Green
-Sea Green
-Deep Pink
-Tomato
-Coral
-Purple
-Indigo
-Burly Wood
-Sandy Brown
-Sienna
-Chocolate
-Teal
-Silver
-
+ $str .= " \n";
+ $str .= " Title:
\n";
+ $str .= " \n";
-
-Font
-Arial
-Times
-Courier
-Century
- */ ?>
-
- Title:
-
-
-
- ";
-}
-?>
-
-
-
-
-
- To make a link, simply type the URL, and the system will
- automagically transform it into an anchor (remember the
- http:// part) .
- Example: http://www.example.com
-
-
- To insert an image, simply type the URL to that image, it will
- automagically be transformed into an image, with a link to the
- original image (again, remember the http:// part).
- Example: http://www.example.com/image.jpg
-
-
- Post
-
-
-show();
+ include_once($UTIL_DIR . "/smileys.php");
+ foreach($smileys as $smiley) {
+ $smile = $smiley[0][0];
+ if($smile == "\\m/") $smile = "\\\\m/";
+ $str .= " ";
+ }
+ $str .= "
\n";
+ $str .= " \n";
+ $str .= " ".
+ convert_xml($message) . " \n";
+ $str .= "
\n";
+ $str .= " \n";
+ $str .= " To make a link, simply type the URL, and the system will\n";
+ $str .= " automagically transform it into an anchor (remember the\n";
+ $str .= " http:// part) . \n";
+ $str .= " Example: http://www.example.com \n";
+ $str .= "
\n";
+ $str .= " \n";
+ $str .= " To insert an image, simply type the URL to that image, it will\n";
+ $str .= " automagically be transformed into an image, with a link to the\n";
+ $str .= " original image (again, remember the http:// part). \n";
+ $str .= " Example: http://www.example.com/image.jpg\n";
+ $str .= "
\n";
+ $str .= " \n";
+ $str .= " Post \n";
+ $str .= "
\n";
+ $str .= "\n";
+
+ if($pid != -1) $str .= $posts->show();
+ } else {
+ $str .= error("Message " . $pid . " not found!");
+ }
} else {
- error("Message " . $pid . " not found!");
+ $str .= error("No message supplied!");
}
-} else {
- error("No message supplied!");
-}
+ return $str;
+}
?>
diff --git a/forum/utils/error.php b/forum/utils/error.php
index 78128d2..bc2cadb 100644
--- a/forum/utils/error.php
+++ b/forum/utils/error.php
@@ -1,6 +1,5 @@
Error: " . $msg . "\n";
- // exit($msg);
+ return "Error: " . $msg . "
\n";
}
?>
\ No newline at end of file
diff --git a/forum/utils/events.php b/forum/utils/events.php
index 9f521b8..2f46f14 100644
--- a/forum/utils/events.php
+++ b/forum/utils/events.php
@@ -8,31 +8,62 @@ class Event {
public $starttime;
public $duration;
public $description;
+ public $concert;
public $user;
public function show()
{
- global $users, $date, $client_is_mobile_device;
+ global $users, $GLOBALS, $client_is_mobile_device;
- $user = $users->getUser($this->user);
+ $str = "";
- echo " \n";
- echo "
". $this->title . "\n";
- // echo "
Edit \n";
- echo "
\n";
- echo "
" . date("G:i", $this->starttime) . " - " .
- date("G:i", $this->starttime + $this->duration) . "
\n";
+ $user = $users->getUser($this->user);
+ $str .= "
concert == "true") $str .= " concert";
+ $str .= "\">\n";
+ $str .= "
". $this->title . "\n";
+ // $str .= "
Edit \n";
+ $str .= "
\n";
+ $str .= "
" . date("G:i", $this->starttime) .
+ " - " . date("G:i", $this->starttime + $this->duration) . "
\n";
if(!$client_is_mobile_device) {
- echo "
". $this->description . "
\n";
+ $str .= "
". $this->description .
+ "
\n";
} else {
- echo "
". $this->description . "
\n";
+ $str .= "
" .
+ $this->description . "
\n";
}
- echo "
By: ".$user->name . "
\n";
- // echo "
eid . "&action=edit\">Edit ";
- echo "
\n";
+ $str .= "
By: ".$user->name . "
\n";
+
+ $datestr = "";
+ if(isset($GLOBALS['date'])) $datestr = "&date=". $GLOBALS['date'];
+
+ $str .= "
eid . "&action=delete\">Delete ";
+ $str .= "
\n";
+
+ return $str;
+ }
+
+ public function show_simple()
+ {
+ global $users, $GLOBALS, $client_is_mobile_device;
+
+ $str = "";
+
+ $str .= " \n";
+ $str .= " " . date("D d M Y", $this->starttime) . " \n";
+ $str .= " ". $this->title . "\n";
+ $str .= " \n";
+ $str .= " " . date("G:i", $this->starttime) .
+ " - " . date("G:i", $this->starttime + $this->duration) . " \n";
+ $str .= "
\n";
+
+ return $str;
}
- public function Event($eid, $title, $starttime, $duration, $description, $user)
+ public function Event($eid, $title, $concert, $starttime, $duration,
+ $description, $user)
{
$this->eid = $eid;
$this->title = $title;
@@ -40,6 +71,7 @@ class Event {
$this->duration = $duration;
$this->description = $description;
$this->user = $user;
+ $this->concert = $concert;
}
}
@@ -53,6 +85,13 @@ class Events {
$this->events[$key] = $event;
}
+ public function delete($eid) {
+ if(isset($this->events[$eid])) {
+ unset($this->events[$eid]);
+ echo "DELETE";
+ }
+ }
+
public function write()
{
$fp = fopen($this->file, "w");
@@ -68,6 +107,11 @@ class Events {
htmlspecialchars($event->eid, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " title=\"" .
htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
+
+ if($event->concert == "true") $concert = "true";
+ else $concert = "false";
+ fwrite($fp, " concert=\"" . $concert . "\"\n");
+
fwrite($fp, " starttime=\"" .
htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " duration=\"" .
@@ -90,7 +134,7 @@ class Events {
unset($this->members[$id]);
// $this->write();
} else {
- echo "ERROR: User! ".$id." does not exist!
\n";
+ $str .= "ERROR: User! ".$id." does not exist!
\n";
return false;
}
return true;
@@ -99,10 +143,12 @@ class Events {
public function show($starttime, $endtime)
{
+ $str = "";
foreach($this->events as $event) {
if($event->starttime > $starttime && $event->starttime < $endtime)
- $event->show();
+ $str .= $event->show();
}
+ return $str;
}
public function getEvent($eid)
@@ -121,6 +167,7 @@ class Events {
foreach ($events as $e) {
$event = new Event($e->getAttribute('eid'),
$e->getAttribute('title'),
+ $e->getAttribute('concert') == "true",
$e->getAttribute('starttime'),
$e->getAttribute('duration'),
$e->getAttribute('description'),
diff --git a/forum/utils/filehandler.php b/forum/utils/filehandler.php
index af1c305..4c18c38 100644
--- a/forum/utils/filehandler.php
+++ b/forum/utils/filehandler.php
@@ -1,36 +1,39 @@
newFile($_FILES['userfile']['tmp_name'], $name);
- else echo "File is too big " . sprintf("%.0f", filesize($_FILES['userfile']['tmp_name'])/1024).
- "kb, max file size: " . sprintf("%.0f", $FILE_MAX_SIZE/1024) . "kb.";
- }
-}
+ if($task == "upload") {
-if($task == "delete" && $fid) {
- $files->deleteFile($fid);
-}
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ $name = $filename;
+ if(!$filename) $name = $_FILES['userfile']['name'];
+ if(filesize($_FILES['userfile']['tmp_name']) <= $FILE_MAX_SIZE) $files->newFile($_FILES['userfile']['tmp_name'], $name);
+ else $str .= "File is too big " . sprintf("%.0f", filesize($_FILES['userfile']['tmp_name'])/1024).
+ "kb, max file size: " . sprintf("%.0f", $FILE_MAX_SIZE/1024) . "kb.";
+ krsort($files->files);
+ }
+ }
+
+ if($task == "delete" && $fid) {
+ $files->deleteFile($fid);
+ }
+
+ $str .= "";
+ $str .= "File:
\n";
+ $str .= "Use alternative filename (leave empty to use original filename):
\n";
+ $str .= "Add file
";
+ $str .= " ";
-$files->show();
+ $str .= $files->show();
-?>
-
-
- File:
-
-
- Use alternative filename (leave empty to use original filename):
-
-
-
- Add file
-
-
+ return $str;
+}
\ No newline at end of file
diff --git a/forum/utils/files.php b/forum/utils/files.php
index 7356ff8..2fa3ec4 100644
--- a/forum/utils/files.php
+++ b/forum/utils/files.php
@@ -18,18 +18,23 @@ class File {
public function show()
{
global $PERMSTORE, $current_user, $users;
- echo " \n";
+
+ $str = "";
+
+ $str .= "
\n";
if($current_user->uid == 0) {
- echo "
fid . "\">X \n";
+ $str .= "
fid . "\">X \n";
}
- echo "
\n";
- echo "
{{" . $this->fid . "}}
\n";
- echo "
\n";
- echo "
" . $this->mimetype. "
\n";
- echo "
" . $users->getUser($this->uid)->name . "
\n";
- echo "
" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb
\n";
- echo "
" . date("M jS Y - G:i", $this->date) . "
\n";
- echo "
\n";
+ $str .= "
\n";
+ $str .= "
{{" . $this->fid . "}}
\n";
+ $str .= "
\n";
+ $str .= "
" . $this->mimetype. "
\n";
+ $str .= "
" . $users->getUser($this->uid)->name . "
\n";
+ $str .= "
" . ceil(filesize($PERMSTORE . "/" . $this->fid) / 1024) . "kb
\n";
+ $str .= "
" . date("M jS Y - G:i", $this->date) . "
\n";
+ $str .= "
\n";
+
+ return $str;
}
public function File($fid, $uid, $name, $date, $mimetype)
@@ -83,25 +88,30 @@ class Files {
public function show()
{
global $current_user;
- echo "\n";
- echo "
\n";
- echo " \n";
foreach($this->files as $file) {
- $file->show();
+ $str .= $file->show();
}
- echo "
\n";
+ $str .= "
\n";
+
+ return $str;
}
public function getFile($fid)
@@ -154,7 +164,7 @@ class Files {
$this->add($file);
}
-
+ krsort($this->files);
}
public function Files($file)
diff --git a/forum/utils/forums.php b/forum/utils/forums.php
index c9c48b5..c93cafb 100644
--- a/forum/utils/forums.php
+++ b/forum/utils/forums.php
@@ -7,8 +7,8 @@ include_once($UTIL_DIR . "/threads.php");
class Forum {
public $fid;
public $name;
- private $newStuff;
- private $numPosts;
+ public $newStuff;
+ public $numPosts;
private $latestPost;
public function setNewStuff($newStuff, $threads)
@@ -25,15 +25,37 @@ class Forum {
public function show()
{
+ global $cache;
+ global $yeah;
+
+ $str = "";
+
$newcls = " forum_nonew";
- if($this->newStuff) $newcls = " forum_new";
-
- echo " \n";
- echo "
\n";
- echo "
fid . "\">" . $this->name . " \n";
- echo "
".$this->latestPost." \n";
- echo "
".sprintf("%d", $this->numPosts)." threads \n";
- echo "
\n";
+ if($yeah) {
+ $lp = $cache->get("forum_lastpost");
+ if($lp->value($this->fid)) $newcls = " forum_new";
+ } else {
+ if($this->newStuff) $newcls = " forum_new";
+ }
+
+ $str .= " \n";
+ $str .= "
\n";
+ $str .= "
fid . "\">" . $this->name . " \n";
+ $str .= "
".
+ $this->latestPost . " \n";
+ if($yeah) {
+ $fc = $cache->get("forum_numberofthreads");
+
+ $str .= "
" .
+ $fc->value($this->fid) . " threads \n";
+ } else {
+ $str .= "
"
+ . sprintf("%d", $this->numPosts)." threads \n";
+ }
+ $str .= "
\n";
+
+ return $str;
}
public function Forum($fid, $name)
@@ -84,11 +106,15 @@ class Forums {
public function show()
{
- echo "\n";
+ $str = "";
+
+ $str .= "
\n";
foreach($this->forums as $forum) {
- $forum->show();
+ $str .= $forum->show();
}
- echo "
\n";
+ $str .= "
\n";
+
+ return $str;
}
private function read()
diff --git a/forum/utils/mimetypes.php b/forum/utils/mimetypes.php
index f9ecfea..96aab15 100644
--- a/forum/utils/mimetypes.php
+++ b/forum/utils/mimetypes.php
@@ -23,7 +23,7 @@ $MIME_TYPES = array(new MimeType("image/jpeg",array("jpg","jpeg","jpe"),true),
new MimeType("audio/mpeg",array("mp3","mpga","mpega","mp2","m4a"),false),
new MimeType("application/ogg",array("ogg"),false),
new MimeType("application/pdf",array("pdf"),false),
- new MimeType("application/msword",array("doc"),false),
+ new MimeType("application/msword",array("doc", "docx"),false),
new MimeType("text/plain", array("asc","txt","text","diff","pot"), true)
);
diff --git a/forum/utils/notify.php b/forum/utils/notify.php
index 8ddbbd0..81a8734 100644
--- a/forum/utils/notify.php
+++ b/forum/utils/notify.php
@@ -34,6 +34,7 @@ function notify($module = "", $event = "")
if($user->enabled == false) continue; // Do not mail disabled accounts.
if($module == "calendar" || // Always mail calendar updates.
+ $user->username == "rasmus" || // Always send mails to Rasmus.
(
$module == "forum" &&
$user != $current_user && // Don't notify current user.
diff --git a/forum/utils/posts.php b/forum/utils/posts.php
index f29354e..32e48e2 100644
--- a/forum/utils/posts.php
+++ b/forum/utils/posts.php
@@ -47,68 +47,72 @@ class Post {
public function show($indent = " ", $recurse = true)
{
+ $str = "";
+
global $users, $fid, $tid, $current_user, $client_is_mobile_device;
$user = $users->getUser($this->user);
- echo $indent . "\n";
+ $str .= $indent . "
\n";
if($client_is_mobile_device) {
$avatar = "mobileavatar.gif";
} else {
if($user->avatar) $avatar = $user->avatar;
else $avatar = "default.gif";
}
- echo $indent . "
\n";
+ $str .= $indent . "
\n";
if(!$client_is_mobile_device) {
- echo $indent . "
ID: " . $this->pid . "
\n";
- echo $indent . "
Title: " . convert_xml($this->title) . "
\n";
+ $str .= $indent . "
ID: " . $this->pid . "
\n";
+ $str .= $indent . "
Title: " . convert_xml($this->title) . "
\n";
}
- echo $indent . "
";
- if(!$client_is_mobile_device) echo "UserID: ";
- echo $user->name . "
\n";
- echo $indent . "
";
- if(!$client_is_mobile_device) echo "Date: ";
- echo date("j. M Y - G:i", $this->date) . "
\n";
- echo $indent . "
\n";
- echo parse($this->message, $indent . " ") . "\n";
+ $str .= $indent . "
";
+ if(!$client_is_mobile_device) $str .= "UserID: ";
+ $str .= $user->name . "
\n";
+ $str .= $indent . "
";
+ if(!$client_is_mobile_device) $str .= "Date: ";
+ $str .= date("j. M Y - G:i", $this->date) . "
\n";
+ $str .= $indent . "
\n";
+ $str .= parse($this->message, $indent . " ") . "\n";
if(trim($user->signature) != "") {
- echo $indent . "
\n";
- echo parse("--------------------------\n" . $user->signature, $indent . " ") . "\n";
- echo $indent . "
\n";
+ $str .= $indent . "
\n";
+ $str .= parse("--------------------------\n" . $user->signature, $indent . " ") . "\n";
+ $str .= $indent . "
\n";
}
- echo $indent . "
\n";
- echo $indent . "
\n";
+ $str .= $indent . "
\n";
+ $str .= $indent . "
\n";
- echo $indent . "
\n";
+ $str .= $indent . "
\n";
+ $str .= $indent . "
\n";
if($recurse) {
foreach($this->replies as $reply) {
- $reply->show($indent . " ");
+ $str .= $reply->show($indent . " ");
}
}
- echo $indent . "
\n";
- echo $indent . "
\n";
+ $str .= $indent . "
\n";
+ $str .= $indent . "
\n";
+
+ return $str;
}
public function Post($pid, $title, $user, $date, $message = "")
@@ -185,15 +189,17 @@ class Posts {
{
global $current_user;
- echo " Down to the bottom ";
+ $str = "";
+
+ $str .= "
Down to the bottom ";
foreach($this->posts_linear as $post) {
if($post->date > $this->thread->lastseen[$current_user->uid]) {
- echo " Down to first unread \n";
+ $str .= " Down to first unread \n";
break;
}
}
- echo "
\n";
- echo " " . $this->thread->name . " \n";
+ $str .= "\n";
+ $str .= " " . $this->thread->name . " \n";
/* // Recursive
foreach($this->posts as $post) {
@@ -206,21 +212,23 @@ class Posts {
foreach($this->posts_linear as $post) {
if($post->date > $this->thread->lastseen[$current_user->uid] && $firstunread == false) {
$firstunread = true;
- echo "
\n";
- echo " \n";
+ $str .= "
\n";
+ $str .= "
\n";
}
- $post->show(" ", false);
+ $str .= $post->show(" ", false);
}
if($firstunread == true) {
- echo "
\n";
+ $str .= "
\n";
}
$this->thread->lastseen[$current_user->uid] = time();
$this->write();
- echo " Up to the top
\n";
+ $str .= " Up to the top
\n";
+
+ return $str;
}
private function recurser($parentpost, $element)
diff --git a/forum/utils/profile.php b/forum/utils/profile.php
index f7595ed..d96b8c2 100644
--- a/forum/utils/profile.php
+++ b/forum/utils/profile.php
@@ -1,45 +1,52 @@
username = $username;
- $current_user->name = $name;
- $current_user->email = $email;
- // $current_user->avatar = $avatar;
- $current_user->signature = stripslashes($signature);
- if($password != "") {
- if($password == $password_confirm) {
- $current_user->password = sha1(md5($password));
- } else {
- error("Passwords do not match - thus not changed!");
- }
- }
+ if($action == "update") {
+ global $name, $email, $signature, $password, $password_confirm, $users;
+ // $current_user->username = $username;
+ $current_user->name = $name;
+ $current_user->email = $email;
+ // $current_user->avatar = $avatar;
+ $current_user->signature = stripslashes($signature);
+ if($password != "") {
+ if($password == $password_confirm) {
+ $current_user->password = sha1(md5($password));
+ } else {
+ error("Passwords do not match - thus not changed!");
+ }
+ }
+
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ if(!file_exists("gfx/avatars")) mkdir("gfx/avatars");
+ // Prepend username to prevent overwriting of other users avatars.
+ $filename = $current_user->username . "_" . $_FILES['userfile']['name'];
+ if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar);
+ move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename);
+ $current_user->avatar = $filename;
+ }
+
+ $users->write();
+ }
- if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
- if(!file_exists("gfx/avatars")) mkdir("gfx/avatars");
- // Prepend username to prevent overwriting of other users avatars.
- $filename = $current_user->username . "_" . $_FILES['userfile']['name'];
- if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar);
- move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename);
- $current_user->avatar = $filename;
- }
-
-
- $users->write();
-}
-?>
-
-username; ?>"> */ ?>
- Name:
- New password:
- Confirm password:
- E-Mail:
- Avatar:
-
-
- Signature:
- signature ?>
-
- Update
-
+ $str .= "";
+ //$str .= " Username: username . "\" ";
+ $str .= " Name: name . "\"> ";
+ $str .= " New password: ";
+ $str .= " Confirm password: ";
+ $str .= " E-Mail: email . "\"> ";
+ $str .= " Avatar: ";
+ $str .= " avatar . "\"/> ";
+ $str .= " ";
+ $str .= " Signature: ";
+ $str .= " ". $current_user->signature . " ";
+ $str .= " ";
+ $str .= " Update ";
+ $str .= " ";
+
+ return $str;
+}
\ No newline at end of file
diff --git a/forum/utils/smileys.php b/forum/utils/smileys.php
index 805ad69..5ee43f8 100644
--- a/forum/utils/smileys.php
+++ b/forum/utils/smileys.php
@@ -15,6 +15,7 @@ $smileys = array(
array(array(":razz:"), "razz.gif"),
array(array(":roll:"), "roll.gif"),
array(array(":evil:"), "evil.gif"),
+ array(array(":jawdrop:"), "jawdrop.gif"),
array(array(":evilgrin:"), "evilgrin.gif"),
array(array(":lol:"), "lol.gif"),
array(array(":cool:"), "cool.gif"),
diff --git a/forum/utils/tasks.php b/forum/utils/tasks.php
index 91f5409..fe66327 100644
--- a/forum/utils/tasks.php
+++ b/forum/utils/tasks.php
@@ -226,79 +226,86 @@ function sendMail($id, $new, $reassigned)
send($email, $subject, $body);
}
-$tasks = tasks_init();
-
-if($action == "tick") {
- $now = time();
-
- $h = (60 * 60);
- $d = ($h * 24);
-
- $mininterval = $d - $h * 4;
- $maxinterval = $d * 7 - $h * 4;
- $overdueinterval = $h * 7;
-
- foreach($tasks->tasks as $task) {
-
- if($task->completed) continue; // no need for reminding
-
- if(($now > $task->deadline) && (($now - $task->lastreminder) > $overdueinterval)) {
- // Deadline is overdue, and it has been more than $overdueinterval since last reminder.
- sendMail($task->id, false, false);
- } elseif((($task->deadline - $now) > $maxinterval) && (($now - $task->lastreminder) > $maxinterval)) {
- // Deadline is a long way off, but it has been $maxinterval since last reminder.
- sendMail($task->id, false, false);
- } elseif((($task->deadline - $now) > $mininterval) && (($now - $task->lastreminder) > $mininterval)) {
- // Deadline is near, and it has been $mininterval since last reminder.
- sendMail($task->id, false, false);
- }
+function tasks()
+{
+ global $action, $GLOBALS;
+
+ $tasks = tasks_init();
+
+ if($action == "tick") {
+ $now = time();
+
+ $h = (60 * 60);
+ $d = ($h * 24);
+
+ $mininterval = $d - $h * 4;
+ $maxinterval = $d * 7 - $h * 4;
+ $overdueinterval = $h * 7;
+
+ foreach($tasks->tasks as $task) {
+
+ if($task->completed) continue; // no need for reminding
+
+ if(($now > $task->deadline) && (($now - $task->lastreminder) > $overdueinterval)) {
+ // Deadline is overdue, and it has been more than $overdueinterval since last reminder.
+ sendMail($task->id, false, false);
+ } elseif((($task->deadline - $now) > $maxinterval) && (($now - $task->lastreminder) > $maxinterval)) {
+ // Deadline is a long way off, but it has been $maxinterval since last reminder.
+ sendMail($task->id, false, false);
+ } elseif((($task->deadline - $now) > $mininterval) && (($now - $task->lastreminder) > $mininterval)) {
+ // Deadline is near, and it has been $mininterval since last reminder.
+ sendMail($task->id, false, false);
+ }
}
-}
+ }
-if($action == "update") {
- $reassigned = false;
- $id = $GLOBALS['id'];
- $task = $tasks->tasks[$id];
- if(isset($GLOBALS['completed'])) $task->completed = $GLOBALS['completed'] == "on";
- if(isset($GLOBALS['userid'])) {
- $reassigned = $task->userid != $GLOBALS['userid'];
- $task->userid = $GLOBALS['userid'];
- }
- $tasks->write();
+ if($action == "update") {
+ $reassigned = false;
+ $id = $GLOBALS['id'];
+ $task = $tasks->tasks[$id];
+ if(isset($GLOBALS['completed'])) $task->completed = $GLOBALS['completed'] == "on";
+ if(isset($GLOBALS['userid'])) {
+ $reassigned = $task->userid != $GLOBALS['userid'];
+ $task->userid = $GLOBALS['userid'];
+ }
+ $tasks->write();
+
+ if($reassigned) sendMail($id, false, true);
+ }
+
+ if($action == "add") {
+
+ $deadline = strtotime($GLOBALS['deadline_year']."-".
+ $GLOBALS['deadline_month']."-".
+ $GLOBALS['deadline_day']);
+
+ $task = new Task($tasks->getNextID(),
+ stripslashes($GLOBALS['title']),
+ $deadline,
+ stripslashes($GLOBALS['description']),
+ 0,
+ $GLOBALS['reassignable'] == "on",
+ $GLOBALS['userid'],
+ false);
+ $tasks->add($task);
+ $tasks->write();
+
+ sendMail($task->id, true, false);
+ }
- if($reassigned) sendMail($id, false, true);
-}
+ $str .= "\n";
+ $str .= " Title: - User: " . userList($current_user->uid) . " -";
+ $str .= " Deadline: D \n";
+ $str .= " M \n";
+ $str .= " Y \n";
+ $str .= " Reassignable: \n";
+ $str .= " \n";
+ $str .= " Add Task \n";
+ $str .= " \n";
+ $str .= " \n";
-if($action == "add") {
-
- $deadline = strtotime($GLOBALS['deadline_year']."-".
- $GLOBALS['deadline_month']."-".
- $GLOBALS['deadline_day']);
-
- $task = new Task($tasks->getNextID(),
- stripslashes($GLOBALS['title']),
- $deadline,
- stripslashes($GLOBALS['description']),
- 0,
- $GLOBALS['reassignable'] == "on",
- $GLOBALS['userid'],
- false);
- $tasks->add($task);
- $tasks->write();
+ $str .= $tasks->show();
- sendMail($task->id, true, false);
+ return $str;
}
-
?>
-
- Title: - User: uid); ?> - Deadline: D
- M
- Y
- Reassignable:
-
- Add Task
-
-
-show();
-?>
\ No newline at end of file
diff --git a/forum/utils/threads.php b/forum/utils/threads.php
index 52dda06..a30bf5c 100644
--- a/forum/utils/threads.php
+++ b/forum/utils/threads.php
@@ -35,6 +35,8 @@ class Thread {
global $fid, $current_user;
global $users;
+ $str = "";
+
$jumptonew = "";
$newcls = " thread_nonew";
if($this->lastseen[$current_user->uid] < $this->lastpost) {
@@ -42,21 +44,23 @@ class Thread {
$jumptonew = "#firstunread";
}
- echo " \n";
- echo "
\n";
- echo "
tid . $jumptonew."\">" . $this->name . " \n";
- echo "
".$this->numposts." posts";
+ $str .= " \n";
+ $str .= "
\n";
+ $str .= "
tid . $jumptonew."\">" . $this->name . " \n";
+ $str .= "
".$this->numposts." posts";
if($this->numunread != 0) {
- echo " (".$this->numunread." unread) ";
+ $str .= " (".$this->numunread." unread) ";
}
- echo " \n";
- echo "
Last post: ".
+ $str .= " \n";
+ $str .= "
Last post: ".
date("j. M Y - G:i", $this->lastpost)." \n";
$user = $users->getUser($this->first_user);
- echo "
By ".$user->name;
- echo " at ". date("j. M Y - G:i", $this->first_date)." \n";
- echo "
\n";
+ $str .= " By ".$user->name;
+ $str .= " at ". date("j. M Y - G:i", $this->first_date)." \n";
+ $str .= " \n";
+
+ return $str;
}
public function processPost($pid, $title, $user, $date)
@@ -190,9 +194,13 @@ class Threads {
public function show()
{
+ $str = "";
+
foreach($this->threads as $thread) {
- $thread->show();
+ $str .= $thread->show();
}
+
+ return $str;
}
public function newStuff()
diff --git a/forum/utils/view.php b/forum/utils/view.php
index 2673394..1e9812a 100644
--- a/forum/utils/view.php
+++ b/forum/utils/view.php
@@ -1,56 +1,65 @@
";
-if($fid) {
- echo "Legend: Forums ";
- if($tid) {
- include_once("forums.php");
- $forums = new Forums($FORUMS_DIR . "/forums.xml");
- $forum = $forums->getForum($fid);
- echo " :: ".$forum->name." ";
-
- include_once("posts.php");
- $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
- echo " :: ".$posts->thread->name;
-
- $posts->show();
-
- } else {
- include_once("forums.php");
- $forums = new Forums($FORUMS_DIR . "/forums.xml");
- $forum = $forums->getForum($fid);
- echo " :: ".$forum->name;
-
- echo " Threads in '".$forum->name."' \n";
- echo " New thread \n";
+
+function viewForum()
+{
+ global $fid, $tid, $action, $current_user, $UTIL_DIR,
+ $FORUMS_DIR, $smileys;
+
+ $legend = " ";
+ $f_str = "";
+ if($fid) {
+ $legend .= "Legend:
Forums ";
+ if($tid) {
+ include_once($UTIL_DIR . "/forums.php");
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ $forum = $forums->getForum($fid);
+ $legend .= " ::
".$forum->name." ";
+
+ include_once($UTIL_DIR . "/posts.php");
+ $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
+ $legend .= " :: ".$posts->thread->name;
+
+ $f_str .= $posts->show();
+
+ } else {
+ include_once($UTIL_DIR . "/forums.php");
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ $forum = $forums->getForum($fid);
+ $legend .= " :: ".$forum->name;
+
+ $f_str .= "
Threads in '".$forum->name."' \n";
+ $f_str .= "
New thread \n";
- include_once("threads.php");
- $threads = new Threads($FORUMS_DIR . "/" . $fid);
- $threads->show();
- }
-} else {
- echo "Legend: Forums";
- echo "
Forums \n";
- include_once("forums.php");
- $forums = new Forums($FORUMS_DIR . "/forums.xml");
+ include_once($UTIL_DIR . "/threads.php");
+ $threads = new Threads($FORUMS_DIR . "/" . $fid);
+ $f_str .= $threads->show();
+ }
+ } else {
+ $legend .= "Legend: Forums";
+ $f_str .= "
Forums \n";
+ include_once("forums.php");
+ $forums = new Forums($FORUMS_DIR . "/forums.xml");
- if($action == "addforum") {
- $newfid = 1;
- while($forums->getForum($newfid)) $newfid++;
+ if($action == "addforum") {
+ $newfid = 1;
+ while($forums->getForum($newfid)) $newfid++;
- $forums->add(new Forum($newfid, $title));
- $forums->write();
- }
+ $forums->add(new Forum($newfid, $title));
+ $forums->write();
+ }
- $forums->show();
+ $f_str .= $forums->show();
- if($current_user->uid == 0) {
-?>
-
-Add new forum: Add
-
-uid == 0) {
+ $f_str .= "
\n";
+ $f_str .= "Add new forum: Add \n";
+ $f_str .= " \n";
+ }
+ }
+
+ $legend .= "
\n";
+
+ return $legend . $f_str;
}
-echo "\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 @@
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 @@
-
+
Admin
findUser($UID);
?>
Logout
-\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 = "
\n";
+ $str = "
\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 .= "
\n";
+ $str .= "
\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, "
\n");
foreach($this->discs as $disc) {
- $disc->write($fp);
+ $disc->write($fp);
}
fwrite($fp, " \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 .= "
value."\">Video: " . $this->title." ";
+ }
+
+ if($this->type == "vimeo") {
+ $str .= "
value."\">Video: " . $this->title." ";
+ }
+
+ 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, "
title) . "\"\n");
fwrite($fp, " time=\"" . xmlenc($this->time) . "\"\n");
- fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">");
- fwrite($fp, xmlenc($this->description));
- fwrite($fp, " \n");
+ fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">\n");
+ fwrite($fp, "
".xmlenc($this->description)." \n");
+ if($this->refs) $this->refs->write($fp, " ");
+ fwrite($fp, " \n");
}
public function show($eventpage)
@@ -40,10 +43,17 @@ class Event {
$str .= "
prefix.$icon->file."\"/>\n";
}
*/
+ if($this->refs) $str .= $this->refs->show();
+
$str .= "
\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 "\n";
echo "
\n";
echo $event->show($this->eventpage);
@@ -159,11 +174,13 @@ class Events {
echo "
Looking ok?
";
$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 .= "
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."
\n";
+ // $str .= $indent." ← Back to albums \n";
$str .= $indent." " . $this->title . " \n";
+ $str .= $indent." Copyright: " . $this->copyright . " \n";
foreach($this->photos as $photo) {
$str .= $indent." id."&p=".$photo->id."\">\n";
$str .= $photo->show($indent." ", "albumicon");
$str .= $indent." \n";
}
- $str .= $indent." \n";
+ $str .= $indent."
← Back to albums \n";
+ // Back to gallery
+ /*
+ $str .= $indent."
\n";
+ $str .= $indent."\n";
+ $str .= $indent." \n";
+ $str .= $indent." \n";
+ $str .= $indent." \n";
+ $str .= $indent." " . $this->title . " \n";
+ $str .= $indent." \n";
+ $str .= $indent." \n";
+ $str .= $indent."\n";
+ */
return $str;
}
@@ -132,6 +158,20 @@ class Album {
return $str;
}
+ public function showRef()
+ {
+ global $page;
+
+ $str = "";
+
+ $str .= $indent."
id."\">\n";
+ $str .= $this->photos[$this->icon]->showRef() .
+ " " .$this->title . "\n";
+ $str .= $indent." \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
\n";
foreach($this->albums as $album) {
- $str .= $album->showIcon(" ");
+ if($album->enabled) $str .= $album->showIcon(" ");
}
$str .= " \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 @@
-original) $prefix = "Translated";
+
+ $str .= "\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, "
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, " ".htmlspecialchars($this->lyrics, ENT_QUOTES, "UTF-8")." \n");
+ fwrite($fp, " \n");
+*/
+ }
+
+ public function show()
+ {
+ $str = "";
+
+ // $str .= $this->id . "\n";
+ $str .= "\n";
+ $str .= "
Origin: ".$this->src." url."\">".$this->url."
\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 .= "
id."\">".$this->title." from ".$this->src." \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, "\n");
+
+ fwrite($fp, "
\n");
+ foreach($this->discs as $disc) {
+ $disc->write($fp);
+ }
+ fwrite($fp, " \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 @@
+mod);
+ if($module && method_exists($module, "showRef")) {
+ $str .= "
\n";
+ $str .= /*"[".$this->mod."] - ".*/$module->showRef($this->id);
+ $str .= "
\n";
+ }
+ return $str;
+ }
+
+ function Ref($mod, $id)
+ {
+ $this->mod = $mod;
+ $this->id = $id;
+ }
+}
+
+class Refs {
+ public $refs = array();
+
+ function show()
+ {
+ $str = "";
+ $str .= "
\n";
+ $str .= " \n";
+ foreach($this->refs as $ref) {
+ $str .= $ref->show();
+ }
+ $str .= "
";
+ return $str;
+ }
+
+ public function write($fp, $indent)
+ {
+ if($this->refs) {
+ fwrite($fp, $indent."
\n");
+ foreach($this->refs as $ref) {
+ fwrite($fp, $indent." [mod."\" id=\"".$ref->id."\"/>\n");
+ }
+ fwrite($fp, $indent."] \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
--
cgit v1.2.3