----admin.php-------
<?php
require "setup/admindaten.php"; require "setup/dbdaten.php";
include "funkt.inc.php"; db_connect();
$installfile = 'installer.php'; if(file_exists($installfile)) { $fehlertitel = "installer.php ist noch vorhanden"; $fehlermeldung = "Datei <b>installer.php</b> löschen und admin.php erneut aufrufen"; fehlerausgabe($fehlertitel,$fehlermeldung); exit; }
$scriptconf = Get_Systemdaten(); $sektionsmenue = menueoutput(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Aktionen und Menue fuer diese Datei // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // if (isset($_GET['action']) && $_GET['action'] != "") { $action = $_GET['action']; } elseif (isset($_POST['action']) && $_POST['action'] != "") { $action = $_POST['action']; }
switch ($action) { case "logincheck": logincheck(); break; case "startseite": startseite(); break; case "systemdaten": systemdaten(); break; case "systemdatensave": systemdatensave(); break; case "admindaten": admindaten(); break; case "newadmindatensave": newadmindatensave(); break; case "logout": logout(); break; default: login(); break; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Logindateneingabe Formular // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function login() { global $scriptconf; // Meldung wenn falsche Logindaten... if (isset($_GET['error'])) { $hinweis = "Logindaten leider falsch..."; } // Meldung wenn ausgeloggt... if (isset($_GET['status'])) { $hinweis = "Sie haben sich ausgeloggt"; }
$sektionstitel = "Administrator Login";
eval("templ_output(\"".tparser("templates/header")."\");");
echo "<form action=\"$scriptconf[URL]/admin.php\" method=\"POST\">"; echo "<input type=\"Hidden\" name=\"action\" value=\"logincheck\">"; eval("templ_output(\"".tparser("templates/logintemplate")."\");"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Logindaten checken und Cookie setzen, oder zurueck zum Login // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function logincheck() {
global $scriptconf,$adminuser,$adminpass;
$username = $_POST['username']; $passwort = $_POST['passwort']; $md5passwort = md5($passwort);
if(($username === $adminuser) && ($md5passwort === $adminpass)) {
setcookie ("Loginuser", "$username", time()+86400); setcookie ("Loginpass", "$md5passwort", time()+86400);
// Daten OK header("Location: $scriptconf[URL]/admin.php?action=startseite"); } else { // Fehler header("Location: $scriptconf[URL]/admin.php?error=1"); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Startseite der Administration // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function startseite() { passdatencheck();
global $sektionsmenue,$scriptconf, $prefix;
$sektionstitel = "Startseite";
$username = $_COOKIE["Loginuser"]; $aktueller_datum = datumausgabe(1);
eval("templ_output(\"".tparser("templates/header")."\");"); eval("templ_output(\"".tparser("templates/verwaltung")."\");");
$linktab = $prefix . "links"; $result = mysql_query("SELECT COUNT(*) from $linktab"); $rowtotal = mysql_fetch_array($result);
$resultfree = mysql_query("SELECT COUNT(*) from $linktab WHERE free = '0'"); $rowfree = mysql_fetch_array($resultfree);
$linkfrei = $rowfree[0] > 0 ? "<a href=\"$scriptconf[URL]/check.php?action=view\">Freischalten?</a>" : "";
$resultdef = mysql_query("SELECT COUNT(*) from $linktab WHERE def = '1'"); $rowdef = mysql_fetch_array($resultdef);
$linkcheck = $rowdef[0] > 0 ? "<a href=\"$scriptconf[URL]/check.php?action=def\">Prüfen?</a>" : "";
?> <table width="100%" cellspacing="1" cellpadding="0" border="0" class="tborder"> <tr> <td colspan="2" class="thead">Linklistenstatistik</td> </tr> <tr> <td class="tnormal" width="40%">Anzahl Links insgesamt:</td> <td class="tnormal" width="60%"><?php echo $rowtotal[0] ?></td> </tr> <tr> <td class="tnormal2">Links zum Freischalten</td> <td class="tnormal2"><?php echo "$rowfree[0] $linkfrei"; ?></td> </tr> <tr> <td class="tnormal">Defekte Links</td> <td class="tnormal"><?php echo "$rowdef[0] $linkcheck"; ?></td> </tr> </table>
<?php eval("templ_output(\"".tparser("templates/footer")."\");"); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Formular Systemdaten aendern // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function systemdaten() { passdatencheck();
global $sektionsmenue, $scriptconf;
$sektionstitel = "Systemdaten ändern";
eval("templ_output(\"".tparser("templates/header")."\");"); eval("templ_output(\"".tparser("templates/verwaltung")."\");");
echo "<form action=\"$scriptconf[URL]/admin.php\" method=\"POST\">"; echo "<input type=\"Hidden\" name=\"action\" value=\"systemdatensave\">";
//$URI = getenv("SCRIPT_URI"); //$SCRIPTURI = preg_replace ("/\/admin.php/", "", $URI);
$outputuserlinks = <<< LISTE1 <select name="NEW_ENTRY" size="1" class="inpu" style="width: 350px;"> <option value="JA">Ja, Userlinkanmeldungen erlauben</option> <option value="NEIN">Nein, keine Userlinkanmeldungen erlauben</option> </select> LISTE1; $muster1 = "/value=\"$scriptconf[NEW_ENTRY]\"/m"; $ersetzung1 = "value=\"$scriptconf[NEW_ENTRY]\" SELECTED"; $outputuserlinks = preg_replace($muster1, $ersetzung1, $outputuserlinks);
$outputdatum = <<< LISTE2 <select name="DATEFORMAT" class="inpu" style="width: 350px;"> <option value="1">Wochentag Tag Monatsname Jahr</option> <option value="2">Tag.Monat.Jahr</option> <option value="3">Tagname Abk. Tag. Monat Abk. Jahr</option> <option value="4">Tag. Monat Abk. Jahr</option> <option value="5">Jahr-Monat-Tag</option> </select> LISTE2; $muster2 = "/value=\"$scriptconf[DATEFORMAT]\"/m"; $ersetzung2 = "value=\"$scriptconf[DATEFORMAT]\" SELECTED"; $outputdatum = preg_replace($muster2, $ersetzung2, $outputdatum);
?>
<table width="100%" cellspacing="1" cellpadding="0" border="0" class="tborder"> <tr> <td colspan="2" class="thead">Systemdaten</td> </tr> <tr> <td class="tnormal" width="40%">Adminname</td> <td class="tnormal" width="60%"><input type="text" class="inpu" style="width: 350px;" name="Adminname" value="<?php echo $scriptconf[Adminname] ?>" size=35 maxlength=150></td> </tr> <tr> <td class="tnormal2">Adminemail</td> <td class="tnormal2"><input type="text" class="inpu" style="width: 350px;" name="Adminemail" value="<?php echo $scriptconf[Adminemail] ?>" size=35 maxlength=150></td> </tr> <tr> <td class="tnormal">Script URL</td> <td class="tnormal"><input type="text" class="inpu" style="width: 350px;" name="URL" value="<?php echo $scriptconf[URL] ?>" size=35 maxlength=150></td> </tr> <tr> <td class="tnormal2">Userlinks erlauben</td> <td class="tnormal2"><?php echo $outputuserlinks ?></td> </tr> <tr> <td class="tnormal">Datumsformat Linkeintragsdatum</td> <td class="tnormal"><?php echo $outputdatum ?></td> </tr>
<tr> <td class="tnormal2" width="40%">Links pro Seite, Useransicht</td> <td class="tnormal2" width="60%"><input type="text" class="inpu" style="width: 50px;" name="LPS_USER" value="<?php echo $scriptconf[LPS_USER] ?>" size=5 maxlength=5></td> </tr> <tr> <td class="tnormal">Links pro Seite, Adminansicht</td> <td class="tnormal"><input type="text" class="inpu" style="width: 50px;" name="LPS_ADMIN" value="<?php echo $scriptconf[LPS_ADMIN] ?>" size=5 maxlength=5></td> </tr>
<tr> <td colspan="2" class="tbottom" align="center"><input class="button" type="Submit" value="Daten speichern"></td> </tr> </table> <?php
echo "</form>";
eval("templ_output(\"".tparser("templates/footer")."\");"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Systemdaten speichern // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function systemdatensave() {
global $prefix;
$Adminname = datensaver($_POST['Adminname']); $Adminemail = datensaver($_POST['Adminemail']); $URL = datensaver($_POST['URL']); $LPS_USER = datensaver($_POST['LPS_USER']); $LPS_ADMIN = datensaver($_POST['LPS_ADMIN']); $NEW_ENTRY = datensaver($_POST['NEW_ENTRY']); $DATEFORMAT = datensaver($_POST['DATEFORMAT']);
$systemdaten = $prefix . "system"; MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$Adminname' WHERE Name = 'Adminname'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$Adminemail' WHERE Name = 'Adminemail'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$URL' WHERE Name = 'URL'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$LPS_USER' WHERE Name = 'LPS_USER'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$LPS_ADMIN' WHERE Name = 'LPS_ADMIN'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$NEW_ENTRY' WHERE Name = 'NEW_ENTRY'"); MYSQL_QUERY("UPDATE $systemdaten SET Wert = '$DATEFORMAT' WHERE Name = 'DATEFORMAT'");
redirect("admin.php?action=systemdaten", 0); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Formular Admindaten aendern // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function admindaten() { passdatencheck();
global $sektionsmenue, $scriptconf;
$sektionstitel = "Formular zum ändern der Administrator Daten";
eval("templ_output(\"".tparser("templates/header")."\");"); eval("templ_output(\"".tparser("templates/verwaltung")."\");");
echo "<form action=\"$scriptconf[URL]/admin.php\" method=\"POST\">"; echo "<input type=\"Hidden\" name=\"action\" value=\"newadmindatensave\">";
eval("templ_output(\"".tparser("templates/admindatentemplate")."\");");
echo "</form>";
eval("templ_output(\"".tparser("templates/footer")."\");"); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Neue Admindaten speichern // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function newadmindatensave() { passdatencheck();
global $scriptconf, $adminuser, $adminpass;
$oldusername = datensaver($_POST['oldusername']); $oldpasswort = datensaver($_POST['oldpasswort']); $testpasswortvergleich = md5($oldpasswort);
$newusername = datensaver($_POST['newusername']); $newpasswort = datensaver($_POST['newpasswort']);
$laengeuser = strlen($newusername); $laengepass = strlen($newpasswort);
//-----------------------------------------------------------------// // Fehlerbehandlung $fehlermeldung = ""; $fehler_gefunden = "";
$errormeldung = "<li>Der Wert des Feldes\"Jetziger Username\" stimmt nicht mit dem vorhandenen, in der Passwortdatei gespeicherten Wert überein! \n"; if ($oldusername !== $adminuser) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
$errormeldung = "<li>Der Wert des Feldes\"Jetziges Passwort\" stimmt nicht mit dem vorhandenen, in der Passwortdatei gespeicherten Wert überein! \n"; if ($testpasswortvergleich !== $adminpass) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
// Prüfung auf unerlaubte Zeichen $errormeldung = "<li>Das Feld \"Neuer Username\" enthält unerlaubte Zeichen. Nur a-z A-Z Umlaute äöüßÄÖÜ sowie 0 - 9 der Unterstrich, Bindestrich und Punkt . sind erlaubt. \n";
if (preg_match ("/[^_\.A-Za-z0-9ÄÖÜäöüß-]/", $newusername)) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
// Prüfung auf unerlaubte Zeichen $errormeldung = "<li>Das Feld \"Neues Passwort\" enthält unerlaubte Zeichen. Nur a-z A-Z Umlaute äöüßÄÖÜ sowie 0 - 9 der Unterstrich, Bindestrich und Punkt . sind erlaubt. \n";
if (preg_match ("/[^_\.A-Za-z0-9ÄÖÜäöüß-]/", $newpasswort)) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
// Prüfung auf bestimmte Minimal und Maximallänge $errormeldung = "<li>Das Feld \"Neuer Username\" wurde nicht korrekt ausgefüllt. Mindestens 5 Zeichen muß, aber höchstens 15 Zeichen lang darf der Inhalt dieses Feldes sein. <b>Sie haben $laengeuser Zeichen eingetragen.</b> \n"; if ((strlen($newusername) < 4 || strlen($newusername) > 15 )) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
// Prüfung auf bestimmte Minimal und Maximallänge $errormeldung = "<li>Das Feld \"Neues Passwort\" wurde nicht korrekt ausgefüllt. Mindestens 5 Zeichen muß, aber höchstens 15 Zeichen lang darf der Inhalt dieses Feldes sein. <b>Sie haben $laengepass Zeichen eingetragen.</b>\n"; if ((strlen($newpasswort) < 4 || strlen($newpasswort) > 15 )) { $fehlermeldung = $fehlermeldung.$errormeldung; $fehler_gefunden = 1; }
// Wenn Fehler - dann aufruf der Fehlerfunktion... if ($fehler_gefunden) { $fehlertitel = "Fehler beim Administratordaten ändern"; fehlerausgabe($fehlertitel,$fehlermeldung); exit; } $newpasswortsave = md5($newpasswort);
$fp = fopen("setup/admindaten.php","w"); flock($fp, 2); fputs($fp, "<?php\n"); fputs($fp, "\$adminuser = \"$newusername\";\n"); fputs($fp, "\$adminpass = \"$newpasswortsave\";\n"); fputs($fp, "?>\n"); fclose($fp);
$aktueller_datum = datumausgabe(1);
$betreff = "Passwortänderung";
// Mail senden $message = "Hallo $scriptconf[Adminname], anbei erhalten Sie die Informationen zu der am $aktueller_datum durchgefuehrten Passwortaenderung. Neuer Username: $newusername Neues Passwort: $newpasswort";
$header="From: $scriptconf[Adminname] <$scriptconf[Adminemail]>\n"; $header .= "Reply-To: $scriptconf[Adminname] <$scriptconf[Adminemail]>\n"; mail($scriptconf[Adminemail],$betreff,$message,$header);
setcookie ("Loginuser", "$newusername", time()+86400); setcookie ("Loginpass", "$newpasswortsave", time()+86400);
redirect("$scriptconf[URL]/admin.php?action=startseite", 2); }
MYSQL_CLOSE(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Ausloggen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function logout() { global $scriptconf; setcookie ("Loginuser", "", time()-86400); setcookie ("Loginpass", "", time()-86400);
header("Location: $scriptconf[URL]/admin.php?status=1"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ?>
|