diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/admin_events.php | 85 | ||||
-rw-r--r-- | utils/admin_gallery.php | 108 | ||||
-rw-r--r-- | utils/admin_guestbook.php | 2 | ||||
-rw-r--r-- | utils/admin_news.php | 121 | ||||
-rw-r--r-- | utils/admin_newsletter.php | 55 | ||||
-rw-r--r-- | utils/admin_pressrelease.php | 55 | ||||
-rw-r--r-- | utils/admin_user.php | 32 | ||||
-rw-r--r-- | utils/admin_users.php | 203 | ||||
-rw-r--r-- | utils/album.php | 137 | ||||
-rw-r--r-- | utils/convert.php | 11 | ||||
-rw-r--r-- | utils/events.php | 130 | ||||
-rw-r--r-- | utils/guestbook.php | 169 | ||||
-rw-r--r-- | utils/links.php | 128 | ||||
-rw-r--r-- | utils/log.php | 15 | ||||
-rw-r--r-- | utils/login.php | 67 | ||||
-rw-r--r-- | utils/news.php | 103 | ||||
-rw-r--r-- | utils/newsletter.php | 146 | ||||
-rw-r--r-- | utils/pressrelease.php | 165 | ||||
-rw-r--r-- | utils/rss.php | 112 | ||||
-rw-r--r-- | utils/thumbnail.php | 39 | ||||
-rw-r--r-- | utils/user.php | 151 | ||||
-rw-r--r-- | utils/xml.php | 126 |
22 files changed, 2160 insertions, 0 deletions
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 @@ +<h2>Events</h2> +<?php +include_once($UTIL_DIR."/events.php"); +include_once($UTIL_DIR."/convert.php"); + +if($task == "confirmevent") { + $time = strtotime($month."/" .$day . "/" . $year);// . " " . $hour . ":" . $minute); + + $title = convert($title); + $description = convert($description); + + $event = new Event($title, $time, $description); + $event->show(); +?> +Is this correct?<br/> +<form method="post" action="?page=admin&module=events&task=postevent"> + <input name="title" type="hidden" value="<?php echo $title ?>"/> + <input name="day" type="hidden" value="<?php echo $day ?>"/> + <input name="month" type="hidden" value="<?php echo $month ?>"/> + <input name="year" type="hidden" value="<?php echo $year ?>"/> + <input name="description" type="hidden" value="<?php echo $description ?>"/> + <button type="submit">Yes</button> +</form> +<form method="post" action="?page=admin&module=events"> + <input name="title" type="hidden" value="<?php echo $title ?>"/> + <input name="day" type="hidden" value="<?php echo $day ?>"/> + <input name="month" type="hidden" value="<?php echo $month ?>"/> + <input name="year" type="hidden" value="<?php echo $year ?>"/> + <input name="description" type="hidden" value="<?php echo $description ?>"/> + <button type="submit">No</button> +</form> +<?php + $title = ""; + $day = ""; + $month = ""; + $year = ""; + $hour = ""; + $minute = ""; + $description = ""; +} +?> + +<?php +if($task == "postevent") { + $time = strtotime($month."/" .$day . "/" . $year . " 23:59:00");// . " " . $hour . ":" . $minute); + + $title = convert($title); + $description = convert($description); + + $events = new Events($DATA_DIR."/events.xml"); + $event = new Event($title, $time, $description); + $events->add($event); + $events->write(); + + echo "<p>Event posted successfully.</p>"; + $title = ""; + $day = ""; + $month = ""; + $year = ""; + $description = ""; +} +?> + +<?php +$now = time(); +if($day == "") $day = date("j", $now); +if($month =="") $month = date("n", $now); +if($year == "") $year = date("Y", $now); +?> +<div class="small_header">Post event</div> +<form method="post" action="?page=admin&module=events&task=confirmevent"> + <p> + Title: <input name="title" value="<?php echo convert($title) ?>"/> + </p> + <p> + Date: <input name="day" style="width: 20px;" value="<?php echo $day ?>"/>/ + <input name="month" style="width: 20px;" value="<?php echo $month ?>"/>- + <input name="year" style="width: 40px;" value="<?php echo $year ?>"/> + </p> + <p> + Description:<br/> + <textarea name="description"><?php echo convert($description) ?></textarea> + </p> + <button type="submit">Post event</button> +</form> 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 @@ +<h2>Gallery</h2> + +<?php include_once($UTIL_DIR."/album.php"); ?> + +<?php +if($task == "newalbum") { + $albumdir = $ALBUMS_DIR . "/" . time(); + echo "New album " . $albumname . "<br/>"; + echo $albumcopyright . "<br/>"; + echo $albumdir . "<br/>"; + mkdir($albumdir); + $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + $xml .= "<album title=\"". $albumname . "\" icon=\"\" copyright=\"" . $albumcopyright . "\">\n"; + $xml .= "</album>\n"; + $fp = fopen($albumdir . "/album.xml", "w"); + fprintf($fp, $xml); + fclose($fp); +} +?> + +<?php +if($task == "uploadimage") { + + echo $album . "<br/>"; + echo $description . "<br/>"; + echo $_FILES['userfile']['tmp_name'] . "<br/>"; + + 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'] . "'."; + } + } +} +?> + +<div class="small_header">New album</div> +<form method="post" action="?page=admin&module=gallery&task=newalbum"> + <p> + Title: <input name="albumname" value="<?php echo $albumname ?>"/> + </p> + <p> + Copyright: <input name="albumcopyright" value="<?php echo $albumcopyright ?>"/> + </p> + <p> + <button type="submit">Create album</button> + </p> +</form> + +<div class="small_header">Upload image</div> +<form enctype="multipart/form-data" action="?page=admin&module=gallery&task=uploadimage" method="post"> + <p> + Album: + <select name="album"> +<?php +$albums = getAllAlbums(); +foreach($albums as $album) +{ + echo " <option value=\"" . $album->album . "\">" . $album->title . "</option>\n"; +} +?> + </select> + </p> + <p> + Description: + <input name="description" value="<?php echo $description ?>"/> + </p> + <p> + Upload this image: + <input name="userfile" type="file"> + </p> + <p> + <button type="submit">Add Image</button> + </p> +</form> 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 @@ +<h2>Guestbook</h2> +... 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 @@ +<h2>News</h2> +<?php +include_once($UTIL_DIR."/news.php"); +include_once($UTIL_DIR."/convert.php"); +include_once($UTIL_DIR."/newsletter.php"); +include_once($UTIL_DIR."/rss.php"); + +if($task == "confirmnews") { + $time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second); + + $title = convert($title); + $description = convert($description); + + $newsentry = new NewsEntry($title, $time, $category, $description); + $newsentry->show(); + + echo "<p>Category: " . $category . "</p>\n"; + if($newsletter) echo "<p><strong>WARNING:</strong> This news will be sent out a newsletter if <em>yes</em> is pressed.</p>\n"; +?> +Is this news correct?<br/> +<form method="post" action="?page=admin&module=news&task=postnews"> + <input name="title" type="hidden" value="<?php echo $title ?>"/> + <input name="category" type="hidden" value="<?php echo $category ?>"/> + <input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/> + <input name="day" type="hidden" value="<?php echo $day ?>"/> + <input name="month" type="hidden" value="<?php echo $month ?>"/> + <input name="year" type="hidden" value="<?php echo $year ?>"/> + <input name="hour" type="hidden" value="<?php echo $hour ?>"/> + <input name="minute" type="hidden" value="<?php echo $minute ?>"/> + <input name="second" type="hidden" value="<?php echo $second ?>"/> + <input name="description" type="hidden" value="<?php echo $description ?>"/> + <button type="submit">Yes</button> +</form> +<form method="post" action="?page=admin&module=news"> + <input name="title" type="hidden" value="<?php echo $title ?>"/> + <input name="category" type="hidden" value="<?php echo $category ?>"/> + <input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/> + <input name="day" type="hidden" value="<?php echo $day ?>"/> + <input name="month" type="hidden" value="<?php echo $month ?>"/> + <input name="year" type="hidden" value="<?php echo $year ?>"/> + <input name="hour" type="hidden" value="<?php echo $hour ?>"/> + <input name="minute" type="hidden" value="<?php echo $minute ?>"/> + <input name="second" type="hidden" value="<?php echo $second ?>"/> + <input name="description" type="hidden" value="<?php echo $description ?>"/> + <button type="submit">No</button> +</form> +<?php + + $title = ""; + $category = ""; + $newsletter = ""; + $day = ""; + $month = ""; + $year = ""; + $hour = ""; + $minute = ""; + $second = ""; + $description = ""; +} +?> + +<?php +if($task == "postnews") { + $time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second); + + $title = convert($title); + $description = convert($description); + + $news = new News($DATA_DIR."/news.xml"); + $newsentry = new NewsEntry($title, $time, $category, $description); + $news->add($newsentry); + $news->write(); + + // Now update the RSS feed. + $rss = new RSS($DATA_DIR."/news.xml", "rss.xml"); + $rss->write(); + + echo "<p>News posted successfully.</p>"; + + // if($newsletter == "on") sendNewsLetter($title, $description); + + $title = ""; + $category = ""; + $newsletter = ""; + $day = ""; + $month = ""; + $year = ""; + $hour = ""; + $minute = ""; + $second = ""; + $description = ""; +} +?> + +<?php +$now = time(); +if($day == "") $day = date("j", $now); +if($month =="") $month = date("n", $now); +if($year == "") $year = date("Y", $now); +if($hour == "") $hour = date("G", $now); +if($minute == "") $minute = date("i", $now); +if($second == "") $second = date("s", $now); +?> + +<div class="small_header">Post news</div> +<form method="post" action="?page=admin&module=news&task=confirmnews"> + Title: <input name="title" width="40" value="<?php echo convert($title) ?>"/><br/> + Category: + <select name="category"> + <option value="main" <?php if($category == "main") echo "selected"; ?>>main</option> + <option value="site" <?php if($category == "site") echo "selected"; ?>>site</option> + </select><br/> + Date: <input name="day" maxlength="2" style="width: 20px;" value="<?php echo $day ?>"/>/ + <input name="month" maxlength="2" style="width: 20px;" value="<?php echo $month ?>"/>- + <input name="year" maxlength="4" style="width: 40px;" value="<?php echo $year ?>"/><br/> + Time: <input name="hour" maxlength="2" style="width: 20px;" value="<?php echo $hour ?>"/>: + <input name="minute" maxlength="2" style="width: 20px;" value="<?php echo $minute ?>"/>: + <input name="second" maxlength="2" style="width: 20px;" value="<?php echo $second ?>"/><br/> + Description: <textarea name="description"><?php echo convert($description) ?></textarea><br/> + <button type="submit">Post news</button> +</form> 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 @@ +<h2>Newsletter</h2> +<?php +include_once($UTIL_DIR . "/newsletter.php"); +include_once($UTIL_DIR . "/convert.php"); + +if($task == "confirm") { + $testmail = new Email($testaddr, time()); + $testmail->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?<br/> +<form method="post" action="?page=admin&module=newsletter&task=send"> + <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/> + <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/> + <input name="message" type="hidden" value="<?php echo convert($message) ?>"/> + <button type="submit">Yes</button> +</form> +<form method="post" action="?page=admin&module=newsletter"> + <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/> + <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/> + <input name="message" type="hidden" value="<?php echo convert($message) ?>"/> + <button type="submit">No</button> +</form> +<?php + $subject = ""; + $message = ""; +} +?> + +<?php +if($task == "send") { + $list = new Mailinglist($DATA_DIR . "/mailinglist.xml"); + $list->post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +<div class="small_header">Post newsletter</div> +<form method="post" action="?page=admin&module=newsletter&task=confirm"> + <p> + Test address: + <input name="testaddr" value="<?php echo convert($testaddr) ?>"/> + </p> + <p> + Subject: + <input name="subject" value="<?php echo convert($subject) ?>"/> + </p> + <p> + Message:<br/> + <textarea name="message"><?php echo convert($message) ?></textarea> + </p> + <p> + <button type="submit">Post news</button> + </p> +</form> 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 @@ +<h2>Pressrelease</h2> +<?php +include_once($UTIL_DIR . "/pressrelease.php"); +include_once($UTIL_DIR . "/convert.php"); + +if($task == "confirm") { + $testmail = new Email("Testname", "http://www.example.com", $testaddr); + $testmail->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?<br/> +<form method="post" action="?page=admin&module=pressrelease&task=send"> + <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/> + <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/> + <input name="message" type="hidden" value="<?php echo convert($message) ?>"/> + <button type="submit">Yes</button> +</form> +<form method="post" action="?page=admin&module=pressrelease"> + <input name="testaddr" type="hidden" value="<?php echo convert($testaddr) ?>"/> + <input name="subject" type="hidden" value="<?php echo convert($subject) ?>"/> + <input name="message" type="hidden" value="<?php echo convert($message) ?>"/> + <button type="submit">No</button> +</form> +<?php + $subject = ""; + $message = ""; +} +?> + +<?php +if($task == "send") { + $list = new PressRelease($DATA_DIR . "/pressrelease.xml"); + $list->post(utf8_decode(stripslashes($subject)), utf8_decode(stripslashes($message))); +} +?> + +<div class="small_header">Post pressrelease</div> +<form method="post" action="?page=admin&module=pressrelease&task=confirm"> + <p> + Test address: + <input name="testaddr" value="<?php echo convert($testaddr) ?>"/> + </p> + <p> + Subject: + <input name="subject" value="<?php echo convert($subject) ?>"/> + </p> + <p> + Message:<br/> + <textarea name="message"><?php echo convert($message) ?></textarea> + </p> + <p> + <button type="submit">Post news</button> + </p> +</form> 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 @@ +<h2>Password</h2> +<?php +include_once($UTIL_DIR."/user.php"); +include_once($UTIL_DIR."/convert.php"); + +if($task == "setpassword") { + $users = new Users($DATA_DIR . "/users.xml"); + $user = $users->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(); +} +?> + +<div class="small_header">Change password</div> +<form method="post" action="?page=admin&module=user&task=setpassword"> + <p> + Old password: + <input type="password" name="oldpassword" style="width: 100px;" value=""/ + </p> + <p> + New password: + <input type="password" name="password1" style="width: 100px;" value=""/> + </p> + <p> + Confirm password: + <input type="password" name="password2" style="width: 100px;" value=""/> + </p> + <p> + <button type="submit">Change password</button> + </p> +</form> 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 @@ +<h2>Users</h2> +<?php +include_once($UTIL_DIR . "/user.php"); +$users = new Users($DATA_DIR. "/users.xml"); +?> + + +<div class="small_header">Add user</div> +<?php +if($task == "adduser") { + if($password1 == $password2) { + if(!$users->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 "<p>User <em>" . $newuserid . "</em> added successfully.</p>\n"; + } else { + echo "<p>ERROR: User <em>" . $newuserid . "</em> already exists.</p>\n"; + } + } else { + echo "<p>ERROR: Passwords do not match.</p>\n"; + } +} +?> +<form method="post" action="?page=admin&module=users&task=adduser"> + <p> + UserID: <input name="newuserid" value="<?php echo $newuserid; ?>"/> + </p> + <p> + <input name="newmodule_users" + type="checkbox" <?php if($newmodule_users == "on") echo "checked"; ?>/> + Add/edit.delete users:<br/> + <input name="newmodule_user" + type="checkbox" <?php if($newmodule_user == "on") echo "checked"; ?>/> + Change password:<br/> + <input name="newmodule_news" + type="checkbox" <?php if($newmodule_news == "on") echo "checked"; ?>/> + Add news:<br/> + <input name="newmodule_events" + type="checkbox" <?php if($newmodule_events == "on") echo "checked"; ?>/> + Add events:<br/> + <input name="newmodule_gallery" + type="checkbox" <?php if($newmodule_gallery == "on") echo "checked"; ?>/> + Add images in gallery:<br/> + <input name="newmodule_newsletter" + type="checkbox" <?php if($newmodule_newsletter == "on") echo "checked"; ?>/> + Send newsletter:<br/> + <input name="newmodule_guestbook" + type="checkbox" <?php if($newmodule_guestbook == "on") echo "checked"; ?>/> + Modify guestbook + </p> + <p> + New password: + <input type="password" name="newpassword1" style="width: 100px;" value="<?php echo $newpassword1; ?>"/> + </p> + <p> + Confirm password: + <input type="password" name="newpassword2" style="width: 100px;" value="<?php echo $newpassword2; ?>"/> + </p> + <p> + <button type="submit">Add user</button> + </p> +</form> + +<div class="small_header">Edit user</div> +<?php +if($task == "updateuser") { + $user = $users->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 "<p>User <em>" . $edituserid . "</em> successfully updated.</p>\n"; + } else { + echo "<p>ERROR: Passwords do not match</p>\n"; + $task = "edituser"; + } + } else { + $users->add($user); + $users->write(); + echo "<p>User <em>" . $edituserid . "</em> successfully updated. Password left untouched.</p>\n"; + } +} +?> +<?php +if($task == "edituser") { + $user = $users->findUser($edituserid); +?> +<form method="post" action="?page=admin&module=users&task=updateuser"> + <p> + UserID: <input name="edituserid" readonly value="<?php echo $user->userid; ?>"/> + </p> + <p> + <input name="module_users" + type="checkbox" <?php if($user->users == "on") echo "checked"; ?>/> + Add/edit.delete users:<br/> + <input name="module_user" + type="checkbox" <?php if($user->user == "on") echo "checked"; ?>/> + Change password:<br/> + <input name="module_news" + type="checkbox" <?php if($user->news == "on") echo "checked"; ?>/> + Add news:<br/> + <input name="module_events" + type="checkbox" <?php if($user->events == "on") echo "checked"; ?>/> + Add events:<br/> + <input name="module_gallery" + type="checkbox" <?php if($user->gallery == "on") echo "checked"; ?>/> + Add images in gallery:<br/> + <input name="module_newsletter" + type="checkbox" <?php if($user->newsletter == "on") echo "checked"; ?>/> + Send newsletter:<br/> + <input name="module_guestbook" + type="checkbox" <?php if($user->guestbook == "on") echo "checked"; ?>/> + Modify guestbook + </p> + <p> + New password: + <input type="password" name="password1" style="width: 100px;" value=""/> + </p> + <p> + Confirm password: + <input type="password" name="password2" style="width: 100px;" value=""/> + </p> + <p> + <button type="submit">Submit changes</button> + </p> +</form> +<?php +} +?> +<form method="post" action="?page=admin&module=users&task=edituser"> + <p> + Select the user you want to edit:<br/> + <select name="edituserid"> +<?php +$uids = $users->useridList(); +foreach($uids as $uid) { +?> + <option value="<?php echo $uid;?>"><?php echo $uid;?></option> +<?php +} +?> + </select> + <button type="submit">Edit</button> + </p> +</form> + +<div class="small_header">Delete user</div> +<?php +if($task == "deleteconfirm") { +?> +Are you sure you want to delete the <em><?php echo $deleteuserid; ?></em> user?<br/> +<form method="post" action="?page=admin&module=users&task=delete"> + <input name="deleteuserid" type="hidden" value="<?php echo $deleteuserid ?>"/> + <button type="submit">Yes</button> +</form> +<form method="post" action="?page=admin&module=users"> + <input name="deleteuserid" type="hidden" value="<?php echo $deleteuderid; ?>"/> + <button type="submit">No</button> +</form> +<?php +} +?> + +<?php +if($task == "delete") { + if($users->deleteUser($deleteuserid)) { + echo "<p>User <em>".$deleteuserid."</em> deleted successfully.</p>\n"; + } +} +?> +<form method="post" action="?page=admin&module=users&task=deleteconfirm"> + <p> + Select the user you want to delete:<br/> + <select name="deleteuserid"> +<?php +$uids = $users->useridList(); +foreach($uids as $uid) { +?> + <option value="<?php echo $uid;?>"><?php echo $uid;?></option> +<?php +} +?> + </select> + <button type="submit">Delete</button> + </p> +</form> 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 @@ +<?php +include_once("thumbnail.php"); + +class Photo { + public $file; + public $text; + + function Photo($file, $text) { + $this->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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<album title=\"". $this->title . "\" icon=\"".$this->icon."\" copyright=\"" . $this->copyright . "\">\n"); + foreach($this->photos as $photo) { + fwrite($fp, " <photo file=\"" . $photo->file . "\"\n"); + fwrite($fp, " text=\"" . $photo->text . "\">\n"); + fwrite($fp, " </photo>\n"); + } + fwrite($fp, "</album>\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 "<p>".$numalbums . " " .$ralbum . " ".$numphotos . " ".$rphoto . "</p>"; + + 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 @@ +<?php + +function convert($message) +{ + $message = stripslashes($message); + $message = htmlspecialchars($message, ENT_QUOTES, "UTF-8"); + // $message = utf8_encode($message); + return $message; +} + +?>
\ 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 @@ +<?php + +include_once("convert.php"); + +class Event { + public $title; + public $time; + public $description; + public $flyer; + + public function show() + { + echo "<div class=\"event\">\n"; + echo " <div class=\"event_title\">" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; + echo " <div class=\"event_time\">" . date("D M jS Y", $this->time) . "</div>\n"; + echo " <div class=\"event_description\">" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n"; + if($this->flyer) { + echo " <img class=\"event_flyer\" alt=\"flyer\" src=\"gfx/flyers/" . $this->flyer . "\"/>\n"; + } + echo "</div>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<events>\n"); + foreach($this->events as $event) { + fwrite($fp, " <event title=\"" . + htmlspecialchars($event->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, " </event>\n"); + } + fwrite($fp, "</events>\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 @@ +<?php +class GuestbookEntry { + public $remoteaddr; + public $title; + public $email; + public $time; + public $text; + + public function GuestbookEntry($title, $email, $time, $remoteaddr, $text) { + $this->title = $title; + $this->email = $email; + $this->time = $time; + $this->remoteaddr = $remoteaddr; + $this->text = $text; + } + + public function show() + { + echo "<div class=\"guestbook_entry\">\n"; + echo " <div class=\"guestbook_name\">" . $this->title . "</div>\n"; + echo " <div class=\"guestbook_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; + echo " <div class=\"guestbook_email\">" . str_replace("@", "(A)", $this->email) . "</div>\n"; + echo " <div class=\"guestbook_text\">" . $this->text . "</div>\n"; + echo "</div>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<guestbook>\n"); + foreach($this->guestbook as $entry) { + fwrite($fp, " <entry name=\"" . + htmlspecialchars($entry->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, " </entry>\n"); + } + fwrite($fp, "</guestbook>\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"); +?> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>404 Not Found</title> +</head><body> +<h1>Not Found</h1> +<p>The requested URL /?page=guestbook was not found on this server.</p> +<hr> +<address>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</address> +</body></html> +<?php + exit(404); +} +?>
\ 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 @@ +<?php + +class Link { + public $title; + public $href; + public $icon; + + public function Link($title, $href, $icon) { + $this->title = $title; + $this->href = $href; + $this->icon = $icon; + } + + public function show() + { + echo "<div class=\"link\">\n"; + if($this->icon != "") { + echo " <a class=\"link_icon\" rel=\"external\" href=\"" . $this->href . "\">\n"; + echo " <img alt=\"" . $this->title . "\" src=\"" . $this->icon . "\"/>\n"; + echo " </a>\n"; + } + echo " <a class=\"link_title\" rel=\"external\" href=\"" . $this->href . "\">\n"; + echo " " . htmlspecialchars_decode($this->title, ENT_QUOTES) . "\n"; + echo " </a>\n"; + echo "</div>\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 "<div class=\"linkgroup\">\n"; + echo " <div class=\"linkgroup_title\">". htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; + foreach($this->links as $link) { + $link->show(); + } + echo "</div>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<links>\n"); + foreach($this->links as $link) { + fwrite($fp, " <link title=\"" . + htmlspecialchars($link->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, " </link>\n"); + } + fwrite($fp, "</links>\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 @@ +<?php + +function _log($action, $username) +{ + global $DATA_DIR; + + $ip = $_SERVER['REMOTE_ADDR']; + $time = date("D M jS Y G:i", time()); + + $fp = fopen($DATA_DIR . "/admin.log", "a"); + fprintf($fp, "%s - %s: User %s from %s\n", $time, $action, $username, $ip); + fclose($fp); +} + +?>
\ 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 @@ +<?php + +$loggedin = false; + +include_once($UTIL_DIR . "/user.php"); +include_once($UTIL_DIR . "/log.php"); + +function checklogin() +{ + global $HTTP_COOKIE_VARS; + global $userid; + global $password; + global $loggedin; + global $action; + global $DATA_DIR; + + $users = new Users($DATA_DIR . "/users.xml"); + + if($action == "login") { + $user = $users->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 @@ +<?php + +include_once("convert.php"); + +class NewsEntry { + public $title; + public $time; + public $description; + public $category; + + public function show() + { + echo "<div class=\"news_entry\">\n"; + echo " <div class=\"news_title\">" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; + echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; + echo " <div class=\"news_description\">" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n"; + echo "</div>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<news>\n"); + foreach($this->news as $newsentry) { + fwrite($fp, " <newsentry title=\"" . + htmlspecialchars($newsentry->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, " </newsentry>\n"); + } + fwrite($fp, "</news>\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 @@ +<?php + +/** + * CONFIG + */ +$subject_prefix = "DIE Newsletter"; +$sender = "DIE <info@executionroom.com>"; +$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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<mailinglist>\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " <email email=\"" . + htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " </email>\n"); + } + fwrite($fp, "</mailinglist>\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 "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\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("<font style=\"font-size: 9px;\">%.0f%%</font>", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "<font style=\"font-size: 9px;\">[100%]</font>>\n<br/>done<br/>\n"; + echo "<a style=\"font-size: 20px; font-weight: bold;\" href=\"?page=admin&module=newsletter\">[CLOSE]</a>"; + echo "</div>\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 @@ +<?php +/** +<?xml version="1.0" encoding="UTF-8"?> +<mailinglist> + <email name="HeavyMetal.dk" url="http://www.heavymetal.dk/" email="info@heavymetal.dk"/> + <email name="Blabbermouth.net" url="http://www.blabbermouth.net" email="bmouth@bellatlantic.net"/> + <email name="Power Metal.dk" url="http://www.powermetal.dk/" email="kenn@powermetal.dk"/> + <email name="Revolution Music" url="http://www.revolution-music.dk" email="heavybear@revolution-music.dk "/> + <email name="Antenna" url="http://www.antenna.nu" email="lolk@antenna.nu"/> + <email name="Supreme Brutality" url="http://www.supremebrutality.net" email="contact@supremebrutality.net"/> + <email name="Vampire Magazine" url="http://www.vampire-magazine.com" email="Ricardo@vampire-magazine.com"/> + <email name="Danish Metal" url="http://www.danishmetal.dk" email="martin@danishmetal.dk"/> + <email name="Revelationz" url="http://www.revelationz.net" email="mail@revelationz.net"/> +</mailinglist> + **/ + + +/** + * CONFIG + */ +$subject_prefix = "DIE Pressrelease"; +$sender = "DIE <info@executionroom.com>"; +$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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<mailinglist>\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " <email email=\"" . + htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " </email>\n"); + } + fwrite($fp, "</mailinglist>\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 "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\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("<font style=\"font-size: 9px;\">%.0f%%</font>", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "<font style=\"font-size: 9px;\">[100%]</font>>\n<br/>done<br/>\n"; + echo "<a style=\"font-size: 20px; font-weight: bold;\" href=\"?page=admin&module=pressrelease\">[CLOSE]</a>"; + echo "</div>\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 @@ +<?php + +include_once("convert.php"); + +class RSSEntry { + public $title; + public $time; + public $description; + public $category; + + /* + public function show() + { + echo "<div class=\"news_entry\">\n"; + echo " <div class=\"news_title\">" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; + echo " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; + echo " <div class=\"news_description\">" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n"; + echo "</div>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + fwrite($fp, "<rss version=\"2.0\">\n"); + fwrite($fp, " <channel>\n"); + fwrite($fp, " <title>DIE News</title>\n"); + fwrite($fp, " <link>http://www.executionroom.com</link>\n"); + fwrite($fp, " <description>DIE - News from ExecutionRoom.com</description>\n"); + fwrite($fp, " <language>en-us</language>\n"); + fwrite($fp, " <pubDate>".$this->date(time())."</pubDate>\n"); + fwrite($fp, " <lastBuildDate>".$this->date(time())."</lastBuildDate>\n"); + fwrite($fp, " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n"); + fwrite($fp, " <generator>ExecutionRoom CMS</generator>\n"); + fwrite($fp, " <managingEditor>info@executionroom.com</managingEditor>\n"); + fwrite($fp, " <webMaster>info@executionroom.com</webMaster>\n"); + + $i = 0; + foreach($this->news as $newsentry) { + fwrite($fp, " <item>\n"); + fwrite($fp, " <title>".$newsentry->title."</title>\n"); + fwrite($fp, " <link>http://www.executionroom.com/?page=news&id=".$newsentry->time."</link>\n"); + fwrite($fp, " <description>".$newsentry->description."</description>\n"); + fwrite($fp, " <pubDate>".$this->date($newsentry->time)."</pubDate>\n"); + fwrite($fp, " <guid>http://www.executionroom.com/?page=news&id=".$newsentry->time."</guid>\n"); + fwrite($fp, " </item>\n"); + $i++; + if($i > 6) break; + } + + fwrite($fp, " </channel>\n"); + fwrite($fp, "</rss>\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 @@ +<?php +function thumbnail($album, $file, $maxwidth, $maxheight) { + global $ALBUMS_DIR; + + if($file =="") return "No such image"; + + // Config + $quality = 70; + $width = $maxwidth; + $height = $maxheight; + + // Filenames + $thumbnaildir = $ALBUMS_DIR . "/" . $album . "/thumbnails/"; + $thumbnail = $thumbnaildir . $maxwidth . "x" . $maxheight . "_" . $file; + $original = $ALBUMS_DIR . "/" . $album . "/" . $file; + + if(!file_exists($thumbnaildir)) { + // The thumbnaildir doesn't exist, create it. + mkdir($thumbnaildir, 0755); + } + + // Create thumbnail + if(!file_exists($thumbnail)) { + list($width_orig, $height_orig) = getimagesize($original); + if ($width && ($width_orig < $height_orig)) { + $width = ($height / $height_orig) * $width_orig; + } else { + $height = ($width / $width_orig) * $height_orig; + } + $image_p = imagecreatetruecolor($width, $height); + $image = imagecreatefromjpeg($original); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + imagejpeg($image_p, $thumbnail, $quality); + } + + // Return thumbnail filename + return $thumbnail; +} +?>
\ 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 @@ +<?php + +include_once("convert.php"); + +class User { + public $userid; + public $password; + public $users; + public $news; + public $events; + public $guestbook; + public $gallery; + public $user; + public $newsletter; + public $pressrelease; + + public function checkPassword($password) { + return $this->password == sha1(md5($password)); + } + + public function setPassword($oldpassword, $password1, $password2) { + if($this->checkPassword($oldpassword) == false) { // Doublecheck the validity of the user. + echo "<p>Current password is incorrect!</p>\n"; + return 1; + } + + if($password1 != $password2) { // Check if passowrds match. + echo "<p>Passwords do not match!</p>\n"; + return 1; + } + + echo "<p>Password updated successfully!</p>\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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + + fwrite($fp, "<users>\n"); + foreach($this->users as $user) { + fwrite($fp, " <user userid=\"" . + htmlspecialchars($user->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, " </user>\n"); + } + fwrite($fp, "</users>\n"); + + fclose($fp); + } + + public function deleteUser($userid) + { + if($userid != "admin") { + if($this->users[$userid]) { + unset($this->users[$userid]); + $this->write(); + } else { + echo "<p>ERROR: User! <em>".$userid."</em> does not exist!</p>\n"; + return false; + } + } else { + echo "<p>ERROR: You cannot delete the admin user!</p>\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 @@ +<?php + +class XMLDOMAttribute +{ + public $name; + public $value; +} + +class XMLDOMNode +{ + public $parentnode; + public $name; + public $contents; + public $attributes = array(); + public $children = array(); + + public function XMLDOMNode(&$parentnode) + { + $this->parentnode = &$parentnode; + } + + public function addNode(&$node) + { + echo "<p>" . $this->name . "::addNode(" . $node->name . ")</p>"; + // $node->parent = &$this; + array_push($this->children, &$node); + } + + public function addAttribute($name, $value) + { + // echo "<p>" . $this->name . "::addAttribute(" . $name . ", ". $value . ")</p>"; + $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<pre>"; + echo $this->root . " - " . $node0 . " - " . $node1 . " - " . $node2 . "\n"; + print_r($this->root); + echo "</pre>\n"; + */ + } +} + + +?>
\ No newline at end of file |