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, "

"); $formstring = eregi_replace("", "", $formstring); $formstring = eregi_replace("", "", $formstring); $formstring = eregi_replace("", "", $formstring); } } else { $formstring = strip_tags($formstring); } if (($emotion == "yes" || $smileypics != 0) && $what == "text") { $formstring = ereg_replace(":)", "", $formstring); $formstring = ereg_replace(":-)", "", $formstring); $formstring = ereg_replace(";)", "", $formstring); $formstring = ereg_replace(";-)", "", $formstring); $formstring = ereg_replace(":\(", "", $formstring); $formstring = ereg_replace(":-\(", "", $formstring); $formstring = eregi_replace(":p", "", $formstring); $formstring = eregi_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); } if ($what == "url") { if (strtolower(substr($formstring, 0, 7)) != "http://") $formstring = "http://"."$formstring"; if (strtolower($formstring) == "http://") $formstring = ""; } elseif ($what == "text") { $formstring = eregi_replace("
\r\n", "
", $formstring); $formstring = eregi_replace("

\r\n", "

", $formstring); $formstring = ereg_replace("\r\n", "
", $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("<", "&lt;", $formstring); $formstring = eregi_replace(">", "&gt;", $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 "



The entry is out of range!
"; Unlock(); exit(); } $input = fopen("../data/index.dat", "r") or die ("Can't open index.dat for reading!"); fseek($input, ($entry * $indexsize), SEEK_SET); $datapos = (int)fgets($input, $indexsize + 1); fclose($input); $input = fopen("../data/data.dat", "r") or die ("Can't open data.dat for reading!"); fseek($input, $datapos, SEEK_SET); $name = rtrim(stripslashes(substr(fgets($input, 1024), 5))); $mail = rtrim(stripslashes(substr(fgets($input, 1024), 5))); $icq = rtrim(stripslashes(substr(fgets($input, 1024), 4))); $aim = rtrim(stripslashes(substr(fgets($input, 1024), 4))); $url = rtrim(stripslashes(substr(fgets($input, 1024), 4))); $text = rtrim(stripslashes(substr(fgets($input, 16384), 5))); $date = fgets($input, 1024); $ip = rtrim(stripslashes(substr(fgets($input, 1024), 3))); $text .= "
--------------------
"; $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 "



The entry is out of range!
"; exit(); } $position = $entry * $indexsize; if ($datacount == $entry) { fseek($input, $position - $indexsize); } else { for ($i = 0; $i < $datacount - $entry; $i++) { fseek($input, $position + ($i * $indexsize)); $buffer = fgets($input, $indexsize + 1); fseek($input, $position + (($i - 1) * $indexsize)); fputs($input, $buffer, $indexsize); } } ftruncate($input, ftell($input)); fclose($input); if (isset($page)) { header ("Location: ../guestbook.php?act=show&page=$page"); } else { Show_Menu($login); } } } elseif ($act == "deleterange") { if (!isset($first) || !isset($last)) { if (!file_exists("deleterange.html")) die ("Can't open deleterange.html!"); include("deleterange.html"); } else { $input = fopen("../data/index.dat", "r+") or die ("The file index.dat is write protected!"); $datacount = filesize("../data/index.dat") / $indexsize; if (($first - 1) < 0 || ($last - 1) > $datacount || $first > $last) { Show_Menu($login); echo "



The values are out of range!
"; exit(); } $position_first = $first * $indexsize; $position_last = $last * $indexsize; if ($datacount == $last) { fseek($input, $position_first - $indexsize); } else { for ($i = 0; $i < $datacount - $first - ($last - $first); $i++) { fseek($input, $position_last + ($i * $indexsize)); $buffer = fgets($input, $indexsize + 1); fseek($input, $position_first + (($i - 1) * $indexsize)); fputs($input, $buffer, $indexsize); } } ftruncate($input, ftell($input)); fclose($input); Show_Menu($login); } } elseif ($act == "editfilter") { if (!isset($do)) { $input = fopen("../data/wordfilter.dat", "r") or die ("Can't open wordfilter.dat for reading!"); $filter = ""; while (!feof($input)) { $filter .= trim(fgets($input, 1024))." "; } fclose($input); if (!file_exists("editfilter.html")) die ("Can't open editfilter.html!"); include("editfilter.html"); } else { $filter = explode(" ", trim($wordfilter)); $output = fopen("../data/wordfilter.dat", "w") or die ("Can't open wordfilter.dat for writing!"); for ($i = 0; $i < count($filter); $i++) { if ($filter[$i] != "") fputs($output, rtrim($filter[$i])."\r\n"); } fclose($output); Show_Menu($login); } } elseif ($act == "changeconfig") { if (!isset($do)) { if (!file_exists("changeconfig.html")) die ("Can't open changeconfig.html!"); include("changeconfig.html"); } else { $output = fopen("../config.php", "w") or die ("Can't open config.php for writing!"); fputs($output, rtrim("")."\r\n"); fclose($output); Show_Menu($login); } } elseif ($act == "newdatabase") { if (!isset($do)) { if (!file_exists("newdatabase.html")) die ("Can't open newdatabase.html!"); include("newdatabase.html"); } else { set_time_limit(300); $input = fopen("../data/index.dat", "r+") or die ("Can't open index.dat for reading!"); $input1 = fopen("../data/data.dat", "r+") or die ("Can't open data.dat for reading!"); mt_srand((double)microtime()*1000000); $random = mt_rand(0, 1000); while (file_exists("../temp/temp".$random.".dat")) { $random = mt_rand(0, 1000); } while (file_exists("../temp/temp".$random1.".dat")) { $random1 = mt_rand(0, 1000); } $output = fopen("../temp/temp".$random.".dat", "w") or die ("Can't create temp".$random.".dat!"); $output1 = fopen("../temp/temp".$random1.".dat", "w") or die ("Can't create temp".$random1.".dat!"); $datacount = filesize("../data/index.dat") / $indexsize; for ($i = 0; $i < $datacount; $i++) { $position = (string)ftell($output1); $dummy = ""; for ($n = strlen($position); $n < $indexsize; $n++) $dummy .= "0"; $position = $dummy.$position; fputs($output, $position); $datapos = (int)fgets($input, $indexsize + 1); fseek($input1, $datapos, SEEK_SET); $name = fgets($input1, 1024); $mail = fgets($input1, 1024); $icq = fgets($input1, 1024); $aim = fgets($input1, 1024); $url = fgets($input1, 1024); $text = fgets($input1, 16384); $date = fgets($input1, 1024); $ip = fgets($input1, 1024); fputs($output1, rtrim($name)."\r\n"); fputs($output1, rtrim($mail)."\r\n"); fputs($output1, rtrim($icq)."\r\n"); fputs($output1, rtrim($aim)."\r\n"); fputs($output1, rtrim($url)."\r\n"); fputs($output1, rtrim($text)."\r\n"); fputs($output1, rtrim($date)."\r\n"); fputs($output1, rtrim($ip)."\r\n"); } fclose($input); fclose($input1); unlink("../data/index.dat"); unlink("../data/data.dat"); fclose($output); fclose($output1); rename("../temp/temp".$random.".dat", "../data/index.dat"); rename("../temp/temp".$random1.".dat", "../data/data.dat"); Show_Menu($login); } } } else { setcookie("GuestbookAdmin", "", time() - 3600, "/"); if (!file_exists("error.html")) die ("Can't open error.html!"); include("error.html"); } Unlock(); ob_end_flush(); ?>
Картаdra nzb i7 zi9 yh88 bog golos bog golos kone8 kon27
rss
Карта