diff --git a/README b/README
index 73b86a7..dd5ae37 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-PHPCSV Guestbook version 0.98
+PHPCSV Guestbook version 0.99
Simple php guestbook with csv file data storage.
@@ -10,6 +10,7 @@ Features:
- 'Read More' button
- Pagination
- Categories
+ - Replies
Working example: https://zlaxyi.soundragon.su/gb
diff --git a/administration.php b/administration.php
index e3ac2fc..45c84d7 100644
--- a/administration.php
+++ b/administration.php
@@ -223,7 +223,7 @@ if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) {
if (isset($_POST["submitdelete"])) {
$_SESSION["DeleteStatus"]="deletion";
foreach($AdminEntries as $e=>$Entry) if (isset($_POST["cb$e"])) $_SESSION["DeleteEntries"][]=$e;
- if (!count($_SESSION["DeleteEntries"])) $_SESSION["DeleteStatus"]="";
+ if (isset($_SESSION["DeleteEntries"])) if (!count($_SESSION["DeleteEntries"])) $_SESSION["DeleteStatus"]="";
} if (isset($_POST["submiteedit"])) if (($_POST["submiteedit"])&&($_SESSION["EditStatus"])) {
$AdminEntries[($_SESSION["EditStatus"]-1)][0]=$_POST["editname"];
if (isset($_POST["editfrom"])) $AdminEntries[($_SESSION["EditStatus"]-1)][1]=$_POST["editfrom"];
diff --git a/anthrstlsht.css b/anthrstlsht.css
index 36d7e35..d2e968e 100644
--- a/anthrstlsht.css
+++ b/anthrstlsht.css
@@ -71,16 +71,22 @@ img {
border: 0;
}
-.btn-link{
- border:none;
- outline:none;
- background:none;
- cursor:pointer;
- color:#0000EE;
- padding:0;
- text-decoration:underline;
- font-family:inherit;
- font-size:inherit;
+.reply {
+ position: relative;
+ padding: 20px;
+ width: 98%;
+}
+
+.btn-link {
+ border: none;
+ outline: none;
+ background: none;
+ cursor: pointer;
+ color: #0000EE;
+ padding: 0;
+ text-decoration: underline;
+ font-family: inherit;
+ font-size: inherit;
}
.button,
diff --git a/index.php b/index.php
index 07e61f8..446febc 100644
--- a/index.php
+++ b/index.php
@@ -93,7 +93,10 @@ function AddEntry() {
} else $NewEntry["subj"]="";
if ($GBcategoryfield) $NewEntry["category"]=strip_tags($_POST["category"]);
else $NewEntry["category"]="";
- $NewEntry["parameters"]="";
+ if (isset($_SESSION["reply"])) {
+ $NewEntry["reply"]=$_SESSION["reply"][5];
+ unset($_SESSION["reply"]);
+ }
$fhandle=fopen($GBdata,"a");
fputcsv($fhandle,$NewEntry);
fclose($fhandle);
@@ -178,17 +181,26 @@ function AddSearchBar() {
function SinlgeEntry($Entry) {
global $Titles;
+ global $GBreplies;
global $GBreadmore;
global $GBcityfield;
global $GBlinkfield;
global $GBsubjectfield;
global $GBcategoryfield;
- echo "
";
+ echo "
\n";
}
function EntriesView() {
@@ -219,6 +238,26 @@ function EntriesView() {
global $GBlinkfield;
global $GBsubjectfield;
global $GBcategoryfield;
+ global $GBreplies;
+ if (isset($_SESSION["reply"])) {
+ echo $Titles["Replying"],"
\n";
+ }
+ if ($GBreplies) {
+ $EntriesReplySorted=$Entries;
+ foreach($Entries as $Entry) {
+ if (isset($Entry[9])) {
+ foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[5]) {
+ $a=$n;
+ }
+ foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[9]) $b=$n;
+ if (isset($b)) {
+ $out=array_splice($EntriesReplySorted, $a, 1);
+ array_splice($EntriesReplySorted, $b, 0, $out);
+ }
+ }
+ }
+ $Entries=$EntriesReplySorted;
+ }
if ($DataStatus=="empty") echo $Titles["EmptyFile"];
else if(isset($_POST["search"])&&isset($_POST["serachq"])) {
$SearchResult=Search($_POST["serachq"]);
@@ -278,6 +317,8 @@ function EntriesView() {
}
}
+if ($GBreplies) $GBshownumbers=false;
+
if(isset($_POST["submit"])) {
if (!$_POST["text"]) $PageStatus="emptytext";
if (!$_POST["name"]) $PageStatus="emptyname";
@@ -302,18 +343,26 @@ if(isset($_POST["submit"])) {
}
} else $PageStatus="wrongcaptcha";
if (($PageStatus)&&!($PageStatus=="added")) {
- $SESSION["value"]["name"]=$_POST["name"];
- $SESSION["value"]["from"]=$_POST["from"];
- $SESSION["value"]["link"]=$_POST["link"];
- $SESSION["value"]["subj"]=$_POST["subj"];
- $SESSION["value"]["category"]=$_POST["category"];
- $SESSION["value"]["email"]=$_POST["email"];
- $SESSION["value"]["text"]=$_POST["text"];
- $Values=$SESSION["value"];
- } else if (isset($SESSION["value"])) Unset($SESSION["value"]);
+ $_SESSION["value"]["name"]=$_POST["name"];
+ $_SESSION["value"]["from"]=$_POST["from"];
+ $_SESSION["value"]["link"]=$_POST["link"];
+ $_SESSION["value"]["subj"]=$_POST["subj"];
+ $_SESSION["value"]["category"]=$_POST["category"];
+ $_SESSION["value"]["email"]=$_POST["email"];
+ $_SESSION["value"]["text"]=$_POST["text"];
+ $Values=$_SESSION["value"];
+ } else if (isset($_SESSION["value"])) Unset($_SESSION["value"]);
}
$Entries=ReadEntries();
+if(isset($_POST["reply"])) {
+ $_SESSION["reply"]=$Entries[$_POST["reply"]-1];
+ $GBsearch=false;
+ unset($Entries);
+ $GBreplies=false;
+ $Entries[0]=$_SESSION["reply"];
+} else unset($_SESSION["reply"]);
+
include "page.php";
?>
diff --git a/settings.php b/settings.php
index cdd32c3..1502f25 100644
--- a/settings.php
+++ b/settings.php
@@ -13,7 +13,7 @@ $GBpassword="password";
$GBpagination=10; // pagination for entries, 0 - disabled
$GBreadmore=255; // number of symbols for 'Read More' feature, 0 - shows full entries
$GBsearch=true; // enable or disable search bar
-$GBcaptcha=false; // enable or disable captcha
+$GBcaptcha=true; // enable or disable captcha
$GBupload=true; // enable or disable upload image feature
$GBimagesize=1048576; // maximum image size
$GBnotificationmailto=""; // leave empty if you don't want send notification
@@ -30,6 +30,8 @@ $GBcategoryfield=array(
4=>"Order",
5=>"Other");
$GBstriptags=true; // enable or disable strip tags function during adding new entry
+$GBreplies=true; // enable or disable replies to mwssages
+$GBshownumbers=true; // show or not show number of entries (if replies enabled - numbers will not shown anyway)
$Titles["HeadTitle"]="Guestbook";
$Titles["Page"]="Guestbook";
$Titles["Name"]="Your name";
@@ -81,4 +83,7 @@ $Titles["WrongImage"]="Can't upload image.";
$Titles["Subject"]="Subject";
$Titles["Category"]="Category";
$Titles["About"]="about";
+$Titles["Reply"]="Reply";
+$Titles["Replied"]="replied";
+$Titles["Replying"]="Replying to this message:";
?>
diff --git a/settings_ru.php b/settings_ru.php
index 5c33399..ff88569 100644
--- a/settings_ru.php
+++ b/settings_ru.php
@@ -31,6 +31,8 @@ $GBcategoryfield=array(
4=>"Order",
5=>"Other");
$GBstriptags=true; // включение или отключение функции обрезания тегов при добавлении новой записи
+$GBreplies=true; // включение или отключение ответов на сообщения
+$GBshownumbers=true; // показывать или не показывать номера сообщений (если включены ответы - номера сообщений не будут показываться)
$Titles["HeadTitle"]="Гостевая книга";
$Titles["Page"]="Гостевая книга";
$Titles["Name"]="Ваше имя";
@@ -82,4 +84,7 @@ $Titles["WrongImage"]="Не могу загрузить изображение."
$Titles["Subject"]="Тема";
$Titles["Category"]="Категория";
$Titles["About"]="о";
+$Titles["Reply"]="Ответить";
+$Titles["Replied"]="ответил";
+$Titles["Replying"]="Ответ на это сообщение:";
?>