Init
This commit is contained in:
commit
dcc4e57846
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/**
|
||||
* Administration program file of PHPCSV Guestbook version 0.9
|
||||
* See settings.php for configuration.
|
||||
* Edit page.php for change appearance.
|
||||
*/
|
||||
session_start();
|
||||
include "settings.php";
|
||||
|
||||
function ReadEntries() {
|
||||
global $GBdata;
|
||||
global $DataStatus;
|
||||
$fhandle=fopen($GBdata,"r") or $DataStatus="empty";
|
||||
for($e=0; $entrydata=fgetcsv($fhandle, 16384, ","); $e++) {
|
||||
$Entries["$e"]=$entrydata;
|
||||
} fclose($fhandle);
|
||||
if (!$Entries[0]) $DataStatus="empty";
|
||||
return $Entries;
|
||||
}
|
||||
|
||||
function SaveEntries() {
|
||||
global $GBdata;
|
||||
global $AdminEntries;
|
||||
$fhandle=fopen($GBdata,"w");
|
||||
foreach($AdminEntries as $e=>$Entry) fputcsv($fhandle,$Entry);
|
||||
fclose($fhandle);
|
||||
}
|
||||
|
||||
function AdminHeaderView() {
|
||||
global $Titles;
|
||||
global $GBadmin;
|
||||
global $GBpassword;
|
||||
echo "<h2><a href=\"index.php\">$Titles[AdminHeader]</a></h2>\n";
|
||||
if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) {
|
||||
echo "<form action=administration.php method=post>\n";
|
||||
echo " <p align=\"right\"><input type=submit name=\"exit\" value=\"$Titles[AdminExit]\"></p>\n";
|
||||
echo "</form>\n";
|
||||
echo " $Titles[AdminHello], $GBadmin!\n";
|
||||
}
|
||||
}
|
||||
|
||||
function AdminEntriesView() {
|
||||
global $Titles;
|
||||
global $DataStatus;
|
||||
global $GBadmin;
|
||||
global $GBpassword;
|
||||
global $AdminEntries;
|
||||
if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) if ($DataStatus=="empty") echo "$Titles[EmptyFile]\n";
|
||||
else if ($_SESSION["DeleteStatus"]=="deletion") {
|
||||
echo " $Titles[AdminSureDel] ",count($_SESSION["DeleteEntries"])," $Titles[AdminSureDelMessages]?\n";
|
||||
echo "<form action=administration.php method=post>\n";
|
||||
echo " <input type=submit name=\"applydelete\" value=\"$Titles[AdminDelete]\">\n";
|
||||
echo " <input type=submit name=\"canceldelete\" value=\"$Titles[AdminCancel]\">\n";
|
||||
echo "</form>\n";
|
||||
} else if ($_SESSION["EditStatus"]) {
|
||||
echo " $Titles[AdminMessage] ", ($_SESSION["EditStatus"]),", ",date("j.m.Y, H:i",$AdminEntries[($_SESSION["EditStatus"]-1)][5]),":<br>\n";
|
||||
echo "<form action=administration.php method=post>\n";
|
||||
echo " $Titles[AdminName]: <input type=text name=\"editname\" value=\"",$AdminEntries[($_SESSION["EditStatus"]-1)][0],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[City] <input type=text name=\"editfrom\" value=\"",$AdminEntries[($_SESSION["EditStatus"]-1)][1],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[Link] <input type=text name=\"editlink\" value=\"",$AdminEntries[($_SESSION["EditStatus"]-1)][2],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[Email] <input type=text name=\"editmail\" value=\"",$AdminEntries[($_SESSION["EditStatus"]-1)][3],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[AdminMessage]:<br>\n <textarea name=\"edittext\" wrap=virtual cols=50 rows=5 maxlength=7168>",$AdminEntries[($_SESSION["EditStatus"]-1)][4],"</textarea><br>\n";
|
||||
echo " $Titles[Response]:<br>\n <textarea name=\"editresp\" wrap=virtual cols=50 rows=5 maxlength=7168>",$AdminEntries[($_SESSION["EditStatus"]-1)][6],"</textarea><br>\n";
|
||||
echo " <input type=submit name=\"submiteedit\" value=\"$Titles[AdminApply]\"> ";
|
||||
echo "<input type=submit name=\"applydelete\" value=\"$Titles[AdminDelete]\"> ";
|
||||
echo "<input type=submit name=\"canceledit\" value=\"$Titles[AdminCancel]\">\n";
|
||||
echo "</form>\n";
|
||||
} else {
|
||||
echo "<form action=administration.php method=post>\n";
|
||||
echo "<table border=1 width=\"100%\">\n <tr><th></th><th>$Titles[AdminName]</th><th>$Titles[City]</th><th>$Titles[Link]</th><th>$Titles[Email]</th><th>$Titles[AdminMessage]</th><th>$Titles[Response]</th><th>$Titles[AdminDate]</th><th></th></tr>\n";
|
||||
foreach($AdminEntries as $e=>$Entry) echo " <tr><td>",($e+1),"<input type=checkbox name=\"cb$e\" value=\"checked\"></td><td>$Entry[0]</td><td>$Entry[1]</td><td>$Entry[2]</td><td>$Entry[3]</td><td>",nl2br($Entry[4]),"</td><td>",nl2br($Entry[6]),"</td><td>",date("j.m.Y, H:i",$Entry[5]),"</td><td><input type=submit name=\"submit$e\" value=\"$Titles[AdminEdit]\"></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo " <input type=submit name=\"submitdelete\" value=\"$Titles[AdminDeleteChecked]\">\n";
|
||||
echo "</form>\n";
|
||||
} else {
|
||||
if (($_POST["login"])&&(!$_SESSION["SessionStatus"])) echo "$Titles[WrongLogin]<br>\n";
|
||||
echo "<form action=administration.php method=post>\n";
|
||||
echo " $Titles[Login] <input type=text name=\"adminlogin\" maxlength=255><br>\n";
|
||||
echo " $Titles[Password] <input type=password name=\"adminpass\" maxlength=255><br>\n";
|
||||
echo " <input type=submit name=\"login\" value=\"$Titles[Enter]\">\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ((($_POST["adminlogin"])==$GBadmin)&&(($_POST["adminpass"])==$GBpassword)) $_SESSION["SessionStatus"]=(md5($GBadmin.$GBpassword));
|
||||
if ($_POST["exit"]) $_SESSION["SessionStatus"]="";
|
||||
if ($_POST["canceldelete"]) {
|
||||
$_SESSION["DeleteStatus"]="";
|
||||
Unset($_SESSION["DeleteEntries"]);
|
||||
}
|
||||
if ($_POST["canceledit"]) Unset($_SESSION["EditStatus"]);
|
||||
if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) {
|
||||
$AdminEntries=ReadEntries();
|
||||
if ($_POST["submitdelete"]) {
|
||||
$_SESSION["DeleteStatus"]="deletion";
|
||||
foreach($AdminEntries as $e=>$Entry) if ($_POST["cb$e"]) $_SESSION["DeleteEntries"][]=$e;
|
||||
if (!count($_SESSION["DeleteEntries"])) $_SESSION["DeleteStatus"]="";
|
||||
} if (($_POST["submiteedit"])&&($_SESSION["EditStatus"])) {
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][0]=$_POST["editname"];
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][1]=$_POST["editfrom"];
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][2]=$_POST["editlink"];
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][3]=$_POST["editmail"];
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][4]=$_POST["edittext"];
|
||||
$AdminEntries[($_SESSION["EditStatus"]-1)][6]=$_POST["editresp"];
|
||||
SaveEntries();
|
||||
Unset($_SESSION["EditStatus"]);
|
||||
$AdminEntries=ReadEntries();
|
||||
} if ($_POST["applydelete"]) {
|
||||
if ($_SESSION["EditStatus"]) {
|
||||
Unset($AdminEntries[($_SESSION["EditStatus"]-1)]);
|
||||
SaveEntries();
|
||||
Unset($_SESSION["EditStatus"]);
|
||||
$AdminEntries=ReadEntries();
|
||||
} if ($_SESSION["DeleteStatus"]) {
|
||||
foreach($_SESSION["DeleteEntries"] as $e=>$DelEnt) Unset($AdminEntries[$DelEnt]);
|
||||
SaveEntries();
|
||||
Unset($_SESSION["DeleteEntries"]);
|
||||
$_SESSION["DeleteStatus"]="";
|
||||
$AdminEntries=ReadEntries();
|
||||
}
|
||||
} if (!$_SESSION["EditStatus"]) for ($e=0;$e<count($AdminEntries);$e++) if ($_POST["submit$e"]) $_SESSION["EditStatus"]=($e+1);
|
||||
}
|
||||
?><html>
|
||||
<head>
|
||||
<title><?php echo $Titles[HeadTitle];?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<?php AdminHeaderView();?>
|
||||
<hr>
|
||||
<?php AdminEntriesView();?>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* Main program file of PHPCSV Guestbook version 0.9
|
||||
* See settings.php for configuration.
|
||||
* Edit page.php for change appearance.
|
||||
* See license.txt for licensing information.
|
||||
*/
|
||||
session_start();
|
||||
include "settings.php";
|
||||
|
||||
function ReadEntries() {
|
||||
global $GBdata;
|
||||
global $DataStatus;
|
||||
$fhandle=fopen($GBdata,"r") or $DataStatus="empty";
|
||||
for($e=0; $entrydata=fgetcsv($fhandle, 16384, ","); $e++) {
|
||||
$Entries["$e"]=$entrydata;
|
||||
$Entries["$e"][7]=$e+1;
|
||||
}
|
||||
fclose($fhandle);
|
||||
if (!$Entries[0]) $DataStatus="empty";
|
||||
return $Entries;
|
||||
}
|
||||
|
||||
function AddEntry() {
|
||||
global $GBdata;
|
||||
global $Titles;
|
||||
global $PageStatus;
|
||||
$NewEntry[name]=$_POST['name'];
|
||||
$NewEntry[from]=$_POST['from'];
|
||||
$NewEntry[link]=$_POST['link'];
|
||||
$NewEntry[email]=$_POST['email'];
|
||||
$NewEntry[text]=$_POST['text'];
|
||||
$NewEntry[datetime]=time();
|
||||
$NewEntry[response]="";
|
||||
$fhandle=fopen($GBdata,"a");
|
||||
fputcsv($fhandle,$NewEntry);
|
||||
fclose($fhandle);
|
||||
$PageStatus="added";
|
||||
$_SESSION['captcha']="";
|
||||
}
|
||||
|
||||
function AddEntryView() {
|
||||
global $Titles;
|
||||
global $Values;
|
||||
global $PageStatus;
|
||||
echo "<h2>",$Titles[Page],"</h2><br>\n";
|
||||
if ($PageStatus=="added") echo "$Titles[Added]"; else {
|
||||
$captchanumber11=rand(1, 4);
|
||||
$captchanumber12=rand(0, 9);
|
||||
$captchanumber21=rand(1, 4);
|
||||
$captchanumber22=rand(0, 9);
|
||||
$_SESSION['captcha']=md5(base64_encode(($captchanumber11.$captchanumber12)+($captchanumber21.$captchanumber22)));
|
||||
echo "<form action=index.php method=post>\n";
|
||||
echo " $Titles[Name]: <input type=text name=\"name\" value=\"",$Values["name"],"\" maxlength=255> ($Titles[Required])<br>\n";
|
||||
echo " $Titles[City]: <input type=text name=\"from\" value=\"",$Values["from"],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[Link]: <input type=text name=\"link\" value=\"",$Values["link"],"\" maxlength=255><br>\n";
|
||||
echo " $Titles[Email]: <input type=text name=\"email\" value=\"",$Values["email"],"\" maxlength=255> ($Titles[NotPublic])<br>\n";
|
||||
echo " $Titles[Text]:<br>\n <textarea name=\"text\" wrap=virtual cols=50 rows=5 maxlength=7168>",$Values["text"],"</textarea><br>\n";
|
||||
echo " $Titles[Captcha]: <font color=\"transparent\">$captchanumber11</font><font>$captchanumber11</font><font>$captchanumber12</font> $Titles[CaptchaPlus] <font>$captchanumber21</font><font>$captchanumber22</font><font color=\"transparent\">$captchanumber21</font> = <input type=text name=\"captcha\" size=2 maxlength=2> ?<br>\n";
|
||||
echo " <input type=submit name=\"submit\" value=\"$Titles[Submit]\">\n";
|
||||
echo "</form>\n";
|
||||
if ($PageStatus=="emptyname") echo "$Titles[EmptyName]<br>\n";
|
||||
if ($PageStatus=="emptytext") echo "$Titles[EmptyText]<br>\n";
|
||||
if ($PageStatus=="wrongcaptcha") echo "$Titles[WrongCaptcha]<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function EntriesView() {
|
||||
global $Titles;
|
||||
global $DataStatus;
|
||||
global $Entries;
|
||||
if ($DataStatus=="empty") echo "$Titles[EmptyFile]";
|
||||
else {
|
||||
$Entries=array_reverse($Entries);
|
||||
foreach($Entries as $e=>$Entry) {
|
||||
echo " ",$Entry[7],". ";
|
||||
if ($Entry[2]) echo "<a href=\"$Entry[2]\">";
|
||||
echo "<b>",$Entry[0],"</b>";
|
||||
if ($Entry[2]) echo "</a>";
|
||||
if ($Entry[1]) echo " ",$Titles[From]," <b>",$Entry[1],"</b>";
|
||||
echo ", ",date("j.m.Y, H:i",$Entry[5]),", ",$Titles[Wrote],":<br>\n";
|
||||
echo " ",nl2br($Entry[4]),"<br>\n";
|
||||
if ($Entry[6]) echo "<br><i><b>$Titles[Response]:</b><br>\n";
|
||||
if ($Entry[6]) echo nl2br($Entry[6]),"</i><br>\n";
|
||||
echo "<hr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_POST['submit']) {
|
||||
if(!$_POST['text']) $PageStatus="emptytext";
|
||||
if(!$_POST['name']) $PageStatus="emptyname";
|
||||
if(($_POST['name'])&&($_POST['text']))
|
||||
if ($_POST["captcha"]&&(md5(base64_encode($_POST["captcha"]))==$_SESSION["captcha"])) AddEntry();
|
||||
else $PageStatus="wrongcaptcha";
|
||||
if (($PageStatus)&&!($PageStatus=="added")) {
|
||||
$SESSION["value"]["name"]=$_POST['name'];
|
||||
$SESSION["value"]["from"]=$_POST['from'];
|
||||
$SESSION["value"]["link"]=$_POST['link'];
|
||||
$SESSION["value"]["email"]=$_POST['email'];
|
||||
$SESSION["value"]["text"]=$_POST['text'];
|
||||
$Values=$SESSION["value"];
|
||||
} else Unset($SESSION["value"]);
|
||||
}
|
||||
|
||||
$Entries=ReadEntries();
|
||||
|
||||
include "page.php";
|
||||
?>
|
|
@ -0,0 +1,30 @@
|
|||
phpCSV Guestbook
|
||||
|
||||
phpCSV Guestbook is released under the DWTW license.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the Do What Thou Wilt License.
|
||||
|
||||
DO WHAT THAU WILT
|
||||
TO PUBLIC LICENSE
|
||||
|
||||
Version 2.5
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. Do what thou wilt shall be the whole of the Law.
|
||||
|
||||
Anyone is allowed to copy and distribute the copies of this license agreement in whole or in part, as well as modify it without any other limitations.
|
||||
|
||||
DWTW – a license with a single requirement: DO WHAT THOU WILT
|
||||
|
||||
The license provides more freedom than any other one (such as GPL or BSD) and does not require saving the license text on copying.
|
||||
|
||||
DWTW – an accomplished and eligible license for free text (including the software, documentation and artwork).
|
||||
|
||||
The license does not contain "no warranty" clause. DWTW can be used in countries that do not legally acknowledge the transition to public domain.
|
||||
|
||||
Summary:
|
||||
|
||||
An author-creator gives his or her source code to the world for free, without becoming distracted by worldly thinking regarding how and why the others will use it.
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Main page of PHPCSV Guestbook version 0.9
|
||||
* See settings.php for configuration.
|
||||
* For changing appearance you can edit this file like simple html. For example: add css tags.
|
||||
*/
|
||||
?><html>
|
||||
<head>
|
||||
<title><?php echo $Titles[HeadTitle];?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<?php AddEntryView();?>
|
||||
<hr>
|
||||
<?php EntriesView();?>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Settings file of PHPCSV Guestbook version 0.9
|
||||
* Edit page.php for change appearance.
|
||||
* $GBdata parameter for changing entries data file.
|
||||
* Please, change $GBadmin and $GBpassword parameters for access to administration page.
|
||||
* Change $Titles[HeadTitle] and $Titles[Page] for personal header.
|
||||
* You can change $Titles parameters for localization.
|
||||
*/
|
||||
$GBdata="gbdb.csv";
|
||||
$GBadmin="root";
|
||||
$GBpassword="password";
|
||||
$Titles[HeadTitle]="Guestbook";
|
||||
$Titles[Page]="Guestbook";
|
||||
$Titles[Name]="Your name";
|
||||
$Titles[Required]="required";
|
||||
$Titles[City]="City";
|
||||
$Titles[Email]="E-mail";
|
||||
$Titles[NotPublic]="will not be published";
|
||||
$Titles[Link]="Homepage";
|
||||
$Titles[Text]="Your message";
|
||||
$Titles[Captcha]="Security question";
|
||||
$Titles[CaptchaPlus]="plus";
|
||||
$Titles[Submit]="Submit";
|
||||
$Titles[Added]="Your message has been added.";
|
||||
$Titles[EmptyName]="Please, type your name.";
|
||||
$Titles[EmptyText]="Please, type your message.";
|
||||
$Titles[WrongCaptcha]="Please, type correct security answer.";
|
||||
$Titles[From]="from";
|
||||
$Titles[Wrote]="wrote";
|
||||
$Titles[Response]="Response";
|
||||
$Titles[EmptyFile]="Guestbook is empty yet.";
|
||||
$Titles[Login]="Administrator login:";
|
||||
$Titles[Password]="Password:";
|
||||
$Titles[Enter]="Enter";
|
||||
$Titles[WrongLogin]="Wrong login or password.";
|
||||
$Titles[AdminHeader]="Guestbook administration";
|
||||
$Titles[AdminExit]="Exit";
|
||||
$Titles[AdminHello]="Hello";
|
||||
$Titles[AdminName]="Name";
|
||||
$Titles[AdminMessage]="Message";
|
||||
$Titles[AdminDate]="Date";
|
||||
$Titles[AdminApply]="Apply changes";
|
||||
$Titles[AdminDeleteChecked]="Delete checked";
|
||||
$Titles[AdminEdit]="Edit";
|
||||
$Titles[AdminDelete]="Delete";
|
||||
$Titles[AdminCancel]="Cancel";
|
||||
$Titles[AdminSureDel]="Are you sure to delete";
|
||||
$Titles[AdminSureDelMessages]="messages";
|
||||
?>
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Russian version of settings file PHPCSV Guestbook version 0.9
|
||||
* Для руссификации гостевой книги замените оригинальный settings.php на содержимое этого файла.
|
||||
* Редактируйте page.php для изменения внешнего вида.
|
||||
* $GBdata параметр служит для смены файла данных записей гостевой книги.
|
||||
* Пожалуйста, измените $GBadmin и $GBpassword параметры для доступа к странице администрирования.
|
||||
* $Titles[HeadTitle] и $Titles[Page] позволит сделать вам персональные заголовки.
|
||||
* Также можно менять все $Titles параметры для изменения отображения текста в гостевой книге.
|
||||
*/
|
||||
$GBdata="gbdb.csv";
|
||||
$GBadmin="root";
|
||||
$GBpassword="password";
|
||||
$Titles[HeadTitle]="Гостевая книга";
|
||||
$Titles[Page]="Гостевая книга";
|
||||
$Titles[Name]="Ваше имя";
|
||||
$Titles[Required]="обязательно";
|
||||
$Titles[City]="Город";
|
||||
$Titles[Email]="Электронная почта";
|
||||
$Titles[NotPublic]="не будет публиковаться";
|
||||
$Titles[Link]="Домашняя страница";
|
||||
$Titles[Text]="Ваше сообщение";
|
||||
$Titles[Captcha]="Вопрос безопасности";
|
||||
$Titles[CaptchaPlus]="плюс";
|
||||
$Titles[Submit]="Отправить";
|
||||
$Titles[Added]="Ваше сообщение было добавлено.";
|
||||
$Titles[EmptyName]="Пожалуйста, введите Ваше имя.";
|
||||
$Titles[EmptyText]="Пожалуйста, введите текст сообщения.";
|
||||
$Titles[WrongCaptcha]="Пожалуйста, введите верный ответ на вопрос безопасности.";
|
||||
$Titles[From]="из";
|
||||
$Titles[Wrote]="написал";
|
||||
$Titles[Response]="Ответ";
|
||||
$Titles[EmptyFile]="Гостевая книга пока пуста.";
|
||||
$Titles[Login]="Имя администратора:";
|
||||
$Titles[Password]="Пароль:";
|
||||
$Titles[Enter]="Войти";
|
||||
$Titles[WrongLogin]="Неверные имя администратора или пароль.";
|
||||
$Titles[AdminHeader]="Администрация гостевой книги";
|
||||
$Titles[AdminExit]="Выход";
|
||||
$Titles[AdminHello]="Приветствую";
|
||||
$Titles[AdminName]="Имя";
|
||||
$Titles[AdminMessage]="Сообщение";
|
||||
$Titles[AdminDate]="Дата";
|
||||
$Titles[AdminApply]="Принять изменения";
|
||||
$Titles[AdminDeleteChecked]="Удалить отмеченные";
|
||||
$Titles[AdminEdit]="Редактирование";
|
||||
$Titles[AdminDelete]="Удалить";
|
||||
$Titles[AdminCancel]="Отменить";
|
||||
$Titles[AdminSureDel]="Вы уверены, что хотите удалить";
|
||||
$Titles[AdminSureDelMessages]="сообщений";
|
||||
?>
|
Loading…
Reference in New Issue