26 require_once(
"../config.php");
46 $dbh =
new PDO(
"mysql:dbname=".DB_DATABASE.
";host=".DB_HOST, DB_USER, DB_PASS,
47 array(PDO::MYSQL_ATTR_INIT_COMMAND =>
"SET NAMES 'utf8'"));
49 }
catch (PDOException $e) {
55 $dbs =
$db->check_tables();
56 $desc = array(
"umfragen" =>
"enthält alle Umfragen, sowie deren Einstellungen und Status",
57 "user_config" =>
"enthält Profileinstellungen der Benutzer",
58 "config" =>
"enthält Einstellungen der Software",
59 "email_stack" =>
"enthält eine Liste von Emails, die abzusenden sind.");
60 echo
"<table style='border-collapse:collapse;border-top:1px solid #E6E6E6;'>";
61 foreach( array_keys($dbs) as $name ){
62 echo
"<tr style='border-bottom:1px solid #E6E6E6;'>";
63 echo
"<th style='text-align:right;padding:.2em 1em .2em 0em;'>$name</th>";
64 if( $dbs[$name] ===
true ){
65 echo
"<td style='background-color:#C7FF3E;padding:.2em .4em'>Gefunden</td>";
68 echo
"<td style='background-color:#FF3E41;padding:.2em .4em'>Fehlt!</td>";
69 echo
"<td style='padding:.2em 0em .2em 1em'> <a href='".$_SERVER[
'SCRIPT_NAME'].
"?make_db=$name'>erstellen</a></td>";
71 echo
"<td style='padding-left:1em;'>{$desc[$name]}</td>";
79 $tables_present =
$db->check_tables();
81 foreach( $tables_present as $table ){
82 if( $table ==
false ){
90 if( ($_SESSION[
"user"]->is_auth ==
true) AND (in_array( $_SESSION[
"user"]->ID ,
$super_admins)) ){
93 header(
"Location: ../login.php");
100 if( (isset($_GET[
"purge"])) AND ($_GET[
"purge"] !=
"") AND (is_numeric($_GET[
"purge"])) ){
102 $purge_ID = intval($_GET[
"purge"]);
103 if( (isset($_POST[
"purge_poll_confirm"])) AND ($_POST[
"purge_poll_confirm"] !=
"") ){
109 }
else if( (isset($_POST[
"purge_selected"])) AND (isset($_POST[
"selection"])) AND (is_array($_POST[
"selection"]) ) ){
110 $action =
"purge_confirm_selection";
111 $purge_IDs = array();
112 $keys = array_keys($_POST[
"selection"]);
113 foreach(
$keys as $ID ){
114 $purge_IDs[] = intval($ID);
117 if( (isset($_POST[
"purge_poll_confirm_selection"])) AND ($_POST[
"purge_poll_confirm_selection"] !=
"") ){
123 }
else if( (isset($_GET[
"restore"])) AND ($_GET[
"restore"] !=
"") AND (is_numeric($_GET[
"restore"])) ){
125 $restore_ID = intval($_GET[
"restore"]);
126 if( (isset($_POST[
"restore_poll_confirm"])) AND ($_POST[
"restore_poll_confirm"] !=
"") ){
132 }
else if( (isset($_POST[
"restore_selected"])) AND (isset($_POST[
"selection"])) AND (is_array($_POST[
"selection"]) ) ){
133 $action =
"restore_confirm_selection";
134 $restore_IDs = array();
135 $keys = array_keys($_POST[
"selection"]);
136 foreach(
$keys as $ID ){
137 $restore_IDs[] = intval($ID);
140 if( (isset($_POST[
"restore_poll_confirm_selection"])) AND ($_POST[
"restore_poll_confirm_selection"] !=
"") ){
146 }
else if( (isset($_GET[
"make_db"])) AND (in_array($_GET[
"make_db"],array(
"umfragen",
"user_config",
"config",
"email_stack"))) ){
148 $name = $_GET[
"make_db"];
153 die(
"Konnte keine Verbindung zur Datenbank aufbauen. Bitte Einstellungen in config.php und Datenbankrechte prüfen." );
157 $db=
new db( DB_USER, DB_PASS, DB_DATABASE, DB_HOST );
176 $db->drop_poll($purge_ID);
177 $db->drop_poll_results($purge_ID);
178 $db->delete_poll($purge_ID);
179 header(
"Location: admin.php");
184 }
else if(
$action ==
"purge_selection"){
185 foreach($purge_IDs as $purge_ID){
186 $db->drop_poll($purge_ID);
187 $db->drop_poll_results($purge_ID);
188 $db->delete_poll($purge_ID);
190 header(
"Location: admin.php");
195 }
else if(
$action ==
"restore"){
197 header(
"Location: admin.php");
202 }
else if(
$action ==
"restore_selection"){
203 foreach($restore_IDs as $restore_ID){
206 header(
"Location: admin.php");
214 if(
$action ==
"make db table"){
215 if( $name ==
"umfragen" ){
216 $db->make_umfragen_table();
217 }
else if ($name ==
"user_config"){
218 $db->make_user_config_table();
219 }
else if ($name ==
"config"){
220 $db->make_config_table();
221 }
else if($name ==
"email_stack"){
222 $db->make_email_stack_table();
224 header(
"Location: admin.php");
244 echo
"<p>Folgende Tabellen <b>müssen</b> existieren und durch die Software selbst angelegt werden. Bitte fehlende Tabellen erstellen (Link)</p>";
248 }
else if(
$action ==
"purge_confirm"){
249 $poll_purge = array(
"ID"=>$purge_ID);
250 foreach($poll_list_del as $p){
251 if($p[
"ID"] == $purge_ID){
255 if (isset($poll_purge[
"name"])){
256 print_warning(
"Umfrage <b>{$poll_purge["name"]}</b> mit der ID <b>{$poll_purge["ID
"]}</b> wirklich <b>endgültig</b> mit <b>allen Daten</b> löschen?");
258 print_warning(
"Umfrage mit der ID <b>{$poll->ID}</b> wirklich <b>endgültig</b> mit <b>allen Daten</b> löschen?");
260 echo
"<form method='POST' action=''>";
261 echo
"<input type='submit' name='purge_poll_confirm' value='Ja, wirklich' />";
267 }
else if(
$action ==
"purge_confirm_selection"){
268 $poll_purge = array();
269 foreach($poll_list_del as $p){
270 if( in_array($p[
"ID"], $purge_IDs) ){
275 $text =
"Folgende Umfragen unwiederruflich mit <b>allen Daten</b> löschen? <ul>";
276 foreach($poll_purge as $p){
277 if (isset($p[
"name"])){
278 $text = $text.
"<li><b>{$p["name
"]}</b> mit der ID <b>{$p["ID
"]}</b></li>
279 <input type='hidden' name='selection[{$p["ID
"]}]' value='ok'/>";
281 $text = $text.
"<li>mit der ID <b>{$p["ID
"]}</b>
282 <input type='hidden' name='selection[{$p["ID
"]}]' value='ok'/> </li>";
285 $text = $text.
"</ul>";
287 echo
"<form method='POST' action=''>";
289 echo
"<input type='hidden' name='purge_selected' value='true' />";
290 echo
"<input type='submit' name='purge_poll_confirm_selection' value='Ja, wirklich' />";
296 }
else if(
$action ==
"restore_confirm"){
297 $poll_restore = array(
"ID"=>$restore_ID);
298 foreach($poll_list_del as $p){
299 if($p[
"ID"] == $restore_ID){
303 if (isset($poll_restore[
"name"])){
304 print_warning(
"Umfrage <b>{$poll_restore["name"]}</b> mit der ID <b>{$poll_restore["ID
"]}</b> wirklich wiederherstellen?");
306 print_warning(
"Umfrage mit der ID <b>{$restore_ID}</b> wirklich wiederherstellen?");
308 echo
"<form method='POST' action=''>";
309 echo
"<input type='submit' name='restore_poll_confirm' value='Ja, wirklich' />";
315 }
else if(
$action ==
"restore_confirm_selection"){
316 $poll_restore = array();
317 foreach($poll_list_del as $p){
318 if( in_array($p[
"ID"], $restore_IDs) ){
319 $poll_restore[] = $p;
323 $text =
"Folgende Umfragen wiederherstellen? <ul>";
324 foreach($poll_restore as $p){
325 if (isset($p[
"name"])){
326 $text = $text.
"<li><b>{$p["name
"]}</b> mit der ID <b>{$p["ID
"]}</b></li>
327 <input type='hidden' name='selection[{$p["ID
"]}]' value='ok'/>";
329 $text = $text.
"<li>mit der ID <b>{$p["ID
"]}</b>
330 <input type='hidden' name='selection[{$p["ID
"]}]' value='ok'/> </li>";
333 $text = $text.
"</ul>";
335 echo
"<form method='POST' action=''>";
337 echo
"<input type='hidden' name='restore_selected' value='true' />";
338 echo
"<input type='submit' name='restore_poll_confirm_selection' value='Ja, wirklich' />";
344 echo
"<h2>Gelöschte Umfragen</h2>";
345 echo
"<div class='admin_container'>";
346 if (
sizeof($poll_list_del) >0){
347 echo
"<form action='' method='POST'>";
348 echo
"<table class='table_1'> ";
349 echo
"<tr> <th></th> <th>ID</th> <th>Name</th> <th>Von</th> <th>edit</th> </tr>";
351 foreach($poll_list_del as $poll){
353 echo
"<tr class='line$r'>";
354 echo
"<td><input type='checkbox' name='selection[{$poll["ID
"]}]' /></td>";
355 echo
"<td>{$poll["ID
"]}</td>";
356 echo
"<td>{$poll["name"]}</td>";
357 echo
"<td>{$poll["owner_fn
"]}</td>";;
359 <a href='admin.php?purge={$poll["ID
"]}'><img src='".APP_ROOT.
"/icons/22/list-remove.png' alt='delete' title='Löschen'/></a>
360 <a href='admin.php?restore={$poll["ID
"]}'><img src='".APP_ROOT.
"/icons/22/list-add.png' alt='restore' title='wiederherstellen'/></a>
366 echo
"<br/> Selektierte Umfragen: <input type='submit' name='purge_selected' value='löschen!' />
367 <input type='submit' name='restore_selected' value='wiederherstellen' style='margin-left:2em'/>";
370 echo
"<p>Es sind keine Umfragen im Papierkorb.</p>";
374 echo
"<h2>Datenbank</h2>";
375 echo
"<div class='admin_container'>";
376 echo
"<p>Folgende Tabellen werden von der Software benötigt. Fehlende Tabellen bitte erstellen.</p>";
381 echo
"<h2>Konfiguration</h2>";
382 echo
"<div class='admin_container'>";
383 echo
"<p> <a href='config.php'>Weiter zu den Einstellungen</a> </p>";