} # End of function - Display Footer
/*
*
* Function: Display Thank You
*
*/
function displaythankyou() {
global $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor, $homepage_title, $homepage_url, $thankyou_msg, $lang;
?>
echo $lang[20] ?>
echo $thankyou_msg ?>
} # End of function - Display Thank You
/*
*
* Function: Validate e-mail address
*
*/
function checkmail ($email) {
if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email)) {
return true;
} else {
return false;
}} # End of function - Validate e-mail address
/*
*
* Function: Display Error Message
*
*/
function errormsg($errortitle,$message) {
global $bodycolor, $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor;
displayheader($errortitle);
?>
echo $errortitle ?> echo $message ?>
displayfooter();
exit;
} # End of function - Display Error Message
/*
*
* Function: Check IP Log
*
*/
function checkiplog($ipaddress) {
global $ipcheck, $datapath;
$filename = $datapath . 'ip_log.dat';
if ($fp = fopen($filename, 'r')) { # File opened for reading
$lock = flock($fp, LOCK_SH);
if ($lock) { # Lock achived
for ($i = 0; $i <= 24; $i++) { $iplist[$i] = fgets($fp, 16); } # Read in IPs
$lock = flock($fp, LOCK_UN);
} # End If - Lock achived
fclose($fp);
} # End If - File opened for reading
$targetip = $ipaddress . "\n";
$ipcount = 0;
for ($i = 0; $i <= 24; $i++) { if ( $targetip == $iplist[$i] ) { $ipcount++; } }
if ( $ipcount < $ipcheck ) { # Update IP log
if ($fp = fopen($filename, 'w')) { # File opened for writing
$lock = flock($fp, LOCK_EX);
if ($lock) { # Lock achived
fwrite( $fp, $targetip ); # Write new IP
for ($i = 0; $i <= 23; $i++) { fwrite( $fp, $iplist[$i] ); } # Write remaining IPs
flock($fp, LOCK_UN);
} # End If - Lock achived
fclose($fp);
} # End If - File opened for writing
return "pass";
} else { return "fail"; }
} # End of function - IP Check
/*
*
* Function: E-mail Notification
*
*/
function notification($recordnumber,$record_data) {
global $notifications, $notification_email, $webmaster_email, $guestbookname, $displayadd1, $displayadd2, $displayadd3,
$displayuin, $adminurl;
if ($notifications == "true" AND $notification_email != "") { # Send notification e-mail(s)
$linebreak = chr(13) . "\n"; # Linebreak & line feed characters.
$breakchar = chr(13);
$data = explode("|", $record_data);
$record_name = stripslashes(reversehtmlspecialchars($data[0]));
$record_date = stripslashes(reversehtmlspecialchars($data[1]));
$record_email = stripslashes(reversehtmlspecialchars($data[2]));
$record_url = stripslashes(reversehtmlspecialchars($data[3]));
$record_website = stripslashes(reversehtmlspecialchars($data[4]));
$record_icq = stripslashes(reversehtmlspecialchars($data[5]));
$record_found = stripslashes(reversehtmlspecialchars($data[6]));
$record_location = stripslashes(reversehtmlspecialchars($data[7]));
$record_comments = stripslashes(reversehtmlspecialchars($data[8]));
$record_ipaddress = stripslashes(reversehtmlspecialchars($data[9]));
$record_remotehost = stripslashes(reversehtmlspecialchars($data[10]));
$record_question1 = stripslashes(reversehtmlspecialchars($data[11]));
$record_question2 = stripslashes(reversehtmlspecialchars($data[12]));
$record_question3 = stripslashes(reversehtmlspecialchars($data[13]));
$record_answer1 = stripslashes(reversehtmlspecialchars($data[14]));
$record_answer2 = stripslashes(reversehtmlspecialchars($data[15]));
$record_answer3 = stripslashes(reversehtmlspecialchars($data[16]));
$guestbooknamestripped = stripslashes(reversehtmlspecialchars($guestbookname));
$record_uid = stripslashes($data[18]);
$record_comments = str_replace($breakchar, "",$record_comments); # Strip linebreaks.
$record_comments = str_replace("\n", "",$record_comments); # Strip linefeeds.
$record_comments = str_replace(" ",$linebreak, $record_comments); # Convert to linebreaks.
$from = $webmaster_email; if ($record_email != "") { $from = "$record_name <$record_email>"; } # Use guest's e-mail of available
$message = "New Addition to $guestbooknamestripped $linebreak $linebreak";
$message .= "Name: $record_name $linebreak";
if ($record_email != "") { $message .= "E-mail: $record_email $linebreak"; }
if ($record_website != "") { $message .= "Website: $record_website $linebreak"; }
if ($record_url != "") { $message .= "URL: $record_url $linebreak"; }
if ($record_icq != "") { $message .= "UIN: $record_icq $linebreak"; }
if ($record_found != "") { $message .= "Found: $record_found $linebreak"; }
if ($record_location != "") { $message .= "Location: $record_location $linebreak"; }
$message .= "$linebreak";
if ($record_answer1 != "") { $message .= "$record_question1
$record_answer1 $linebreak $linebreak"; }
if ($record_answer2 != "") { $message .= "$record_question2
$record_answer2 $linebreak $linebreak"; }
if ($record_answer3 != "") { $message .= "$record_question3
$record_answer3 $linebreak $linebreak"; }
if ($record_comments != "") { $message .= "Comment:
$record_comments $linebreak $linebreak"; }
$message .= "
Record #: $recordnumber
Date: $record_date
IP Address: $record_ipaddress
Remote Host: $record_remotehost
To edit, delete or add a comment to this post, click on the following URL:
$adminurl?action=uidsearch&uid=$record_uid&page=0
";
# Send e-mail
mail ("$notification_email", "New Addition to $guestbooknamestripped",$message,"From: $from");
} # End If - Send notification e-mail(s)
} # End of function - E-mail Notification
/*
*
* Function: Sign Guestbook
*
*/
function signguestbook() {
global $addquestion1, $displayadd1, $addquestion2, $displayadd2, $addquestion3, $displayadd3, $displayuin, $displayemail,
$foundoptions, $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor, $homepage_title, $homepage_url, $webmaster_email,
$welcome_msg, $browser, $lang;
$halflength = "33"; if ($browser == "MSIE") { $halflength = "37"; } # Adjust input box length for IE
$fulllength = "70"; if ($browser == "MSIE") { $fulllength = "79"; } # Adjust input box length for IE
$new_name = ""; $record_name = "";
$new_date = ""; $record_date = "";
$new_email = ""; $record_email = "";
$new_url = ""; $record_url = "";
$new_website = ""; $record_website = "";
$new_icq = ""; $record_icq = "";
$new_found = ""; $record_found = "";
$new_location = ""; $record_location = "";
$new_comments = ""; $record_comments = "";
$new_ipaddress = ""; $record_ipaddress = "";
$new_remotehost = ""; $record_remotehost = "";
$new_question1 = $addquestion1;
$new_question2 = $addquestion2;
$new_question3 = $addquestion3;
$new_answer1 = ""; $record_answer1 = "";
$new_answer2 = ""; $record_answer2 = "";
$new_answer3 = ""; $record_answer3 = "";
$new_adminmsg = ""; $record_adminmsg = "";
displayheader($lang[21]);
?>
displayfooter();
exit;
} # End of function - Sign Guestbook
/*
*
* Function: Preview
*
*/
function preview ($record_data) {
global $displayadd1, $displayadd2, $displayadd3, $displayuin, $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor,
$homepage_title, $homepage_url, $webmaster_email, $notifications, $totalrecords, $lang;
$record_number = "TBA";
$data = explode("|", $record_data);
$record_name = stripslashes($data[0]);
$record_date = stripslashes($data[1]);
$record_email = stripslashes($data[2]);
$record_url = stripslashes($data[3]);
$record_website = stripslashes($data[4]);
$record_icq = stripslashes($data[5]);
$record_found = stripslashes($data[6]);
$record_location = stripslashes($data[7]);
$record_comments = stripslashes($data[8]);
$record_ipaddress = stripslashes($data[9]);
$record_remotehost = stripslashes($data[10]);
$record_question1 = stripslashes($data[11]);
$record_question2 = stripslashes($data[12]);
$record_question3 = stripslashes($data[13]);
$record_answer1 = stripslashes($data[14]);
$record_answer2 = stripslashes($data[15]);
$record_answer3 = stripslashes($data[16]);
$record_adminmsg = stripslashes($data[17]);
$breakchar = chr(13);
$linebreak = chr(13) . "\n"; # Linebreak & line feed characters.
$record_comments = str_replace($breakchar, "",$record_comments); # Strip linebreaks.
$record_comments = str_replace("\n", "",$record_comments); # Strip linefeeds.
$record_adminmsg = str_replace($breakchar, "",$record_adminmsg); # Strip linebreaks.
$record_adminmsg = str_replace("\n", "",$record_adminmsg); # Strip linefeeds.
/* Check for missing or incorrect data. */
if ( $record_name == "" ) { errormsg($lang[23],$lang[24]); }
if ( $record_email != "" ) { # Check for e-mail
if (checkmail($record_email) != 1) {
errormsg($lang[23],$lang[25]); }
} # End If - Check for e-mail
if ( $record_comments == "" ) { errormsg($lang[23],$lang[26]); }
if ( $record_url != "" ) { # Check for URL
if ( strtolower(substr($record_url, 0, 7)) != "http://" ) { $record_url = "http://" . $record_url; } # Add http tag to URL if it's missing.
if ( strtolower(substr($record_url, 0, 14)) == "http://http://" ) { $record_url = substr($record_url, 7); } # Remove "double" http://
} # End If - Check for URL
/* Check for double post */
if ($totalrecords > 0) { # - Check for double post
$last_record = loadrecord($totalrecords);
$last_data = explode("|", $last_record);
if ( $data[0] == $last_data[0] AND $data[8] == $last_data[8] )
{ errormsg($lang[23],"$lang[27] $lang[28]"); }
} # End If - Check for double post
displayheader($lang[29]);
?>
echo $lang[29] ?> echo $lang[30] ?>
include("display_template.php"); # Use template to display guestbook entry
$record_comments = str_replace(" ",$linebreak, $record_comments); # Convert to linebreaks.
$record_adminmsg = str_replace(" ",$linebreak, $record_adminmsg); # Convert to linebreaks.
?>
displayfooter();
exit;
} # End of function - Preview
/*
*
* Function: Display Record
*
*/
function displayrecord ($record_number, $record_data, $page) {
global $displayadd1, $displayadd2, $displayadd3, $displayuin, $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor, $lang;
$data = explode("|", $record_data);
$record_name = stripslashes($data[0]);
$record_date = stripslashes($data[1]);
$record_email = stripslashes($data[2]);
$record_url = stripslashes($data[3]);
$record_website = stripslashes($data[4]);
$record_icq = stripslashes($data[5]);
$record_found = stripslashes($data[6]);
$record_location = stripslashes($data[7]);
$record_comments = stripslashes($data[8]);
$record_ipaddress = stripslashes($data[9]);
$record_remotehost = stripslashes($data[10]);
$record_question1 = stripslashes($data[11]);
$record_question2 = stripslashes($data[12]);
$record_question3 = stripslashes($data[13]);
$record_answer1 = stripslashes($data[14]);
$record_answer2 = stripslashes($data[15]);
$record_answer3 = stripslashes($data[16]);
$record_adminmsg = stripslashes($data[17]);
# $record_email = ""; # Do not display e-mail to public.
$breakchar = chr(13);
$record_adminmsg = str_replace($breakchar, "",$record_adminmsg); # Strip linebreaks.
$record_adminmsg = str_replace("\n", "",$record_adminmsg); # Strip linefeeds.
include("display_template.php"); # Use template to display guestbook entry
print " \n";
} # End of function - Display Record
/*
*
* Function: Display Page
*
*/
function displaypage ($page) {
global $perpage, $totalrecords;
/* Calculate range of records on this page. */
if ($totalrecords == 0) { $totalpages = 0; }
else { $totalpages = intval(($totalrecords - 1) / $perpage) + 1; } # Calculate how many pages there are.
$end = $totalrecords - (($totalpages - $page) * $perpage);
$start = $end - ($perpage - 1); if ($start < 1) { $start = 1; }
$records = loadrange($start,$end);
$recordindex = sizeof($records);
for ($i = $end;$i >= $start;$i--) { displayrecord($i,$records[$recordindex],$page); $recordindex--; }
} # End of function - Display Page
/*
*
* Function: Opening Screen
*
*/
function openingscreen($page) {
global $perpage, $bordercolor, $tablecolor, $barcolor, $textcolor, $bartextcolor, $guestbookname, $homepage_title, $guestbookbannerurl,
$signguestbookurl1, $signguestbookurl2, $homepage_url, $webmaster_email, $totalrecords, $confirm, $lang;
if ($totalrecords == 0) { $totalpages = 0; }
else { $totalpages = intval(($totalrecords - 1) / $perpage) + 1; } # Calculate how many pages there are.
if ($page == "" OR $page > $totalpages) { $page = $totalpages; }
$currentpage = $page;
displayheader("$guestbookname");
if ($guestbookbannerurl != "") { print "
\n"; } # Display banner or text
else { print "
\n";
print "
\n";
print "
$guestbookname\n";
print "
\n";
} # End If - Display banner or text
if ($homepage_title != "" AND $homepage_url != "" AND $homepage_url !="http://" ) { # Display a link back to homepage
?>