Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php error_reporting (E_ALL);
- ini_set('display_errors', '1');
- session_start() ;
- if(!isset($_SESSION["login"]) || $_SESSION["login"] == "" || $_SESSION["team"] != "99")
- {
- header("Location: index.php") ;
- }//fin if
- else
- {
- date_default_timezone_set('Europe/Dublin');
- include_once('sql.php');
- include_once('graphique.php');
- if(isset($_POST['modification']))
- {
- if($_POST['modification'] == 'delete_user')
- {
- if($_POST['modification'] == 'yes')
- {
- $agent = $_POST['agent3'];
- $ajout = $sql->delete_user($agent);
- }
- }
- if($_POST['modification'] == "add_user")
- {
- if(isset($_POST['username']))
- {
- //On vérifie si on a récupéré les données
- if((( $_POST['username'])!=""))
- {
- if((( $_POST['password1'])!=""))
- {
- if((( $_POST['password2'])!=""))
- {
- if(($_POST['password1'])==$_POST['password2'])
- {
- if((( $_POST['email'])!=""))
- {
- if(($_POST['team'])!="0")
- {
- // Récupère les informations postées
- $agent = str_replace("'", " ", $_POST['username']) ;
- $agent = htmlentities(addslashes(htmlspecialchars($agent)));
- $password = md5(htmlentities(addslashes(htmlspecialchars($_POST['password1']))));
- $team = htmlentities(addslashes(htmlspecialchars($_POST['team'])));
- $email = htmlentities(addslashes(htmlspecialchars($_POST['email'])));
- $table = "authentification";
- $champ = "username";
- $sql = new SQL();
- $user_exist = $sql->if_user_exist($agent, $table, $champ);
- If($user_exist == 0)
- {
- $nom_user = $sql->calcul_nombre($champ, $table);
- $ajout = $sql->add_user($agent, $password, $team, $email);
- $message = "User added";
- $_POST['username']="";
- }
- else
- {
- $message = "User already exist";
- }
- }
- else
- {
- $message = "Please choose a team";
- }
- }
- else
- {
- $message = "Email invalid";
- }
- }
- else
- {
- $message = "The second password has to be the same";
- }
- }
- else $message = "Please enter the confirmation of the new password";
- }
- else
- {
- $message = "Please enter a password";
- }
- }
- else
- {
- $message = "Please enter a username";
- }
- }
- }
- if($_POST['modification'] == "modify_user")
- {
- //$message = $_POST['agent2']; gets the id number of the agent to change
- if($_POST['reset_pwd'] == "yes")
- {
- // I verify if the agent enter the first new password
- if((( $_POST['passwordnew1'])!=""))
- {
- // I verify if the agent enter the second new password
- if((( $_POST['passwordnew2'])!=""))
- {
- // I verify if the agent enter the same new 2 passwords
- if(($_POST['passwordnew1'])==$_POST['passwordnew2'])
- {
- // I fetch the information
- $password1 = md5(htmlentities(addslashes(htmlspecialchars($_POST['passwordnew1']))));
- $password2 = md5(htmlentities(addslashes(htmlspecialchars($_POST['passwordnew2']))));
- $agent = $_POST['agent2'];
- // I create the SQL Object
- $sql = new SQL();
- // $message = $password1;
- // I verify if the old password in the DB is the same as the one entered
- //$old_pwd = $sql->if_good_old_password($agent, $old_password);
- // If the password entered is good
- //if($old_pwd==1)
- //{
- $ajout = $sql->reset_password($agent, $password1);
- //}
- }
- else
- {
- $message = "The second password has to be the same";
- }
- }
- }
- }
- }
- }
- $graph = new Graphique();
- $tracker = FALSE;
- $fiel_autofocus = "username";
- $haut_page = $graph->haut_page($tracker, $fiel_autofocus);
- ?>
- <form action="add_usertest.php" method="post" name="form_onload">
- <table align="center" class="table_entree_add_user">
- <tr>
- <td colspan="2" align="center">
- <div class="titre">About Users</div>
- <?php echo $_SESSION["login"] ?>
- </td>
- </tr>
- <tr><td colspan="2"><hr></td></tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td colspan="2">
- <label><input class="input_radio" type="radio" name="modification" value="add_user" /><b>Add user</b><br /></label>
- </td>
- </tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> User Name:
- </td>
- <td class="padding-left">
- <input type="text" name="username" <?php if(isset($_POST["username"])){ echo 'value="'.$_POST["username"].'"';} ?> />
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Password :
- </td>
- <td class="padding-left">
- <input type="password" name="password1" />
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Please confirm the password :
- </td>
- <td class="padding-left">
- <input type="password" name="password2" />
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Email address:
- </td>
- <td class="padding-left">
- <input type="text" name="email" class="taille_select"/>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Team :
- </td>
- <td class="padding-left">
- <?php
- $sql = new SQL();
- $table = "team";
- $champ = "num_equipe";
- $order_by = "num_equipe";
- $nb_team = $sql->calcul_nombre($champ, $table);
- $num_equipe_equipe = $sql->infos_equipes($champ, $table, $order_by);
- //print_r($num_equipe_equipe);
- $champ = "nom_equipe";
- $order_by = "num_equipe";
- $nom_equipe_equipe = $sql->infos_equipes($champ, $table, $order_by);
- //print_r($nom_equipe_equipe);
- echo ' <select name="team" id="team" Value="Please choose a Team" class="taille_select">
- <option value="0">Please choose a Team</option>';
- for($i = 0; $i < $nb_team; $i++)
- {
- if($nom_equipe_equipe[$i] != "Administrator")
- {
- echo '<option value="'.$num_equipe_equipe[$i].'">Team '.$num_equipe_equipe[$i].' - '.$nom_equipe_equipe[$i].'</option>';
- }
- else
- {
- echo '<option value="'.$num_equipe_equipe[$i].'">'.$nom_equipe_equipe[$i].'</option>';
- }
- }
- echo '</select>';
- ?>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td colspan="2">
- <label><input class="input_radio" type="radio" name="modification" value="modify_user" /><b>Modify user<b><br /></label>
- </td>
- </tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Please select user :
- </td>
- <td class="padding-left">
- <?php
- $sql = new SQL();
- $table = "authentification";
- $champ1 = "username";
- $champ2 = "email";
- $order_by1 = "username";
- $order_by2 = "id";
- $nb_user = $sql->calcul_nombre($champ1, $table);
- $nom_user = $sql->infos_equipes($champ1, $table, $order_by1);
- $email_user = $sql->infos_equipes($champ2, $table, $order_by2);
- //print_r($nom_equipe_equipe);
- $champ = "id";
- $order_by = "username";
- $id = $sql->infos_equipes($champ, $table, $order_by);
- //print_r($id);
- echo ' <select name="agent2" id="agent2" Value="Please choose the Agent" class="taille_select">
- <option value="0">Please choose the Agent</option>';
- for($i = 0; $i < $nb_user; $i++)
- {
- echo '<option value="'.$id[$i].'" >'.$nom_user[$i].'</option>';
- }
- echo '</select>';
- ?>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Reset password?
- </td>
- <td class="padding-left">
- <input style="border: 0px solid black;" name="reset_pwd" type="radio" value="yes" /> <label for="yes"><b><u><i>Yes</i></u></b></label><br>
- <input style="border: 0px solid black;" name="reset_pwd" type="radio" value="no" checked/> <label for="No"><b><u><i>No</i></u></b></label>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> New password:
- </td>
- <td class="padding-left">
- <input type="password" name="passwordnew1" />
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Confirm the new one :
- </td>
- <td class="padding-left">
- <input type="password" name="passwordnew2" />
- </td>
- </tr>
- <tr>
- <tr><td colspan="2"><br></td></tr>
- <td colspan="2">
- <label><input class="input_radio" type="radio" name="modification" value="delete_user" /><b>Delete user - Under Test do not Use<b><br /></label>
- </td>
- </tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Please select user :
- </td>
- <td class="padding-left">
- <?php
- $sql = new SQL();
- $table = "authentification";
- $champ1 = "username";
- $champ2 = "email";
- $order_by1 = "username";
- $order_by2 = "id";
- $nb_user = $sql->calcul_nombre($champ1, $table);
- $nom_user = $sql->infos_equipes($champ1, $table, $order_by1);
- $email_user = $sql->infos_equipes($champ2, $table, $order_by2);
- //print_r($nom_equipe_equipe);
- $champ = "id";
- $order_by = "username";
- $id = $sql->infos_equipes($champ, $table, $order_by);
- //print_r($id);
- echo ' <select name="agent3" id="agent3" Value="Please choose the Agent" class="taille_select">
- <option value="0">Please choose the Agent</option>';
- for($i = 0; $i < $nb_user; $i++)
- {
- echo '<option value="'.$id[$i].'" >'.$nom_user[$i].'</option>';
- }
- echo '</select>';
- ?>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td class="padding-left">
- <span class="etoile">*</span> Are you sure?
- </td>
- <td class="padding-left">
- <input style="border: 0px solid black;" name="delete_user" type="radio" value="yes" /> <label for="yes"><b><u><i>Yes</i></u></b></label><br>
- <input style="border: 0px solid black;" name="delete_user" type="radio" value="no" checked/> <label for="No"><b><u><i>No</i></u></b></label>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- <tr><td colspan="2"><hr></td></tr>
- <tr><td colspan="2"><br></td></tr>
- <tr>
- <td colspan="2" align="center">
- <input class="bouton_envoyer" type="submit" name="submit" value=" --> Apply <-- " /> <br>
- </td>
- </tr>
- <tr><td colspan="2"><br></td></tr>
- </table>
- </form>
- <?php if(isset($message)){echo '<div class="message">'.$message.'</div>' ;} ?>
- </body>
- <?php
- //$graph->pied_de_page();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement