summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htdocs/index.php27
-rw-r--r--utils/guestbook.php4
-rw-r--r--utils/imagecache.php98
-rw-r--r--utils/modules/gallery.php121
-rw-r--r--utils/modules/guestbook.php446
-rw-r--r--utils/modules/news.php2
6 files changed, 674 insertions, 24 deletions
diff --git a/htdocs/index.php b/htdocs/index.php
index c1ac7d7..8373362 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -1,5 +1,12 @@
<?php
include_once("config.php");
+
+if($mode == "imagecache") {
+ include_once($UTIL_DIR. "/imagecache.php");
+ getCachedImage($uri, $mw, $mh);
+ return;
+}
+
include_once($MODULES_DIR . "/config.php");
$config = new Config($DATA_DIR . "/config.xml");
@@ -45,9 +52,9 @@ $pages = new Pages($DATA_DIR . "/pages.xml");
<body>
<div style="display: none;">
<?php
-$ps = $config->value('preload');
-foreach($ps as $p) {
- echo " <img alt=\"preload\" src=\"".$p."\"/>\n";
+$_ps = $config->value('preload');
+foreach($_ps as $_p) {
+ echo " <img alt=\"preload\" src=\"".$_p."\"/>\n";
}
?>
</div>
@@ -81,9 +88,9 @@ if(sizeof($menu)) {
if($page == "admin") {
include($UTIL_DIR."/admin.php");
} else {
- if($page) $p = $pages->getPage($page);
- else $p = $pages->getPage($config->value('default'));
- if($p) $p->show();
+ if($page) $_p = $pages->getPage($page);
+ else $_p = $pages->getPage($config->value('default'));
+ if($_p) $_p->show();
}
?>
</div>
@@ -91,15 +98,15 @@ if($page == "admin") {
echo "style=\"width: 249px;\"";
?>>
<?php
-$p = $pages->getPage("column");
-if($p) $p->show();
+$_p = $pages->getPage("column");
+if($_p) $_p->show();
?>
</div>
</div>
<div class="footer">
<?php
-$p = $pages->getPage("footer");
-if($p) $p->show();
+$_p = $pages->getPage("footer");
+if($_p) $_p->show();
?>
</div>
</div>
diff --git a/utils/guestbook.php b/utils/guestbook.php
index ca9cd81..21b0fda 100644
--- a/utils/guestbook.php
+++ b/utils/guestbook.php
@@ -1,4 +1,5 @@
<?php
+ /*
class GuestbookEntry {
public $remoteaddr;
public $title;
@@ -165,5 +166,6 @@ if($page == "guestbook" && $action == "post" &&
</body></html>
<?php
exit(404);
-}
+}
+*/
?> \ No newline at end of file
diff --git a/utils/imagecache.php b/utils/imagecache.php
new file mode 100644
index 0000000..39c741e
--- /dev/null
+++ b/utils/imagecache.php
@@ -0,0 +1,98 @@
+<?php
+
+include_once("config.php");
+
+function rescale($image, $maxwidth, $maxheight)
+{
+ $width = imagesx($image);
+ $height = imagesy($image);
+
+ if($width <= $maxwidth && $height <= $maxheight) return $image;
+
+ $scale = 1;
+ if($width > $maxwidth) $scale = $width / $maxwidth;
+ if($height / $scale > $maxheight) $scale = $height / $maxheight;
+
+ $image_p = imagecreatetruecolor($width / $scale, $height / $scale);
+ imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width / $scale, $height / $scale, $width, $height);
+
+ return $image_p;
+}
+
+function errorImage($message)
+{
+ header("Content-type: image/png");
+ $im = @imagecreate(8 + strlen($message) * 5, 20)
+ or die("Cannot Initialize new GD image stream");
+ $background_color = imagecolorallocate($im, 0, 0, 0);
+ $text_color = imagecolorallocate($im, 233, 14, 91);
+ imagestring($im, 1, 5, 5, $message, $text_color);
+ imagepng($im);
+ imagedestroy($im);
+}
+
+function getCachedImage($filename, $maxwidth, $maxheight)
+{
+ global $IMAGECACHE;
+ $fullfilename = $IMAGECACHE . "/" . $maxwidth . ":" . $maxheight . ":". urlencode($filename);
+
+ // Test the storage dir
+ if(!file_exists($IMAGECACHE)) {
+ if(!mkdir($IMAGECACHE)) errorImage("Could not create directory: " . $IMAGECACHE);
+ }
+ if(!is_dir($IMAGECACHE)) errorImage($IMAGECACHE . " exists but is not a directory");
+ if(!is_readable($IMAGECACHE) || !is_writeable($IMAGECACHE) || !is_executable($IMAGECACHE)) {
+ errorImage($IMAGECACHE . " exists but does not have the correct permissions. (r/w/x)");
+ }
+ // end of dir test
+
+ if(!file_exists($fullfilename)) {
+
+ $url = parse_url($filename);
+ $filetype = strrchr($url["path"], '.');
+
+ if( true || ping($url["hostname"], 1000) != -1) {
+
+ error_reporting(E_ERROR | E_PARSE);
+
+ switch(strtolower($filetype)) {
+ case ".jpeg":
+ case ".jpg":
+ $image = imagecreatefromjpeg(urldecode($filename));
+ if(!$image) errorImage("Could not read: ". $filename);
+ $image = rescale($image, $maxwidth, $maxheight);
+ imagejpeg($image, $fullfilename, 90);
+ break;
+
+ case ".gif":
+ $image = imagecreatefromgif(urldecode($filename));
+ if(!$image) errorImage("Could not read: ". $filename);
+ $image = rescale($image, $maxwidth, $maxheight);
+ imagegif($image, $fullfilename);
+ break;
+
+ case ".png":
+ $image = imagecreatefrompng(urldecode($filename));
+ if(!$image) errorImage("Could not read: ". $filename);
+ $image = rescale($image, $maxwidth, $maxheight);
+ imagepng($image, $fullfilename);
+ break;
+
+ default:
+ if(!$image) errorImage("Unknown image type " . $filetype);
+ break;
+ }
+
+ error_reporting(E_ALL ^ E_NOTICE);
+
+ }
+ }
+
+ header('Content-Description: File Transfer');
+ header('Content-Type: image/jpeg');
+ header('Content-Length: ' . filesize($fullfilename));
+ header('Content-Disposition: inline; filename=' . basename($filename));
+ readfile($fullfilename);
+}
+
+?> \ No newline at end of file
diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php
index c6d2f86..74a0ba0 100644
--- a/utils/modules/gallery.php
+++ b/utils/modules/gallery.php
@@ -42,10 +42,13 @@ class Photo {
htmlspecialchars($this->image, ENT_QUOTES, "UTF-8") . "\"/>\n");
}
- public function show()
+ public function show($maxwidth = 100, $maxheight = 100, $showbig = false)
{
$str = "<p>\n";
- $str .= " <img src=\"" . $this->path . "/" . $this->image . "\" width=\"100\"/><br/>\n";
+ if($showbig) $str .= " <a href=\"" . $this->path . "/" . $this->image . "\">\n";
+
+ $str .= " <img src=\"?mode=imagecache&amp;uri=" . $this->path . "/" . $this->image . "&amp;mw=".$maxwidth."&amp;mh=".$maxheight."\"\"/><br/>\n";
+ if($showbig) $str .= " </a>\n";
$str .= " " . $this->title . "\n";
$str .= "</p>\n";
return $str;
@@ -66,6 +69,7 @@ class Album {
public $title;
public $copyright;
public $enabled;
+ public $icon;
public $photos = array();
public function add($photo)
@@ -91,18 +95,26 @@ class Album {
fwrite($fp, " </album>\n");
}
- public function show()
+ public function show($maxwidth, $maxheight)
{
+ global $page;
$str = "<p>\n";
- $str .= "<img src=\"" . $this->getPath() . "/" . $this->photos[$this->icon]->image . "\" width=\"64\"/>\n";
+ //$str .= " <img src=\"?mode=imagecache&amp;uri=" . $this->getPath() . "/" . $this->photos[$this->icon]->image . "&amp;mw=".($maxwidth/2)."&amp;mh=".($maxheight/2)."\"\"/><br/>\n";
+ //$str .= "<img src=\"" . $this->getPath() . "/" . $this->photos[$this->icon]->image . "\" width=\"64\"/>\n";
$str .= "<strong>" . $this->title . "</strong>\n";
$str .= "</p>\n";
foreach($this->photos as $photo) {
- $str .= $photo->show();
+ $str .= "<a href=\"?page=".$page."&amp;a=".$this->id."&amp;p=".$photo->id."\">".$photo->show($maxwidth, $maxheight)."</a>";
}
return $str;
}
+ public function showIcon($maxwidth, $maxheight)
+ {
+ global $page;
+ return "<a href=\"?page=".$page."&amp;a=".$this->id."\">".$this->title . $this->photos[$this->icon]->show($maxwidth, $maxheight)."</a>\n";
+ }
+
public function getPath()
{
global $ALBUMS_DIR;
@@ -176,9 +188,18 @@ class Gallery {
private $file;
private $albums = array();
+ // Local attributes
+ private $maxwidth_icon;
+ private $maxheight_icon;
+ private $maxwidth_rand;
+ private $maxheight_rand;
+ private $maxwidth;
+ private $maxheight;
+
// Admin config
public $admin_title = "Gallery";
- public $admin_submodules = array("New album" => "new",
+ public $admin_submodules = array("Options" => "options",
+ "New album" => "new",
"Edit album" => "edit",
"Delete album" => "delete");
@@ -191,7 +212,7 @@ class Gallery {
unpackImages($_FILES['images'], $album);
$this->add($album);
$this->write();
- echo $album->show();
+ echo $album->show($this->maxwidth_icon, $this->maxheight_icon);
break;
case "select":
@@ -207,9 +228,37 @@ class Gallery {
}
}
+ public function admin_options($action, $vars)
+ {
+ switch($action) {
+ case "store":
+ $this->maxwidth_icon = $vars['maxwidth_icon'];
+ $this->maxheight_icon = $vars['maxheight_icon'];
+ $this->maxwidth_rand = $vars['maxwidth_rand'];
+ $this->maxheight_rand = $vars['maxheight_rand'];
+ $this->maxwidth = $vars['maxwidth'];
+ $this->maxheight = $vars['maxheight'];
+ $this->write();
+ default:
+ $form = new Form("store");
+ $form->addWidget(new LineEdit("Icon maxwidth:", "maxwidth_icon", $this->maxwidth_icon));
+ $form->addWidget(new LineEdit("Icon maxheight:", "maxheight_icon", $this->maxheight_icon));
+ $form->addWidget(new LineEdit("Random maxwidth:", "maxwidth_rand", $this->maxwidth_rand));
+ $form->addWidget(new LineEdit("Random maxheight:", "maxheight_rand", $this->maxheight_rand));
+ $form->addWidget(new LineEdit("Image maxwidth:", "maxwidth", $this->maxwidth));
+ $form->addWidget(new LineEdit("Image maxheight:", "maxheight", $this->maxheight));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
+
public function admin($sub, $action, $vars)
{
switch($sub) {
+ case "options":
+ $this->admin_options($action, $vars);
+ break;
case "new":
$this->admin_new($action, $vars);
break;
@@ -222,15 +271,50 @@ class Gallery {
}
}
+ public function showRandomPhoto()
+ {
+ srand((float) microtime() * 10000000);
+ if(sizeof($this->albums) == 0) return "";
+ $album = array_rand($this->albums);
+ if(sizeof($this->albums[$album]->photos) == 0) return "";
+ $photo = array_rand($this->albums[$album]->photos);
+ return "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".$photo."\">".$this->albums[$album]->photos[$photo]->show($this->maxwidth_rand, $this->maxheight_rand)."</a>";
+ }
+
+ public function showAlbums()
+ {
+ $str = "";
+ foreach($this->albums as $album) {
+ $str .= $album->showIcon($this->maxwidth_icon, $this->maxheight_icon);
+ }
+ return $str;
+ }
+
+ public function showPhoto($album, $photo)
+ {
+ $str = $this->albums[$album]->photos[$photo]->show($this->maxwidth, $this->maxheight, true);
+ if($this->albums[$album]->photos[$photo - 1])
+ $str .= "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo-1)."\">". $this->albums[$album]->photos[$photo - 1]->show($this->maxwidth_icon, $this->maxheight_icon) . "</a>";
+ $str .= "<a href=\"?page=gallery&amp;a=".$album."\"><img src=\"snot.jpg\"/></a>";
+ if($this->albums[$album]->photos[$photo + 1])
+ $str .= "<a href=\"?page=gallery&amp;a=".$album."&amp;p=".($photo+1)."\">".$this->albums[$album]->photos[$photo + 1]->show($this->maxwidth_icon, $this->maxheight_icon)."</a>";
+ return $str;
+ }
+
public function run($params)
{
+ global $a, $p;
+
$str = "";
foreach($params as $param) {
switch($param) {
default:
- foreach($this->albums as $album) {
- $str .= $album->show();
- }
+ if($p != "" && $a != "") return $this->showPhoto($a, $p);
+ if($a != "") return $this->albums[$a]->show($this->maxwidth_icon, $this->maxheight_icon);
+ return $this->showAlbums();
+
+ case "random":
+ $str .= $this->showRandomPhoto();
break;
}
}
@@ -255,7 +339,12 @@ class Gallery {
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<gallery>\n");
+ fwrite($fp, "<gallery maxwidth_icon=\"".$this->maxwidth_icon."\"\n");
+ fwrite($fp, " maxheight_icon=\"".$this->maxheight_icon."\"\n");
+ fwrite($fp, " maxwidth_rand=\"".$this->maxwidth_rand."\"\n");
+ fwrite($fp, " maxheight_rand=\"".$this->maxheight_rand."\"\n");
+ fwrite($fp, " maxwidth=\"".$this->maxwidth."\"\n");
+ fwrite($fp, " maxheight=\"".$this->maxheight."\">\n");
foreach($this->albums as $album) {
$album->write($fp);
}
@@ -273,7 +362,15 @@ class Gallery {
$dom->load($this->file);
$gallery = $dom->documentElement;
- // $this->width = $gallery->getAttribute('width');
+
+ $this->maxwidth_icon = $gallery->getAttribute('maxwidth_icon');
+ $this->maxheight_icon = $gallery->getAttribute('maxheight_icon');
+
+ $this->maxwidth_rand = $gallery->getAttribute('maxwidth_rand');
+ $this->maxheight_rand = $gallery->getAttribute('maxheight_rand');
+
+ $this->maxwidth = $gallery->getAttribute('maxwidth');
+ $this->maxheight = $gallery->getAttribute('maxheight');
foreach($gallery->childNodes as $albumElem) {
diff --git a/utils/modules/guestbook.php b/utils/modules/guestbook.php
new file mode 100644
index 0000000..babd1ec
--- /dev/null
+++ b/utils/modules/guestbook.php
@@ -0,0 +1,446 @@
+<?php
+/* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+include_once($UTIL_DIR . "/forms.php");
+include_once($UTIL_DIR . "/convert.php");
+
+class GuestbookEntry {
+ public $remoteaddr;
+ public $title;
+ public $email;
+ public $time;
+ public $text;
+
+ public function show()
+ {
+ $str = "<div class=\"guestbook_entry\">\n";
+ $str .= " <div class=\"guestbook_name\">" . $this->title . "</div>\n";
+ $str .= " <div class=\"guestbook_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n";
+ $str .= " <div class=\"guestbook_email\">" . str_replace("@", "(A)", $this->email) . "</div>\n";
+ $str .= " <div class=\"guestbook_text\">" . $this->text . "</div>\n";
+ $str .= "</div>\n";
+ return $str;
+ }
+
+ public function write($fp)
+ {
+ fwrite($fp, " <entry name=\"" .
+ htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " time=\"" . $this->time . "\"\n");
+ fwrite($fp, " email=\"" .
+ htmlspecialchars($this->email, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " remoteaddr=\"" .
+ htmlspecialchars($this->remoteaddr, ENT_QUOTES, "UTF-8") . "\"\n");
+ fwrite($fp, " text=\"" .
+ htmlspecialchars($this->text, ENT_QUOTES, "UTF-8") . "\">\n");
+ fwrite($fp, " </entry>\n");
+ }
+
+ public function GuestbookEntry($title, $email, $time, $remoteaddr, $text) {
+ $this->title = $title;
+ $this->email = $email;
+ $this->time = $time;
+ $this->remoteaddr = $remoteaddr;
+ $this->text = $text;
+ }
+}
+
+class Guestbook {
+ private $file;
+ private $guestbook = array();
+
+ // Admin config
+ public $admin_title = "Guestbook";
+ public $admin_submodules = array();
+ /*
+ public $admin_submodules = array("New Newsentry" => "new",
+ "Edit Newsentry" => "edit",
+ "Delete Newsentry" => "delete");
+
+ public function admin_add($action, $vars)
+ {
+ global $UID, $ICONS_DIR;
+
+ switch($action) {
+ case "add":
+ $n = new NewsEntry($vars["title"], DateTimeEdit::toTimestamp($vars, "time"),
+ $vars["category"], $vars["description"], $UID, $vars["icon"]);
+ echo "\"" .$n->title . "\" has now been added.";
+ $this->add($n);
+ $this->write();
+ break;
+
+ case "preview":
+ $n = new NewsEntry($vars["title"], DateTimeEdit::toTimestamp($vars, "time"),
+ $vars["category"], $vars["description"], $UID, $vars["icon"]);
+ echo "<div class=\"preview\">\n";
+ echo "<div class=\"content\">\n";
+ echo $n->show();
+ echo "</div>\n";
+ echo "</div>\n";
+ echo "<p>Looking ok?</p>";
+ $form = new Form("add");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("yes"));
+ $form->render();
+
+ $form = new Form("retry");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("no"));
+ $form->render();
+ break;
+
+ case "retry":
+ $title = $vars["title"];
+ $time = DateTimeEdit::toTimestamp($vars, "time");
+ $category = $vars["category"];
+ $description = $vars["description"];
+ default:
+ $form = new Form("preview");
+ $form->addWidget(new LineEdit("Title", "title", $title));
+ $form->addWidget(new DateTimeEdit("Time", "time", $time));
+ $form->addWidget(new ComboBox("Category", "category", $category, array("Main" => "main", "Site" => "site")));
+ $form->addWidget(new TextEdit("Description", "description", $description));
+ $form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/")));
+ $form->addWidget(new Button("Post news"));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin_edit($action, $vars)
+ {
+ global $UID, $ICONS_DIR;
+
+ switch($action) {
+ case "add":
+ $this->news[$vars["newsid"]]->title = $vars["title"];
+ $this->news[$vars["newsid"]]->userid = $UID;
+ $this->news[$vars["newsid"]]->time = DateTimeEdit::toTimestamp($vars, "time");
+ $this->news[$vars["newsid"]]->category = $vars["category"];
+ $this->news[$vars["newsid"]]->description = $vars["description"];
+ $this->news[$vars["newsid"]]->icon = $vars["icon"];
+ $this->write();
+ echo "\"" . $this->news[$vars["newsid"]]->title . "\" has now been edited.";
+ break;
+
+ case "preview":
+ $n = new NewsEntry($vars["title"], DatetimeEdit::toTimestamp($vars, "time"), $vars["category"], $vars["description"], $UID, $vars["icon"]);
+ echo "<div class=\"preview\">\n";
+ echo "<div class=\"content\">\n";
+ echo $n->show();
+ echo "</div>\n";
+ echo "</div>\n";
+ echo "<p>Looking ok?</p>";
+ $form = new Form("add");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("yes"));
+ $form->render();
+
+ $form = new Form("retry");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("no"));
+ $form->render();
+ break;
+
+ case "edit":
+ case "retry":
+ if(isset($vars["title"])) $title = $vars["title"];
+ else $title = $this->news[$vars["newsid"]]->title;
+ if(isset($vars["time_year"])) $time = DateTimeEdit::toTimestamp($vars, "time");
+ else $time = $this->news[$vars["newsid"]]->time;
+ if(isset($vars["category"])) $category = $vars["category"];
+ else $category = $this->news[$vars["newsid"]]->category;
+ if(isset($vars["description"])) $description = $vars["description"];
+ else $description = $this->news[$vars["newsid"]]->description;
+ if(isset($vars["icon"])) $icon = $vars["icon"];
+ else $icon = $this->news[$vars["newsid"]]->icon;
+
+ $form = new Form("preview");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new LineEdit("Title", "title", $title));
+ $form->addWidget(new DateTimeEdit("Time", "time", $time));
+ $form->addWidget(new ComboBox("Category", "category", $category,
+ array("Main" => "main", "Site" => "site")));
+ $form->addWidget(new TextEdit("Description", "description", $description));
+ $form->addWidget(new ImageComboBox("Icon", "icon", $icon, new Icons($ICONS_DIR."/")));
+ $form->addWidget(new Button("Post news"));
+ $form->render();
+ break;
+
+ case "select":
+ default:
+ $newslist = array();
+ foreach($this->news as $newsentry) {
+ $newslist[$newsentry->title] = $newsentry->time;
+ }
+
+ $form = new Form("edit");
+ $form->addWidget(new ComboBox("Edit this entry:", "newsid", "", $newslist));
+ $form->addWidget(new Button("Edit..."));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin_delete($action, $vars)
+ {
+ switch($action) {
+ case "delete":
+ echo "\"". $this->news[$vars["newsid"]]->title . "\" has now been deleted.";
+ unset($this->news[$vars["newsid"]]);
+ $this->write();
+ break;
+
+ case "confirm":
+ echo "Really delete: " . $this->news[$vars["newsid"]]->title . "?";
+ $form = new Form("delete");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("yes"));
+ $form->render();
+
+ $form = new Form("select");
+ $form->addWidget(new Hidden($vars));
+ $form->addWidget(new Button("no"));
+ $form->render();
+ break;
+
+ case "select":
+ default:
+ $newslist = array();
+ foreach($this->news as $newsentry) {
+ $newslist[$newsentry->title] = $newsentry->time;
+ }
+ $form = new Form("confirm");
+ $form->addWidget(new ComboBox("Delete this entry:", "newsid", "", $newslist));
+ $form->addWidget(new Button("Delete..."));
+ $form->render();
+ break;
+ }
+ }
+ */
+ public function admin($sub, $action, $vars)
+ {
+ /*
+ switch($sub) {
+ case "new":
+ $this->admin_add($action, $vars);
+ break;
+
+ case "edit":
+ $this->admin_edit($action, $vars);
+ break;
+
+ case "delete":
+ $this->admin_delete($action, $vars);
+ break;
+ }
+ */
+ }
+
+ public function editor()
+ {
+ $str = "<div class=\"guestbook_form\">\n";
+ $str .= "<form action=\"?page=guestbook&amp;action=post\" method=\"post\"> \n";
+ $str .= "<p> \n";
+ $str .= "Name: <input style=\"display: none\" name=\"name\"/><input name=\"name_hidden\"/> \n";
+ $str .= "Email: <input style=\"display: none\" name=\"email\"/><input name=\"email_hidden\"/><br/> \n";
+ $str .= "Message:<br/> \n";
+ $str .= "<textarea style=\"display: none\" rows=\"2\" cols=\"74\" name=\"message\"></textarea> \n";
+ $str .= "<textarea rows=\"2\" cols=\"74\" name=\"message_hidden\"></textarea><br/> \n";
+ $str .= "<button type=\"submit\">Post</button><br/> \n";
+ $str .= "</p> \n";
+ $str .= "</form> \n";
+ $str .= "</div> \n";
+ return $str;
+ }
+
+ 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;
+ }
+
+ public function newpost()
+ {
+ global $name, $email, $message, $name_hidden, $email_hidden, $message_hidden;
+
+ // Check is the message is SPAM
+ if($this->filtermessage($name, $email, $message, $name_hidden, $email_hidden, $message_hidden)) {
+ // It was not... now add it to the book.
+ $entry = new GuestbookEntry($name_hidden,
+ $email_hidden,
+ time(),
+ $_SERVER['REMOTE_ADDR'],
+ convert($message_hidden));
+ $this->add($entry);
+ $this->write();
+ $str = "ok";
+ } else {
+ $str = "SPAM";
+ }
+ return $str;
+ }
+
+
+ public function run($params)
+ {
+ global $show, $action;
+
+ $str = "";
+ if($action == "post") {
+ $str .= $this->newpost();
+ unset($action); // Make sure the post is not posted several times if module is included several times.
+ }
+
+ foreach($params as $param) {
+ switch($param) {
+ case "editor":
+ return $str . $this->editor();
+ break;
+
+ default:
+ if($show == "all") return $this->show(-1);
+ else return $this->show(7);
+ break;
+ }
+ }
+ }
+
+ 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) {
+ $entry->write($fp);
+ }
+ fwrite($fp, "</guestbook>\n");
+
+ fclose($fp);
+ }
+
+ public function show($number)
+ {
+ $str = "";
+
+ // If number is -1 show all shows.
+ if($number == -1) $number = 100000;
+
+ foreach($this->guestbook as $entry) {
+ $str .= $entry->show();
+ $number--;
+ if(!$number) break;
+ }
+
+ return $str;
+ }
+
+ 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;
+ if(file_exists($file)) $this->read();
+ }
+}
+
+function guestbook_init()
+{
+ global $DATA_DIR;
+ return new Guestbook($DATA_DIR . "/guestbook.xml");
+}
+
+/*
+*/
+/*
+//
+// 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);
+}
+*/
+
+?>
diff --git a/utils/modules/news.php b/utils/modules/news.php
index 9e542ae..d4eee3e 100644
--- a/utils/modules/news.php
+++ b/utils/modules/news.php
@@ -264,7 +264,7 @@ class News {
switch($params) {
default:
if($show == "all") return $this->show(-1, "all");
- else return $this->show(-1, "main");
+ else return $this->show(3, "main");
break;
}
}