################################################################################## # The Website Comments System, written by Andrea Cabibbo # ###### # # Version 1.0 # # # # # Redistribution is NOT allowed and will be actively # # # # # prosecuted by legal means ####### # # # If you find bugs or have suggestions, please contact # # # # # the author at the PHP Guestbook official home page: # # ###### # # # # http://www.cellbiol.com/scripts/free_php_guestbook/free_php_guestbook.html # ################################################################################## # The directory/folder containing this file should be set to a 777 permission. # The html guestbook file and the configuration files (conf.php) need at least a 666 permission for the script to work # THE CONFIGURATION VARIABLES ARE NOW IN THE include/conf.php FILE error_reporting(1); $global_conf="include/global_conf.php"; include $global_conf; $gbid=1; if($_POST['gbid']){$gbid=$_POST['gbid'];$gbid_in_post=1;}else{$gbid_in_post=0;} if($_GET['gbid']){$gbid=$_GET['gbid'];} $gbfolder="gbooks/gb".$gbid."/"; $gbconf=$gbfolder."gbconf.php"; $posts_dir="posts"; $posts_file=$gbfolder.$posts_dir."/".$posts_file_name; $logfile=$gbfolder.$posts_dir."/".$logfile_name; include $gbconf; include $used_language; include "include/classes.php"; include "include/functions.php"; include "include/mixvar.php";include "include/html/forms.php";include "include/html/mix_html.php"; $wlc=count(preg_split('/m\/s/',$wlf)); $date=EncodeMessage($date); $create_post_array='$post_array=array("post_id"=>$post_id,"gbid"=>$gbid,"name"=>$name,"email"=>$email,"message"=>$message,"date"=>$date,"ip_addr"=>$ip_addr,"show_email"=>$show_email,"show_message"=>$show_message,"approved"=>$approved);'; # GETTING THE VARIABLES POSTED THROUGH THE FORM(S) /* $docroot=$_SERVER['DOCUMENT_ROOT']; $referer=$_SERVER['HTTP_REFERER']; $refurl=parse_url($referer); $refpath=$docroot.$refurl["path"]; foreach ($urlcomps as $key=>$val){echo "The value of $key is $val
";} */ if($_POST['gbid']){$gbid=$_POST['gbid'];} elseif($_GET['gbid']){$gbid=$_GET['gbid'];} $show_email="yes"; if($_POST['show_email']){$show_email=$_POST['show_email'];} $show_message="yes"; if($_POST['show_message']){$show_message=$_POST['show_message'];} if($_POST['name']){$name=$_POST['name'];$name=CleanName($name);} if($_POST['email']){$email=$_POST['email']; $email=CleanEmail($email);$email=EncodeMessage($email);} if($_POST['message']) { $message=$_POST['message']; # MESSAGE $message = trim($message); if (function_exists('get_magic_quotes_gpc')){ $mq=get_magic_quotes_gpc(); if ($mq==1){ $message=stripslashes($message); } } //$message=stripslashes($message); $message=EncodeMessage($message); $message=ConvertToHtml ($message); if (preg_match('//'.i,$message)==1 AND preg_match('/<\/B>/'.i,$message)==0){$message=$message."";} if (preg_match('//'.i,$message)==0){$message=$message."";} if (preg_match('//'.i,$message)==0){$message=$message."";} if (preg_match('//'.i,$message)==1 AND preg_match('/<\/i>/'.i,$message)==0){$message=$message."";} } if($_POST['task']){$task=$_POST['task'];} elseif($_GET['task']){$task=$_GET['task'];} if($_POST['adpass']){$posted_pass=trim($_POST['adpass']);} if($_POST['imgverify']){$imgverify=$_POST['imgverify'];} if($_POST['random']){$random=$_POST['random'];$random = trim($random);} if($_POST['post_id']){$post_id=$_POST['post_id'];} # POST ID if($_GET['post_id']){$post_id=$_GET['post_id'];} if($_POST['approved']){$approved=$_POST['approved'];} $gb=new Guestbook($gbid); $wcs=new wcs; //#######//#######//#######//TASKS START HERE//#######//#######//#######//#######//####### if ($task=="postnm"){ # from the form in the html guestbook postnm=post new message $gbstatus=GetGBStatus($gbidsfile,$gbid); if ($gbstatus=="b"){die ("Comments for this page were temporarily disabled - Back");} if ($gbid_in_post==0){die("The posting form does not contain a field for the guestbook id, check your form html - Back");} $all_ids=GetGBids($gbidsfile); $gbcheck=0; foreach ($all_ids as $value){ if ($value==$gbid){$gbcheck=1;break;} } if ($gbcheck==0){die ("You are apparently posting from a guestbook with the following id: $gbid, that does not exist on this Comments System - Back");} # Checking for missing name or message if ($name==''){die($nam_field_empty);}# the script stops if the name is missing if (count($name)>40){die ("The name is too long");} if (count($email)>40){die ("The e-mail is too long");} if ($message==''){die($mes_field_empty);}# the script stops if the message is missing # Checking the overall message length if (strlen($message)>$max_message_length){die ($mes_too_long);} # CHECKING FOR TOO LONG WORDS THAT COULD BREAK THE PAGE DESIGN if (CheckLongWords($message, $max_word_length)==0){die ($mes_word_too_long);} ##### CHECK TO SEE IF THE POSTER IS ADMIN #### $resnam_array=array(); $resnam_array[]=$reserved_name; #$resnam_array[]="another name"; # to add more reserved names/admin names for posting, create a line like this one for each name you want to add. Of course uncomment the line to activate #$resnam_array[]="Alexander"; # to add more reserved names/admin names for posting, create a line like this one for each name you want to add. Of course uncomment the line to activate $check_name=CheckForForbidden($name,$resnam_array); #if ($name==$reserved_name and $activate_res_name==1){ if ($check_name==0 and $activate_res_name==1){ eval("\$adm_verif_form = \"$admin_verif_form\";"); echo $adm_verif_form; } elseif ($enable_image_verification_step==1){ //if ($use_sessions==1){session_unset();session_start();} //session_unset(); session_start(); //echo "the new string is ".$_SESSION['new_string']."
"; //$new_string=CreateCaptchaImage(); //if ($use_sessions==1){$_SESSION['new_string'] = $new_string;} echo "
";
//$_SESSION['new_string'] = '';
echo "";
//echo "the new string is ".$_SESSION['new_string']."
";
//echo"
";
//$new_string=CreateCaptchaImage();
//if ($use_sessions==1){session_unset();session_start();}
//if ($use_sessions==1){$_SESSION['new_string'] = $new_string;}
//echo "the session new string is ".$_SESSION['new_string'];
echo "
$type_captcha_code
";
eval("\$captcha_form = \"$captcha_form\";");
echo "$captcha_form";
echo "
$wcs_login_foot";
}
elseif ($enable_image_verification_step==0){
$check=1;
$check_name=CheckForForbidden($name,$forbidden_strings);
$check_mail=CheckForForbidden($email,$forbidden_strings);
$check_message=CheckForForbidden($message,$forbidden_strings);
$check_ip=CheckForForbidden($ip_addr,$forbidden_strings);
if ($check_name==0 OR $check_mail==0 OR $check_message==0 OR $check_ip==0){$check=0;}
if ($check==1){
if ($moderation_active=="yes"){$approved="no";}
else{$approved="yes";}
$post_id=GetNextAvailableId($posts_file);
eval ($create_post_array);
$post=new Post($post_array);
#$post->SetThisVarsFromPostArray($post_array);
#$gb=new Guestbook;
$gb->AddPost($post_array);
$message=$post->RemoveBreaks($message);
$post_log=$post->MailLogLine("log");
$mail_log=$post->MailLogLine();
writelog($logfile,$post_log);
if ($sendmail_onpost==1){
if ($moderation_active=="no"){
eval("\$email_mssg1 = \"$email_mssg1\";");
msendmail($gbook_email,$admin_email,$email_subj1,$email_mssg1);
}
elseif ($moderation_active=="yes"){
eval("\$email_mssg1 = \"$email_mssg3\";");
msendmail($gbook_email,$admin_email,$email_subj3,$email_mssg1);
}
}
echo($confirm);
}
else{
echo($confirm2);
if ($sendmail_onspam==1){
eval("\$email_mssg2 = \"$email_mssg2\";");
msendmail($gbook_email,$admin_email,$email_subj2,$email_mssg2);
}
}
} # end "if captcha disabled"
} # END if task=postnm
elseif ($task=="ForceDelete"){
session_start();
if ($_SESSION['adm_pass']==$admin_pass OR $posted_pass==$admin_pass){
$_SESSION['adm_pass']=$admin_pass;
$wcs->DeleteGuestbook($gbid);
echo "Guestbook number $gbid Deleted
"; } else{ echo "$admin_pag_style\n"."$wcs_login_head
"; echo "