Be sure writing is allowed in this directory."; $langPassChanged = "The password has been changed."; $langPassError = "The new passwords don't match! "; $langPassword = "Change $langBsCal Password"; $langRetype = "Retype new Password: "; $langSubmit = "Send the entry"; $langSubmitModif = "Submit Modifications"; $langSystemError = "System Error"; $langSystemMessage = "System Message"; $langWrongPassword = "Wrong Admin Password"; $langNewEntry = "Add new entry to calendar"; $langEntMod = "Modify entries"; $langNewEnt2 = "Eventname is missing!
New entry not added."; $langUnknownErr = "Unknown Error!"; // FRENCH $langAdminError = "Erreur Administrateur"; $langBsCal = "Der Verlorene Haufen - Livre d'Or"; $langChPassword = "Changement de mot de passe"; $langEntry = "Message"; $langWhen = "Date"; $langWhere = "Place"; $langGbAdmin = "Administration"; $langMessage = "Message: "; $langName = "Nom"; $langnewPassword = "Nouveau mot de passe: "; $langOpenError = "Erreur d'ouverture de fichier!
Assurez-vous d'avoir les droits d'écriture."; $langPassChanged = "Le mot de passe a été changé."; $langPassError = "Les mots de passe ne correspondent pas."; $langPassword = "Changer le mot de passe de $langBsGuestbook"; $langRetype = "Confirmez le mot de passe: "; $langSubmit = "Envoyer le message"; $langSubmitModif = "Confirmer les modifications"; $langSystemError = "Erreur Système"; $langSystemMessage = "Message du Système"; $langWrongPassword = "Mauvais mot de passe"; $langNewEntry = "Add new entry to calendar"; $langEntMod = "Modify entries"; $langNewEnt2 = "Eventname is missing!
New entry not added."; $langUnknownErr = "Unknown Error!"; // ITALIAN $langAdminError = "Errore Amministratore"; $langBsCal = "Der Verlorene Haufen - Termine"; $langChPassword = "Cambia Password"; $langEntry = "Messagio"; $langWhen = "Data"; $langWhere = "Cittá/Paese"; $langGbAdmin = "Amministrazione"; $langMessage = "Istruzione"; $langName = "Convegni"; $langnewPassword = "Nuova password: "; $langOpenError = "Errore di apertura del file!
Assicurati che la directory abbia i permessi di scrittura."; $langPassChanged = "La password è stata cambiata."; $langPassError = "La nuova password non corrisponde!"; $langPassword = "Cambia la Password di $langBsGuestbook"; $langRetype = "Ripeti password: "; $langSubmit = "Invia il messaggio"; $langSubmitModif = "Invia modifiche"; $langSystemError = "Errore di sistema"; $langSystemMessage = "Messaggio di sistema"; $langWrongPassword = "Password Amministratore Errata"; $langNewEntry = "Add new entry to calendar"; $langEntMod = "Modify entries"; $langNewEnt2 = "Eventname is missing!
New entry not added."; $langUnknownErr = "Unknown Error!"; */ // GERMAN $langAdminError = "Administrator Fehler"; // Define title of your calender (it's included in -tag in the header). $langBsCal = "Terminkalender"; $langChPassword = "Ändere Passwort"; $langEntry = "Eintrag"; $langWhen = "Datum"; $langWhere = "Ort"; $langGbAdmin = "Kalender Administration"; $langMessage = "Bemerkung"; $langName = "Veranstaltung"; $langnewPassword = "Neues Passwort: "; $langOpenError = "Fehler beim öffnen der Datei! <br>Sind Sie sicher, dass Sie die richtigen Rechte für dieses Verzeichnis besitzen?"; $langPassChanged = "Neues Passwort OK."; $langPassError = "Das neue Password funktioniert nicht! "; $langPassword = "<i>$langBsCal</i> Passwort ändern"; $langRetype = "Wiederholen Sie das neue Passwort: "; $langSubmit = "Eintrag abschicken"; $langSubmitModif = "Änderungen abschicken"; $langSystemError = "System Fehler"; $langSystemMessage = "System Nachricht"; $langWrongPassword = "Falsches Administrator-Passwort"; $langNewEnt = "Neuen Kalendereintrag hinzufügen"; $langEntMod = "Einträge bearbeiten"; $langNewEnt2 = "Veranstaltungsname fehlt! <br>Neuen Kalendereintrag nicht hinzugefügt."; $langUnknownErr = "Unbekannter Fehler!"; //***************************************************************************** // Configuration Step 2 : Stylesheet, Design and optional JavaScript File //***************************************************************************** // Define Path and name of your css-file. $cssFile = "\"../program/css/main.css\""; //***************************************************************************** // Configuration Step 3 : Header //***************************************************************************** function displayHeader() { global $cssFile; global $langBsCal; header ("Expires: Sat, 01 Jan 2000 00:00:00 GMT"); // You migh use and include instead of all this : // include ("head.inc"); echo ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); echo ("<html><head>\n"); echo ("<title>$langBsCal\n"); if (isset($cssFile)) echo ("\n"); echo ("\n"); echo ("

$langBsCal

\n"); } //***************************************************************************** // Configuration Step 4 : Footer //***************************************************************************** function displayFooter() { echo ("\n"); } //***************************************************************************** // Configuration Step 5 : Number of messages displayed //***************************************************************************** // Number of fields to be displayed simultaneously. // To display everything, set $displayStep to 0. $displayStep = 0; //***************************************************************************** // Configuration Step 6 : Allow AutoLink System //***************************************************************************** $allowAutoLink=0; //***************************************************************************** // End of Configuration //***************************************************************************** /* $absoluteScriptPath is the name of the current script (this file) and which is going to be modified by itself. This means that (theoretically) this file can be placed anywhere on the system, with any fileName.*/ $absoluteScriptPath = $PATH_TRANSLATED; $relativeScriptPath = $PHP_SELF; // when the php preprocessor is installed as an independant binary (as CGI). if ($PATH_INFO!="") { $relativeScriptPath = $PATH_INFO; } /* to be used when $PHP_SELF contains virtual directory reference (for multi-users servers, eg : free.fr, online.fr ..)*/ if (($SERVER_NAME=="php.proxad.net")||(($SERVER_NAME=="php3.pro.proxad.net"))) { $relativeScriptPath = substr($relativeScriptPath, strpos(substr($relativeScriptPath, 1), "/")+1); } $theName = substr($absoluteScriptPath, 0, strrpos($absoluteScriptPath, ".")); $extension = substr($absoluteScriptPath, strrpos($absoluteScriptPath, ".")+1); /* The dataFile contains all the guestbook entries, and $adminpassword. $adminpassword is the password which will be asked for any administration actions. This password could be changed only if in admin mode (old $adminpassword matches $admin). Defines the name of the database file where the entries are stored.*/ //***************************************************************************** // $dataFile = "${theName}.dat.${extension}"; //***************************************************************************** /* If this does not work (e.g. $datafile = .dat.) then enter a new name for your datafile.*/ $dataFile = "../guestbook/cal.dat.php"; //***************************************************************************** // function displayMessage displays the $errorMessage error message. //***************************************************************************** function displayMessage($errorMessage,$msgType) { global $langAdminError; global $langSystemError; global $langSystemMessage; global $langBsCal; displayHeader(); echo ("

"); if ($msgType=="1") // Admin Message echo ("  $langAdminError ! "); if ($msgType=="2") // System Error echo ("  $langSystemError ! "); if ($msgType=="3") // System Message echo ("  $langSystemMessage ! "); echo ("

\n"); echo ("


$errorMessage



