Erreur : cet utilisateur n'existe pas

\n"; return; } $name = "pc-de-".str_replace(" ", "-", strtolower($a['prenom'])); $r = pg_query("SELECT name FROM computer"); $a = pg_fetch_all_columns($r); $i = 2; while(in_array($name, $a)) { $name .= $i; $i++; } ?>

Nouvelle machine pour

Nom de machine
Adresse MAC : : : : :
Erreur : cette machine n'existe pas

\n"; return; } $mac = explode(":", strtoupper($a['mac'])); ?>

Modification de machine

Nom de machine
Adresse MAC : : : : :
$comp"); $a = pg_fetch_array($r); if($a) return "Erreur : il y a deja une machine avec ce nom ou cette adresse MAC"; pg_query("UPDATE computer SET name = '".$_POST['name']."', mac = '$mac' WHERE idcomp = $comp"); UpdateInterface($user); return true; } function DeleteComp($comp) { $r = pg_query("SELECT iduser FROM computer WHERE idcomp = $comp"); $a = pg_fetch_array($r); if(!$a) return false; pg_query("UPDATE ip_user SET free = '1' WHERE ip IN(SELECT ip FROM computer WHERE idcomp = $comp)"); pg_query("DELETE FROM computer WHERE idcomp = $comp"); UpdateInterface($a['iduser']); return $a['iduser']; } function UpdateInterface($user) { $r = pg_query("SELECT idinterface, datedeco, certif FROM room r, user_pac u WHERE u.idroom = r.idroom AND iduser = $user"); $a = pg_fetch_array($r); $idif = $a['idinterface']; $ddeco = explode("-", $a['datedeco']); $adeco = $ddeco[0]; $mdeco = $ddeco[1]; $certif = ($a['certif'] == 't' || (date("n") >= 9 && date("n") < 11)); $r = pg_query("SELECT MAX(idaction) FROM action"); $a = pg_fetch_array($r); if($a) $newid = $a[0]+1; else $newid = 1; $r = pg_query("SELECT COUNT(*) FROM computer WHERE iduser = $user"); $a = pg_fetch_array($r); $nb = max(1, $a[0]); pg_query("INSERT INTO action(idaction, idinterface, numaction) VALUES($newid, $idif, 0)"); $newid++; pg_query("INSERT INTO action(idaction, idinterface, numaction, option) VALUES($newid, $idif, 3, '$nb')"); $newid++; $r = pg_query("SELECT mac FROM fdb WHERE idinterface = $idif AND type = 2 AND datelast = (SELECT MAX(datelast) FROM fdb)"); while($a = pg_fetch_array($r)) { pg_query("INSERT INTO action(idaction, idinterface, numaction, option) VALUES($newid, $idif, 4, '".$a['mac']."')"); $newid++; } if(($adeco > date("Y") || $mdeco >= date("m")) && $certif) pg_query("INSERT INTO action(idaction, idinterface, numaction) VALUES($newid, $idif, 1)"); } if(isset($_POST['user']) && $_POST['user'] != "") { if($roles['inscription']) { $val = ValidateNew($_POST['user']); if($val === true) header("Location: user.php?id=".$_POST['user']); else { include "inc/inc.header.php"; echo "

$val

\n"; } } else { include "denied.php"; return; } } else if(isset($_POST['comp']) && $_POST['comp'] != "") { if($roles['edit_comp']) { $val = ValidateEdit($_POST['comp']); if($val === true) { $r = pg_query("SELECT iduser FROM computer WHERE idcomp = ".$_POST['comp']); $a = pg_fetch_array($r); header("Location: user.php?id=".$a['iduser']); } else { include "inc/inc.header.php"; echo "

$val

\n"; } } else { include "denied.php"; return; } } else if(isset($_GET['user']) && $_GET['user'] != "") { if($roles['inscription']) { include "inc/inc.header.php"; FormNew($_GET['user']); } else { include "denied.php"; return; } } else if(isset($_GET['id']) && $_GET['id'] != "") { if($roles['edit_comp']) { include "inc/inc.header.php"; FormEdit($_GET['id']); } else { include "denied.php"; return; } } else if(isset($_GET['del']) && $_GET['del'] != "") { if($roles['inscription']) { $user = DeleteComp($_GET['del']); if($user === false) { include "inc/inc.header.php"; echo "

Erreur : cette machine n'existe pas

\n"; } else header("Location: user.php?id=$user"); } else { include "denied.php"; return; } } include "inc/inc.footer.php"; ?>