From cce5e7710295021b41d9aaecc503a60fb99256be Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 4 Oct 2008 10:38:03 +0000 Subject: Initial revision --- utils/admin_events.php | 85 ++++++++++++++++++ utils/admin_gallery.php | 108 +++++++++++++++++++++++ utils/admin_guestbook.php | 2 + utils/admin_news.php | 121 ++++++++++++++++++++++++++ utils/admin_newsletter.php | 55 ++++++++++++ utils/admin_pressrelease.php | 55 ++++++++++++ utils/admin_user.php | 32 +++++++ utils/admin_users.php | 203 +++++++++++++++++++++++++++++++++++++++++++ utils/album.php | 137 +++++++++++++++++++++++++++++ utils/convert.php | 11 +++ utils/events.php | 130 +++++++++++++++++++++++++++ utils/guestbook.php | 169 +++++++++++++++++++++++++++++++++++ utils/links.php | 128 +++++++++++++++++++++++++++ utils/log.php | 15 ++++ utils/login.php | 67 ++++++++++++++ utils/news.php | 103 ++++++++++++++++++++++ utils/newsletter.php | 146 +++++++++++++++++++++++++++++++ utils/pressrelease.php | 165 +++++++++++++++++++++++++++++++++++ utils/rss.php | 112 ++++++++++++++++++++++++ utils/thumbnail.php | 39 +++++++++ utils/user.php | 151 ++++++++++++++++++++++++++++++++ utils/xml.php | 126 +++++++++++++++++++++++++++ 22 files changed, 2160 insertions(+) create mode 100644 utils/admin_events.php create mode 100644 utils/admin_gallery.php create mode 100644 utils/admin_guestbook.php create mode 100644 utils/admin_news.php create mode 100644 utils/admin_newsletter.php create mode 100644 utils/admin_pressrelease.php create mode 100644 utils/admin_user.php create mode 100644 utils/admin_users.php create mode 100644 utils/album.php create mode 100644 utils/convert.php create mode 100644 utils/events.php create mode 100644 utils/guestbook.php create mode 100644 utils/links.php create mode 100644 utils/log.php create mode 100644 utils/login.php create mode 100644 utils/news.php create mode 100644 utils/newsletter.php create mode 100644 utils/pressrelease.php create mode 100644 utils/rss.php create mode 100644 utils/thumbnail.php create mode 100644 utils/user.php create mode 100644 utils/xml.php (limited to 'utils') diff --git a/utils/admin_events.php b/utils/admin_events.php new file mode 100644 index 0000000..058b9de --- /dev/null +++ b/utils/admin_events.php @@ -0,0 +1,85 @@ +

Events

+show(); +?> +Is this correct?
+
+ + + + + + +
+
+ + + + + + +
+ + +add($event); + $events->write(); + + echo "

Event posted successfully.

"; + $title = ""; + $day = ""; + $month = ""; + $year = ""; + $description = ""; +} +?> + + +
Post event
+
+

+ Title: +

+

+ Date: / + - + +

+

+ Description:
+ +

+ +
diff --git a/utils/admin_gallery.php b/utils/admin_gallery.php new file mode 100644 index 0000000..b584229 --- /dev/null +++ b/utils/admin_gallery.php @@ -0,0 +1,108 @@ +

Gallery

+ + + +"; + echo $albumcopyright . "
"; + echo $albumdir . "
"; + mkdir($albumdir); + $xml = "\n"; + $xml .= "\n"; + $xml .= "\n"; + $fp = fopen($albumdir . "/album.xml", "w"); + fprintf($fp, $xml); + fclose($fp); +} +?> + +"; + echo $description . "
"; + echo $_FILES['userfile']['tmp_name'] . "
"; + + if($_FILES['userfile']['tmp_name'] != "") { + echo "Filename [". $_FILES['userfile']['tmp_name'] . "]"; + if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { + echo "File ". $_FILES['userfile']['name'] ." uploaded successfully.\n"; + + $outputfile = time() . ".jpg"; + + $image = imagecreatefromjpeg($_FILES["userfile"]["tmp_name"]); + list($w, $h) = getimagesize($_FILES["userfile"]["tmp_name"]); + + // output size and quality + $quality = 80; + + $max = 530; + + $width = 530;; + $height = 380; + + if($w > $h) { + $width = 530; + $height = 530 / $w * $h; + } else { + $height = 530; + $width = 530 / $h * $w; + } + $image_p = imagecreatetruecolor($width, $height); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $w, $h); + imagejpeg($image_p, $ALBUMS_DIR ."/" .$album ."/" .$outputfile, $quality); + + $photo = new Photo($outputfile, $description); + $album = new Album($album); + $album->add($photo); + $album->write(); + + } else { + echo "Possible file upload attack: "; + echo "filename '". $_FILES['userfile']['tmp_name'] . "'."; + } + } +} +?> + +
New album
+
+

+ Title: +

+

+ Copyright: +

+

+ +

+
+ +
Upload image
+
+

+ Album: + +

+

+ Description: + +

+

+ Upload this image: + +

+

+ +

+
diff --git a/utils/admin_guestbook.php b/utils/admin_guestbook.php new file mode 100644 index 0000000..ebdefbf --- /dev/null +++ b/utils/admin_guestbook.php @@ -0,0 +1,2 @@ +

Guestbook

+... nothing to see here ... yet! \ No newline at end of file diff --git a/utils/admin_news.php b/utils/admin_news.php new file mode 100644 index 0000000..b27cf31 --- /dev/null +++ b/utils/admin_news.php @@ -0,0 +1,121 @@ +

News

+show(); + + echo "

Category: " . $category . "

\n"; + if($newsletter) echo "

WARNING: This news will be sent out a newsletter if yes is pressed.

\n"; +?> +Is this news correct?
+
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
+ + +add($newsentry); + $news->write(); + + // Now update the RSS feed. + $rss = new RSS($DATA_DIR."/news.xml", "rss.xml"); + $rss->write(); + + echo "

News posted successfully.

"; + + // if($newsletter == "on") sendNewsLetter($title, $description); + + $title = ""; + $category = ""; + $newsletter = ""; + $day = ""; + $month = ""; + $year = ""; + $hour = ""; + $minute = ""; + $second = ""; + $description = ""; +} +?> + + + +
Post news
+
+ Title:
+ Category: +
+ Date: / + - +
+ Time: : + : +
+ Description:
+ +
diff --git a/utils/admin_newsletter.php b/utils/admin_newsletter.php new file mode 100644 index 0000000..29275ab --- /dev/null +++ b/utils/admin_newsletter.php @@ -0,0 +1,55 @@ +

Newsletter

+send(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); + echo "A testmail has been sent to " . $testaddr . ". Check this email to berify the correctness of the contents."; + +?> +Is the newsmail correct?
+
+ + + + +
+
+ + + + +
+ + +post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +
Post newsletter
+
+

+ Test address: + +

+

+ Subject: + +

+

+ Message:
+ +

+

+ +

+
diff --git a/utils/admin_pressrelease.php b/utils/admin_pressrelease.php new file mode 100644 index 0000000..65ba35a --- /dev/null +++ b/utils/admin_pressrelease.php @@ -0,0 +1,55 @@ +

Pressrelease

+send(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); + echo "A testmail has been sent to " . $testaddr . ". Check this email to berify the correctness of the contents."; + +?> +Is the press mail correct?
+
+ + + + +
+
+ + + + +
+ + +post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +
Post pressrelease
+
+

+ Test address: + +

+

+ Subject: + +

+

+ Message:
+ +

+

+ +

+
diff --git a/utils/admin_user.php b/utils/admin_user.php new file mode 100644 index 0000000..42ed784 --- /dev/null +++ b/utils/admin_user.php @@ -0,0 +1,32 @@ +

Password

+findUser($HTTP_COOKIE_VARS["UserID"]); + $user->setPassword($oldpassword, $password1, $password2); + $users->add($user); // We need to update the user after changing the password! + $users->write(); +} +?> + +
Change password
+
+

+ Old password: + +

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
diff --git a/utils/admin_users.php b/utils/admin_users.php new file mode 100644 index 0000000..c2e742f --- /dev/null +++ b/utils/admin_users.php @@ -0,0 +1,203 @@ +

Users

+ + + +
Add user
+findUser($newuserid)) { + $user = new User($newuserid, + sha1(md5($newpassword1)), + $newmodule_users, + $newmodule_news, + $newmodule_events, + $newmodule_guestbook, + $newmodule_gallery, + $newmodule_user, + $newmodule_newsletter); + $users->add($user); + $users->write(); + echo "

User " . $newuserid . " added successfully.

\n"; + } else { + echo "

ERROR: User " . $newuserid . " already exists.

\n"; + } + } else { + echo "

ERROR: Passwords do not match.

\n"; + } +} +?> +
+

+ UserID: +

+

+ /> + Add/edit.delete users:
+ /> + Change password:
+ /> + Add news:
+ /> + Add events:
+ /> + Add images in gallery:
+ /> + Send newsletter:
+ /> + Modify guestbook +

+

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
+ +
Edit user
+findUser($edituserid); + $user->users = $module_users; + $user->user = $module_user; + $user->news = $module_news; + $user->events = $module_events; + $user->gallery = $module_gallery; + $user->newsletter = $module_newsletter; + $user->guestbook = $module_guestbook; + if($password1 != "") { + if($password1 == $password2) { + $user->password = sha1(md5($password1)); + $users->add($user); + $users->write(); + echo "

User " . $edituserid . " successfully updated.

\n"; + } else { + echo "

ERROR: Passwords do not match

\n"; + $task = "edituser"; + } + } else { + $users->add($user); + $users->write(); + echo "

User " . $edituserid . " successfully updated. Password left untouched.

\n"; + } +} +?> +findUser($edituserid); +?> +
+

+ UserID: +

+

+ users == "on") echo "checked"; ?>/> + Add/edit.delete users:
+ user == "on") echo "checked"; ?>/> + Change password:
+ news == "on") echo "checked"; ?>/> + Add news:
+ events == "on") echo "checked"; ?>/> + Add events:
+ gallery == "on") echo "checked"; ?>/> + Add images in gallery:
+ newsletter == "on") echo "checked"; ?>/> + Send newsletter:
+ guestbook == "on") echo "checked"; ?>/> + Modify guestbook +

