Added locked and sticky posts
This commit is contained in:
parent
5a0ecd8a72
commit
68618f974f
3
README
3
README
|
@ -1,4 +1,4 @@
|
|||
PHPCSV Guestbook version 0.99
|
||||
PHPCSV Guestbook version 0.99.2
|
||||
|
||||
Simple php guestbook with csv file data storage.
|
||||
|
||||
|
@ -11,6 +11,7 @@ Features:
|
|||
- Pagination
|
||||
- Categories
|
||||
- Replies
|
||||
- Locked and sticky posts
|
||||
|
||||
Working example: https://zlaxyi.soundragon.su/gb
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ function AdminEntriesView() {
|
|||
global $GBlinkfield;
|
||||
global $GBsubjectfield;
|
||||
global $GBcategoryfield;
|
||||
global $GBstickylocked;
|
||||
if (isset($_SESSION["SessionStatus"])?($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))):false) if ($DataStatus=="empty") echo $Titles["EmptyFile"],"\n";
|
||||
else if (isset($_SESSION["DeleteStatus"])) {
|
||||
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["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=\"applydelete\" value=\"",$Titles["AdminDelete"],"\"> ";
|
||||
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]="";
|
||||
if (isset($_POST["editcategory"])) $AdminEntries[($_SESSION["EditStatus"]-1)][8]=$_POST["editcategory"];
|
||||
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();
|
||||
Unset($_SESSION["EditStatus"]);
|
||||
$AdminEntries=ReadEntries();
|
||||
|
|
32
index.php
32
index.php
|
@ -208,6 +208,10 @@ function SinlgeEntry($Entry) {
|
|||
echo " ";
|
||||
if ($GBreplies&&isset($Entry[9])&&$Entry[9]) echo "<div class=\"reply\">";
|
||||
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 ($Entry[2]) echo "<a href=\"",$Entry[2],"\">";
|
||||
echo "<b>",$Entry[0],"</b>";
|
||||
|
@ -234,7 +238,7 @@ function SinlgeEntry($Entry) {
|
|||
} else 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";
|
||||
if ($GBreplies) {
|
||||
if ($GBreplies&&!($Entry[11])) {
|
||||
echo "<form action=index.php method=post>";
|
||||
echo "<p align=\"right\"><button type=submit name=\"reply\" value=\"",$Entry[10],"\">",$Titles["Reply"],"</button></p>";
|
||||
echo "</form>";
|
||||
|
@ -255,24 +259,46 @@ function EntriesView() {
|
|||
global $GBsubjectfield;
|
||||
global $GBcategoryfield;
|
||||
global $GBreplies;
|
||||
global $GBstickylocked;
|
||||
if (isset($_SESSION["reply"])) {
|
||||
echo $Titles["Replying"],"<br>\n";
|
||||
}
|
||||
if ($GBstickylocked) {
|
||||
if (isset($Entries)) {
|
||||
$EntriesStickySorted=$Entries;
|
||||
$i = count($Entries);
|
||||
while (--$i >= 0) {
|
||||
if (isset($EntriesStickySorted[$i][12])&&($EntriesStickySorted[$i][12]=="on")) {
|
||||
$item = $EntriesStickySorted[$i];
|
||||
unset($EntriesStickySorted[$i]);
|
||||
array_push($EntriesStickySorted, $item);
|
||||
}
|
||||
}
|
||||
$Entries=array_values($EntriesStickySorted);
|
||||
}
|
||||
}
|
||||
if ($GBreplies) {
|
||||
if (isset($Entries)) {
|
||||
$EntriesReplySorted=$Entries;
|
||||
if (isset($Entries)) foreach($Entries as $Entry) {
|
||||
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]) $b=$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"];
|
||||
else if(isset($_POST["search"])&&isset($_POST["serachq"])) {
|
||||
$SearchResult=Search($_POST["serachq"]);
|
||||
|
|
|
@ -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=true; // enable or disable captcha
|
||||
$GBcaptcha=false; // 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
|
||||
|
@ -32,6 +32,7 @@ $GBcategoryfield=array(
|
|||
$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)
|
||||
$GBstickylocked=true; // stick or lock entries in admin panel
|
||||
$Titles["HeadTitle"]="Guestbook";
|
||||
$Titles["Page"]="Guestbook";
|
||||
$Titles["Name"]="Your name";
|
||||
|
@ -86,4 +87,6 @@ $Titles["About"]="about";
|
|||
$Titles["Reply"]="Reply";
|
||||
$Titles["Replied"]="replied";
|
||||
$Titles["Replying"]="Replying to this message:";
|
||||
$Titles["Locked"]="Locked";
|
||||
$Titles["Sticky"]="Sticky";
|
||||
?>
|
||||
|
|
|
@ -33,6 +33,7 @@ $GBcategoryfield=array(
|
|||
$GBstriptags=true; // включение или отключение функции обрезания тегов при добавлении новой записи
|
||||
$GBreplies=true; // включение или отключение ответов на сообщения
|
||||
$GBshownumbers=true; // показывать или не показывать номера сообщений (если включены ответы - номера сообщений не будут показываться)
|
||||
$GBstickylocked=true; // приклеивать или лочить записи через панель администратора
|
||||
$Titles["HeadTitle"]="Гостевая книга";
|
||||
$Titles["Page"]="Гостевая книга";
|
||||
$Titles["Name"]="Ваше имя";
|
||||
|
@ -87,4 +88,6 @@ $Titles["About"]="о";
|
|||
$Titles["Reply"]="Ответить";
|
||||
$Titles["Replied"]="ответил";
|
||||
$Titles["Replying"]="Ответ на это сообщение:";
|
||||
$Titles["Locked"]="Нельзя ответить";
|
||||
$Titles["Sticky"]="Закрепленное сверху";
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue