Added locked and sticky posts

This commit is contained in:
ivan 2017-10-02 10:28:59 +03:00
parent 5a0ecd8a72
commit 68618f974f
5 changed files with 60 additions and 15 deletions

3
README
View File

@ -1,4 +1,4 @@
PHPCSV Guestbook version 0.99 PHPCSV Guestbook version 0.99.2
Simple php guestbook with csv file data storage. Simple php guestbook with csv file data storage.
@ -11,6 +11,7 @@ Features:
- Pagination - Pagination
- Categories - Categories
- Replies - Replies
- Locked and sticky posts
Working example: https://zlaxyi.soundragon.su/gb Working example: https://zlaxyi.soundragon.su/gb

View File

@ -104,6 +104,7 @@ function AdminEntriesView() {
global $GBlinkfield; global $GBlinkfield;
global $GBsubjectfield; global $GBsubjectfield;
global $GBcategoryfield; global $GBcategoryfield;
global $GBstickylocked;
if (isset($_SESSION["SessionStatus"])?($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))):false) if ($DataStatus=="empty") echo $Titles["EmptyFile"],"\n"; if (isset($_SESSION["SessionStatus"])?($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))):false) if ($DataStatus=="empty") echo $Titles["EmptyFile"],"\n";
else if (isset($_SESSION["DeleteStatus"])) { else if (isset($_SESSION["DeleteStatus"])) {
if ($_SESSION["DeleteStatus"]=="deletion") { if ($_SESSION["DeleteStatus"]=="deletion") {
@ -132,6 +133,13 @@ function AdminEntriesView() {
} }
echo " ",$Titles["AdminMessage"],":<br>\n <textarea name=\"edittext\" wrap=virtual cols=50 rows=5 maxlength=$GBtextlenght>",$AdminEntries[($_SESSION["EditStatus"]-1)][4],"</textarea><br>\n"; echo " ",$Titles["AdminMessage"],":<br>\n <textarea name=\"edittext\" wrap=virtual cols=50 rows=5 maxlength=$GBtextlenght>",$AdminEntries[($_SESSION["EditStatus"]-1)][4],"</textarea><br>\n";
echo " ",$Titles["Response"],":<br>\n <textarea name=\"editresp\" wrap=virtual cols=50 rows=5 maxlength=$GBtextlenght>",$AdminEntries[($_SESSION["EditStatus"]-1)][6],"</textarea><br>\n"; echo " ",$Titles["Response"],":<br>\n <textarea name=\"editresp\" wrap=virtual cols=50 rows=5 maxlength=$GBtextlenght>",$AdminEntries[($_SESSION["EditStatus"]-1)][6],"</textarea><br>\n";
if ($GBstickylocked) {
echo " <input type=\"checkbox\" name=\"lock\" ";
if ($AdminEntries[($_SESSION["EditStatus"]-1)][11]) echo "checked";
echo "> ",$Titles["Locked"]," <input type=\"checkbox\" name=\"sticky\" ";
if ($AdminEntries[($_SESSION["EditStatus"]-1)][12]) echo "checked";
echo "> ",$Titles["Sticky"],"<br>\n";
}
echo " <input type=submit name=\"submiteedit\" value=\"",$Titles["AdminApply"],"\"> "; echo " <input type=submit name=\"submiteedit\" value=\"",$Titles["AdminApply"],"\"> ";
echo "<input type=submit name=\"applydelete\" value=\"",$Titles["AdminDelete"],"\"> "; echo "<input type=submit name=\"applydelete\" value=\"",$Titles["AdminDelete"],"\"> ";
echo "<input type=submit name=\"canceledit\" value=\"",$Titles["AdminCancel"],"\">\n"; echo "<input type=submit name=\"canceledit\" value=\"",$Titles["AdminCancel"],"\">\n";
@ -245,6 +253,10 @@ if (isset($_SESSION["SessionStatus"])?($_SESSION["SessionStatus"]==(md5($GBadmin
else $AdminEntries[($_SESSION["EditStatus"]-1)][7]=""; else $AdminEntries[($_SESSION["EditStatus"]-1)][7]="";
if (isset($_POST["editcategory"])) $AdminEntries[($_SESSION["EditStatus"]-1)][8]=$_POST["editcategory"]; if (isset($_POST["editcategory"])) $AdminEntries[($_SESSION["EditStatus"]-1)][8]=$_POST["editcategory"];
else $AdminEntries[($_SESSION["EditStatus"]-1)][8]=""; else $AdminEntries[($_SESSION["EditStatus"]-1)][8]="";
if (isset($_POST["lock"])) $AdminEntries[($_SESSION["EditStatus"]-1)][11]=$_POST["lock"];
else $AdminEntries[($_SESSION["EditStatus"]-1)][11]="";
if (isset($_POST["sticky"])) $AdminEntries[($_SESSION["EditStatus"]-1)][12]=$_POST["sticky"];
else $AdminEntries[($_SESSION["EditStatus"]-1)][12]="";
SaveEntries(); SaveEntries();
Unset($_SESSION["EditStatus"]); Unset($_SESSION["EditStatus"]);
$AdminEntries=ReadEntries(); $AdminEntries=ReadEntries();

View File

@ -208,6 +208,10 @@ function SinlgeEntry($Entry) {
echo " "; echo " ";
if ($GBreplies&&isset($Entry[9])&&$Entry[9]) echo "<div class=\"reply\">"; if ($GBreplies&&isset($Entry[9])&&$Entry[9]) echo "<div class=\"reply\">";
echo "<div class=\"entry\"><div class=\"messages_header\"><h4>"; echo "<div class=\"entry\"><div class=\"messages_header\"><h4>";
if ($Entry[11]) echo "[",$Titles["Locked"],"] ";
if ($Entry[12]) echo "[",$Titles["Sticky"],"] ";
if ($GBreplies&&isset($Entry[9])&&$Entry[9]) echo "";
else echo "";
if ($GBshownumbers) echo $Entry[10],". "; if ($GBshownumbers) echo $Entry[10],". ";
if ($Entry[2]) echo "<a href=\"",$Entry[2],"\">"; if ($Entry[2]) echo "<a href=\"",$Entry[2],"\">";
echo "<b>",$Entry[0],"</b>"; echo "<b>",$Entry[0],"</b>";
@ -234,7 +238,7 @@ function SinlgeEntry($Entry) {
} else echo " ",nl2br($Entry[4]),"<br>\n"; } else echo " ",nl2br($Entry[4]),"<br>\n";
if ($Entry[6]) echo "<br><i><b>",$Titles["Response"],":</b><br>\n"; if ($Entry[6]) echo "<br><i><b>",$Titles["Response"],":</b><br>\n";
if ($Entry[6]) echo nl2br($Entry[6]),"</i><br>\n"; if ($Entry[6]) echo nl2br($Entry[6]),"</i><br>\n";
if ($GBreplies) { if ($GBreplies&&!($Entry[11])) {
echo "<form action=index.php method=post>"; echo "<form action=index.php method=post>";
echo "<p align=\"right\"><button type=submit name=\"reply\" value=\"",$Entry[10],"\">",$Titles["Reply"],"</button></p>"; echo "<p align=\"right\"><button type=submit name=\"reply\" value=\"",$Entry[10],"\">",$Titles["Reply"],"</button></p>";
echo "</form>"; echo "</form>";
@ -255,23 +259,45 @@ function EntriesView() {
global $GBsubjectfield; global $GBsubjectfield;
global $GBcategoryfield; global $GBcategoryfield;
global $GBreplies; global $GBreplies;
global $GBstickylocked;
if (isset($_SESSION["reply"])) { if (isset($_SESSION["reply"])) {
echo $Titles["Replying"],"<br>\n"; echo $Titles["Replying"],"<br>\n";
} }
if ($GBreplies) { if ($GBstickylocked) {
$EntriesReplySorted=$Entries; if (isset($Entries)) {
if (isset($Entries)) foreach($Entries as $Entry) { $EntriesStickySorted=$Entries;
if (isset($Entry[9])) { $i = count($Entries);
unset($a); unset($b); while (--$i >= 0) {
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[5]) $a=$n; if (isset($EntriesStickySorted[$i][12])&&($EntriesStickySorted[$i][12]=="on")) {
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[9]) $b=$n; $item = $EntriesStickySorted[$i];
if (isset($b)) { unset($EntriesStickySorted[$i]);
$out=array_splice($EntriesReplySorted, $a, 1); array_push($EntriesStickySorted, $item);
array_splice($EntriesReplySorted, $b, 0, $out);
}
} }
} }
$Entries=$EntriesReplySorted; $Entries=array_values($EntriesStickySorted);
}
}
if ($GBreplies) {
if (isset($Entries)) {
$EntriesReplySorted=$Entries;
foreach($Entries as $Entry) {
if (isset($Entry[9])) {
unset($a); unset($b);
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[5]) $a=$n;
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[9]) {
if (isset($EntrySort[12])&&$EntrySort[12]=="on") $b=$n-1;
else $b=$n;
}
if (isset($b)) {
if (!(isset($Entry[12])&&$Entry[12]=="on")) {
$out=array_splice($EntriesReplySorted, $a, 1);
array_splice($EntriesReplySorted, $b, 0, $out);
}
}
}
}
$Entries=$EntriesReplySorted;
}
} }
if ($DataStatus=="empty") echo $Titles["EmptyFile"]; if ($DataStatus=="empty") echo $Titles["EmptyFile"];
else if(isset($_POST["search"])&&isset($_POST["serachq"])) { else if(isset($_POST["search"])&&isset($_POST["serachq"])) {

View File

@ -13,7 +13,7 @@ $GBpassword="password";
$GBpagination=10; // pagination for entries, 0 - disabled $GBpagination=10; // pagination for entries, 0 - disabled
$GBreadmore=255; // number of symbols for 'Read More' feature, 0 - shows full entries $GBreadmore=255; // number of symbols for 'Read More' feature, 0 - shows full entries
$GBsearch=true; // enable or disable search bar $GBsearch=true; // enable or disable search bar
$GBcaptcha=true; // enable or disable captcha $GBcaptcha=false; // enable or disable captcha
$GBupload=true; // enable or disable upload image feature $GBupload=true; // enable or disable upload image feature
$GBimagesize=1048576; // maximum image size $GBimagesize=1048576; // maximum image size
$GBnotificationmailto=""; // leave empty if you don't want send notification $GBnotificationmailto=""; // leave empty if you don't want send notification
@ -32,6 +32,7 @@ $GBcategoryfield=array(
$GBstriptags=true; // enable or disable strip tags function during adding new entry $GBstriptags=true; // enable or disable strip tags function during adding new entry
$GBreplies=true; // enable or disable replies to mwssages $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) $GBshownumbers=true; // show or not show number of entries (if replies enabled - numbers will not shown anyway)
$GBstickylocked=true; // stick or lock entries in admin panel
$Titles["HeadTitle"]="Guestbook"; $Titles["HeadTitle"]="Guestbook";
$Titles["Page"]="Guestbook"; $Titles["Page"]="Guestbook";
$Titles["Name"]="Your name"; $Titles["Name"]="Your name";
@ -86,4 +87,6 @@ $Titles["About"]="about";
$Titles["Reply"]="Reply"; $Titles["Reply"]="Reply";
$Titles["Replied"]="replied"; $Titles["Replied"]="replied";
$Titles["Replying"]="Replying to this message:"; $Titles["Replying"]="Replying to this message:";
$Titles["Locked"]="Locked";
$Titles["Sticky"]="Sticky";
?> ?>

View File

@ -33,6 +33,7 @@ $GBcategoryfield=array(
$GBstriptags=true; // включение или отключение функции обрезания тегов при добавлении новой записи $GBstriptags=true; // включение или отключение функции обрезания тегов при добавлении новой записи
$GBreplies=true; // включение или отключение ответов на сообщения $GBreplies=true; // включение или отключение ответов на сообщения
$GBshownumbers=true; // показывать или не показывать номера сообщений (если включены ответы - номера сообщений не будут показываться) $GBshownumbers=true; // показывать или не показывать номера сообщений (если включены ответы - номера сообщений не будут показываться)
$GBstickylocked=true; // приклеивать или лочить записи через панель администратора
$Titles["HeadTitle"]="Гостевая книга"; $Titles["HeadTitle"]="Гостевая книга";
$Titles["Page"]="Гостевая книга"; $Titles["Page"]="Гостевая книга";
$Titles["Name"]="Ваше имя"; $Titles["Name"]="Ваше имя";
@ -87,4 +88,6 @@ $Titles["About"]="о";
$Titles["Reply"]="Ответить"; $Titles["Reply"]="Ответить";
$Titles["Replied"]="ответил"; $Titles["Replied"]="ответил";
$Titles["Replying"]="Ответ на это сообщение:"; $Titles["Replying"]="Ответ на это сообщение:";
$Titles["Locked"]="Нельзя ответить";
$Titles["Sticky"]="Закрепленное сверху";
?> ?>