commit dcc4e5784610d9a015bbb04d5644f70ab1a6f8a0 Author: feder Date: Fri May 6 23:02:56 2016 +0300 Init diff --git a/administration.php b/administration.php new file mode 100644 index 0000000..b0f981d --- /dev/null +++ b/administration.php @@ -0,0 +1,133 @@ +$Entry) fputcsv($fhandle,$Entry); + fclose($fhandle); +} + +function AdminHeaderView() { + global $Titles; + global $GBadmin; + global $GBpassword; + echo "

$Titles[AdminHeader]

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

\n"; + echo "
\n"; + echo " $Titles[AdminHello], $GBadmin!\n"; + } +} + +function AdminEntriesView() { + global $Titles; + global $DataStatus; + global $GBadmin; + global $GBpassword; + global $AdminEntries; + 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 ($_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"; + echo " $Titles[City]
\n"; + echo " $Titles[Link]
\n"; + echo " $Titles[Email]
\n"; + echo " $Titles[AdminMessage]:
\n
\n"; + echo " $Titles[Response]:
\n
\n"; + echo " "; + echo " "; + echo "\n"; + echo "
\n"; + } else { + echo "
\n"; + echo "\n \n"; + foreach($AdminEntries as $e=>$Entry) echo " \n"; + echo "
$Titles[AdminName]$Titles[City]$Titles[Link]$Titles[Email]$Titles[AdminMessage]$Titles[Response]$Titles[AdminDate]
",($e+1),"$Entry[0]$Entry[1]$Entry[2]$Entry[3]",nl2br($Entry[4]),"",nl2br($Entry[6]),"",date("j.m.Y, H:i",$Entry[5]),"
\n"; + echo " \n"; + echo "
\n"; + } else { + if (($_POST["login"])&&(!$_SESSION["SessionStatus"])) echo "$Titles[WrongLogin]
\n"; + echo "
\n"; + echo " $Titles[Login]
\n"; + echo " $Titles[Password]
\n"; + echo " \n"; + echo "
\n"; + } +} + +if ((($_POST["adminlogin"])==$GBadmin)&&(($_POST["adminpass"])==$GBpassword)) $_SESSION["SessionStatus"]=(md5($GBadmin.$GBpassword)); +if ($_POST["exit"]) $_SESSION["SessionStatus"]=""; +if ($_POST["canceldelete"]) { + $_SESSION["DeleteStatus"]=""; + Unset($_SESSION["DeleteEntries"]); + } +if ($_POST["canceledit"]) Unset($_SESSION["EditStatus"]); +if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) { + $AdminEntries=ReadEntries(); + if ($_POST["submitdelete"]) { + $_SESSION["DeleteStatus"]="deletion"; + foreach($AdminEntries as $e=>$Entry) if ($_POST["cb$e"]) $_SESSION["DeleteEntries"][]=$e; + if (!count($_SESSION["DeleteEntries"])) $_SESSION["DeleteStatus"]=""; + } if (($_POST["submiteedit"])&&($_SESSION["EditStatus"])) { + $AdminEntries[($_SESSION["EditStatus"]-1)][0]=$_POST["editname"]; + $AdminEntries[($_SESSION["EditStatus"]-1)][1]=$_POST["editfrom"]; + $AdminEntries[($_SESSION["EditStatus"]-1)][2]=$_POST["editlink"]; + $AdminEntries[($_SESSION["EditStatus"]-1)][3]=$_POST["editmail"]; + $AdminEntries[($_SESSION["EditStatus"]-1)][4]=$_POST["edittext"]; + $AdminEntries[($_SESSION["EditStatus"]-1)][6]=$_POST["editresp"]; + SaveEntries(); + Unset($_SESSION["EditStatus"]); + $AdminEntries=ReadEntries(); + } if ($_POST["applydelete"]) { + if ($_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 (!$_SESSION["EditStatus"]) for ($e=0;$e + + <?php echo $Titles[HeadTitle];?> + + + + +
+ + + diff --git a/gbdb.csv b/gbdb.csv new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php new file mode 100644 index 0000000..cf84c9c --- /dev/null +++ b/index.php @@ -0,0 +1,109 @@ +",$Titles[Page],"
\n"; + if ($PageStatus=="added") echo "$Titles[Added]"; else { + $captchanumber11=rand(1, 4); + $captchanumber12=rand(0, 9); + $captchanumber21=rand(1, 4); + $captchanumber22=rand(0, 9); + $_SESSION['captcha']=md5(base64_encode(($captchanumber11.$captchanumber12)+($captchanumber21.$captchanumber22))); + echo "
\n"; + echo " $Titles[Name]: ($Titles[Required])
\n"; + echo " $Titles[City]:
\n"; + 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"; + echo " \n"; + echo "
\n"; + if ($PageStatus=="emptyname") echo "$Titles[EmptyName]
\n"; + if ($PageStatus=="emptytext") echo "$Titles[EmptyText]
\n"; + if ($PageStatus=="wrongcaptcha") echo "$Titles[WrongCaptcha]
\n"; + } +} + +function EntriesView() { + global $Titles; + global $DataStatus; + global $Entries; + if ($DataStatus=="empty") echo "$Titles[EmptyFile]"; + else { + $Entries=array_reverse($Entries); + foreach($Entries as $e=>$Entry) { + echo " ",$Entry[7],". "; + if ($Entry[2]) echo ""; + echo "",$Entry[0],""; + if ($Entry[2]) echo ""; + if ($Entry[1]) echo " ",$Titles[From]," ",$Entry[1],""; + echo ", ",date("j.m.Y, H:i",$Entry[5]),", ",$Titles[Wrote],":
\n"; + echo " ",nl2br($Entry[4]),"
\n"; + if ($Entry[6]) echo "
$Titles[Response]:
\n"; + if ($Entry[6]) echo nl2br($Entry[6]),"

\n"; + echo "
\n"; + } + } +} + +if($_POST['submit']) { + if(!$_POST['text']) $PageStatus="emptytext"; + if(!$_POST['name']) $PageStatus="emptyname"; + if(($_POST['name'])&&($_POST['text'])) + if ($_POST["captcha"]&&(md5(base64_encode($_POST["captcha"]))==$_SESSION["captcha"])) AddEntry(); + else $PageStatus="wrongcaptcha"; + if (($PageStatus)&&!($PageStatus=="added")) { + $SESSION["value"]["name"]=$_POST['name']; + $SESSION["value"]["from"]=$_POST['from']; + $SESSION["value"]["link"]=$_POST['link']; + $SESSION["value"]["email"]=$_POST['email']; + $SESSION["value"]["text"]=$_POST['text']; + $Values=$SESSION["value"]; + } else Unset($SESSION["value"]); +} + +$Entries=ReadEntries(); + +include "page.php"; +?> diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..54d05da --- /dev/null +++ b/license.txt @@ -0,0 +1,30 @@ +phpCSV Guestbook + +phpCSV Guestbook is released under the DWTW license. + +This program is free software; you can redistribute it and/or modify it under the terms of the Do What Thou Wilt License. + +DO WHAT THAU WILT +TO PUBLIC LICENSE + +Version 2.5 + +Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. Do what thou wilt shall be the whole of the Law. + +Anyone is allowed to copy and distribute the copies of this license agreement in whole or in part, as well as modify it without any other limitations. + +DWTW – a license with a single requirement: DO WHAT THOU WILT + +The license provides more freedom than any other one (such as GPL or BSD) and does not require saving the license text on copying. + +DWTW – an accomplished and eligible license for free text (including the software, documentation and artwork). + +The license does not contain "no warranty" clause. DWTW can be used in countries that do not legally acknowledge the transition to public domain. + +Summary: + +An author-creator gives his or her source code to the world for free, without becoming distracted by worldly thinking regarding how and why the others will use it. \ No newline at end of file diff --git a/page.php b/page.php new file mode 100644 index 0000000..c9d4ce4 --- /dev/null +++ b/page.php @@ -0,0 +1,17 @@ + + + <?php echo $Titles[HeadTitle];?> + + + + +
+ + + diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..70b41ea --- /dev/null +++ b/settings.php @@ -0,0 +1,50 @@ + diff --git a/settings_ru.php b/settings_ru.php new file mode 100644 index 0000000..ae683a8 --- /dev/null +++ b/settings_ru.php @@ -0,0 +1,51 @@ +