Werbung:

Ein Adventskalender für registrierte User!
Hier die etwas aufwändige Einbauanleitung:
Zuerst erweitert man die etchat_user-Tabelle in der Datenbank um eine Spalte namens adventcount und setzt diese auf VARCHAR(24).
Wenn wir schon dabei sind, legen wir eine Tabelle etchat_advent komplett neu an. Bedenkt das Präfix dazu. Sollte euer Präfix db1_ lauten muss die Tabelle natürlich db1_etchat_advent heißen.
Gebt folgende Spalten an:
id int(8) AUTO_INCREMENT,
tuer VARCHAR(2),
inhalt TEXT
Nun braucht die etchat_advent erst noch 25 Einträge. Id wird automatisch gemacht. In tuer schreibt man die Zahl von 1 - 25. Den Rest kann man leer lassen.
Mit der DB sind wir fertig und machen uns an die großen Dateien.
In euer class-Verzeichnis kommt eine Datei namens adventshow.class.php mit diesem Inhalt Code  <?php
/**
* Adventskalender fuer ET-Chat v3
*
* LICENSE: CREATIVE COMMONS PUBLIC LICENSE "Namensnennung Nicht-kommerziell 2.0"
*
* @copyright Fizzy Lemon
* @license http://creativecommons.org/licenses/by-nc/2.0/de/
* @version 1.0
*/
class adventshow extends DbConectionMaker
{
public function __construct (){
// call parent Constructor from class DbConectionMaker
parent::__construct();
session_start();
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('content-type: application/html; charset=utf-8');
$hgbild="img/christmas-snowflake-green-background.jpg"; //<<<< hier wird das Hintergrundbild eingetragen
$userid=$_POST['userid'];
$door=$_POST['door'];
$akt_Tag=date("j");
$entry_array=$this->dbObj->sqlGet("SELECT inhalt FROM {$this->_prefix}etchat_advent");
$user_array=$this->dbObj->sqlGet("SELECT adventcount FROM {$this->_prefix}etchat_user WHERE etchat_user_id = ".$userid);
$door_open00=$user_array[0][0];
$door_open01=$door_open00[0];
$door_open02=$door_open00[1];
$door_open03=$door_open00[2];
$door_open04=$door_open00[3];
$door_open05=$door_open00[4];
$door_open06=$door_open00[5];
$door_open07=$door_open00[6];
$door_open08=$door_open00[7];
$door_open09=$door_open00[8];
$door_open10=$door_open00[9];
$door_open11=$door_open00[10];
$door_open12=$door_open00[11];
$door_open13=$door_open00[12];
$door_open14=$door_open00[13];
$door_open15=$door_open00[14];
$door_open16=$door_open00[15];
$door_open17=$door_open00[16];
$door_open18=$door_open00[17];
$door_open19=$door_open00[18];
$door_open20=$door_open00[19];
$door_open21=$door_open00[20];
$door_open22=$door_open00[21];
$door_open23=$door_open00[22];
$door_open24=$door_open00[23];
echo"<style>.calender {background-image: url('$hgbild');} .door25{width: 496px; height: 330px; border: 1px solid orange; margin: 2px; text-align: center; font-weight: 800; font-size: 24px; color: orange; text-shadow: 2px 2px 2px black, 1px -1px 0px black, -1px -1px 0px black, -1px 1px 0px black, 1px 1px 0px black; } td.open{background-color: black; font-weight: 800; font-size: 24px; color: orange; text-shadow: 2px 2px 2px black, 1px -1px 0px black, -1px -1px 0px black, -1px 1px 0px black, 1px 1px 0px black; width: 80px; height: 80px; border: 1px solid orange; cursor: pointer; text-align: center;} td.door{font-weight: 800; font-size: 24px; color: orange; text-shadow: 2px 2px 2px black, 1px -1px 0px black, -1px -1px 0px black, -1px 1px 0px black, 1px 1px 0px black; width: 80px; height: 80px; border: 1px solid orange; cursor: pointer; text-align: center;} td.door:hover{background-color: rgba(22,22,22,0.8); color: #fff; border: 1px solid white;} .btn-back{background-color: black; color: white; text-align: center; width: 150px; margin: 5px; padding: 5px; cursor: pointer;} .btn-back:hover{background-color: green; color: white; text-align: center; width: 150px; margin: 5px; padding: 5px; cursor: pointer;}</style>";
if ($door=="0"){
echo"<div class=\"calender\" id=\"advent-calender\"><table>";
echo"<tr>";
if ($door_open22=="0"){
echo"<td class=\"door\" id=\"door22\">22</td>";
} else {
echo"<td class=\"open\" id=\"door22\">22</td>";
}
if ($door_open09=="0"){
echo"<td class=\"door\" id=\"door9\">9</td>";
} else {
echo"<td class=\"open\" id=\"door9\">9</td>";
}
if ($door_open05=="0"){
echo"<td class=\"door\" id=\"door5\">5</td>";
} else {
echo"<td class=\"open\" id=\"door5\">5</td>";
}
if ($door_open02=="0"){
echo"<td class=\"door\" id=\"door2\">2</td>";
} else {
echo"<td class=\"open\" id=\"door2\">2</td>";
}
if ($door_open15=="0"){
echo"<td class=\"door\" id=\"door15\">15</td>";
} else {
echo"<td class=\"open\" id=\"door15\">15</td>";
}
if ($door_open06=="0"){
echo"<td class=\"door\" id=\"door6\">6</td>";
} else {
echo"<td class=\"open\" id=\"door6\">6</td>";
}
echo"</tr><tr>";
if ($door_open08=="0"){
echo"<td class=\"door\" id=\"door8\">8</td>";
} else {
echo"<td class=\"open\" id=\"door8\">8</td>";
}
if ($door_open01=="0"){
echo"<td class=\"door\" id=\"door1\">1</td>";
} else {
echo"<td class=\"open\" id=\"door1\">1</td>";
}
if ($door_open16=="0"){
echo"<td class=\"door\" id=\"door16\">16</td>";
} else {
echo"<td class=\"open\" id=\"door16\">16</td>";
}
if ($door_open14=="0"){
echo"<td class=\"door\" id=\"door14\">14</td>";
} else {
echo"<td class=\"open\" id=\"door14\">14</td>";
}
if ($door_open21=="0"){
echo"<td class=\"door\" id=\"door21\">21</td>";
} else {
echo"<td class=\"open\" id=\"door21\">21</td>";
}
if ($door_open12=="0"){
echo"<td class=\"door\" id=\"door12\">12</td>";
} else {
echo"<td class=\"open\" id=\"door12\">12</td>";
}
echo"</tr><tr>";
if ($door_open03=="0"){
echo"<td class=\"door\" id=\"door3\">3</td>";
} else {
echo"<td class=\"open\" id=\"door3\">3</td>";
}
if ($door_open07=="0"){
echo"<td class=\"door\" id=\"door7\">7</td>";
} else {
echo"<td class=\"open\" id=\"door7\">7</td>";
}
if ($door_open11=="0"){
echo"<td class=\"door\" id=\"door11\">11</td>";
} else {
echo"<td class=\"open\" id=\"door11\">11</td>";
}
if ($door_open19=="0"){
echo"<td class=\"door\" id=\"door19\">19</td>";
} else {
echo"<td class=\"open\" id=\"door19\">19</td>";
}
if ($door_open24=="0"){
echo"<td class=\"door\" id=\"door24\">24</td>";
} else {
echo"<td class=\"open\" id=\"door24\">24</td>";
}
if ($door_open20=="0"){
echo"<td class=\"door\" id=\"door20\">20</td>";
} else {
echo"<td class=\"open\" id=\"door20\">20</td>";
}
echo"</tr><tr>";
if ($door_open13=="0"){
echo"<td class=\"door\" id=\"door13\">13</td>";
} else {
echo"<td class=\"open\" id=\"door13\">13</td>";
}
if ($door_open23=="0"){
echo"<td class=\"door\" id=\"door23\">23</td>";
} else {
echo"<td class=\"open\" id=\"door23\">23</td>";
}
if ($door_open18=="0"){
echo"<td class=\"door\" id=\"door18\">18</td>";
} else {
echo"<td class=\"open\" id=\"door18\">18</td>";
}
if ($door_open04=="0"){
echo"<td class=\"door\" id=\"door4\">4</td>";
} else {
echo"<td class=\"open\" id=\"door4\">4</td>";
}
if ($door_open10=="0"){
echo"<td class=\"door\" id=\"door10\">10</td>";
} else {
echo"<td class=\"open\" id=\"door10\">10</td>";
}
if ($door_open17=="0"){
echo"<td class=\"door\" id=\"door17\">17</td>";
} else {
echo"<td class=\"open\" id=\"door17\">17</td>";
}
echo"</tr></table></div><br><center><div class=\"advent-footer\" id=\"advent-footer\">Script by Fizzy Lemon</div></center>";
}
elseif ($door=="1" && $akt_Tag > 0){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[0][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open01="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="2" && $akt_Tag > 1){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[1][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open02="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="3" && $akt_Tag > 2){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[2][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open03="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="4" && $akt_Tag > 3){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[3][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open04="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="5" && $akt_Tag > 4){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[4][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open05="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="6" && $akt_Tag > 5){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[5][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open06="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="7" && $akt_Tag > 6){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[6][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open07="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="8" && $akt_Tag > 7){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[7][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open08="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="9" && $akt_Tag > 8){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[8][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open09="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="10" && $akt_Tag > 9){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[9][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open10="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="11" && $akt_Tag > 10){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[10][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open11="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="12" && $akt_Tag > 11){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[11][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open12="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="13" && $akt_Tag > 12){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[12][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open13="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="14" && $akt_Tag > 13){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[13][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open14="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="15" && $akt_Tag > 14){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[14][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open15="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="16" && $akt_Tag > 15){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[15][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open16="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="17" && $akt_Tag > 16){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[16][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open17="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="18" && $akt_Tag > 17){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[17][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open18="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="19" && $akt_Tag > 18){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[18][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open19="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="20" && $akt_Tag > 19){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[19][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open20="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="21" && $akt_Tag > 20){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[20][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open21="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="22" && $akt_Tag > 21){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[21][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open22="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="23" && $akt_Tag > 22){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[22][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open23="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
}
elseif ($door=="24" && $akt_Tag > 23){
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[23][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
$door_open24="1";
$door_open00=$door_open01.$door_open02.$door_open03.$door_open04.$door_open05.$door_open06.$door_open07.$door_open08.$door_open09.$door_open10.$door_open11.$door_open12.$door_open13.$door_open14.$door_open15.$door_open16.$door_open17.$door_open18.$door_open19.$door_open20.$door_open21.$door_open22.$door_open23.$door_open24;
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '".$door_open00."' WHERE etchat_user_id = ".$userid);
} else {
echo "<div class=\"calender\" id=\"advent-calender\"><table><tr><td class=\"door25\">".$entry_array[24][0]."</td></tr></table></div><br><center><div class=\"btn-back\" id=\"door0\">Zurück</div></center>";
}
$this->dbObj->close();
}
}
Dort solltet ihr auch in der Variablen $hgbild eine Grafik verlinken. Styling ist dort direkt im Code. Wer das nicht möchte, kann die Einträge auch in die CSS übertragen.
In das styles/admin_tpl -Verzeichnis kommt eine Datei namens Advent.tpl.html und diesem Inhalt
Code  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>Adventskalender</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="styles/<?php echo $_SESSION['etchat_'.$this->_prefix.'style']; ?>/style.css" rel="stylesheet" type="text/css"/>
<script src="js/prototype.js" type="text/javascript"></script>
</head>
<body id="adminbereich_body">
<?php
echo "<a href=\"./?AdminIndex\"><<< Zurueck</a><hr size=\"1\">";
if (is_array($feld)){
echo "Geben Sie hier den Text ein, der hinter den Türchen auftauchen soll. <br /><br />";
echo "
<form action=\"./?AdminAdventUpdate\" method=\"post\">
<div>Türchen 1:</div><textarea name=\"adventinhalt1\" id=\"advent1\" cols=\"30\" rows=\"8\">".$feld[0][1]."</textarea><br />
<div>Türchen 2:</div><textarea name=\"adventinhalt2\" id=\"advent2\" cols=\"30\" rows=\"8\">".$feld[1][1]."</textarea><br />
<div>Türchen 3:</div><textarea name=\"adventinhalt3\" id=\"advent3\" cols=\"30\" rows=\"8\">".$feld[2][1]."</textarea><br />
<div>Türchen 4:</div><textarea name=\"adventinhalt4\" id=\"advent4\" cols=\"30\" rows=\"8\">".$feld[3][1]."</textarea><br />
<div>Türchen 5:</div><textarea name=\"adventinhalt5\" id=\"advent5\" cols=\"30\" rows=\"8\">".$feld[4][1]."</textarea><br />
<div>Türchen 6:</div><textarea name=\"adventinhalt6\" id=\"advent6\" cols=\"30\" rows=\"8\">".$feld[5][1]."</textarea><br />
<div>Türchen 7:</div><textarea name=\"adventinhalt7\" id=\"advent7\" cols=\"30\" rows=\"8\">".$feld[6][1]."</textarea><br />
<div>Türchen 8:</div><textarea name=\"adventinhalt8\" id=\"advent8\" cols=\"30\" rows=\"8\">".$feld[7][1]."</textarea><br />
<div>Türchen 9:</div><textarea name=\"adventinhalt9\" id=\"advent9\" cols=\"30\" rows=\"8\">".$feld[8][1]."</textarea><br />
<div>Türchen 10:</div><textarea name=\"adventinhalt10\" id=\"advent10\" cols=\"30\" rows=\"8\">".$feld[9][1]."</textarea><br />
<div>Türchen 11:</div><textarea name=\"adventinhalt11\" id=\"advent11\" cols=\"30\" rows=\"8\">".$feld[10][1]."</textarea><br />
<div>Türchen 12:</div><textarea name=\"adventinhalt12\" id=\"advent12\" cols=\"30\" rows=\"8\">".$feld[11][1]."</textarea><br />
<div>Türchen 13:</div><textarea name=\"adventinhalt13\" id=\"advent13\" cols=\"30\" rows=\"8\">".$feld[12][1]."</textarea><br />
<div>Türchen 14:</div><textarea name=\"adventinhalt14\" id=\"advent14\" cols=\"30\" rows=\"8\">".$feld[13][1]."</textarea><br />
<div>Türchen 15:</div><textarea name=\"adventinhalt15\" id=\"advent15\" cols=\"30\" rows=\"8\">".$feld[14][1]."</textarea><br />
<div>Türchen 16:</div><textarea name=\"adventinhalt16\" id=\"advent16\" cols=\"30\" rows=\"8\">".$feld[15][1]."</textarea><br />
<div>Türchen 17:</div><textarea name=\"adventinhalt17\" id=\"advent17\" cols=\"30\" rows=\"8\">".$feld[16][1]."</textarea><br />
<div>Türchen 18:</div><textarea name=\"adventinhalt18\" id=\"advent18\" cols=\"30\" rows=\"8\">".$feld[17][1]."</textarea><br />
<div>Türchen 19:</div><textarea name=\"adventinhalt19\" id=\"advent19\" cols=\"30\" rows=\"8\">".$feld[18][1]."</textarea><br />
<div>Türchen 20:</div><textarea name=\"adventinhalt20\" id=\"advent20\" cols=\"30\" rows=\"8\">".$feld[19][1]."</textarea><br />
<div>Türchen 21:</div><textarea name=\"adventinhalt21\" id=\"advent21\" cols=\"30\" rows=\"8\">".$feld[20][1]."</textarea><br />
<div>Türchen 22:</div><textarea name=\"adventinhalt22\" id=\"advent22\" cols=\"30\" rows=\"8\">".$feld[21][1]."</textarea><br />
<div>Türchen 23:</div><textarea name=\"adventinhalt23\" id=\"advent23\" cols=\"30\" rows=\"8\">".$feld[22][1]."</textarea><br />
<div>Türchen 24:</div><textarea name=\"adventinhalt24\" id=\"advent24\" cols=\"30\" rows=\"8\">".$feld[23][1]."</textarea><br />
<div>Noch nicht:</div><textarea name=\"adventinhalt25\" id=\"advent25\" cols=\"30\" rows=\"8\">".$feld[24][1]."</textarea><br /><br />
<input type=\"Submit\" name=\"\" value=\"Ändern\"><br /> <br />
</form>";
}else{
echo "Fehler!";
return false;
}
?>
</body>
</html>
In das class/admin-Verzeichnis kommen zwei weitere Dateien, einmal die AdminAdventIndex.class.php und diesem Inhalt
Code  <?php
/**
* Adventskalender fuer ET-Chat v3
*
* LICENSE: CREATIVE COMMONS PUBLIC LICENSE "Namensnennung Nicht-kommerziell 2.0"
*
* @copyright Fizzy Lemon
* @license http://creativecommons.org/licenses/by-nc/2.0/de/
* @version 1.0
*/
class AdminAdventIndex extends DbConectionMaker
{
public function __construct (){
parent::__construct();
session_start();
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('content-type: text/html; charset=utf-8');
if ($_SESSION['etchat_'.$this->_prefix.'user_priv']=="admin"){
$feld=$this->dbObj->sqlGet("SELECT tuer, inhalt FROM {$this->_prefix}etchat_advent");
$this->dbObj->close();
include_once("styles/admin_tpl/Advent.tpl.html");
}
}
}
sowie eine Datei namens AdminAdventUpdate.class.php in die ihr das hier eintragen dürft.
Code  <?php
/**
* Adventskalender fuer ET-Chat v3
*
* LICENSE: CREATIVE COMMONS PUBLIC LICENSE "Namensnennung Nicht-kommerziell 2.0"
*
* @copyright Fizzy Lemon
* @license http://creativecommons.org/licenses/by-nc/2.0/de/
* @version 1.0
*/
class AdminAdventUpdate extends DbConectionMaker
{
public function __construct (){
parent::__construct();
session_start();
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('content-type: text/html; charset=utf-8');
if ($_SESSION['etchat_'.$this->_prefix.'user_priv']=="admin"){
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt1']."' WHERE tuer = '1'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt2']."' WHERE tuer = '2'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt3']."' WHERE tuer = '3'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt4']."' WHERE tuer = '4'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt5']."' WHERE tuer = '5'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt6']."' WHERE tuer = '6'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt7']."' WHERE tuer = '7'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt8']."' WHERE tuer = '8'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt9']."' WHERE tuer = '9'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt10']."' WHERE tuer = '10'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt11']."' WHERE tuer = '11'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt12']."' WHERE tuer = '12'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt13']."' WHERE tuer = '13'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt14']."' WHERE tuer = '14'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt15']."' WHERE tuer = '15'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt16']."' WHERE tuer = '16'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt17']."' WHERE tuer = '17'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt18']."' WHERE tuer = '18'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt19']."' WHERE tuer = '19'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt20']."' WHERE tuer = '20'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt21']."' WHERE tuer = '21'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt22']."' WHERE tuer = '22'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt23']."' WHERE tuer = '23'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt24']."' WHERE tuer = '24'");
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_advent SET inhalt = '".$_POST['adventinhalt25']."' WHERE tuer = '25'");
$this->dbObj->close();
echo "<a href=\"./?AdminIndex\"><<< Zurueck</a><hr size=\"1\">";
echo "Update erfolgreich!";
}else{
echo "<a href=\"./?AdminIndex\"><<< Zurueck</a><hr size=\"1\">";
echo "Fehler!";
return false;
}
}
}
Nun sind noch ein paar kleinere Eingriffe nötig. Einmal in der UserCheckerAndInserter.class.php
sucht:
Code  // if the user name is just exists in the user table
if (is_array($this->_user_exists)){
fügt dahinter in einer neuen Zeile ein:
Code  if (date('n') != 12){
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_user SET adventcount = '000000000000000000000000' WHERE etchat_user_id = ".$this->_user_exists[0][0]);
}
Durch diesen Eingriff stellt ihr sicher, dass der Vermerk, welches Türchen der User schon geöffnet hat, von Januar bis November auf 0 gesetzt wird. Nur im Dezember bleibt dieses "Gedächtnis" bestehen.
Nun geht es in die chat.js, wo drei Erweiterungen gemacht werden müssen:
Ganz oben kommt noch ein zusätzlcher Eintrag rein
sucht:
Code 
fügt dahinter in einer neuen Zeile ein:
Code  this.win_adventskalender;
Etwas weiter unten
sucht:
Code  AjaxReadRequest(); // Erste Messageabfrage beim Start
und ersetzt den Code mit:
Code  //##### ADVENTSKALENDER START #####
if (self.userPrivilegienGlobal!='gast'){
var monat = new Date(), dezember = monat.getMonth(), deztag = monat.getDate();
if (dezember==11 && deztag < 28){
self.adventskalender(0);
}}
//##### ADVENTSKALENDER ENDE #####
AjaxReadRequest(); // Erste Messageabfrage beim Start
Wundert Euch nicht über die 11. In JavaScript ist der Dezember 11 und der Januar 0. Mit diesem Abschnitt stellt ihr sicher, dass Nicht-Gästen nur im Dezember der Kalender angezeigt wird. Zum Testen des Kalenders könnt ihr die 11 einfach auf 10 (November) setzen oder wann immer ihr das auch testen wollt. deztag gibt an, bis zu welchem Tag im Dezember der Kalender angezeigt werden soll. In diesem Beispiel nur bis einschließlich 27. Dezember. (<28)
Wer nicht möchte, dass der Kalender automatisch auftaucht, kann auch einen Button in der Leiste unten anzeigen lassen, den man drückt, um das Kalenderfenster zu öffnen. Wer das möchte, setzt stattdessen folgenen Abschnitt ein (beachtet, dass ihr natürlich die Quelle des img_button setzen müsst!):
Code  //##### ADVENTSKALENDER START ##############
if (self.userPrivilegienGlobal!='gast'){
var monat = new Date(), dezember = monat.getMonth(), deztag = monat.getDate();
if (dezember==11 && deztag < 28){
$("form_right").innerHTML+=" <img id="advent_button" class="img_button" src="img/advent.png" width="32" height="32" border="0" alt="Adventskalender" title="Adventskalender">";
}
$("advent_button").onclick = function(){
self.adventskalender(0);
}
}
//##### ADVENTSKALENDER ENDE ##############
Nun gehts weiter runter bis zum Anfang des HistoryWindows
sucht:
Code  // (Stop) UseronlineUpdater - uebertragung der Chatrooms und Onlineuser im Interval ----------------------------
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fügt dahinter in einer neuen Zeile ein:
Code 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// (Start) Adventskalender --------------------------------------------------------------------------------------
this.adventskalender = function(door) {
if (typeof self.win_adventskalender!="object"){
var hoehe = ($('chatinhalt').getHeight()-200);
var breite = ($('chatinhalt').getWidth()-250);
self.win_adventskalender = new Window({title: "Adventskalender", className: self.win_style, width:500, height:400, top:eval(hoehe/2), left:eval(breite/2), resizable: false, showEffect:Effect.Appear, hideEffect: Effect.Fade, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}, draggable: true, minimizable: false, maximizable: false, destroyOnClose: true });
self.win_adventskalender.setHTMLContent('<div id="advent-calender">Loading...</div>');
}
self.win_adventskalender.show();
new Ajax.Request("./?adventshow",
{
onSuccess:function(result){
$("advent-calender").innerHTML=result.responseText;
Event.observe('advent-calender', 'click', function(event){
if (Event.element(event).id.slice(0, 4)=="door"){
Event.stop(event);
self.adventskalender(Event.element(event).id.slice(4, Event.element(event).id.length));
}});
Event.observe('door25', 'click', function(event){
Event.stop(event);
self.adventskalender(0);
} );
},
postBody: "door="+door+"&userid="+self.user_id
});
}
// (Stop) Adventskalender --------------------------------------------------------------------------------------
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Nun noch zur Bequemlichkeit. Damit man die Türchen einfach befüllen kann, erweitert man im styles/admin_tpl-Verzeichnis die index.tpl.html um folgenden Aufruf:
sucht:
Code  <a href="./?AdminPropertyIndex"><?php echo $lang->link[3]->tagData; ?></a><br>
fügt dahinter in einer neuen Zeile ein
Code  <a href="./?AdminAdventIndex">Adventskalender</a><br>
Solltet ihr das alles bis hierhin korrekt eingebaut haben, müsstet ihr nun aus der Administration heraus ganz einfach die Türchen befüllen können. Es kann ganz normaler HTML-Code oder einfacher Text verwendet werden. Versucht doch bspw. mal das in ein Türchen zu setzen:
Code  Nikolaus<br>
<iframe width="300" height="210" src="https://www.youtube.com/embed/vgaODLvQ-Ew" frameborder="0" allowfullscreen></iframe>
|