// ***************************************************************
// * *
// * BIG SAM : Built-In Guestbook / Stand-Alone Module *
// * Version 1.1.05 November, 26th 2000 *
// * *
// * Copyleft 2000 Georges Zadrozynski & Rémi Lecoupé-Grainville *
// * gezzed@atilla.org & rlg@atilla.org *
// * *
// * Homepage : http://www.atilla.org/bigsam/ *
// * Mail : bigsam@atilla.org *
// * *
// * This source is under GNU/GPL General Public License *
// * *
// ***************************************************************
/*
BIG SAM - Built-In Guestbook / Stand-Alone Module - PHP Guestbook
Copyright (C) Georges Zadrozynski & Rémi Lecoupé-Grainville
This program 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
of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$version = "1.1.05";
/**********************************
* Configuration Step 1 : Language *
**********************************/
// Please remove all the unwanted language blocks
//SPANISH
//By Valéry Frémaux (vf@eisti.fr)
$langAdminError = "Error Del Administrador";
$langBsGuestbook = "";
$langChPassword = "Cambio del pass";
$langEmail = "E-mail: ";
$langEntry = "Elemento: ";
$langGbAdmin = "Administración de los Mensajes";
$langMessage = "Mensaje: ";
$langName = "Nombre: ";
$langnewPassword = "Nuevo pass: ";
$langOpenError = "Error de escritura del fichero!
Verifica que es possible escribir en este directorio.";
$langPassChanged = "Se ha cambiado el pass.";
$langPassError = "Los pass no corresponden!";
$langPassword = "Cambie el pass de Big Sam";
$langRetype = "Confirma su nuevo pass: ";
$langSubmit = "Mandar";
$langSubmitModif = "Mandar Las Modificaciones";
$langSystemError = "Error Sistema";
$langSystemMessage = "Mensaje del sistema";
$langWrongPassword = "Pass Incorrecto";
/*******************************************
* Configuration Step 2 : Carbon Copy Email *
*******************************************/
// carbonCopy = 1 enables mail sending to mailRecipient.
// mailRecipient receives a mail each times an entry is entered (if carbonCopy = 1)
// mailSubject is the subject of the mail which is sent.
$carbonCopy = 0;
$mailRecipient = "franmuno@cec.uchile.cl";
$mailSubject = "Nuevo Mensaje en la Página de Padrinos";
/********************************
* Configuration Step 3 : Colors *
*********************************/
// Choosing colors (Remove the unwanted color-model)
/*
// Standard (Greys, bright background)
$colorWhite = "\"#FFFFFF\"";
$colorBlack = "\"#000000\"";
$colorHeads = "\"#666666\"";
$colorBody1 = "\"#EEEEEE\"";
$colorBody2 = "\"#DDDDDD\"";
*/
// colores
$colorWhite = "\"#FFFFFF\"";
$colorBlack = "\"#333399\"";
$colorHeads = "\"#006699\"";
$colorBody1 = "\"#FFFFFF\"";
$colorBody2 = "\"#FFFFDD\"";
// Data submission form colors
$formHeadColor = $colorHeads;
$formBodyColor = $colorBody1;
$formTailColor = $colorBody2;
$formHeadText = $colorWhite;
$formBodyText = $colorBlack;
// Guestbook entries colors
$entryHeadColor = $colorHeads;
$entryBodyColor1 = $colorBody2;
$entryBodyColor2 = $colorBody1;
$entryHeadText = $colorWhite;
$entryBodyText1 = $colorBlack;
$entryBodyText2 = $colorHeads;
// Messages colors
$adminHeadColor = $colorHeads;
$adminHeadText = $colorWhite;
$adminBodyColor1 = $colorBody2;
$adminBodyText1 = $colorBlack;
$adminBodyColor2 = $colorBody1;
$adminBodyText2 = $colorHeads;
/********************************
* Configuration Step 4 : Header *
*********************************/
function displayHeader()
{
global $version;
header ("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
// echo ("\n");
echo ("\n");
// You migh use and include instead of all this :
// include ("head.inc");
include ("top.inc");
}
/********************************
* Configuration Step 5 : Footer *
*********************************/
function displayFooter()
{
include ("bottom.inc");
}
/******************************************************
* Configuration Step 6 : Number of messages displayed *
*******************************************************/
// Number of fields to be displayed simultaneously.
// To display everything, set $displayStep to 0.
$displayStep = 20;
/************************************************
* Configuration Step 7 : Allow AutoLink Suystem *
************************************************/
$allowAutoLink=1;
/************************
* 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)
if ($SERVER_NAME=="php.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}";
//******************************************************************************
// function displayForm : Display the form which enables the client to type a
// message.
function displayForm()
{
global $relativeScriptPath;
$borderThickness = 3;
global $formHeadColor;
global $formBodyColor;
global $formTailColor;
global $formHeadText;
global $formBodyText;
global $langName;
global $langEmail;
global $langMessage;
global $langSubmit;
// Writing HTML Code
echo ("
");
echo ("
\n"); echo (" |
\n"); // Message arrays are displayed here : echo "
| "); echo (" $archive_date[$msgNumber] "); echo (" |
| "); echo (""); if ($archive_mail[$msgNumber]!="") { echo ("$msgNumber : ".standardizeDisplayedText($archive_name[$msgNumber]).""); } else { echo ("$msgNumber : ".standardizeDisplayedText($archive_name[$msgNumber])); } echo (""); echo (" |
| "); echo (""); if ($allowAutoLink==1) echo ("".seekHttp(standardizeDisplayedText($archive_text[$msgNumber])).""); else echo ("".standardizeDisplayedText($archive_text[$msgNumber]).""); 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"); else if ($displayBegin==$nextBegin && $nextEnd==$nextBegin) echo ("[$nextBegin]\n"); else if ($nextEnd==$nextBegin) echo ("[$nextBegin]\n"); else echo ("[$nextBegin-$nextEnd]\n"); } echo "
"; // Displays the entry form to enable the client to type a messag e. displayForm(); displayFooter(); return; } //****************************************************************************** function readData($resetBegin) { global $adminpassword; global $index; global $dataFile; global $archive_mail, $archive_name, $archive_text, $archive_date; global $displayBegin, $displayStep; // 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; } } //****************************************************************************** // If the Datafile does not exist, creates it. if (!file_exists(${dataFile})) { $fout = Xfopen($dataFile, "w+", false); fputs($fout, "\n"); fputs($fout, "\$adminpassword = \"bigsam\";\n"); fputs($fout, "\$archive_name[++\$index] = \"The BigSam Team\";\n"); fputs($fout, "\$archive_mail[ \$index] = \"bigsam@atilla.org\";\n"); fputs($fout, "\$archive_date[ \$index] = \"25th October 2000 - 09:00:00 AM\";\n"); fputs($fout, "\$archive_text[ \$index] = \"Thank you for using Big Sam v.$version.\";\n"); fputs($fout, "?>"); Xfclose ($fout); } if (!isset($admin)) { if (!isset($name)) { $name=""; $message=""; } if ($name=="" || $message=="") { /**************************************************************************************** * Use Case no 1-A * * * * This case is encountered when a client simply wants to add a message to the * * guestbook. (Every variable is empty); * ************************************************************************************/ readData(0); fullDisplay(); exit; } else { /******************************************************************************** * Use Case no 1-B * * * * Case is encountered when a client has just filled in the appropriate fields * * (name, mail, message). * * $name = "Some Name" * * $email = "Some@Email" * * $message = "Some Message" * * Simply add message in the top of all previous messages. * ********************************************************************************/ $position = filesize($dataFile); $fout = Xfopen($dataFile, "r+", false); fseek($fout,$position-2); $insert_msgdate = date( "dS F Y - h:i:s A" ); $name=standardizeStoredText($name); $email=standardizeStoredText($email); $message=standardizeStoredText($message); fputs ($fout,"\$archive_name[++\$index] = \"$name\";\n"); fputs ($fout,"\$archive_mail[ \$index] = \"$email\";\n"); fputs ($fout,"\$archive_date[ \$index] = \"$insert_msgdate\";\n"); fputs ($fout,"\$archive_text[ \$index] = \"$message\";\n"); fputs ($fout,"\n?>"); Xfclose($fout); // Sending a mail to $mailRecipient if $carbonCopy=1, with the subject $mailSubject. $mailBody = "From: $name <$email>\n$insert_msgdate\n$message"; if ($carbonCopy==1) { mail($mailRecipient,$mailSubject,$mailBody,"From: $email\nReply-to: $name <$email>"); } if (strpos($HTTP_REFERER, "?")==false) $page=$HTTP_REFERER; else $page=substr($HTTP_REFERER, 0, strpos($HTTP_REFERER, "?")); header("Location: $page?"); exit; } } else { readData(0); if ($admin==$adminpassword) { if ($command=="") { displayHeader(); /************************************************************************ * Use Case no 2-A * * * * 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. * ************************************************************************/ echo("