getUser($this->user); echo "
\n"; echo "
". $this->title . "\n"; // echo " Edit\n"; echo "
\n"; echo "
" . date("G:i", $this->starttime) . " - " . date("G:i", $this->starttime + $this->duration) . "
\n"; if(!$client_is_mobile_device) { echo "
". $this->description . "
\n"; } else { echo "
". $this->description . "
\n"; } echo "
By: ".$user->name . "
\n"; // echo " Edit"; echo "
\n"; } public function Event($eid, $title, $starttime, $duration, $description, $user) { $this->eid = $eid; $this->title = $title; $this->starttime = $starttime; $this->duration = $duration; $this->description = $description; $this->user = $user; } } class Events { private $file; public $events = array(); public function add($event) { $key = $event->eid; $this->events[$key] = $event; } public function write() { $fp = fopen($this->file, "w"); $block = TRUE; flock($fp, LOCK_EX, $block); // do an exclusive lock fwrite($fp, "\n"); fwrite($fp, "\n"); foreach($this->events as $event) { fwrite($fp, " eid, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " title=\"" . htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " starttime=\"" . htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " duration=\"" . htmlspecialchars($event->duration, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " description=\"" . htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " user=\"" . htmlspecialchars($event->user, ENT_QUOTES, "UTF-8") . "\">\n"); fwrite($fp, " \n"); } fwrite($fp, "\n"); fclose($fp); } /* public function deleteForumUser($id) { if($this->members[$id]) { unset($this->members[$id]); // $this->write(); } else { echo "

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

\n"; return false; } return true; } */ public function show($starttime, $endtime) { foreach($this->events as $event) { if($event->starttime > $starttime && $event->starttime < $endtime) $event->show(); } } public function getEvent($eid) { $event = $this->events[$eid]; return $event; } private function read() { $dom = new DomDocument; $dom->preserveWhiteSpace = FALSE; $dom->load($this->file); $events = $dom->getElementsByTagName('event'); foreach ($events as $e) { $event = new Event($e->getAttribute('eid'), $e->getAttribute('title'), $e->getAttribute('starttime'), $e->getAttribute('duration'), $e->getAttribute('description'), $e->getAttribute('user')); $this->add($event); } } public function Events($file) { $this->file = $file; $this->read(); } } ?>