Location: PHPKode > projects > Skrupel User Game Administration > admin.php
<?php
include ("./include/conf.inc.php");
include ("$basepfath/inc.conf.php");
include ("$usedpfath/include/header.inc.php");
include ("$usedpfath/include/usercheck.inc.php");

if ($HTTP_GET_VARS["fu"] == 1 OR $HTTP_POST_VARS["fu"] == 1 AND $skrupel_admin == 1)
 {
 function get_global($var_name)
  {
  if(!isset($GLOBALS[$var_name]))
   {
   return ("");
   }
   else
    {
    return ($GLOBALS[$var_name]);
    }
  }

 function remove_designtags($html_tags)
  {
  return preg_replace("/DESIGNTIMESP[^>]+>/",">",$html_tags);
  }

if($action == "user")
 {
 }

elseif($action == "setting")
 {
 }

elseif($action == "send")
 {
 if ($what == "info")
  {
  $usermail ="hide@address.com";
  @mail($usermail, "Nachricht aus dem UsedComm", $inhalt,"From: $senderemail\r\n"."Reply-To: $senderemail\r\n"."X-Mailer: PHP/" . phpversion());
  }
 if ($what == "letter")
  {
  $abf = "SELECT * FROM skrupel_usedcommletter WHERE id = '$id'";
  $result = mysql_query($abf);
  if (mysql_num_rows($result) > 0)
   {
   while ($row = mysql_fetch_array ($result))
    {
    $datum =$row->datum;
    $headline = $row->headline;
    $inhalt = $row->html_text;
    }
   }


  $abf = "SELECT * FROM skrupel_usedcommgetletter";
  $result = mysql_query($abf);
  if (mysql_num_rows($result) > 0)
   {
   while ($row = mysql_fetch_array ($result))
    {
    $tomail = $row->email;
	$toname = $row->name;
    $nachricht = "Hallo $toname,\n\nDer neue $servername Newsletter vom $datum\n\n für Dich als EMail.\n\n------------------------------------------------------------\n\n$html_text\n\n\n\n------------------------------------------------------------\n\nGruß vom $servername Team";
    @mail($tomail, "$servername Newsletter vom $datum", $nachricht,"From: $absenderemail\r\n"."Reply-To: $absenderemail\r\n"."X-Mailer: PHP/" . phpversion());
    }
   }
  $abf = "UPDATE skrupel_usedcommletter SET online=1 WHERE id = '$id'";
  $result = mysql_query($abf);
  }
 }

elseif($action == "change")
 {
 $sql="SELECT online FROM skrupel_usedcomm$what WHERE id='$id'";
 $result=mysql_query($sql);
 $row = mysql_fetch_array ($result);
 if($row["online"]=="1")
  {
  $result=mysql_query("UPDATE skrupel_usedcomm$what SET online=0 WHERE id='$id'");
  }
  else
   {
   $result=mysql_query("UPDATE skrupel_usedcomm$what SET online=1 WHERE id='$id'");
   }
 }

elseif($action == "delete")
 {
 $sql="DELETE FROM skrupel_usedcomm$what WHERE id='$id'";
 $result=mysql_query($sql);
 }

elseif($action == "edit")
 {
 $html_text="";
 $headline="";
 $datum="";
 if($id !="neu")
  {
  if($what == "messages")
   {
   $sql="SELECT headline FROM skrupel_usedcomm$what WHERE id='$id'";
   }
   else
	{
    $sql="SELECT headline, DATE_FORMAT(datum, '%Y-%m-%d') FROM skrupel_usedcomm$what WHERE id='$id'";
	}
  $result=mysql_query($sql);
  $row=mysql_fetch_array ($result);
  $headline=$row["headline"];
  if($what != "messages")
   {
   $datum=$row[1];
   }
  }
 }

elseif($action == "save")
 {
 $id=get_global("id");
 $text= remove_designtags(get_global("html_text"));
 $text=str_replace("'", "&#146;",$text );

 if($datum=="")
  {
  $datum= date("Y-m-d");
  }

 if($id == "neu")
  {
  if($what == "messages")
   {
   // id="neu" also Neuen Eintrag erstellen.
   $sql="INSERT INTO skrupel_usedcomm$what (html_text, headline, online) VALUES('$text','$headline','0')";
   }
   else
	{
    // id="neu" also Neuen Eintrag erstellen.
    $sql="INSERT INTO skrupel_usedcomm$what (html_text, headline, datum, online) VALUES('$text','$headline','$datum','0')";
	}
  }
  else
   {
   if($what == "messages")
    {
    // Bestehenden Eintrag ändern
    $sql="UPDATE skrupel_usedcomm$what SET html_text= '$text', headline='$headline' WHERE ID='$id'";
    }
    else
	 {
     // Bestehenden Eintrag ändern
     $sql="UPDATE skrupel_usedcomm$what SET html_text= '$text', headline='$headline' WHERE ID='$id'";
	 }
   }
 $do=mysql_query($sql);
 $action="done";
 }

 $adminheader = new EasyTemplate ("$usedpfath/templates/adminheader.tpl");
 $adminfooter = new EasyTemplate ("$usedpfath/templates/adminfooter.tpl");
 $adminheader -> assign("TITLE","Skrupel - UsedComm");
 $adminheader -> assign("URL",$usedurl);
 $adminheader -> easy_print();
 ?>
<body text="#ffffff" bgcolor="#444444" link="#000000" vlink="#000000" alink="#000000" leftmargin="0" rightmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" border="0" width="500" height="100%">
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td width="100%">
  <center>

<div class="tab-pane" id="reg1">
<script type="text/javascript">
reg1 = new WebFXTabPane( document.getElementById( "reg1" ) );
</script>

<div class="tab-page" id="reg">
<h2 class="tab">Allgemein</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg" ) );
</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%" height="100%">
  <?
  if ($action == "edit" and $what == "messages")
   {
   ?>
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admintopic">Messages<? if($id == "neu"){echo " erstellen";} else{ echo " bearbeiten";}?></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=&what=&id=">Zurück zu Übersicht</a></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <form name="form1" action="admin.php" method="post">
    <tr>
     <td align="left" width="10%" class="admincontent">Headline</td>
	 <td align="left" width="90%" class="admincontent"><input name=headline type=text maxlength=80 size=75 value="<?= $headline ?>"></td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Datum</td>
	 <td align="left" width="90%" class="admincontent"><input name=datum type=text maxlength=10 size=15 value="<? if($id == "neu"){echo date("Y-m-d");} else{ echo $datum;}?>">&nbsp;JJJJ-MM-TT</td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Text<td><iframe id="editor" name=edit src="editor.php?fu=1&action=edit&what=messages&id=<?= $id ?>" width=390 height=200 scrolling=yes></iframe></td></tr>
    </tr>
    <input type=hidden name=fu value="1">
    <input type=hidden name=action value="save">
    <input type=hidden name=what value="messages">
    <input type=hidden name=html_text value="">
    <input type=hidden name=id value="<?= $id ?>">
    </form>
   </table>
   <?
   }
   else
    {
    ?>
    <?
    $sql = "SELECT ID, headline, html_text, online FROM skrupel_usedcommmessages";
    $result=mysql_query($sql);
    ?>
    <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
     <tr>
      <td>&nbsp;</td>
     </tr>
     <tr>
      <td width="100%" align="left" valign="top" class="admintopic">Messages des Administrator im Wilkommensfenster</td>
     </tr>
     <tr>
      <td>&nbsp;</td>
     </tr>
     <tr>
      <td width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=edit&what=messages&id=neu">Neuen Eintrag erstellen</a></td>
     </tr>
     <tr>
      <td>&nbsp;</td>
     </tr>
    </table>
    <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
     <tr align=middle>
      <td align="middle" width="5%" class="adminheader">ID</td>
      <td align="left" width="55%" class="adminheader">Headline</td>
      <td align="middle" width="15%" align="middle" class="adminheader">Online</td>
      <td align="left" width="25%" class="adminheader" colspan="2">Aktion</td>
	 </tr>
     <tr>
      <td class="tab_oben" colspan="5">&nbsp;</td>
     </tr>
      <?
      while ($row = mysql_fetch_array ($result)) {
      ?>
     <tr>
	  <td align="middle" valign="top" class="admincontent"><?= $row["ID"] ?></td>
      <td align="left" valign="top" class="admincontent"><?= $row["headline"] ?></td>
      <td align="middle" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=change&what=messages&id=<?= $row["ID"] ?>"><? if($row["online"]==0){ echo "Nein";} else { echo "Ja";} ?></a></td>
      <td align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=edit&what=messages&id=<?= $row["ID"] ?>">Ändern</a></td>
      <td align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=delete&what=messages&id=<?= $row["ID"] ?>">Löschen</a></td>
     </tr>
     <?
     }
     ?>
     <tr>
      <td colspan="6" align="left" valign="top" class="tab_unten">&nbsp;</td>
     </tr>
    </table>
    <?
    }
    ?>
  </td>
 </tr>
</table>
</div>
</div>

<div class="tab-page" id="reg2">
<h2 class="tab">News</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg2" ) );
</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%" height="100%">
  <?
  if ($action == "edit" and $what == "news")
   {
   ?>
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admintopic">News<? if($id == "neu"){echo " erstellen";} else{ echo " bearbeiten";}?></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=&what=&id=">Zurück zu Übersicht</a></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <form name="form1" action="admin.php" method="post">
    <tr>
	 <td align="left" width="10%" class="admincontent">Headline</td>
	 <td align="left" width="90%" class="admincontent"><input name=headline type=text maxlength=80 size=75 value="<?= $headline ?>"></td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Datum</td>
	 <td align="left" width="90%" class="admincontent"><input name=datum type=text maxlength=10 size=15 value="<? if($id == "neu"){echo date("Y-m-d");} else{ echo $datum;}?>">&nbsp;JJJJ-MM-TT</td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Text<td><iframe id="editor" name=edit src="editor.php?fu=1&action=edit&what=news&id=<?= $id ?>" width=390 height=200 scrolling=yes></iframe></td></tr>
    </tr>
    <input type=hidden name=fu value="1">
    <input type=hidden name=action value="save">
    <input type=hidden name=what value="news">
    <input type=hidden name=html_text value="">
    <input type=hidden name=id value="<?= $id ?>">
    </form>
   </table>
   <?
   }
   else
    {
    ?>
    <?
    $sql = "SELECT DATE_FORMAT(datum, '%Y-%m-%d'), ID, headline, html_text, online FROM skrupel_usedcommnews";
    $result=mysql_query($sql);
    ?>
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td width="100%" align="left" valign="top" class="admintopic">Neuigkeiten</td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=edit&what=news&id=neu">Neuen Eintrag erstellen</a></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
   </table>
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr align=middle>
     <td align="middle" width="5%" class="adminheader">ID</td>
     <td align="left" width="18%" class="adminheader">Datum</td>
	 <td align="left" width="47%" class="adminheader">Headline</td>
     <td align="middle" width="10%" align="middle" class="adminheader">Online</td>
     <td align="middle" width="20%" class="adminheader" colspan="2">Aktion</td>
	</tr>
    <tr>
     <td class="tab_oben" colspan="6">&nbsp;</td>
    </tr>
     <?
     while ($row = mysql_fetch_array ($result)) {
     ?>
    <tr>
	 <td align="middle" valign="top" class="admincontent"><?= $row["ID"] ?></td>
     <td align="left" valign="top" class="admincontent"><?= $row[0]?></td>
     <td align="left" valign="top" class="admincontent"><?= $row["headline"] ?></td>
     <td align="middle" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=change&what=news&id=<?= $row["ID"] ?>"><? if($row["online"]==0){ echo "Nein";} else { echo "Ja";} ?></a></td>
     <td align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=edit&what=news&id=<?= $row["ID"] ?>">Ändern</a></td>
     <td align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=delete&what=news&id=<?= $row["ID"] ?>">Löschen</a></td>
    </tr>
    <?
    }
    ?>
     <tr>
      <td colspan="6" align="left" valign="top" class="tab_unten">&nbsp;</td>
     </tr>
   </table>
    <?
    }
    ?>
  </td>
 </tr>
</table>
</div>
</div>

<div class="tab-page" id="reg3">
<h2 class="tab">Newsletter</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg3" ) );</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%" height="100%">
  <?
  if ($action == "edit" and $what == "letter")
   {
   ?>
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admintopic">Newsletter<? if($id == "neu"){echo " erstellen";} else{ echo " bearbeiten";}?></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=&what=&id=">Zurück zu Übersicht</a></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <form name="form1" action="admin.php" method="post">
    <tr>
	 <td align="left" width="10%" class="admincontent">Headline</td>
	 <td align="left" width="90%" class="admincontent"><input name=headline type=text maxlength=80 size=75 value="<?= $headline ?>"></td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Datum</td>
	 <td align="left" width="90%" class="admincontent"><input name=datum type=text maxlength=10 size=15 value="<? if($id == "neu"){echo date("Y-m-d");} else{ echo $datum;}?>">&nbsp;JJJJ-MM-TT</td>
    <tr>
	 <td align="left" width="10%" class="admincontent">Text<td><iframe id="editor" name=edit src="editor.php?fu=1&action=edit&what=letter&id=<?= $id ?>" width=390 height=200 scrolling=yes></iframe></td></tr>
    </tr>
    <input type=hidden name=fu value="1">
    <input type=hidden name=action value="save">
    <input type=hidden name=what value="letter">
    <input type=hidden name=html_text value="">
    <input type=hidden name=id value="<?= $id ?>">
    </form>
   </table>
   <?
   }
   else
    {
    ?>
    <?
    $sql = "SELECT DATE_FORMAT(datum, '%Y-%m-%d'), ID, headline, html_text, online FROM skrupel_usedcommletter";
    $result=mysql_query($sql);
    ?>
    <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
     <tr>
      <td>&nbsp;</td>
     </tr>
     <tr>
      <td width="100%" align="left" valign="top" class="admintopic">Newsletter</td>
     </tr>
     <tr>
      <td>&nbsp;</td>
     </tr>
     <tr>
      <td width="100%" align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=edit&what=letter&id=neu">Neuen Eintrag erstellen</a></td>
     </tr>
     <tr>
      <td>&nbsp;</td>
     </tr>
    </table>
    <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
     <tr align=middle>
      <td align="middle" width="5%" class="adminheader">ID</td>
      <td align="left" width="20%" class="adminheader">Datum</td>
	  <td align="left" width="45%" class="adminheader">Headline</td>
      <td align="middle" align="middle" width="10%" class="adminheader">Gesendet</td>
      <td align="middle" width="20%" class="adminheader" colspan="2">Aktion</td>
	 </tr>
     <tr>
      <td class="tab_oben" colspan="6">&nbsp;</td>
     </tr>
      <?
      while ($row = mysql_fetch_array ($result)) {
      ?>
     <tr>
	  <td align="middle" valign="top" class="admincontent"><?= $row["ID"] ?></td>
      <td align="left" valign="top" class="admincontent"><?= $row[0]?></td>
      <td align="left" valign="top" class="admincontent"><?= $row["headline"] ?></td>
      <td align="middle" valign="top" class="admincontent"><? if($row["online"]==0){echo "<a class=\"adminlink\" href=\"admin.php?fu=1&action=send&what=letter&id=$row[ID]\">Nein</a>";} else { echo "Ja";} ?></td>
      <td align="left" valign="top" class="admincontent"><? if($row["online"]==0){echo "<a class=\"adminlink\" href=\"admin.php?fu=1&action=edit&what=letter&id=$row[ID]\">Ändern</a>";} else { echo "--";} ?></td>
      <td align="left" valign="top" class="admincontent"><a class="adminlink" href="admin.php?fu=1&action=delete&what=letter&id=<?= $row["ID"] ?>">Löschen</a></td>
     </tr>
     <?
     }
     ?>
     <tr>
      <td colspan="6" align="left" valign="top" class="tab_unten">&nbsp;</td>
     </tr>
    </table>
    <?
    }
    ?>
  </td>
 </tr>
</table>
</div>
</div>


<div class="tab-page" id="reg4">
<h2 class="tab">User</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg4" ) );</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%">
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td>Hier wird momentan noch gearbeitet. Der Administrator soll hier die Möglichkeit haben Userdaten zu bearbeiten und / oder einen User zu löschen.</td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
   </table>
  </td>
 </tr>
</table>
</div>
</div>


<div class="tab-page" id="reg5">
<h2 class="tab">Settings</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg5" ) );</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%">
   <table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
    <tr>
     <td>Hier wird ebenfalls noch gearbeitet. Der Administrator soll hier die Möglichkeit haben generelle Einstellungen an der UsedComm vornehmen zu können.</td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
   </table>
  </td>
 </tr>
</table>
</div>
</div>


<div class="tab-page" id="reg6">
<h2 class="tab">Feedback</h2>
<script type="text/javascript">reg1.addTabPage( document.getElementById( "reg6" ) );</script>
<div align="center">
<table cellspacing="0" style="table-layout:fixed">
 <tr>
  <td width="100%">
   <table border="0" width="95%" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td class="adminheader">Du hast einen Fehler gefunden oder eine gute Idee zur Weiterentwicklung? Dann schicke mir eine EMail</td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
   </table>
   <table border="0" width="90%" cellspacing="0" cellpadding="0">
    <tr>
     <form name="formular" method="POST" action="admin.php?fu=1&action=sendmail&what=info">
     <td class="admincontent" width="10%">Von&nbsp;</td>
     <td class="admincontent" width="40%"><input type="text" name="sender"  value="" size="40"></td>
    </tr>
    <tr>
     <td class="admincontent" width="10%">EMail&nbsp;</td>
     <td class="admincontent" width="40%"><input type="text" name="senderemail"  value="" size="40"></td>
    </tr>
    <tr>
     <td class="admincontent">Betrifft</td>
     <td class="admincontent"><input type="text" name="betreff"  value="" size="40"></td>
    </tr>
    <tr>
     <td colsapn="2">&nbsp;</td>
    </tr>
   </table>
   <table border="0" width="95%" cellspacing="0" cellpadding="0">
    <tr>
     <td class="admincontent">Nachricht</td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td class="admincontent"><textarea name="inhalt" cols="90" rows="10"></textarea></td>
    </tr>
   </table>
   <table border="0" width="90%" cellspacing="0" cellpadding="0">
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td align="center"><input type="submit" name="bla" value="Nachricht senden" style="width:200px;"></td>
    </tr>
    </form>
   </table>
  </td>
 </tr>
</table>
</div>
</div>
</center>
</td>
</tr>
</table>
 <?
 }

$footer -> easy_print();
?>

Return current item: Skrupel User Game Administration