Jump to content

php code help


dannybrazil

Recommended Posts

Hello ,

i got a guest book code and i implemented it into my site http://www.ronaldorobotika.com (in guest book).

 

as you can see it is really simple and with out CSS , i wanted to know if some one can help me find the place in the php code that i can add or change it to make the results look nicer.

 

for example :

- i want that every entry will be separated by <hr> or something like that

- i want to add background only for the entry part(each entry )

-where can i change the "how many results per page to show"

here is the code :

<?
/*
Silentum Guestbook v2.0.2
Modified March 13, 2008
sign.php copyright 2006-2008 "HyperSilence"
*/

session_start();

$date_format = "F d, Y";
$time_format = "h:i:sa";

$guestbook_file = "guestbook.txt";
$guestbook_page = "guestbook.php";
$html_allowed = false; // Change this to true if you want to allow HTML to be posted

// What is displayed if the fields are left blank when an entry is added

$blank_name = "Anonymous";
$blank_email = "anonymous@anonymous.net";
$blank_uri = "http://";
$blank_message = "N/A";

// Begin censored word filter
// A lot of these words were acquired from bots posting spam links in my guestbook
// Feel free to remove or add words as you wish

$filter = array(".biz", ".info", "adipex", "adult", "affiliat", "afford", "allegra", "ambien", "apartment", "asshole", "baccarat", "beer", "bitch", "black jack", "blackjack", "blow", "bontril", "breast", "buy", "carisoprodol", "carookee", "cash", "casino", "cell", "cheap", "check", "cialis", "cigar", "claritin", "clit", "cock", "cok", "commerc", "crack", "crap", "credit", "cum", "cunt", "dating", "debt", "dexone", "dick", "diet", "dildo", "discount", "drug", "dvd", "ebay", "ephedra", "erection", "fack", "fag", "fck", "fock", "fuck", "fuk", "fvck", "gambl", "gay", "gift", "goatse", "health", "hentai", "homo", "horny", "horo scope", "horoscope", "hotbox", "hotel", "idiot", "insuran", "incest", "ipod", "jew", "join", "keno", "lesbian", "levitra", "license", "lipitor", "lottery", "master card", "mastercard", "masturbat", "medic", "member", "meridia", "money", "mortgage", "movie", "mp3", "naked", "nigg", "nokia", "nude", "offer", "onsize", "paxil", "pedo", "penis", "pharm", "phent", "phone", "pill", "play", "poker", "porn", "prescription", "prize", "product", "prozac", "ps2", "ps3", "psp", "purchase", "pussy", "requip", "reward", "ring tone", "ringtone", "roul", "screen saver", "screensaver", "serial", "sex", "shat", "shit", "shop", "slot", "soft ware", "software", "soma", "sponsor", "sprint", "suck", "ticket", "tourna", "tramadol", "travel", "tubgirl", "ultram", "url=", "vagina", "valium", "verizon", "vernulsa", "viagra", "visa", "voyeur", "wall paper", "wallpaper", "web cam", "webcam", "weight", "whore", "xanax", "xbox", "xxx", "zoloft", "zyrtec");

// End censored word filter

// Begin functions

function remove_tags($source) {
$source = strip_tags($source);
return preg_replace('/<(.*?)>/ie', "'<'.'\\1'.'>'", $source);
}

function word_wrap($message) {
$cut = " ";
$max_length = 60;
$result = "";
$word_length = 0;

// End functions

$length = strlen($message);

$tag = FALSE;
for($i = 0; $i < $length; $i++) {
$character = substr($message, $i, 1);
if($character == "<") {
$tag = TRUE;
}
elseif($character == ">") {
$tag = FALSE;
}
elseif(!$tag && $character == " ") {
$word_length = 0;
}
elseif(!$tag) {
$word_length++;
}
if(!$tag && !($word_length%$max_length)) {
$character .= $cut;
}
$result .= $character;
}
return $result;
}

// Begin field manipulation

