Added ability to enable/disable captcha

This commit is contained in:
ivan 2017-09-27 09:26:08 +03:00
parent 4c4d09a953
commit 3e16941936
4 changed files with 13 additions and 7 deletions

2
README
View File

@ -1,4 +1,4 @@
PHPCSV Guestbook version 0.95
PHPCSV Guestbook version 0.96
Simple php guestbook with csv file data storage.

View File

@ -55,6 +55,7 @@ function AddEntryView() {
global $Titles;
global $Values;
global $PageStatus;
global $GBcaptcha;
echo "<h2>",$Titles[Page],"</h2><br>\n";
if ($PageStatus=="added") echo "$Titles[Added]"; else {
$captchanumber11=rand(1, 4);
@ -68,7 +69,7 @@ function AddEntryView() {
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 class=\"text\">$captchanumber11</font><font>$captchanumber11</font><font>$captchanumber12</font> $Titles[CaptchaPlus] <font>$captchanumber21</font><font>$captchanumber22</font><font class=\"text\">$captchanumber21</font> = <input type=text name=\"captcha\" size=2 maxlength=2> ?<br>\n";
if ($GBcaptcha) echo " $Titles[Captcha]: <font class=\"text\">$captchanumber11</font><font>$captchanumber11</font><font>$captchanumber12</font> $Titles[CaptchaPlus] <font>$captchanumber21</font><font>$captchanumber22</font><font class=\"text\">$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";
@ -126,7 +127,7 @@ function EntriesView() {
$CurrentPage=0;
break;
case $Titles[Last]:
$CurrentPage=intdiv(count($Entries),$GBpagination);
$CurrentPage=intdiv((count($Entries)-1),$GBpagination);
break;
case "$Titles[Previous]":
$CurrentPage=$_SESSION['currentpage']-1;
@ -151,7 +152,7 @@ function EntriesView() {
if ($Entries[$e][6]) echo nl2br($Entries[$e][6]),"</i><br>\n";
echo "</div><hr>\n";
}
echo "<form action=\".\" method=\"get\">\n";
echo "<form action=index.php method=\"get\">\n";
if ($CurrentPage>0) {
echo " <input type=\"submit\" value=\"$Titles[First]\" name=\"page\"/>\n";
echo " <input type=\"submit\" value=\"$Titles[Previous]\" name=\"page\"/>\n";
@ -194,6 +195,9 @@ if($_POST['submit']) {
if ($_POST["captcha"]&&(md5(base64_encode($_POST["captcha"]))==$_SESSION["captcha"])) {
AddEntry();
if ($GBnotificationmailto) SendMail();
} else if (!$GBcaptcha) {
AddEntry();
if ($GBnotificationmailto) SendMail();
} else $PageStatus="wrongcaptcha";
if (($PageStatus)&&!($PageStatus=="added")) {
$SESSION["value"]["name"]=$_POST['name'];

View File

@ -12,6 +12,7 @@ $GBadmin="root";
$GBpassword="password";
$GBpagination=10; // pagination for entries, 0 - disabled
$GBsearch=true; // enable or disable search bar
$GBcaptcha=true; // enable or disable captcha
$GBnotificationmailto=""; // leave empty if you don't want send notification
$GBnotificationmailfrom="";
$Titles[HeadTitle]="Guestbook";

View File

@ -12,7 +12,8 @@ $GBdata="gbdb.csv";
$GBadmin="root";
$GBpassword="password";
$GBpagination=10; // количество записей на странице, 0 - все записи на одной странице
$GBsearch=true; // включение или отключения строки поиска
$GBsearch=true; // включение или отключение строки поиска
$GBcaptcha=true; // включение или отключение капчи
$GBnotificationmailto=""; // оставьте поле пустым, если не хотите отправки уведомлений о новых записях
$GBnotificationmailfrom="";
$Titles[HeadTitle]="Гостевая книга";