\n"); displayFooter(); exit; } //***************************************************************************** // function standardizeText filters ambiguous chains in $str //***************************************************************************** function standardizeStoredText($str) { $str = str_replace("\\'", "'", $str); $str = str_replace("\\\"", "\"", $str); $str = htmlspecialchars($str); $str = str_replace("\n", "
", $str); $str = str_replace("$", "$", $str); return $str; } function standardizeDisplayedText($str) { return $str; } function standardizeAdminText($str) { return $str; } function seekHttp($rawText) { $pattern = array("/http:\/\/((\w|\.|\?|\%|=|\/|-|~|#)*)/", "/mailto:((\w|\.|@|-)*)/"); $replacement = array( "http://\\1", "\\1"); $hyperLinkedText = preg_replace($pattern, $replacement, $rawText); return $hyperLinkedText; } //***************************************************************************** // function Xfopen : opens a file $fileName and locks it //***************************************************************************** function Xfopen($fileName, $openMode, $sharing) { global $langOpenError; $fp=@fopen($fileName, $openMode); if (!$fp) { displayMessage($langOpenError,2); } if ($sharing==true) { $op=1; } else { $op=2; } if (!@flock($fp,$op)) { @flock($fp,3); displayMessage("flock timeout",2); } return $fp; } //***************************************************************************** // function Xfclose : unlocks the file $fp and closes it //***************************************************************************** function Xfclose($fp) { @flock($fp,3); @fclose($fp); } //***************************************************************************** // function fullDisplay //***************************************************************************** function fullDisplay() { global $displayStep, $displayBegin, $maxDisplay; global $relativeScriptPath; global $index; global $archive_name, $archive_text, $archive_when, $archive_where; global $allowAutoLink; global $langMessage, $langName, $langWhen, $langWhere; // Checks if $displayBegin is not too large if ($displayBegin>$maxDisplay) { $displayBegin=$maxDisplay-$displayStep+1; } displayHeader(); if ($index==0) { displayFooter(); return; } // Message arrays are displayed here : // Displaying all the entries. if ($displayStep==0) { $displayBegin=1; $displayStep=$index; } if ($displayBegin==1) { $startAt=$index % $displayStep; if ($startAt==0) $startAt=$displayStep; } else { $startAt=$displayBegin+$displayStep-1; } for ($msgNumber=$startAt ; $msgNumber>=$displayBegin ; $msgNumber--) { echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n\n"); echo (""); echo ("\n\n

$langWhere & $langWhen:

$archive_where[$msgNumber]   -   $archive_when[$msgNumber]

$langName: ".standardizeDisplayedText($archive_name[$msgNumber])); echo ("
$langMessage: "); if ($allowAutoLink==1) echo (seekHttp(standardizeDisplayedText($archive_text[$msgNumber]))); else echo (standardizeDisplayedText($archive_text[$msgNumber])); echo ("

\n"); } echo ("

\n"); for($i=1;$i<=$index;$i=$nextEnd+1) { $nextBegin = $i; if ($i==1) { $nextEnd=$index % $displayStep; if ($nextEnd==0) $nextEnd=$displayStep; } else $nextEnd = $i+$displayStep-1; if ($displayBegin==$nextBegin && $nextEnd!=$nextBegin) echo ("[$nextBegin-$nextEnd]\n"); elseif ($displayBegin==$nextBegin && $nextEnd==$nextBegin) echo ("[$nextBegin]\n"); elseif ($nextEnd==$nextBegin) echo ("[$nextBegin]\n"); else echo ("[$nextBegin-$nextEnd]\n"); } displayFooter(); } //***************************************************************************** function readData($resetBegin) { global $adminpassword; global $index; global $dataFile; global $archive_name, $archive_text, $archive_when, $archive_where; global $displayBegin, $displayStep, $maxDisplay; // Includes automatically filled data arrays : $index = 0; $fout=Xfopen($dataFile, "r", true); include($dataFile); Xfclose($fout); // From now, $index will indicate the number of data entries. // Beginning of the data to be displayed, default = 1 if (!isset($displayBegin)) $displayBegin=""; if ($displayBegin=="" || $resetBegin==1) { $displayBegin = $index-$displayStep+1; if ($displayBegin<=0) $displayBegin=1; } // Sets the maximum that $displayBegin can reach $maxDisplay = $index; } //****************************************************************************** //* Start of Program //****************************************************************************** // If the Datafile does not exist, creates it. if (!file_exists($dataFile)) { $fout = Xfopen($dataFile, "w+", false); fputs($fout, ""); Xfclose ($fout); } readData(0); if (!isset($admin)) { /******************************************************************************** * Use Case no 1-A, no Adminmode * * * * This case is encountered when a client simply wants to see the calendar. * * No Adminmode (Every variable is empty); * ********************************************************************************/ fullDisplay(); exit; } if ($admin==$adminpassword) { if ($command=="") { /************************************************************************ * Use Case no 2-A, Adminmode * * * * Admin mode (The administrator can modify password, fields, or remove * * messages). * * $admin = $adminpassword * * Shows a password modification form. * * Shows all messages and enables to modify/delete them. * * Shows a form to add new entries. * ************************************************************************/ displayHeader(); echo("

$langGbAdmin



\n"); //******************************************************************* // Message arrays are displayed here in forms in order to modify them //******************************************************************* echo ("$langEntMod
\n"); echo ("
\n"); for ($i=1 ; $i<=$index ; $i++) { $msgNumber = $index - $i + 1; $str = str_replace("
", "\n", $archive_text[$msgNumber]); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n
$langEntry \n\n"); echo ("
  
\n
\n"); } echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo("


\n"); //******************************************************************* // Displays the entry form to enable the client to type an entry. //******************************************************************* echo ("$langNewEnt
\n"); echo ("
\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
$langName: 
$langWhen: $langWhere: 
$langMessage: 
\n"); echo ("

\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo ("
\n"); echo("


\n"); //******************************************************************* // Display the password modification form //******************************************************************* echo ("$langPassword
\n"); echo ("
\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
 $langnewPassword 
 $langRetype 

\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo ("
\n"); displayFooter(); exit; } elseif ($command=="add" && $name!="") { /******************************************************************************** * Use Case no 2-B, add new entries to file. * * * * Case is encountered when the admin has just filled in the appropriate fields * * (name, when, where, message). * * Simply add the entry in the top of all previous messages. * ********************************************************************************/ $position = filesize($dataFile); $fout = Xfopen($dataFile, "r+", false); fseek($fout,$position-2); $when=standardizeStoredText($when); $where=standardizeStoredText($where); $name=standardizeStoredText($name); $message=standardizeStoredText($message); fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n"); fputs ($fout,"\$archive_when[ \$index] = \"$when\";\n"); fputs ($fout,"\$archive_where[ \$index] = \"$where\";\n"); fputs ($fout,"\$archive_text[ \$index] = \"$message\";\n"); fputs ($fout,"\n?>"); Xfclose($fout); if (strpos($HTTP_REFERER, "?")==false) $page=$HTTP_REFERER; else $page=substr($HTTP_REFERER, 0, strpos($HTTP_REFERER, "?")); header("Location: $page?admin=$adminpassword"); } elseif ($command=="add" && $name=="") { displayMessage("$langNewEnt2",3); } elseif ($command=="passwd") { /******************************************************************** * Use Case no 2-C * * * * Admin mode (The administrator is modifying his password.). * * $admin = $adminpassword * * $newPassword1 = "New Password 1" * * $newPassword2 = "New Password 2" * * Check if $newPassword1 matches $newPassword2 * * Set the $adminpassword line to: * * $adminpassword = "$newPassword1" in the dataFile * ********************************************************************/ if($newPassword1!=$newPassword2) { // The passwords doesn't match displayMessage("$langPassError",1); } else { // Rewrites the whole Datafile with the new password, and all the entries. $fout = Xfopen($dataFile, "w", false); fputs ($fout,""); Xfclose($fout); displayMessage("$langPassChanged",3); } } elseif ($command=="modify") { /********************************************************************************* * Use Case no 2-D * * * * Admin mode (The administrator is updating entries). * * $admin = $adminpassword * * $nameXXX = "Modified name (no XXX)" * * $whenXXX = "Modified when (no XXX)" * * $whereXXX = "Modified where (no XXX)" * * $messageXXX = "Modified message (no XXX)" * * $keep = "on" or "" * * Check if $admin matches $adminpassword. * * Rewrites ALL the fields except when $keepXXX = "" * * Rewrites the whole Datafile with the new password, and all the entries. * *********************************************************************************/ for ($i=1 ; $i<=$index ; $i++) { $variable="keep$i"; if (${$variable}!="") { // Get values from the form when necessary, and standardize them $variable="nr$i"; $nr=standardizeStoredText("${$variable}"); $variable="name$i"; $name=standardizeStoredText("${$variable}"); $variable="when$i"; $when=standardizeStoredText("${$variable}"); $variable="where$i"; $where=standardizeStoredText("${$variable}"); $variable="message$i"; $message=standardizeStoredText("${$variable}"); // Array for entries $entries[$i]=array($nr,$name,$when,$where,$message); } } sort ($entries); reset ($entries); // Save to File $fout = Xfopen($dataFile, "w", false); fputs ($fout,""); Xfclose($fout); if (strpos($HTTP_REFERER, "?")==false) $page=$HTTP_REFERER; else $page=substr($HTTP_REFERER, 0, strpos($HTTP_REFERER, "?")); header("Location: $page?admin=$adminpassword"); exit; } else { displayMessage("$langUnknownErr",3); } } else { /************************************************ * Use Case no 3-A * * * * If $admin does NOT match $adminpassword. * * $admin != $adminpassword * * Error message : "Wrong Admin Password" * ************************************************/ displayMessage("$langWrongPassword",1); } ?>