This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this package; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
ob_start();
error_reporting(0);
$i = 0;
while (file_exists("../data/data.lck") || file_exists("../data/index.lck")) {
usleep(500000);
$i++;
if ($i > 19) die ("User activities in progress! Please wait a little bit and try it again!");
}
if (!ignore_user_abort()) ignore_user_abort(true);
if (!file_exists("../config.php")) die ("Can't open config.php!");
include("../config.php");
if ((!isset($GuestbookAdmin) || md5($GuestbookAdmin) != $adminpass) && isset($login)) {
if (md5($login) == $adminpass)
$cookielifetime = ($cookielifetime > 31536000) ? 31536000 : $cookielifetime;
setcookie("GuestbookAdmin", $login, time() + $cookielifetime, "/");
} else {
if (isset($GuestbookAdmin) && md5($GuestbookAdmin) == $adminpass)
$login = $GuestbookAdmin;
}
register_shutdown_function("Unlock");
if (!file_exists("../data/lock.lck")) {
$lock = fopen("../data/lock.lck", "w") or die ("Can't create lock.lck!");
fclose($lock);
}
function Unlock($errno = 0, $errstr = "") {
if (file_exists("../data/lock.lck")) unlink("../data/lock.lck");
exit();
}
function Format_String(&$formstring, $emotion, $what) {
$formstring = trim($formstring);
if ($what == "text") {
$formstring = strip_tags($formstring, "
\r\n", " ", $formstring);
$formstring = ereg_replace("\r\n", "
\r\n", "
", $formstring);
$formstring = eregi_replace("
", $formstring);
}
}
function Format_String1(&$formstring) {
$formstring = ereg_replace("", ":)", $formstring);
$formstring = ereg_replace("", ";)", $formstring);
$formstring = ereg_replace("", ':(', $formstring);
$formstring = ereg_replace("", ":p", $formstring);
$formstring = ereg_replace("", ":o", $formstring);
$formstring = ereg_replace("", ":cool:", $formstring);
$formstring = ereg_replace("", ":D", $formstring);
$formstring = ereg_replace("", ":confused:", $formstring);
$formstring = ereg_replace("", ":eek:", $formstring);
$formstring = ereg_replace("", ":mad:", $formstring);
$formstring = ereg_replace("", ":rolleyes:", $formstring);
$formstring = eregi_replace("<", "<", $formstring);
$formstring = eregi_replace(">", ">", $formstring);
}
function Show_Menu(&$login) {
if (!file_exists("menu.html")) die ("Can't open menu.html!");
include("menu.html");
}
if (!isset($login)) {
if (!file_exists("login.html")) die ("Can't open login.html!");
include("login.html");
}
elseif (md5($login) == $adminpass) {
if (!isset($act)) {
Show_Menu($login);
}
elseif ($act == "changeentry") {
if (!isset($entry)) {
if (!file_exists("changeentry_a.html")) die ("Can't open changeentry_a.html!");
include("changeentry_a.html");
}
elseif (isset($entry) && !isset($do)) {
$datacount = filesize("../data/index.dat") / $indexsize;
if (--$entry < 0 || $entry > $datacount) {
Show_Menu($login);
echo "
--------------------
";
$text = ereg_replace("
", "\r\n", $text);
fclose($input);
Format_String1($name);
Format_String1($mail);
Format_String1($icq);
Format_String1($aim);
Format_String1($url);
Format_String1($text);
if (!file_exists("changeentry_b.html")) die ("Can't open changeentry_b.html!");
include("changeentry_b.html");
}
elseif (isset($entry) && $do == "write") {
if ($language == "eng") {
$newdate = strftime("%m.%d.%Y %H:%M", time());
} else {
$newdate = strftime("%d.%m.%Y %H:%M", time());
}
Format_String($newname, $emotion, "name");
Format_String($newmail, $emotion, "mail");
Format_String($newicq, $emotion, "icq");
Format_String($newaim, $emotion, "aim");
Format_String($newurl, $emotion, "url");
Format_String($newtext, $emotion, "text");
$output = fopen("../data/data.dat", "a") or die ("The file data.dat is write protected!");
$output1 = fopen("../data/index.dat", "r+") or die ("The file index.dat is write protected!");
fseek($output, 0, SEEK_END); #fix for windows?!?!
$position = (string)ftell($output);
fputs($output, rtrim("name=".$newname)."\r\n");
fputs($output, rtrim("mail=".$newmail)."\r\n");
fputs($output, rtrim("icq=".$newicq)."\r\n");
fputs($output, rtrim("aim=".$newaim)."\r\n");
fputs($output, rtrim("url=".$newurl)."\r\n");
fputs($output, rtrim("text=".$newtext)."\r\n");
fputs($output, rtrim("date=".$newdate)."\r\n");
fputs($output, rtrim("ip=".$newip)."\r\n");
for ($i = strlen($position); $i < $indexsize; $i++)
$dummy .= "0";
$position = $dummy.$position;
fseek($output1, ($entry * $indexsize), SEEK_SET);
fputs($output1, $position, $indexsize);
fclose($output);
fclose($output1);
if (isset($page)) {
header ("Location: ../guestbook.php?act=show&page=$page");
} else {
Show_Menu($login);
}
}
}
elseif ($act == "deleteentry") {
if (!isset($entry)) {
if (!file_exists("deleteentry.html")) die ("Can't open deleteentry.html!");
include("deleteentry.html");
}
elseif (isset($page) && !isset($warning)) {
if (!file_exists("warning.html")) die ("Can't open warning.html!");
include("warning.html");
}
elseif (isset($page) && !$warning) {
header ("Location: ../guestbook.php?act=show&page=$page");
} else {
$input = fopen("../data/index.dat", "r+") or die ("The file index.dat is write protected!");
$datacount = filesize("../data/index.dat") / $indexsize;
if (($entry - 1) < 0 || ($entry - 1) > $datacount) {
Show_Menu($login);
echo "