$Entry) { unset($Entry[10]); fputcsv($fhandle,$Entry); } fclose($fhandle); } function Search($SearchQuery) { $Entries=ReadEntries(); $SearchResultCount=0; $SearchResult=false; foreach($Entries as $e=>$Entry) { for($p=0; $p<9; $p++) { if (mb_stristr($Entry[$p],$SearchQuery)) { $SearchResult[$SearchResultCount][0]=$e; $SearchResult[$SearchResultCount][1]=$Entry; $SearchResultCount++; break; } } } return $SearchResult; } function AddSearchBar() { global $Titles; global $GBsearch; if ($GBsearch) if (!(isset($_SESSION["EditStatus"]) or ($_SESSION["DeleteStatus"]=="deletion"))) { echo "
"; echo ""; echo ""; echo "
"; } } function AdminHeaderView() { global $Titles; global $GBadmin; global $GBpassword; echo "

",$Titles["AdminHeader"],"

\n"; if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) { echo "
",AddSearchBar(),"
"; echo "
\n"; echo "

\n"; echo "
\n"; echo " ",$Titles["AdminHello"],", $GBadmin!\n"; } } function SingleEntry($Entry) { global $Titles; global $GBcityfield; global $GBlinkfield; global $GBsubjectfield; global $GBcategoryfield; echo " ",($Entry[10]),"$Entry[0]"; if ($GBcityfield) echo "$Entry[1]"; if ($GBlinkfield) echo "$Entry[2]"; if ($GBsubjectfield) echo "$Entry[7]"; if ($GBcategoryfield) echo "$Entry[8]"; echo "$Entry[3]",nl2br($Entry[4]),"",nl2br($Entry[6]),"",date("j.m.Y, H:i",$Entry[5]),"\n"; } function AdminEntriesView() { global $Titles; global $DataStatus; global $GBadmin; global $GBpassword; global $AdminEntries; global $GBpagination; global $GBtextlenght; global $GBcityfield; global $GBlinkfield; global $GBsubjectfield; global $GBcategoryfield; if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) if ($DataStatus=="empty") echo $Titles["EmptyFile"],"\n"; else if ($_SESSION["DeleteStatus"]=="deletion") { echo " ",$Titles["AdminSureDel"]," ",count($_SESSION["DeleteEntries"])," ",$Titles["AdminSureDelMessages"],"?\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; } else if (isset($_SESSION["EditStatus"])) { echo " ",$Titles["AdminMessage"]," ", ($_SESSION["EditStatus"]),", ",date("j.m.Y, H:i",$AdminEntries[($_SESSION["EditStatus"]-1)][5]),":
\n"; echo "
\n"; echo " ",$Titles["AdminName"],":
\n"; if ($GBcityfield) echo " ",$Titles["City"],"
\n"; if ($GBlinkfield) echo " ",$Titles["Link"],"
\n"; echo " ",$Titles["Email"],"
\n"; if ($GBsubjectfield) echo " ",$Titles["Subject"],"
\n"; if ($GBcategoryfield) { echo " ",$Titles["Category"],"
\n"; } echo " ",$Titles["AdminMessage"],":
\n
\n"; echo " ",$Titles["Response"],":
\n
\n"; echo " "; echo " "; echo "\n"; echo "
\n"; } else { if(isset($_POST["search"])&&$_POST["serachq"]) { $SearchResult=Search($_POST["serachq"]); if ($SearchResult) { $GBpagination=0; unset($AdminEntries); foreach($SearchResult as $n=>$Entry) $AdminEntries[$n]=$Entry[1]; } else echo $Titles["NoResult"],": '",$_POST["serachq"],"'.
\n"; } if (($GBpagination>0)&&(count($AdminEntries)>$GBpagination)) { $Entries=array_reverse($AdminEntries); if (isset($_GET["page"])) switch ($_GET["page"]) { case $Titles["First"]: $CurrentPage=0; break; case $Titles["Last"]: $CurrentPage=intdiv(count($Entries),$GBpagination); break; case $Titles["Previous"]: $CurrentPage=$_SESSION["currentpage"]-1; break; case $Titles["Next"]: $CurrentPage=$_SESSION["currentpage"]+1; break; default: $CurrentPage=$_GET["page"]-1; } else $CurrentPage=0; echo "
\n"; if ($CurrentPage>0) { echo " \n"; echo " \n"; } for ($p = ($CurrentPage-2); $p <= ($CurrentPage+2); $p++) { $page = $p+1; if (($p>=0)&&($p<(count($Entries)/$GBpagination))) { echo " \n"; } } if ($CurrentPage<((count($Entries)/$GBpagination)-1)) { echo " \n"; echo " \n"; } echo "
\n"; echo "
\n"; echo "\n "; if ($GBcityfield) echo ""; if ($GBlinkfield) echo ""; if ($GBsubjectfield) echo ""; if ($GBcategoryfield) echo ""; echo "\n"; for ($e = ($GBpagination*$CurrentPage); $e < ($GBpagination*($CurrentPage+1)); $e++) { if ($e>=count($Entries)) break; $Entry = $Entries[$e]; SingleEntry($Entry); } $_SESSION["currentpage"]=$CurrentPage; } else { echo "\n"; echo "
",$Titles["AdminName"],"",$Titles["City"],"",$Titles["Link"],"",$Titles["Subject"],"",$Titles["Category"],"",$Titles["Email"],"",$Titles["AdminMessage"],"",$Titles["Response"],"",$Titles["AdminDate"],"
\n "; if ($GBcityfield) echo ""; if ($GBlinkfield) echo ""; if ($GBsubjectfield) echo ""; if ($GBcategoryfield) echo ""; echo "\n"; $Entries=array_reverse($AdminEntries); foreach($Entries as $e=>$Entry) SingleEntry($Entry); } echo "
",$Titles["AdminName"],"",$Titles["City"],"",$Titles["Link"],"",$Titles["Subject"],"",$Titles["Category"],"",$Titles["Email"],"",$Titles["AdminMessage"],"",$Titles["Response"],"",$Titles["AdminDate"],"
\n"; echo " \n"; echo "
\n"; } else { if (isset($_POST["login"])&&(!$_SESSION["SessionStatus"])) echo $Titles["WrongLogin"],"
\n"; echo "
\n"; echo " ",$Titles["Login"],"
\n"; echo " ",$Titles["Password"],"
\n"; echo " \n"; echo "
\n"; } } if (isset($_POST["adminlogin"])) if ((($_POST["adminlogin"])==$GBadmin)&&(($_POST["adminpass"])==$GBpassword)) $_SESSION["SessionStatus"]=(md5($GBadmin.$GBpassword)); if (isset($_POST["exit"])) $_SESSION["SessionStatus"]=""; if (isset($_POST["canceldelete"])) { $_SESSION["DeleteStatus"]=""; Unset($_SESSION["DeleteEntries"]); } if (isset($_POST["canceledit"])) Unset($_SESSION["EditStatus"]); if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) { $AdminEntries=ReadEntries(); 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($_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"]; else $AdminEntries[($_SESSION["EditStatus"]-1)][1]=""; if (isset($_POST["editlink"])) $AdminEntries[($_SESSION["EditStatus"]-1)][2]=$_POST["editlink"]; else $AdminEntries[($_SESSION["EditStatus"]-1)][2]=""; $AdminEntries[($_SESSION["EditStatus"]-1)][3]=$_POST["editmail"]; $AdminEntries[($_SESSION["EditStatus"]-1)][4]=$_POST["edittext"]; $AdminEntries[($_SESSION["EditStatus"]-1)][6]=$_POST["editresp"]; if (isset($_POST["editsubj"])) $AdminEntries[($_SESSION["EditStatus"]-1)][7]=$_POST["editsubj"]; else $AdminEntries[($_SESSION["EditStatus"]-1)][7]=""; if (isset($_POST["editcategory"])) $AdminEntries[($_SESSION["EditStatus"]-1)][8]=$_POST["editcategory"]; else $AdminEntries[($_SESSION["EditStatus"]-1)][8]=""; SaveEntries(); Unset($_SESSION["EditStatus"]); $AdminEntries=ReadEntries(); } if (isset($_POST["applydelete"])) if ($_POST["applydelete"]) { if (isset($_SESSION["EditStatus"])) { Unset($AdminEntries[($_SESSION["EditStatus"]-1)]); SaveEntries(); Unset($_SESSION["EditStatus"]); $AdminEntries=ReadEntries(); } if ($_SESSION["DeleteStatus"]) { foreach($_SESSION["DeleteEntries"] as $e=>$DelEnt) Unset($AdminEntries[$DelEnt]); SaveEntries(); Unset($_SESSION["DeleteEntries"]); $_SESSION["DeleteStatus"]=""; $AdminEntries=ReadEntries(); } } if (!isset($_SESSION["EditStatus"])) for ($e=0;$e <?php echo $Titles["HeadTitle"];?>