Location: PHPKode > projects > Free Blog Creator > freeblog/form.php

<?php
$Log=@file("./log/basic2.cgi");
$line=explode(",",$Log[0]);
$delivfree=$line[0];
$delivmail=$line[1];
$commentname=$line[2];
$commentemail=$line[3];
$commentlink=$line[4];
$commenttext=$line[5];
$tblink=$line[6];
$arrip=$line[7];
$arrtext=$line[8];

if($arrip){
$ip = getenv("REMOTE_ADDR");
$iline = explode("<br />",$arrip);
for($i = 0; $i < count($iline); $i++) {
if (ereg($iline[$i], $ip)) {
$preview1 .= 'err<br>';
$flag = 1;
}
}
}
if($arrtext){

$tline = explode("<br />",$arrtext);
for($i = 0; $i < count($tline); $i++) {
if (ereg($tline[$i], $_POST['name'])) {
$preview1 .= 'err<br>';
$flag = 1;
}
if (ereg($tline[$i], $_POST['email'])) {
$preview1 .= 'err<br>';
$flag = 1;
}
if (ereg($tline[$i], $_POST['link'])) {
$preview1 .= 'err<br>';
$flag = 1;
}
if (ereg($tline[$i], $_POST['text'])) {
$preview1 .= 'err<br>';
$flag = 1;
}
}
}
if($commentname==1){
if($_POST['name'] == '') {
$preview1 .= 'Please enter Your Name.<br>';
$flag = 1;
}
}
if($commentemail==1){
if($_POST['email'] == '') {
$preview1 .= 'Please enter E-mail.<br>';
$flag = 1;
}
}
if($commentlink==1){
if($_POST['link'] == '') {
$preview1 .= 'Please enter URL.<br>';
$flag = 1;
}
}	
if($commenttext==1){
if($_POST['text'] == '') {
$preview1 .= 'Please enter product name.<br>';
$flag = 1;
}
}
if($_POST['email'] != '') {
if (!preg_match('/^[a-zA-Z0-9_\.\-]+?@[A-Za-z0-9_\.\-]+$/',$_POST['email'])) {
$preview1 .= 'Email seems invalid.<br>';
$flag = 1;
}
}
if($_POST['link'] != '') {
if (!preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/',$_POST['link'])) {
$preview1 .= 'URL seems invalid.<br>';
$flag = 1;
}
}
if($_POST['text'] != '') {
$dumptext = (mb_strlen($_POST['text'], 'SJIS'));
if (10000 < $dumptext) {
$preview1 .= 'Please enter Prohibited IP that is less than or equal to 10000 characters.<br>';
$flag = 1;
}
}


$err = '';
if($preview1 != '') {
$err .= $preview1;
$flag = 1;
}
?>

<?php
if ($flag){
?>
<?=$err?>
<?php
}
?>

<?php
if (!$flag){
if($_POST['action'] == "preview"){
$name=$_POST['name'];
$email=$_POST['email'];
$link=$_POST['link'];
$text=$_POST['text'];

$name = strip_tags($name);
$text = strip_tags($text);
$text=nl2br($text);
$text=str_replace("\n","",$text);
$text=str_replace("\r","",$text);


print "Name: $name<br>";
print "E-mail: $email<br>";
print "URL: $link<br>";
print "Body: $text<br>";
}
}
?>

<?php
if (!$flag){ 
if($_POST['action'] == "send"){
$sid=$_POST['sid'];
$year = substr($sid, -4, 4);
$name=$_POST['name'];
$email=$_POST['email'];
$link=$_POST['link'];
$text=$_POST['text'];

$view = date("Y-m-d H:i");
$name = strip_tags($name);
$text=strip_tags($text);
$text = ereg_replace("(https?|ftp)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)", "<a href=\"\\1\\2\" target=\"_blank\" rel=\"nofollow\">\\1\\2</a>" , $text);
$text=nl2br($text);
$text=str_replace("\n","",$text);
$text=str_replace("\r","",$text);

if($delivfree==1){
$Host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$Useragent = $_SERVER['HTTP_USER_AGENT'];
$Referer = $_SERVER["HTTP_REFERER"];

$Subject="New Comment";

$Content = "";
$Content .= "Name: $name\n";
$Content .= "E-mail: $email\n";
$Content .= "URL: $link\n";
$Content .= "Body: $text\n";
$Content .= "IP: $ip\n";
$Content .= "Host: $Host\n";
$Content .= "Useragent: $Useragent\n";
$Content .= "Referer: $Referer\n";
$Content .= "----------------------------------------------\n";

$Log=@file(dirname(__FILE__)."/log/basic.cgi");
$line=explode(",",$Log[0]);
$httphost=$line[0];

$Text.="Archive:\n";
$Text.=$httphost."?sid=".$sid."\n";
$Sign.="\n--------------------\n";
$Sign.="$adminsign";
$Sign.="\n\n\n".$sign;
$Header2  = "From: $delivmail";
$Content2 .= "$Text\n";
$Content2 .= $Content;
$Content2 .= $Sign;
mb_send_mail($delivmail, $Subject, $Content2, $Header2);
}

$code = time();
$ip = getenv("REMOTE_ADDR");
$lines=array("$code","$sid","$year","$view","$name","$email","$link","$text","$ip","0","1");
$lines=implode("<>",$lines);
$lines=$lines."\n";

$fp=fopen("./log/comment/$year.cgi","a");
fputs($fp,$lines);	
fclose($fp);
chmod("./log/comment/$year.cgi",0666);



print "Your message has been sent.<br><br>";
}
}
?>
Return current item: Free Blog Creator