From 8aafefe813e22db63b3a4b502a3e8d0a335b775e Mon Sep 17 00:00:00 2001
From: deva <deva>
Date: Tue, 26 Jan 2010 13:00:58 +0000
Subject: Add guestbook module.

---
 utils/modules/guestbook.php | 48 +++++++++++++++++++++------------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

(limited to 'utils/modules')

diff --git a/utils/modules/guestbook.php b/utils/modules/guestbook.php
index babd1ec..45fb4c5 100644
--- a/utils/modules/guestbook.php
+++ b/utils/modules/guestbook.php
@@ -259,44 +259,33 @@ class Guestbook {
 		global $_SERVER;
 
 		// First filter known bad IPs
-		$spammers = array("85.255.118.10",
-											"216.32.84.82",
-											"220.226.63.254");
+		$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);
+				return false;
 			}
 		}
 		
 		// Bot catcher!
-		if($name || $email || $message) return false;//$spam .= "BOTCatch\n";
-		
+		if($name || $email || $message) return false;
+				
 		$name = strip_tags($name_hidden);
 		$email = strip_tags($email_hidden);
-		if($name == "" && $email == "") return false;//$spam .= "Empty name and mail\n";
+		if($name == "" && $email == "") return false;
 		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";
+		$words = array("incest", "estate", "phentermine", "viagra", "ringtones",
+									 "messed up in the email of mine", "ambien", "dating", "levitra");
+		foreach($words as $word) {
+			if(stristr($message, $word)) return false;
+		}
 		
-		if($message == "") return false;//$spam .= "Empty message\n";
-		$date = date("r");
-		//if(strstr($message, "http://")) return false;//$spam .= "Contains URL\n";
+		if($message == "") return false; // Empty message
 		
 		// Message is not SPAM
 		return true;
@@ -316,7 +305,7 @@ class Guestbook {
 																	convert($message_hidden));
 			$this->add($entry);
 			$this->write();
-			$str = "ok";
+			$str = "";
 		} else {
 			$str = "SPAM";
 		}
@@ -334,18 +323,25 @@ class Guestbook {
 			unset($action); // Make sure the post is not posted several times if module is included several times.
 		}
 
+		$showeditor = false;
+		$showposts = 0;
     foreach($params as $param) {
 			switch($param) {
 			case "editor":
-				return $str . $this->editor();
+				$showeditor = true;
 				break;
 
 			default:
-				if($show == "all") return $this->show(-1);
-				else return $this->show(7);
+				if($show == "all") $showposts = -1;
+				else $showposts = 7;
 				break;
 			}
 		}
+
+		if($showeditor == true) $str .= $this->editor();
+		if($showposts != 0) $str .= $this->show($showposts);
+
+		return $str;
   }
 
 	public function add($entry) {
-- 
cgit v1.2.3