|
|
@ -5,4 +5,125 @@ |
|
|
|
* @version $Id$ |
|
|
|
**/ |
|
|
|
|
|
|
|
?>
|
|
|
|
if (!isset($_GET['id']) || !is_numeric(trim($_GET['id']))) |
|
|
|
{ |
|
|
|
Przekieruj('index.php?mode=admin_gallery', 'Nieprawidłowy ID użytkownika'); |
|
|
|
} |
|
|
|
|
|
|
|
$id = intval($_GET['id']); |
|
|
|
$msg = ''; |
|
|
|
|
|
|
|
#a teraz czy wogole user istnieje w bazie ;)
|
|
|
|
$sql = "SELECT * FROM `admins` WHERE `id`='$id';"; |
|
|
|
if (!$result = $DB->query($sql)) |
|
|
|
{ |
|
|
|
blad('Nie mozna pobrac info o administratorze'); |
|
|
|
} |
|
|
|
if ($result->num_rows == 0) |
|
|
|
{ |
|
|
|
Przekieruj('index.php?mode=admin_users', 'Użytkownik nie istnieje!'); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$row = $result->fetch_assoc(); |
|
|
|
} |
|
|
|
|
|
|
|
#edycja w bazie - caly "mechanizm"
|
|
|
|
if (isset($_POST['nick'])) |
|
|
|
{ |
|
|
|
$_POST['nick'] = addslashes(strip_tags(trim($_POST['nick']))); |
|
|
|
$_POST['email'] = addslashes(strip_tags(trim($_POST['email']))); |
|
|
|
|
|
|
|
#sprawdzanie, czy nick nie jest zajety
|
|
|
|
$sql = "SELECT `id` FROM `admins` WHERE `nick` ='".$_POST['nick']."';"; |
|
|
|
if (!$result = $DB->query($sql)) |
|
|
|
{ |
|
|
|
blad('Nie mozna sprawdzic, czy nick nie zostal zajety.'); |
|
|
|
} |
|
|
|
if ($result->num_rows>0) |
|
|
|
{ |
|
|
|
$reserved = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$reserved = false; |
|
|
|
} |
|
|
|
$result->free(); |
|
|
|
|
|
|
|
if (strlen($_POST['nick']) > 0 && trim($_POST['nick']) != $row['nick'] && ~$reserved) |
|
|
|
{ |
|
|
|
$sql = "UPDATE `admins` SET `nick`='".$_POST['nick']."' WHERE `id`='$id'"; |
|
|
|
if (!$DB->query($sql)) |
|
|
|
{ |
|
|
|
blad('Nie mozna zaaktualizowac nicku administratora.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (strlen($_POST['email']) > 0 && trim($_POST['nick']) != $row['email']) |
|
|
|
{ |
|
|
|
if (ereg ("^.+@.+\..+$", $_POST['email'])) |
|
|
|
{ |
|
|
|
$sql = "UPDATE `admins` SET `email`='".$_POST['email']."' WHERE `id`='$id'"; |
|
|
|
if (!$DB->query($sql)) |
|
|
|
{ |
|
|
|
blad('Nie mozna zaaktualizowac emaila administratora.'); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$msg = 'Adres email jest nieprawidłowy! (przykład: [email protected])'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (strlen(trim($_POST['pass'])) > 0 && md5(trim($_POST['pass'])) != $row['password']) |
|
|
|
{ |
|
|
|
$_POST['pass'] = md5(addslashes(strip_tags(trim($_POST['pass'])))); |
|
|
|
$sql = "UPDATE `admins` SET `password`='".$_POST['pass']."' WHERE `id`='$id'"; |
|
|
|
if (!$DB->query($sql)) |
|
|
|
{ |
|
|
|
blad('Nie mozna zaaktualizowac hasla administratora.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($msg == '') |
|
|
|
{ |
|
|
|
Przekieruj('index.php?mode=admin_users', 'Użytkownik został zaaktualizowany! Powrót...'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
NaglowekPA('Edycja użytkownika'); |
|
|
|
|
|
|
|
if ($msg != '') |
|
|
|
{ |
|
|
|
$msg = '<span style="color: red; font-weight: bold">'.$msg.'</span>'; |
|
|
|
} |
|
|
|
?>
|
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<?php echo $msg; ?>
|
|
|
|
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST"> |
|
|
|
<table width="600" border="1" style="border-color: gray; border-style: solid; border-collapse: collapse"> |
|
|
|
<tr> |
|
|
|
<td colspan="2" bgcolor="yellow">Edycja użytkownika "<?php echo $row['nick']; ?>"</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td align="right">Nazwa użytkownika:</td> |
|
|
|
<td align="left"><input type="text" name="nick" value="<?php echo $row['nick']; ?>" /></td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td align="right">Hasło:</td> |
|
|
|
<td align="left"><input type="password" name="pass" /></td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td align="right">Email:</td> |
|
|
|
<td align="left"><input type="text" name="email" value="<?php echo $row['email']; ?>" /></td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td colspan="2"> |
|
|
|
<input type="submit" value="Zapisz" /> |
|
|
|
<input type="reset" value="Wyczyść" /> |
|
|
|
</td> |
|
|
|
</tr> |
|
|
|
</table> |
|
|
|
<br /> |
|
|
|
<?php StopkaPA(); ?>
|