// define the variables
$postIndex = "board.html"; // Web page that indexes all posts
$templateFile = "template.txt"; // text file that stores the template for posts
$templatemess = "tempmess.txt"; // template for wiev messages
$numberFile = "noposts.txt"; // text file that stores the number of posts
$postingOrder = 0; // 0 for most to least recent; 1 for least to most recent
// DO NOT EDIT BELOW THIS POINT UNLESS YOU KNOW PHP! //
// if necessary info is not provided, print an error message
if ($name == "" || $message == "") {
echo "\n";
echo "
\n";
echo "";
exit;
}
// get rid of those "magic quotes"
$name = stripslashes($name);
$subject = stripslashes($subject);
$message = stripslashes($message);
// get the currrent post number
$fp_postno = fopen($numberFile, "r");
$number = fread($fp_postno, filesize($numberFile));
fclose($fp_postno);
// increment the number
$number++;
// save the new post number
$fp_postno = fopen($numberFile, "w");
fputs($fp_postno, $number);
fclose($fp_postno);
// get the date and time
$datetime = date('d.m.Y G:i');
// if an e-mail address is provided, include it in the "stamp"
if ($email != "") {
$stamp = "$email - $datetime \n";
}
// otherwise, just include the name and date and time
else {
$stamp = "$name - $datetime\n";
}
// strip HTML and PHP tags from the subject
$subject = strip_tags($subject);
$message = strip_tags($message, "");
// create the post entry for the index
if (isset($reply)) {
if ($postingOrder) {
$post = "
$name a scris.. \n";
$post .= $datetime;
$post .= "";
}
}
// get the lines of the post index
$lines = file($postIndex);
// replace the appropriate post tag with the post entry
if (isset($reply)) {
$lines = preg_replace("//", $post, $lines);
}
else {
$lines = preg_replace("//", $post, $lines);
}
// put all the lines back into a file
$file = join("", $lines);
// add the new post entry to the index
$fp_index = fopen($postIndex, "w");
fputs($fp_index, $file);
fclose($fp_index);
// get the post template
$template = file($templatemess);
// replace newline characters with the HTML break tag
$message = preg_replace("/\n/", " ", $message);
// replace the tags with the actual data
$template = preg_replace("//", $subject, $template);
$template = preg_replace("//", "$message ", $template);
$template = preg_replace("//", $stamp, $template);
$template = preg_replace("//", $number, $template);
// put all the lines back into a file
$file = join("", $template);
// create the new post page
$fp_post = fopen("messages/$number.html", "w");
fputs($fp_post, $file);
fclose($fp_post);
?>
Mesaj receptionat. Va multumim! Pentru a vizualiza mesajul click Inapoi si dati un Refresh la pagina.