+

+ New password: + +

+

+ Confirm password: + +

+

+ +

+
+ +
+

+ Select the user you want to edit:
+ + +

+
+ +
Delete user
+ +Are you sure you want to delete the user?
+
+ + +
+
+ + +
+ + +deleteUser($deleteuserid)) { + echo "

User ".$deleteuserid." deleted successfully.

\n"; + } +} +?> +
+

+ Select the user you want to delete:
+ + +

+
diff --git a/utils/album.php b/utils/album.php new file mode 100644 index 0000000..1b6b662 --- /dev/null +++ b/utils/album.php @@ -0,0 +1,137 @@ +file = $file; + $this->text = $text; + } +} + +class Album { + // Album directory (and identifier) + public $album; + + // Photo array + public $photos; + + // Album data + public $title; + public $icon; + public $copyright; + + public function add($photo) { + // First added image is automatically made album icon. + if($this->icon == "") $this->icon = $photo->file; + + $key = $photo->file; + $this->photos[$key] = $photo; + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "title . "\" icon=\"".$this->icon."\" copyright=\"" . $this->copyright . "\">\n"); + foreach($this->photos as $photo) { + fwrite($fp, " file . "\"\n"); + fwrite($fp, " text=\"" . $photo->text . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + + $params = $dom->getElementsByTagName('album'); + foreach ($params as $param) { + $this->title = $param->getAttribute('title'); + $this->icon = $param->getAttribute('icon'); + $this->copyright = $param->getAttribute('copyright'); + } + + $params = $dom->getElementsByTagName('photo'); + foreach ($params as $param) { + $photo = new Photo($param->getAttribute('file'), $param->getAttribute('text')); + $this->add($photo); + } + + // Key sort + if(sizeof($this->photos) > 0) ksort($this->photos); + } + + public function Album($album) + { + global $ALBUMS_DIR; + $this->album = $album; + $this->file = $ALBUMS_DIR ."/". $album . "/album.xml"; + $this->read(); + } + +} + + +function getAllAlbums() +{ + global $ALBUMS_DIR; + $albums = array(); + + $handle = opendir($ALBUMS_DIR . "/"); + $albumdirs = array(); + while($albumdir = readdir($handle)) { + array_push($albumdirs, $albumdir); + } + + rsort($albumdirs); + + foreach($albumdirs as $albumdir) { + if(!strstr($albumdir, ".") && !strstr($albumdir, "..")) { + $album = new Album($albumdir); + array_push($albums, $album); + } + } + + return $albums; +} + +function getRandomPhoto() +{ + $album; + $photo; + + $albums = getAllAlbums(); + + $numalbums = sizeof($albums); + $ralbum = rand(0, sizeof($albums)-1); + foreach($albums as $a) { + $album = $a; + $ralbum--; + if(!$ralbum) break; + } + + $numphotos = sizeof($album->photos); + $rphoto = rand(0, $numphotos-1); + foreach($album->photos as $p) { + $photo = $p; + $rphoto--; + if(!$rphoto) break; + } + + // echo "

".$numalbums . " " .$ralbum . " ".$numphotos . " ".$rphoto . "

"; + + return array($album, $photo); +} + + +?> \ No newline at end of file diff --git a/utils/convert.php b/utils/convert.php new file mode 100644 index 0000000..6ba1964 --- /dev/null +++ b/utils/convert.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/utils/events.php b/utils/events.php new file mode 100644 index 0000000..27ec873 --- /dev/null +++ b/utils/events.php @@ -0,0 +1,130 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + if($this->flyer) { + echo " \"flyer\"flyer . "\"/>\n"; + } + echo "\n"; + } + + public function Event($title, $time, $description, $flyer = "") + { + $this->title = $title; + $this->time = $time; + $this->description = $description; + $this->flyer = $flyer; + } +} + +class Events { + + private $file; + private $events = array(); + + public function showcoming($number) + { + $foundany = false; + + // Key sort + ksort($this->events); + + // If number is -1 show all shows. + if($number == -1) $number = 100000; + + foreach($this->events as $event) { + if($event->time >= time()) { + $foundany = true; + $event->show(); + $number--; + } + if(!$number) return; + } + + if($foundany == false) echo "No shows available at the moment."; + } + + public function showold($number) + { + // Key sort + krsort($this->events); + + // If number is -1 show all shows. + if($number == -1) $number = 100000; + + foreach($this->events as $event) { + if($event->time <= time()) { + $event->show(); + $number--; + } + if(!$number) return; + } + } + + public function add($event) { + $key = $event->time; + // array_push($this->events, $event); + $this->events[$key] = $event; + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->events as $event) { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " time=\"" . $event->time . "\"\n"); + fwrite($fp, " description=\"" . + htmlspecialchars($event->description, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " flyer=\"" . $event->flyer . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('event'); + + foreach ($params as $param) { + $event = new Event($param->getAttribute('title'), + $param->getAttribute('time'), + $param->getAttribute('description'), + $param->getAttribute('flyer')); + $this->add($event); + } + + } + + public function Events($file) + { + $this->file = $file; + $this->read(); + } + +} + +?> \ No newline at end of file diff --git a/utils/guestbook.php b/utils/guestbook.php new file mode 100644 index 0000000..ca9cd81 --- /dev/null +++ b/utils/guestbook.php @@ -0,0 +1,169 @@ +title = $title; + $this->email = $email; + $this->time = $time; + $this->remoteaddr = $remoteaddr; + $this->text = $text; + } + + public function show() + { + echo "
\n"; + echo "
" . $this->title . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . str_replace("@", "(A)", $this->email) . "
\n"; + echo "
" . $this->text . "
\n"; + echo "
\n"; + } +} + +class Guestbook { + private $file; + private $guestbook = array(); + + public function add($entry) { + $key = $entry->time; + $this->guestbook[$key] = $entry; + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->guestbook as $entry) { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " time=\"" . $entry->time . "\"\n"); + fwrite($fp, " email=\"" . + htmlspecialchars($entry->email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " remoteaddr=\"" . + htmlspecialchars($entry->remoteaddr, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " text=\"" . + htmlspecialchars($entry->text, ENT_QUOTES, "UTF-8") . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + public function show($number) + { + // If number is -1 show all shows. + if($number == -1) $number = 100000; + + foreach($this->guestbook as $entry) { + $entry->show(); + $number--; + if(!$number) return; + } + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('entry'); + + foreach ($params as $param) { + $entry = new GuestbookEntry($param->getAttribute('name'), + $param->getAttribute('email'), + $param->getAttribute('time'), + $param->getAttribute('remoteaddr'), + $param->getAttribute('text')); + + $this->add($entry); + } + + // Key sort + krsort($this->guestbook); + } + + public function Guestbook($file) + { + $this->file = $file; + $this->read(); + } +} + +function filtermessage($name, $email, $message, $name_hidden, $email_hidden, $message_hidden) +{ + global $_SERVER; + + // First filter known bad IPs + $spammers = array("85.255.118.10", + "216.32.84.82", + "220.226.63.254"); + $ip = $_SERVER['REMOTE_ADDR']; + foreach($spammers as $spamip) { + if($ip == $spamip) { + // echo "Go away evil spammer!!!!"; + return false;//die(1); + } + } + + // Bot catcher! + if($name || $email || $message) return false;//$spam .= "BOTCatch\n"; + + $name = strip_tags($name_hidden); + $email = strip_tags($email_hidden); + if($name == "" && $email == "") return false;//$spam .= "Empty name and mail\n"; + if($name == "") $name = "Name unknown"; + if($email == "") $email = "Email unknown"; + + $message = strip_tags($message_hidden); + + // Banned words + if(stristr($message, "incest")) return false;//$spam .= "Contained word 'incest'\n"; + if(stristr($message, "estate")) return false;//$spam .= "Contained word 'estate'\n"; + if(stristr($message, "phentermine")) return false;//$spam .= "Contained word 'phentermine'\n"; + if(stristr($message, "viagra")) return false;//$spam .= "Contained word 'viagra'\n"; + if(stristr($message, "ringtones")) return false;//$spam .= "Contained word 'ringtones'\n"; + //if(stristr($message, "vaginal")) return false;//$spam .= "Contained word 'vaginal'\n"; + if(stristr($message, "messed up in the email of mine")) return false;//$spam .= "Contained words 'messed up in the email of mine'\n"; + if(stristr($message, "ambien")) return false;//$spam .= "Contained word 'ambien'\n"; + if(stristr($message, "dating")) return false;//$spam .= "Contained word 'dating'\n"; + if(stristr($message, "levitra")) return false;//$spam .= "Contained word 'levitra'\n"; + //if(stristr($message, "myspace")) return false;//$spam .= "Contained word 'myspace'\n"; + + if($message == "") return false;//$spam .= "Empty message\n"; + $date = date("r"); + //if(strstr($message, "http://")) return false;//$spam .= "Contains URL\n"; + + // Message is not SPAM + return true; +} + +// +// INIT CODE: +// +if($page == "guestbook" && $action == "post" && + !filtermessage($name, $email, $message, $name_hidden, $email_hidden, $message_hidden)) { +//!strstr($_SERVER['HTTP_REFERER'], "guestbook")) { + header("HTTP/1.0 404 Not Found"); +?> + + +404 Not Found + +

Not Found

+

The requested URL /?page=guestbook was not found on this server.

+
+
Apache/2.0.58 (Gentoo) mod_ssl/2.0.58 OpenSSL/0.9.7j PHP/5.1.6-pl6-gentoo Server at www.executionroom.com Port 80
+ + \ No newline at end of file diff --git a/utils/links.php b/utils/links.php new file mode 100644 index 0000000..e093eb2 --- /dev/null +++ b/utils/links.php @@ -0,0 +1,128 @@ +title = $title; + $this->href = $href; + $this->icon = $icon; + } + + public function show() + { + echo "
\n"; + if($this->icon != "") { + echo " href . "\">\n"; + echo " \""title . "\" src=\"" . $this->icon . "\"/>\n"; + echo " \n"; + } + echo " href . "\">\n"; + echo " " . htmlspecialchars_decode($this->title, ENT_QUOTES) . "\n"; + echo " \n"; + echo "
\n"; + } +} + +class LinkGroup { + public $title; + public $id; + private $links = array(); + + public function LinkGroup($title, $id) { + $this->title = $title; + $this->id = $id; + } + + public function add($link) { + $key = $link->title; + $this->links[$key] = $link; + } + + public function show() + { + echo "
\n"; + echo "
". htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + foreach($this->links as $link) { + $link->show(); + } + echo "
\n"; + } +} + +class Links { + private $file; + private $groups = array(); + + public function add($group) { + $key = $group->title; + $this->groups[$key] = $group; + } + /* + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->links as $link) { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " href=\"" . + htmlspecialchars($link->href, ENT_QUOTES, "UTF-8") . "\">\n"); + fwrite($fp, " icon=\"" . + htmlspecialchars($link->icon, ENT_QUOTES, "UTF-8") . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + */ + public function show($groupid) + { + foreach($this->groups as $group) { + if($groupid == $group->id || $groupid == "all") $group->show(); + } + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + + $xmlgroups = $dom->getElementsByTagName('group'); + + foreach ($xmlgroups as $xmlgroup) { + + $group = new LinkGroup($xmlgroup->getAttribute('name'), + $xmlgroup->getAttribute('id')); + $xmllinks = $xmlgroup->getElementsByTagName('link'); + + foreach ($xmllinks as $xmllink) { + $link = new Link($xmllink->getAttribute('title'), + $xmllink->getAttribute('href'), + $xmllink->getAttribute('icon')); + + $group->add($link); + } + + $this->add($group); + } + + // Key sort + // ksort($this->events); + } + + public function Links($file) + { + $this->file = $file; + $this->read(); + } +} + +?> \ No newline at end of file diff --git a/utils/log.php b/utils/log.php new file mode 100644 index 0000000..e6f2789 --- /dev/null +++ b/utils/log.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/utils/login.php b/utils/login.php new file mode 100644 index 0000000..950476e --- /dev/null +++ b/utils/login.php @@ -0,0 +1,67 @@ +findUser($userid); + if($user) { + if($user->checkPassword($password)) { + $loggedin = true; + _log("Logged in", $userid); + } else { + _log("Wrong password", $userid); + } + setcookie("UserID", $userid, time()+600); // expire in 10 minutes + setcookie("Password", $password, time()+600); // expire in 10 minutes + return; + } else { + _log("Failed", $userid); + return; + } + } + + if($action == "logout") { + _log("Logged out", $HTTP_COOKIE_VARS["UserID"]); + setcookie("UserID", "", time()-1); // remove cookie + setcookie("Password", "", time()-1); // remove cookie + $userid = ""; + $password = ""; + $loggedin = false; + return; + } + + if($HTTP_COOKIE_VARS["UserID"] == "") { + _log("Failed", $UserID); + return; + } + + $user = $users->findUser($HTTP_COOKIE_VARS["UserID"]); + if($user) { + if($user->checkPassword($HTTP_COOKIE_VARS["Password"])) { + setcookie("UserID", $HTTP_COOKIE_VARS["UserID"], time()+600); // expire in 10 minutes + setcookie("Password", $HTTP_COOKIE_VARS["Password"], time()+600); // expire in 10 minutes + $loggedin = true; + return; + } else { + _log("Wrong password", $HTTP_COOKIE_VARS["UserID"]); + } + } else { + _log("Failed", $UserID); + } +} + +?> \ No newline at end of file diff --git a/utils/news.php b/utils/news.php new file mode 100644 index 0000000..809e8dc --- /dev/null +++ b/utils/news.php @@ -0,0 +1,103 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + echo "\n"; + } + + public function NewsEntry($title, $time, $category, $description) + { + $this->title = $title; + $this->time = $time; + $this->category = $category; + $this->description = $description; + } +} + +class News { + + private $file; + private $news = array(); + + public function show($number, $category) + { + // If number is -1 show all shows. + if($number == -1) $number = 100000; + + foreach($this->news as $newsentry) { + if($newsentry->category == $category || $category == "all") { + $newsentry->show(); + $number--; + } + if(!$number) return; + } + } + + public function add($newsentry) { + $key = $newsentry->time; + $this->news[$key] = $newsentry; + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->news as $newsentry) { + fwrite($fp, " title, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " time=\"" . $newsentry->time . "\"\n"); + fwrite($fp, " category=\"" . $newsentry->category . "\"\n"); + fwrite($fp, " description=\"" . + htmlspecialchars($newsentry->description, ENT_QUOTES, "UTF-8") . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('newsentry'); + + foreach ($params as $param) { + $newsentry = new NewsEntry($param->getAttribute('title'), + $param->getAttribute('time'), + $param->getAttribute('category'), + $param->getAttribute('description')); + $this->add($newsentry); + } + + // Key sort + krsort($this->news); + } + + public function News($file) + { + $this->file = $file; + $this->read(); + } + +} + +?> diff --git a/utils/newsletter.php b/utils/newsletter.php new file mode 100644 index 0000000..049e3f5 --- /dev/null +++ b/utils/newsletter.php @@ -0,0 +1,146 @@ +"; +$replyto = $sender; +$footer = " + +Stay Brutal! +// DIE +http://www.executionroom.com +info@executionroom.com +"; + +class Email { + public $timestamp; + public $email; + + public function Email($email, $timestamp) + { + $this->email = $email; + $this->timestamp = $timestamp; + } + + function send($subject, $message) { + global $subject_prefix; + global $sender; + global $replyto; + global $footer; + + $message .= $footer; + $message .= "\nTo stop receiving this newsletter, click the following link: http://www.executionroom.com/?page=news&action=unsubscribe&email=". $this->email . "\n"; + $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(); + $subject = "[".$subject_prefix."] " . $subject; + + $ret = mail($this->email, $subject, $message, $headers); + if(!$ret) echo "Fail(".$this->email.")"; + + //usleep(100000); + } +} + +class Mailinglist { + private $file; + private $mailinglist = array(); + + public function add($email) { + $key = $email->email; + $this->mailinglist[$key] = $email; + } + + public function remove($email) { + if(array_key_exists($email, $this->mailinglist)) { + unset($this->mailinglist[$email]); + } + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('email'); + + foreach ($params as $param) { + $email = new Email($param->getAttribute('email'), + $param->getAttribute('timestamp')); + $this->add($email); + } + } + + public function subscribe($email) + { + $email = new EMail($email, time()); + $this->add($email); + $this->write(); + } + + public function unsubscribe($email) + { + $this->remove($email); + $this->write(); + } + + public function post($subject, $message) + { + $sz = sizeof($this->mailinglist); + + echo "
Sending ". $sz ." mails
\n<"; + ob_flush(); + flush(); + + $num = 0; + $lvl = 0; + $steps = floor($sz / 10) + 1; + + foreach($this->mailinglist as $email) { + $email->send($subject, $message); + $pct = $num / $sz * 100; + if($pct >= $lvl) { + printf("%.0f%%", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "[100%]>\n
done
\n"; + echo "[CLOSE]"; + echo "
\n"; + ob_flush(); + flush(); + } + + public function Mailinglist($file) + { + $this->file = $file; + $this->read(); + } +} + +?> \ No newline at end of file diff --git a/utils/pressrelease.php b/utils/pressrelease.php new file mode 100644 index 0000000..3ae25b4 --- /dev/null +++ b/utils/pressrelease.php @@ -0,0 +1,165 @@ + + + + + + + + + + + + + **/ + + +/** + * CONFIG + */ +$subject_prefix = "DIE Pressrelease"; +$sender = "DIE "; +$replyto = $sender; +$footer = " + +Stay Brutal! +// DIE +http://www.executionroom.com +info@executionroom.com +"; + +class Email { + public $name; + public $url; + public $email; + + public function Email($name, $url, $email) + { + $this->name = $name; + $this->url = $url; + $this->email = $email; + } + + function send($subject, $message) { + global $subject_prefix; + global $sender; + global $replyto; + global $footer; + + $message .= $footer; + $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(); + $subject = "[".$subject_prefix."] " . $subject; + + $ret = mail($this->email, $subject, $message, $headers); + if(!$ret) echo "Fail(".$this->email.")"; + + //usleep(100000); + } +} + +class PressRelease { + private $file; + private $mailinglist = array(); + + public function add($email) { + $key = $email->email; + $this->mailinglist[$key] = $email; + } + + public function remove($email) { + if(array_key_exists($email, $this->mailinglist)) { + unset($this->mailinglist[$email]); + } + } + + public function write() + { + /* + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + */ + } + + private function read() + { + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('email'); + + foreach ($params as $param) { + $email = new Email($param->getAttribute('name'), + $param->getAttribute('url'), + $param->getAttribute('email')); + $this->add($email); + } + } + /* + public function subscribe($email) + { + $email = new EMail($email, time()); + $this->add($email); + $this->write(); + } + + public function unsubscribe($email) + { + $this->remove($email); + $this->write(); + } + */ + public function post($subject, $message) + { + $sz = sizeof($this->mailinglist); + + echo "
Sending ". $sz ." mails
\n<"; + ob_flush(); + flush(); + + $num = 0; + $lvl = 0; + $steps = floor($sz / 10) + 1; + + foreach($this->mailinglist as $email) { + $email->send($subject, $message); + $pct = $num / $sz * 100; + if($pct >= $lvl) { + printf("%.0f%%", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "[100%]>\n
done
\n"; + echo "[CLOSE]"; + echo "
\n"; + ob_flush(); + flush(); + } + + public function PressRelease($file) + { + $this->file = $file; + $this->read(); + } +} + +?> \ No newline at end of file diff --git a/utils/rss.php b/utils/rss.php new file mode 100644 index 0000000..e6aa83f --- /dev/null +++ b/utils/rss.php @@ -0,0 +1,112 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + echo "\n"; + } + */ + public function RSSEntry($title, $time, $category, $description) + { + $this->title = $title; + $this->time = $time; + $this->category = $category; + $this->description = $description; + } +} + +class RSS { + + private $newsfile; + private $rssfile; + private $news = array(); + + public function add($newsentry) { + $key = $newsentry->time; + $this->news[$key] = $newsentry; + } + + private function date($time) { + return date("r", $time); + } + + public function write() + { + $fp = fopen($this->rssfile, "w"); + fwrite($fp, "\n"); + fwrite($fp, "\n"); + fwrite($fp, " \n"); + fwrite($fp, " DIE News\n"); + fwrite($fp, " http://www.executionroom.com\n"); + fwrite($fp, " DIE - News from ExecutionRoom.com\n"); + fwrite($fp, " en-us\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " http://blogs.law.harvard.edu/tech/rss\n"); + fwrite($fp, " ExecutionRoom CMS\n"); + fwrite($fp, " info@executionroom.com\n"); + fwrite($fp, " info@executionroom.com\n"); + + $i = 0; + foreach($this->news as $newsentry) { + fwrite($fp, " \n"); + fwrite($fp, " ".$newsentry->title."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " ".$newsentry->description."\n"); + fwrite($fp, " ".$this->date($newsentry->time)."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " \n"); + $i++; + if($i > 6) break; + } + + fwrite($fp, " \n"); + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->newsfile); + $params = $dom->getElementsByTagName('newsentry'); + + foreach ($params as $param) { + $rssentry = new RSSEntry($param->getAttribute('title'), + $param->getAttribute('time'), + $param->getAttribute('category'), + $param->getAttribute('description')); + $this->add($rssentry); + } + + // Key sort + krsort($this->news); + } + + public function RSS($newsfile, $rssfile) + { + $this->newsfile = $newsfile; + $this->rssfile = $rssfile; + $this->read(); + } + +} + +?> diff --git a/utils/thumbnail.php b/utils/thumbnail.php new file mode 100644 index 0000000..f1f4b38 --- /dev/null +++ b/utils/thumbnail.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/utils/user.php b/utils/user.php new file mode 100644 index 0000000..508f83d --- /dev/null +++ b/utils/user.php @@ -0,0 +1,151 @@ +password == sha1(md5($password)); + } + + public function setPassword($oldpassword, $password1, $password2) { + if($this->checkPassword($oldpassword) == false) { // Doublecheck the validity of the user. + echo "

Current password is incorrect!

\n"; + return 1; + } + + if($password1 != $password2) { // Check if passowrds match. + echo "

Passwords do not match!

\n"; + return 1; + } + + echo "

Password updated successfully!

\n"; + + $this->password = sha1(md5($password1)); + return 0; + } + + public function User($userid, $password, $users, $news, $events, $guestbook, $gallery, $user, $newsletter, $pressrelease) + { + $this->userid = $userid; + $this->password = $password; + $this->users = $users; + $this->news = $news; + $this->events = $events; + $this->guestbook = $guestbook; + $this->gallery = $gallery; + $this->user = $user; + $this->newsletter = $newsletter; + $this->pressrelease = $pressrelease; + } +} + +class Users { + + private $file; + private $users = array(); + + public function add($user) { + $key = $user->userid; + $this->users[$key] = $user; + } + + public function write() + { + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->users as $user) { + fwrite($fp, " userid, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " password=\"" . $user->password . "\"\n"); + fwrite($fp, " users=\"" . $user->users . "\"\n"); + fwrite($fp, " news=\"" . $user->news . "\"\n"); + fwrite($fp, " events=\"" . $user->events . "\"\n"); + fwrite($fp, " guestbook=\"" . $user->guestbook . "\"\n"); + fwrite($fp, " gallery=\"" . $user->gallery . "\"\n"); + fwrite($fp, " user=\"" . $user->user . "\"\n"); + fwrite($fp, " newsletter=\"" . $user->newsletter . "\"\n"); + fwrite($fp, " pressrelease=\"" . $user->pressrelease . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + } + + public function deleteUser($userid) + { + if($userid != "admin") { + if($this->users[$userid]) { + unset($this->users[$userid]); + $this->write(); + } else { + echo "

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

\n"; + return false; + } + } else { + echo "

ERROR: You cannot delete the admin user!

\n"; + return false; + } + return true; + } + + public function findUser($userid) + { + $user = $this->users[$userid]; + return $user; + } + + public function useridList() + { + $useridlist = array(); + foreach($this->users as $user) { + array_push($useridlist, $user->userid); + } + return $useridlist; + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('user'); + + foreach ($params as $param) { + $user = new User($param->getAttribute('userid'), + $param->getAttribute('password'), + $param->getAttribute('users'), + $param->getAttribute('news'), + $param->getAttribute('events'), + $param->getAttribute('guestbook'), + $param->getAttribute('gallery'), + $param->getAttribute('user'), + $param->getAttribute('newsletter'), + $param->getAttribute('pressrelease')); + $this->add($user); + } + + } + + public function Users($file) + { + $this->file = $file; + $this->read(); + } + +} +?> \ No newline at end of file diff --git a/utils/xml.php b/utils/xml.php new file mode 100644 index 0000000..69059b0 --- /dev/null +++ b/utils/xml.php @@ -0,0 +1,126 @@ +parentnode = &$parentnode; + } + + public function addNode(&$node) + { + echo "

" . $this->name . "::addNode(" . $node->name . ")

"; + // $node->parent = &$this; + array_push($this->children, &$node); + } + + public function addAttribute($name, $value) + { + // echo "

" . $this->name . "::addAttribute(" . $name . ", ". $value . ")

"; + $attribute = new XMLDOMAttribute(); + $attribute->name = strtolower($name); + $attribute->value = $value; + array_push($this->attributes, &$attribute); + } + +} + +class XMLDOMReader +{ + private $parent; + private $curnode; + public $root; + + private function startThreadElement($parser, $name, $attribs) + { + $this->parent = &$this->curnode; + + $this->curnode = new XMLDOMNode(&$this->parent); + $this->curnode->name = $name; + + while (list($name, $value) = each($attribs)) { + $this->curnode->addAttribute($name, $value); + } + + $this->parent->addNode(&$this->curnode); + } + + private function dataThreadElement($parser, $data) + { + $this->curnode->contents = $data; + } + + private function endThreadElement($parser, $name) + { + $this->curnode = &$this->parent; + } + + public function XMLDOMReader($file) + { + $doc = new DOMDocument(); + $doc->load('book.xml'); + echo $doc->saveXML(); + + /* + $this->root = new XMLDOMNode(&$this->root); + $this->root->name = "root"; + $this->parent = &$this->root; + + // parse the xml file + $xml_parser = xml_parser_create("ISO-8859-1"); + xml_set_element_handler($xml_parser, "startThreadElement", "endThreadElement"); + xml_set_character_data_handler($xml_parser, "dataThreadElement"); + xml_set_object ( $xml_parser, $this ); + + $data = file_get_contents($file); + + if (!xml_parse($xml_parser, $data, true)) { + die(sprintf("XML error: %s at line %d", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } + xml_parser_free($xml_parser); + */ + + // $parent; + /* + $this->root = new XMLDOMNode(&$this->root); + $this->root->name = "Root"; + + $node0 = new XMLDOMNode(&$this->root); + $node0->name = "Node1"; + array_push($this->root->children, &$node0); + // $this->root->addNode(&$node0); + + $node1 = new XMLDOMNode(&$node0); + $node1->name = "Node1.1"; + array_push($node0->children, &$node1); + // $node0->addNode(&$node1); + + $node2 = new XMLDOMNode(&$node0); + $node2->name = "Node1.2"; + array_push($node0->children, &$node2); + // $node0->addNode(&$node2); + + echo "\n
";
+		echo $this->root . " - " . $node0 . " - " . $node1 . " - " . $node2 . "\n";
+		print_r($this->root);
+		echo "
\n"; + */ + } +} + + +?> \ No newline at end of file -- cgit v1.2.3