Erreur: cet identifiant n'existe pas

\n"; return false; } $rroom_name = pg_query("SELECT name FROM room WHERE idroom = '$a[5]'"); $aroom_name = pg_fetch_array($rroom_name); echo "

Chambre " . $aroom_name[0] . "

"; echo "

Utilisateur

\n"; echo "

Les modifications effectuées ici prendront effet dans un délai maximum de 1 heure.

\n"; } else { $r = pg_query("SELECT iduser, nom, prenom FROM user_pac WHERE idroom = $idroom"); // -- Supression de l'ancien user if($a = pg_fetch_array($r)) { if(!isset($_GET['confirm']) || $_GET['confirm'] != "1") { echo "

Ajouter un utilisateur sur cette chambre ($idroom) supprimera l'ancien (".$a['nom']." ".$a['prenom'].").
\n"; echo "Voulez vous continuer ? [Oui] - [Non]

\n"; return false; } else { RemoveUser($idroom); } } // -- $a['nom'] = $a['prenom'] = $a['datedeco'] = $a['mail'] = $a['certif'] = ""; $a['idroom'] = $idroom; } if($act != "") { echo "
"; } echo "\n"; echo "\n"; echo ""; } else { $deco = (strtotime(date("Y-m", strtotime($a['datedeco']." +1 month"))) < time()); echo ($deco?"":"").date("F Y", strtotime($a['datedeco'])).($deco?"":""); } echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo "
Nom"; if($act != "") echo ""; echo "
Prénom"; if($act != "") echo ""; echo "
Mois de fin de connexion"; if($act != "") { if($act == "edit") { $mdeco = get_month($a['datedeco']); $ydeco = get_year($a['datedeco']); } else $mdeco = 0; $month = date("n"); $year = date("Y"); if ($roles['inscription_adv'] || ($act == "new") || ($mdeco == 9 && (($month == 9)||($month == 10)))) { echo "\n"; } else { $deco = (strtotime(date("Y-m", strtotime($a['datedeco']." +1 month"))) < time()); echo ($deco?"":"").date("F Y", strtotime($a['datedeco'])).($deco?"":""); echo ""; } if(($act == "edit") && ($mdeco != 9) && (CompareDate($a['datedeco'], StartDate()) == 2)) { echo "
Étendre à l'année ?"; echo ""; } echo "
eMail"; if($act != "") echo ""; echo "
Chambre"; $r = pg_query("SELECT name FROM room WHERE idroom = ".$a['idroom']); $a2 = pg_fetch_array($r); echo $a2['name']; echo "
Certificat ?"; if($act != "") { echo ""; } else if($a['certif'] == "t") echo "Oui"; else echo "Non"; echo "
Cas particulier ?"; if($act != "" && $roles['inscription_adv']) { echo ""; } else if($a['special_case'] == "t") echo "Oui"; else echo "Non"; echo "
Commentaire"; if($act != "" && $roles['inscription_adv']) { echo ""; } else if($roles['inscription_adv']) echo $a['comment']; echo "
\n"; if($act == "" && $roles['inscription']) echo "

[Corriger]

\n"; else if($act != "") echo "

\n"; return ($act != "new"); } function ValidateForm() { global $roles; if(!$roles['inscription']) return false; if(!isset($_POST['name'])||$_POST['name'] == "" || !isset($_POST['firstname'])||$_POST['firstname'] == "" || !isset($_POST['datedeco'])||$_POST['datedeco'] == "" || (isset($_POST['mail']) && $_POST['mail'] != "" && preg_match("/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]{2,4}$/",$_POST['mail']) == 0)) { echo "

Erreur dans le formulaire

\n"; DisplayUser($_GET['id'], $_GET['act'], $_GET['room']); return false; } $_POST['name'] = str_replace("'", " ", $_POST['name']); $_POST['firstname'] = str_replace("'", " ", $_POST['firstname']); if ($_POST['extend'] == "checked") { $datedeco = (get_year(StartDate())+1)."-9-28"; } else { $datedeco = $_POST['datedeco']; } if($_POST['certif'] == "1" || $_POST['certif'] == "on" || $_POST['certif'] == "checked") $certif = 1; else $certif = 0; if(!isset($_POST['mail']) || $_POST['mail'] == "") $mail = "NULL"; else $mail = "'".$_POST['mail']."'"; if($_POST['special_case'] == "1" || $_POST['special_case'] == "on" || $_POST['special_case'] == "checked") {$special_case = 1;} else {$special_case = 0;} if(isset($_POST['comment'])) {$comment = $_POST['comment'];} else {$comment = "";} if($_GET['id']) { // needed for logging_actions $r = pg_query("SELECT nom, prenom, datedeco, certif FROM user_pac WHERE idroom = ".$_POST['idroom']); $am = pg_fetch_array($r); $edit = "edit"; if (new DateTime($am[2]) != new DateTime($datedeco)) { $edit = "new"; if(! isset($_POST['confirm_amount'])) { confirm_amount($am[2]); return false; } } if($am[3] == t) $cert = 'cert'; else $cert = 'nocert'; $oldopt = $am[0] . ' ' . $am[1] . ' ' . $am[2] . ' ' . $cert; // Update pg_query("UPDATE user_pac SET nom = '".strtoupper($_POST['name'])."', prenom = '".$_POST['firstname']."', datedeco = '$datedeco', mail = $mail, certif = '$certif', special_case = '$special_case', comment = '$comment' WHERE iduser = ".$_GET['id']); $r = pg_query("SELECT datedeco FROM user_pac WHERE iduser = ".$_GET['id']); $datedeco_db = pg_fetch_array($r); logging_actions($oldopt, $certif, $datedeco_db[0], $_POST['name'], $_POST['firstname'], $_GET['id'], $edit); return $_GET['id']; } else { // Insert if(! isset($_POST['confirm_amount'])) { confirm_amount("0"); return false; } $r = pg_query("SELECT MAX(iduser) FROM user_pac"); if($a = pg_fetch_array($r)) $newid = $a[0]+1; else $newid = 1; pg_query("INSERT INTO user_pac(iduser, nom, prenom, datedeco, mail, certif, idroom) VALUES($newid, '".strtoupper($_POST['name'])."', '".$_POST['firstname']."', '$datedeco', $mail, '$certif', ".$_POST['idroom'].")"); $oldopt = " "; logging_actions($oldopt, $certif, $datedeco, $_POST['name'], $_POST['firstname'], $newid, "new"); return $newid; } } function SellCable() { global $roles; $amount = 2; if(!$roles['inscription']) return false; if(! isset($_POST['confirm_amount'])) { if(AreAccountsClosed()) { echo "Impossible : trésorerie de l'année précédente non clôturée."; return false; } echo "

Vous devez faire payer '$amount'€.

Attention, si vous confirmez, cet argent vous sera demandé. Merci de remettre l'argent régulièrement aux trésoriers en précisant absolument votre nom.

"; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo "
\n"; return false; } UpdateAccount($amount); logging_actions(" ", " ", " ", " ", " ", $_GET['id'], "cable"); return true; } function UpdateAccount($amount) { global $auth_user; $r = pg_query("SELECT iduser FROM cam_user WHERE login = '$auth_user'"); $am = pg_fetch_array($r); $idcam_user = $am[0]; $r = pg_query("UPDATE account SET amount=amount+'$amount' WHERE iduser='$idcam_user'"); } // calcule le nombre de mois à faire payer quelle que soit la situation function months_to_pay($olddatedeco, $newdatedeco) { $startdate=date('Y-n-j'); if($olddatedeco != "0") { if(LowestDate($olddatedeco,$startdate) == $startdate) { $startdate=$olddatedeco; } } $year = get_year($newdatedeco); if ($year > get_year($startdate)) { $months = 12 - get_month($startdate) + get_month($newdatedeco) + 1; } else $months = get_month($newdatedeco) - get_month($startdate) + 1; // si la personne est déjà déconnectée, le 20 du mois est passé et au moins 2 mois sont demandés alors le premier mois n'est pas facturé if (($startdate != $olddatedeco) && (date(j) > 20) && ($months > 1)) $months--; return $months; } function AreAccountsClosed() { $r = pg_query("SELECT MAX(year) FROM money"); if($a = pg_fetch_array($r)) { if(isset($a[0]) && CompareDate($a[0], StartDate()) != 0) { $r = pg_query("SELECT SUM(amount) FROM account"); if($a = pg_fetch_array($r)) { if($a[0] != 0) { return true; } else { $r = pg_query("INSERT INTO money(year, amount) VALUES('".StartDate()."', '0')"); } } } elseif(! isset($a[0])) { $r = pg_query("INSERT INTO money(year, amount) VALUES('".StartDate()."', '0')"); } } return false; } function confirm_amount($olddatedeco) { $months = 0; $amount = 0; $new = $_GET['act']; if(AreAccountsClosed()) { echo "Impossible d'inscrire : trésorerie de l'année précédente non clôturée."; return false; } if($olddatedeco != "0") { // pour septembre, vérifier dans les logs que l'inscription n'a pas eu lieu cette année (paiement mensuel) if(LowestDate($olddatedeco,StartDate()) == $olddatedeco) { $new = "new"; } } $newdatedeco=$_POST['datedeco']; if($new == "new") { $months=months_to_pay("0", $newdatedeco); $amount = min($months * 6, 50); } else { if ($_POST['extend'] == "checked") { $newdatedeco=(get_year(StartDate())+1)."-9-28"; $r = pg_query("SELECT MAX(idlog) FROM action_log WHERE iduser = ".$_GET['id']." AND numaction = 5"); $am = pg_fetch_array($r); if ($am[0] != "") { $r = pg_query("SELECT amount FROM action_log WHERE idlog = ".$am[0]); $am = pg_fetch_array($r); if ($am[0] != "N/A") { if (! strstr($am[0], 'tresorier')) { $months=months_to_pay($olddatedeco, $newdatedeco); $amount = min(50 - intval($am[0]),$months*6); } else { echo "Erreur : il s'agit d'un cas particulier, merci de demander l'aide du trésorier."; return false;} } else { echo "Erreur : inscription introuvable dans les logs."; return false;} } else { echo "Erreur : inscription introuvable dans les logs."; return false;} } } if(($new == "new") || ($_POST['extend'] == "checked")) { echo "

Vous devez faire payer '$amount'€.

Attention, si vous confirmez, cet argent vous sera demandé. Merci de remettre l'argent régulièrement aux trésoriers en précisant absolument votre nom.

"; } else { echo "

Montant ?

"; } echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; if(($new == "new") || ($_POST['extend'] == "checked")) { echo ""; echo "
"; } else { echo ""; echo ""; echo ""; } echo "
"; echo "
\n"; } function logging_actions($oldopt, $certif, $datedeco, $name, $firstname, $iduser, $act) { global $auth_user; if(isset($_POST['idroom'])) { $r = pg_query("SELECT idinterface FROM room WHERE idroom = ".$_POST['idroom']); if($am = pg_fetch_array($r)) { $id = $am[0]; } } $r = pg_query("SELECT MAX(idlog) FROM action_log"); if($am = pg_fetch_array($r)) $newid = $am[0]+1; else $newid = 1; if($certif) $cert = 'cert'; else $cert = 'nocert'; $opt = $name . ' ' .$firstname . ' ' . $datedeco . ' ' . $cert; $amount = "N/A"; if ($act=="edit") { $num = 8; } elseif ($act=="new") { $num = 5; $amount = $_POST['confirm_amount']; UpdateAccount($amount); if (isset($_POST['tresorier'])) { $amount .= " (tresorier)"; } } elseif ($act=="cable") { $num=9; $r = pg_query("SELECT nom, prenom, datedeco, certif, idroom FROM user_pac WHERE iduser = $iduser"); $a = pg_fetch_array($r); if($a[3]) $cert = 'cert'; else $cert = 'nocert'; $opt = $a[0] . ' ' .$a[1] . ' ' . $a[2] . ' ' . $cert; $r = pg_query("SELECT idinterface FROM room WHERE idroom = ".$a[4]); if($am = pg_fetch_array($r)) { $id = $am[0]; } $amount = $_POST['confirm_amount']; } $r = pg_query("INSERT INTO action_log VALUES($newid, '$auth_user', ".time().", $id, $num, '$oldopt', '$opt', '$iduser', '$amount')"); } function DisplayComputers($id) { global $roles; echo "

Liste des machines

\n"; $r = pg_query("SELECT idcomp, name, mac, ip FROM computer WHERE iduser = $id"); $n = pg_num_rows($r); if($n > 0) { echo "
    "; while($a = pg_fetch_array($r)) { echo "
  • ".$a['name']." - ".strtoupper($a['mac'])." - ".$a['ip']." -"; if($roles['edit_comp']) echo " [Changer]"; if($roles['inscription']) echo " [Supprimer]"; echo "
  • \n"; } echo "
\n"; } else echo "

Aucune machine

\n"; if($n < 3 && $roles['inscription']) echo "

[Ajouter]

\n"; } function DisplayEthernetCable() { global $roles; if($roles['inscription']) { echo "
"; echo ""; echo ""; echo "
\n
";} } function DisplayRegistration($idcam) { global $roles; global $auth_user; echo "

Compte camembert

\n"; if($_POST['create'] != 1) { $r = pg_query("SELECT login FROM cam_user WHERE iduser = $idcam"); $a = pg_fetch_array($r); } if($roles['roles']) { echo "
";} echo ""; echo ""; } else { echo "\"/>"; echo ""; } } else { echo $a['login'].""; } echo "
Pseudo"; if($roles['roles']) { echo "
\n"; if($roles['roles']) { echo ""; echo "
\n";} if(($roles['inscription'] && $auth_user == $a['login']) || $roles['inscription_adv']) { $r = pg_query("SELECT amount FROM account WHERE iduser = $idcam"); $a = pg_fetch_array($r); echo "
Montant dû :
".$a['amount']." €"; } } function RegisterUser($id) { echo "

Compte camembert

\n"; echo "
"; echo ""; echo "
\n"; } function NewRegistration($id) { $r = pg_query("SELECT MAX(iduser) FROM cam_user"); if($a = pg_fetch_array($r)) $newid = $a[0]+1; else $newid = 1; $r = pg_query("SELECT iduser FROM cam_user WHERE login = '".$_POST['pseudo']."'"); if(($a = pg_fetch_array($r)) === false) { pg_query("INSERT INTO cam_user(iduser, login, groupe) VALUES($newid, '".$_POST['pseudo']."', 1)"); pg_query("INSERT INTO id(idcam_user, iduser) VALUES($newid, $id)"); return $newid; } else { return 0; } } function UpdateRegistration($idcam) { $r = pg_query("SELECT iduser FROM cam_user WHERE login = '".$_POST['pseudo']."'"); if(($a = pg_fetch_array($r)) === false) { $r2 = pg_query("SELECT login FROM cam_user WHERE iduser = $idcam"); $a2 = pg_fetch_array($r2); pg_query("UPDATE cam_user SET login='".$_POST['pseudo']."' WHERE iduser = ".$idcam); return 0; } else { return 1; } } if((!isset($_POST['idroom'])) && (!isset($_POST['cable']))) { $ok = DisplayUser($_GET['id'], $_GET['act'], $_GET['room']); if($ok && ($_GET['act'] != "edit")) { DisplayComputers($_GET['id']); DisplayEthernetCable(); $r = pg_query("SELECT idcam_user FROM id WHERE iduser = ".$_GET['id']); if($a = pg_fetch_array($r)) { if(isset($_POST['pseudo']) && $roles['roles'] && ($_POST['pseudo'] != "") ) { $value = UpdateRegistration($a['idcam_user']); if($value) { echo "Pseudo déjà utilisé."; } } DisplayRegistration($a['idcam_user']); } elseif($roles['roles']) { if(!isset($_POST['create'])) { RegisterUser($_GET['id']);} elseif($_POST['create'] == 1) { DisplayRegistration(0); } elseif(($_POST['create'] == 2) && isset($_POST['pseudo']) && ($_POST['pseudo'] != "") ) { $value = NewRegistration($_GET['id']); if(! $value) { echo "Pseudo déjà utilisé."; } else { DisplayRegistration($value);} } } } } elseif(isset($_POST['cable'])) { $id = $_GET['id']; if(SellCable()) { DisplayUser($id, "", ""); DisplayComputers($id); DisplayEthernetCable(); } } else { $id = ValidateForm(); if($id !== false) { UpdateInterfaceForUser($id); echo "

Retour à l'utilisateur

"; } } include "inc/inc.footer.php"; ?>