$layout = "<strong>!date!</strong> at <strong>!time!</strong><br />
<em><small>!ipaddress! * *</small></em><br />
!name!, <a href=\"mailto:!email!\" title=\"Email\">Email</a>, <a href=\"!uri!\" title=\"Web Site\">Web Site</a><br />
!message!<br /><br />";

$_POST["message"] = str_replace("
", "<br />", $_POST["message"]);
$message = word_wrap(remove_tags($message));
$message = stripslashes($_POST["message"]);
$message = str_replace(array("&", "\r\n\r\n"), array("&", " "), $message);
$message = str_replace(array("&gt;", "&lt;", "\r\n"), array(">", "<", "<br />"), $message);

if($html_allowed == false) {
$message = str_replace(array("<", ">"), array("<", ">"), $message);
$message = strip_tags(stripslashes($_POST["message"]));
}

$name = strip_tags(stripslashes($_POST["name"]));
$email = urlencode(strip_tags(stripslashes($_POST["email"])));
$uri = urlencode(strip_tags(stripslashes($_POST["uri"])));
$uri = str_replace(array("%2F", "%3A"), array("/", ":"), $uri);

$ip = explode(".", $_SERVER["REMOTE_ADDR"]);
$display_ip = $ip[0].".".$ip[1];

if(trim($name) == "") $name = $blank_name;
if(trim($email) == "") $email = $blank_email;
if(trim($uri) == "") $uri = $blank_uri;
if(stristr($uri, "http://") === false) $uri = "http://".$uri;
if(trim($message) == "") $message = $blank_message;

$transition = $layout;
$variables = array("\n", "!name!", "!email!", "!uri!", "!message!", "!date!", "!time!", "!ipaddress!");
$input = array("", $name, $email, $uri, $message, date($date_format), date($time_format), $display_ip);

$input = str_replace("", "<img alt=\"\" src=\"images/smile.gif\" style=\"vertical-align: middle\" title=\"\" />", $input);
$input = str_replace("", "<img alt=\"\" src=\"images/frown.gif\" style=\"vertical-align: middle\" title=\"\" />", $input);
$input = str_replace("", "<img alt=\"\" src=\"images/wink.gif\" style=\"vertical-align: middle\" title=\"\" />", $input);
$input = str_replace("", "<img alt=\"\" src=\"images/happy.gif\" style=\"vertical-align: middle\" title=\"\" />", $input);
$input = str_replace("", "<img alt=\"\" src=\"images/tongue.gif\" style=\"vertical-align: middle\" title=\"\" />", $input);

if(strlen($message) >= 260) {
header("Location: ".$guestbook_page."?page=1&msg=1&l=".strlen($message));
exit;
}

if(strlen($name) >= 36 || strlen($email) >= 126 || strlen($uri) >= 126) {
header("Location: ".$guestbook_page."?page=1");
exit;
}

if($_POST["verification"] != $_SESSION["veri"] || $_POST["verification"] == "") {
header("Location: ".$guestbook_page."?page=1&msg=3");
exit;
}

if($_COOKIE["guestbook_signed"] == "true") {
header("Location: ".$guestbook_page."?page=1&msg=4");
exit;
}

if($_POST["check"] == "1") {
header("Location: ".$guestbook_page."?page=1");
exit;
}

// End field manipulation

$transition = str_replace($variables, $input, $transition);

$past_entries = @fopen($guestbook_file, "r");
$content = @fread($past_entries, filesize($guestbook_file));
@fclose($past_entries);

$cw_check = $transition;

foreach($filter as $censored_word) {
if(stristr($cw_check, $censored_word)) {
header("Location: ".$guestbook_page."?page=1&msg=2&cw=".$censored_word);
exit;
}
}

$new_entry = $transition."\n".$content;

$all_entries = @fopen($guestbook_file, "w");
@fwrite($all_entries, $new_entry);
@fclose($all_entries);

setcookie("guestbook_signed", "true", time());

header("Location: ".$guestbook_page."?page=1&msg=5");
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.