Codice:
<?php
include("config.php");
// No HTML Part
if($name == "" || $name == "Name" || $cjmsg == "" || $cjmsg == "Message"){ // if some idiot just clicks "tag"
header("location: $display");
exit;
}
if ($url != "Url"){ // If url is given
$url = trim($url);
$url = ereg_replace("http://", "", $url);
$s=substr_count($url,"http://");
$d=substr_count($url,".");
}
else {
$url = ""; // incase just http:// is entered
}
$cjmsg = str_replace("<","<", $cjmsg);
$cjmsg = str_replace(">",">", $cjmsg);
$cjmsg = strip_tags($cjmsg); // strips HTML tags from tag
$name = strip_tags($name); // strips all HTML tags from name
$ename = $name; // sets email name
//CONVERTING EMOTICONS!!
// one day i will write a function to do the following...
if($smilies == 1){
$cjmsg = str_replace(":D","<img src=\"e/grin.gif\">", $cjmsg);
$cjmsg = str_replace(":)","<img src=\"e/smile.gif\">", $cjmsg);
$cjmsg = str_replace(":lol","<img src=\"e/lol.gif\">", $cjmsg);
$cjmsg = str_replace(":p","<img src=\"e/razz.gif\">", $cjmsg);
$cjmsg = str_replace(":evil","<img src=\"e/evil.gif\">", $cjmsg);
$cjmsg = str_replace(":(","<img src=\"e/sad.gif\">", $cjmsg);
$cjmsg = str_replace(":|","<img src=\"e/shocked.gif\">", $cjmsg);
$cjmsg = str_replace(";)","<img src=\"e/wink.gif\">", $cjmsg);
$cjmsg = str_replace(":x","<img src=\"e/mad.gif\">", $cjmsg);
$cjmsg = str_replace(":cry","<img src=\"e/cry.gif\">", $cjmsg);
$cjmsg = str_replace(":blink","<img src=\"e/rolleyes.gif\">", $cjmsg);
$cjmsg = str_replace(":o","<img src=\"e/suprised.gif\">", $cjmsg);
$cjmsg = str_replace(":?","<img src=\"e/question.gif\">", $cjmsg);
$cjmsg = str_replace(":s","<img src=\"e/confused.gif\">", $cjmsg);
$cjmsg = str_replace("B)","<img src=\"e/cool.gif\">", $cjmsg);
$cjmsg = str_replace(":red","<img src=\"e/redface.gif\">", $cjmsg);
$cjmsg = str_replace("\n","", $cjmsg); // fixed this bug, str_replace seems to stick in random \n's and \r's
$cjmsg = str_replace("\r","", $cjmsg);
}
// ...but not today
// Bad Word Filter function
foreach($badword_array as $insult=>$ok){
$cjmsg = eregi_replace("$insult", "$ok", "$cjmsg");
}
foreach($badword_array as $insult=>$ok){
$name = eregi_replace("$insult", "$ok", "$name");
}
// End
// Main Program can (finally) start! ------------------//
if (!$name || !$cjmsg){
header("location: $display");
}
else $name .= ":";
$person = $name;
$name = "<img src=\"e/ip.gif\" border =\"0\"> $person";
// does anyone actually read these comment tags? discuss - webmaster@cj-design.com
if($stats == 1){
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
}
else{
$ip = getenv(REMOTE_ADDR);
}
$date = date("l d F - Y");
$time = date("g:i:s a");
// fixed bug below, instead of \n - use
which is the alt equivilant!
$write = "<small><b><a href=\"http://$url\" title=\"$person
IP: $ip
Date: $date
Time: $time\" target=\"_blank\">$name</a></b><br>$cjmsg<br></small>\r\n";
}
else{
$write = "<small><b><a href=\"http://$url\" target=\"_blank\">$name</a></b><br>$cjmsg<br></small>\r\n";
}
$tagomfile = file($datfile);
if ($cjmsg != "") {
if (strlen($cjmsg) < 2000) { // after converting smilies...
$fd = fopen ($datfile, "w");
$write = stripslashes($write);
fwrite ($fd, $write);
for ($count = 0; $count < $NUM_COMMENTS-1; $count++) {
fwrite ($fd, $tagomfile[$count]);
}
if($printall == 1){
$alltagomfile = file($datfileall);
$amount = count($alltagomfile);
$fdall = fopen ($datfileall, "w");
fwrite ($fdall, $write);
for ($counter = 0; $counter <= $amount+1; $counter++) {
fwrite ($fdall, $alltagomfile[$counter]);
}
fclose($fdall);
}
}
fclose($fd);
// Write the counter....
require("tagcount.txt");
$countfilename = "tagcount.txt";
$increment = $tagcount + 1;
$incrementoutput = "<? $" . "tagcount = " . $increment . "; ?>";
$countwrite = fopen($countfilename, "w");
fwrite ($countwrite, $incrementoutput);
fclose($countwrite);
}
// email the admin?
if($send_notify == "yes"){
$cjmsg = strip_tags($cjmsg); // strips potential smilies from tag
$recipient = "$yourname <$email>";
$subject = "You have been Tagged!";
$message = "$yourwebsite has been tagged!\nOn: $date - $time\n\nName: $ename\n\nMessage: $cjmsg";
$headers = "From: $ename <$email>\r\nReply-To: $email\r\n";
mail ($recipient, $subject, $message, $headers);
}
// else dont do anything to the data file
header("location: $display");
?>