From 3e169419368c8af67de8b83731673b22e3c4d547 Mon Sep 17 00:00:00 2001 From: zlaxy Date: Wed, 27 Sep 2017 09:26:08 +0300 Subject: [PATCH] Added ability to enable/disable captcha --- README | 2 +- index.php | 14 +++++++++----- settings.php | 1 + settings_ru.php | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README b/README index 3f78b4e..2d49564 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -PHPCSV Guestbook version 0.95 +PHPCSV Guestbook version 0.96 Simple php guestbook with csv file data storage. diff --git a/index.php b/index.php index 18fc35b..f5a3c18 100644 --- a/index.php +++ b/index.php @@ -55,6 +55,7 @@ function AddEntryView() { global $Titles; global $Values; global $PageStatus; + global $GBcaptcha; echo "

",$Titles[Page],"


\n"; if ($PageStatus=="added") echo "$Titles[Added]"; else { $captchanumber11=rand(1, 4); @@ -68,7 +69,7 @@ function AddEntryView() { echo " $Titles[Link]:
\n"; echo " $Titles[Email]: ($Titles[NotPublic])
\n"; echo " $Titles[Text]:
\n
\n"; - echo " $Titles[Captcha]: $captchanumber11$captchanumber11$captchanumber12 $Titles[CaptchaPlus] $captchanumber21$captchanumber22$captchanumber21 = ?
\n"; + if ($GBcaptcha) echo " $Titles[Captcha]: $captchanumber11$captchanumber11$captchanumber12 $Titles[CaptchaPlus] $captchanumber21$captchanumber22$captchanumber21 = ?
\n"; echo " \n"; echo "\n"; if ($PageStatus=="emptyname") echo "$Titles[EmptyName]
\n"; @@ -120,13 +121,13 @@ function EntriesView() { } else echo "$Titles[NoResult]: '",$_POST['serachq'],"'.
\n"; } if (($GBpagination>0)&&(count($Entries)>$GBpagination)) { - $Entries=array_reverse($Entries); + $Entries=array_reverse($Entries); if ($_GET['page']) switch ($_GET['page']) { case $Titles[First]: $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]),"
\n"; echo "
\n"; } - echo "
\n"; + echo "\n"; if ($CurrentPage>0) { echo " \n"; echo " \n"; @@ -194,7 +195,10 @@ if($_POST['submit']) { if ($_POST["captcha"]&&(md5(base64_encode($_POST["captcha"]))==$_SESSION["captcha"])) { AddEntry(); if ($GBnotificationmailto) SendMail(); - } else $PageStatus="wrongcaptcha"; + } else if (!$GBcaptcha) { + AddEntry(); + if ($GBnotificationmailto) SendMail(); + } else $PageStatus="wrongcaptcha"; if (($PageStatus)&&!($PageStatus=="added")) { $SESSION["value"]["name"]=$_POST['name']; $SESSION["value"]["from"]=$_POST['from']; diff --git a/settings.php b/settings.php index c205e51..a4acfdf 100644 --- a/settings.php +++ b/settings.php @@ -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"; diff --git a/settings_ru.php b/settings_ru.php index b229c96..383b164 100644 --- a/settings_ru.php +++ b/settings_ru.php @@ -12,7 +12,8 @@ $GBdata="gbdb.csv"; $GBadmin="root"; $GBpassword="password"; $GBpagination=10; // количество записей на странице, 0 - все записи на одной странице -$GBsearch=true; // включение или отключения строки поиска +$GBsearch=true; // включение или отключение строки поиска +$GBcaptcha=true; // включение или отключение капчи $GBnotificationmailto=""; // оставьте поле пустым, если не хотите отправки уведомлений о новых записях $GBnotificationmailfrom=""; $Titles[HeadTitle]="Гостевая книга";