Einstein-511
Mitglied
Hallo ich hoffe ihr könnt mir helfen =) Also ich habe nen kleines Adminscript für mein Uploadscript geschrieben mit Sicherheitscode doch wenn ich das Passwort und den Sicherheitscode eingebe passiert nichts. Hier der gesamte Code der admin.php
PHP:
<?php
include "config.inc.php";
@mysql_connect($mysql,$user,$pw)
or die ($err_ms_con);
@mysql_select_db($db)
or die ($err_ms_db);
$sql = "";
$result = "";
$id = $_GET['id'];
$path = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$cookie = $HTTP_COOKIE_VARS['uploadadmin'];
srand ((double)microtime()*1000000);
$zufallszahl= rand(1,100);
function head() {
include "header.tpl";
}
function foot() {
include "footer.tpl";
exit;
}
if($_POST['code'] == $zufallszahl) {
echo "";
if($_POST['pw'] == $password) {
setcookie('uploadadmin', $password);
$cookie = $HTTP_COOKIE_VARS['uploadadmin'];
header("Location: $path");
exit;
}
}
if($cookie != $password) {
head();
echo "Sicherheitscode: ";
echo $zufallszahl;
echo '<br><br>';
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">Password: <input type="password" name="pw"><br><method="post"> Sicherheitszahl: <input type="text" name="code"><br><input type="submit" value="OK"><br></form><small>Cookies are used.</small>';
foot();
}
if($_GET['mode'] == 'del' && isset($_POST['id'])) {
$id = $_POST['id'];
$sql = "SELECT * FROM upload WHERE `id`=$id";
$result = mysql_query($sql);
while($output = mysql_fetch_assoc($result)) {
unlink($output[file]);
}
$sql = "DELETE FROM upload WHERE `id`=$id";
if(!mysql_query($sql)) {
head();
echo "$delf<br>";
echo '<a href="?mode=none">'.$back.'</a>';
foot();
}
else {
head();
echo "$dels<br>";
echo '<a href="?mode=none">'.$back.'</a>';
foot();
}
}
if($_GET['mode'] == 'ed' && isset($_POST['id'])) {
$id = $_POST['id'];
head();
echo "$edit: ";
$sql = "SELECT * FROM upload WHERE `id`=$id";
$result = mysql_query($sql);
while($output = mysql_fetch_assoc($result)) {
echo $output[file].'<br>';
echo "$ulby $output[author]<br>\n$desc: $output[desc]<br>\n";
echo "<form action=\"".$_SERVER['PHP_SELF']."?mode=eds\" method=\"post\">\n
<input type=\"hidden\" name=\"id\" value=\"$id\"><br>
<input type=\"text\" value=\"$output[author]\" name=\"author\"><br>
<textarea rows=\"10\" cols=\"40\" name=\"desc\">$output[desc]</textarea><br><br>
<input type=\"submit\" value=\"$edit\"></form>";
}
foot();
}
if ($_GET['mode'] == 'eds') {
$id = $_POST['id'];
$fehler = 'none';
$desc = htmlentities($_POST['desc']);
$author = htmlentities($_POST['author']);
if(strlen($desc)>900) { $fehler = "$tl_d"; }
if(strlen($author)>20) { $fehler = "$tl_n"; }
if($fehler == 'none') {
$sql = "UPDATE `upload` SET `desc`='$desc', `author`='$author' WHERE `id`='$id'";
if(!mysql_query($sql)) { echo 'Query failed!'; }
head();
echo "<b>$suc</b><br><br><a href=\"?mode=start\">OK</a>";
foot();
}
else {
head();
echo $fehler."<br>\n";
echo '<a href="?mode=ed">'.$back.'</a>';
foot();
}
}
head();
echo "<h2>$adminmsg</h2><a href=\"index.php\">$index</a><br><br>";
echo '<form action="'.$_SERVER['PHP_SELF'].'?mode=del" method="post">
<fieldset>
<legend>'.$del.'</legend>
<label for="id">ID: <input name="id" type="text"></label>
<input type="submit" value="'.$del.'">
</fieldset>
</form>';
echo '<form action="'.$_SERVER['PHP_SELF'].'?mode=ed" method="post">
<fieldset>
<legend>'.$edit.'</legend>
<label for="id">ID: <input name="id" type="text"></label>
<input type="submit" value="'.$edit.'">
</fieldset>
</form>';
foot();
?>