Unable to connect to the database server at this time.

"; exit; } mysql_select_db(DATABASE, $dbcnx); if (!@mysql_select_db(DATABASE)) { echo "

Unable to locate the database at this time.

"; exit; } // Super Globals are disabled on the new server - deal with it $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; $name = $_POST['name']; $email = $_POST['email']; $relationship = $_POST['relationship']; $private = $_POST['private']; $story = $_POST['story']; $VerificationCodeX = $_POST['VerificationCodeX']; //project honey pot spam check function php_lookup($ip) { $php_key = 'sdjxmjysotgx'; /* * Validate IP */ if(!ip2long($ip)) { return 0; } /* * Break the IP into 4 octets */ $array = explode(".", $ip, 4); /* * Reverse the order of the octets */ $array = array_reverse($array); /* * Assemble our request */ $reverse = implode(".", $array); $request = $php_key .'.' .$reverse .'.dnsbl.httpbl.org'; //request PHP's opinion $phpResponse = gethostbyname($request); $phpData[1] = $phpResponse; //break apart the return $response = explode(".", $phpResponse, 4); /* $response[0] = 127 if in the PHP DB $response[1] = number of days since last activity $response[2] = threat score (25 = 100 spams, 50 = 1,000 spams, 75 = 1,000,000 spams) $response[3] = type of threat 0 Search Engine 1 Suspicious 2 Harvester 4 Comment Spammer */ //anything greater than 1 is spam if($response[0] != 127) //there was an error $phpData[0] = 0; elseif($response[3] == 4 && $response[2] > 5) // be mean to comment spammers $phpData[0] = 2; elseif($response[1] > 180 && $response[2] < 25) //if it is old, only block very bad ones $phpData[0] = 1; elseif($response[2] >10) // kill anything with a threat level higher than 10 $phpData[0] = 3; else // if i don't have it categorized, let it through $phpData[0] = 1; return $phpData; } function black_list_lookup($ip) { global $dbcnx; $sql = "SELECT number_of_hits FROM black_list WHERE ip_address = '$ip'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); ($row[0] < 1)? $count=0 : $count=$row[0]; return $count; } if($_POST['name']) { $spam_string = "\n\nThis message was submitted by " .$REMOTE_ADDR ."
\nThis message was blocked because "; $SpamFree = 1; // Assume that there isn't SPAM - if there is, the flag will switch to 0 $black_list = black_list_lookup($REMOTE_ADDR); $phpResult = php_lookup($REMOTE_ADDR); if($black_list >= 1) { $SpamFree = 0; $spam_error .= "they are on the black list."; $spam_string .= $spam_error; } else if($VerificationCodeX != "") { // $VerificationCodeX should be a hidden value that will only be filled in if BOTS come through $SpamFree = 0; $spam_error .= "they entered text into the hidden field."; $spam_string .= $spam_error; } else if($phpResult[0] > 1) { $SpamFree = 0; $spam_error .= "they failed Project Honey Pot's lookup."; $spam_string .= $spam_error; } else { $spam = array("[url", "[link", "viagra", "cialis", "oxytocin", "http://", "= 1) { $count = $black_list + 1; $sql_blacklist = "UPDATE black_list SET date_seen = NOW(), number_of_hits = " .$count ." WHERE ip_address = '" .$REMOTE_ADDR ."'"; } else { $sql_blacklist = "INSERT INTO black_list (ip_address, date_added, date_seen, number_of_hits, failure_reason) VALUES ('" .$REMOTE_ADDR ."', NOW(), NOW(), '1', '$spam_error')"; } mysql_query($sql_blacklist) or die("Blacklist Error: ".mysql_error()); // -- Removed SPAM notifications, they were getting very noisy // mail('sgt.ben@gmail.com', 'Spam Alert', "The following post has been blocked as SPAM from being entered as a Brian Story:

\n\n$spam_string
\n
\n$story\n\n

Blacklist Count: $black_list", $mailheaders); } } //Insert a story into the DB if there is a name coming in if($SpamFree == 1) { $story = nl2br($story); $sql = "INSERT INTO stories (name, date, email, relationship, story, private, ip_address) VALUES ('$name', NOW(), '$email', '$relationship', '$story', '$private', '" .$REMOTE_ADDR ."')"; mysql_query($sql) or die("Failed to save story: " .mysql_error()); //Get the ID of the last story for the email $sql = "SELECT id FROM stories ORDER BY id DESC LIMIT 1"; $result = mysql_query($sql) or die("I couldn't get the id of the last story: " .mysql_error()); $row = mysql_fetch_array($result); $id = $row['id']; //Send Email when there is a new story posted //fill array will all email addresses to be notified //$notify=array("ben@newleafinternet.com"); $notify=array("sgt.ben@gmail.com", "stephen.parker1@comcast.net"); //Send emails to everyone in the notify array foreach ($notify as $address) { if($private == 1) $strPrivate = "private"; else $strPrivate = ''; $emailBody = "A new $strPrivate story has been added to Brian's Web Page

"; $emailBody .= "Name: " .stripslashes($name) ."
"; $emailBody .= "Relationship: " .stripslashes($relationship) ."
"; $emailBody .= "Email Address: $email
"; $emailBody .= "Story:
"; $emailBody .= stripslashes($story); $emailBody .= "

"; $emailBody .= "
Click Here to Edit the Story"; //Build the email HTML $body = "
\"Brian
$emailBody

\n

BrianRParker.com

If you have any questions about this email, please email Steve

IP: " .$REMOTE_ADDR ." PHP Score: " .$phpResult[0] ." - PHP Response: " .$phpResult[1] ."

"; //build the header information $msg =" $subject "; //add the email itself $msg .= $body; //close the tags $msg .= ""; // build the message $mailheaders = "From: Stories \n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"; //Send the email mail($address, "New Brian Story", $msg, $mailheaders); } //end ForEach /****************** End Emails *************************************************/ } $title = "Brian Stories"; ?>

Brian was an amazing man that touched countless lives while he was with us. We would like to encourage you to share your "Brian Stories" with us as a way to remember everything that Brian meant to so many individuals.

If you would like to share your "Brian Story" with everyone, it will be posted on the web page for others to read. You can choose to only share your story with Brian's family as well if you would prefer to keep your story private. Either way, thank you for sharing!

Please enter your name.
Please enter your email address.Invalid format.
(optional)

A value is required.

$name"; if(!empty($relationship)) echo "-- $relationship, " .date("M d, Y", $row['date']) .""; echo "
$story


"; } ?>