Ciao a tutti!
Sto modificando uno script che permetta all'admin di aggiungere utenti ad un'area riservata.Ho quasi finito il tutto, già riesco ad aggiungere e modificare un utente, il problema è quando devo eliminare l'utente stesso. Infatti mi dice che non ho i permessi per farlo, eppure sono loggato come admin. Lo script non ha DB, ma si appoggia ad un'altra pagina (users.php).
Vi posto la parte del codice che dovrebbe essere modificata:
codice:
<?php
session_start(); // Maintain session state
header("Cache-control: private"); // Fixes IE6's back button problem.
// Check that we are logged in and an admin
if(@$_SESSION["permission"] > 1){
// Check if we have a number to mod
if(@$_GET["del"]){
// Check if we have already made changes and want
// to post
if(@$_GET["go"]){
// Get the line number we are changing
$id = $_GET["del"];
// Dont allow the first user to be deleted
if($id == 1){
// Redirect to del page
header("location: delUser.php?dontDelete=1");
}
else{
// Get the original vars
$file = file("users.php");
// Create the new file structure
#1. before line
for($i = 0; $i < $id; $i++){
$oldLines[$i] = $file[$i];
}
#2. after line
for($i = ($id +1); $i < sizeof($file); $i++){
$oldLines[$i] = $file[$i];
}
// Replace users file
$fp = fopen("users.php", "w");
// Add contents
for($i = 0; $i < sizeof($file); $i++){
if($i != $id) fwrite($fp, $oldLines[$i]);
else fwrite($fp, "//\r\n");
}
// Close file
fclose($fp);
// Redirect to del page
header("location: delUser.php?deleted=1");
}
}
?>
<script language = "javascript" type = "text/javascript">
<!-- // Confirm user wants to delete this user
if(confirm("Are you sure that you want to delete this user?\nThis action cannot be undone.") == 1) location.href = '<?php print($_SERVER["PHP_SELF"]. "?del=". $_GET["del"]."&go=1");?>';
else location.href = 'delUser.php';
-->
</script>
<?php
}
else{
?>
Grazie