Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.57 KB | None | 0 0
  1. <?php error_reporting (E_ALL);
  2. ini_set('display_errors', '1');
  3. session_start() ;
  4. if(!isset($_SESSION["login"]) || $_SESSION["login"] == "" || $_SESSION["team"] != "99")
  5. {
  6. header("Location: index.php") ;
  7. }//fin if
  8. else
  9. {
  10. date_default_timezone_set('Europe/Dublin');
  11. include_once('sql.php');
  12. include_once('graphique.php');
  13.  
  14.  
  15. if(isset($_POST['modification']))
  16. {
  17. if($_POST['modification'] == 'delete_user')
  18. {
  19. if($_POST['modification'] == 'yes')
  20. {
  21. $agent = $_POST['agent3'];
  22. $ajout = $sql->delete_user($agent);
  23. }
  24. }
  25.  
  26. if($_POST['modification'] == "add_user")
  27. {
  28. if(isset($_POST['username']))
  29. {
  30. //On vérifie si on a récupéré les données
  31. if((( $_POST['username'])!=""))
  32. {
  33. if((( $_POST['password1'])!=""))
  34. {
  35. if((( $_POST['password2'])!=""))
  36. {
  37. if(($_POST['password1'])==$_POST['password2'])
  38. {
  39. if((( $_POST['email'])!=""))
  40. {
  41. if(($_POST['team'])!="0")
  42. {
  43. // Récupère les informations postées
  44. $agent = str_replace("'", " ", $_POST['username']) ;
  45. $agent = htmlentities(addslashes(htmlspecialchars($agent)));
  46. $password = md5(htmlentities(addslashes(htmlspecialchars($_POST['password1']))));
  47. $team = htmlentities(addslashes(htmlspecialchars($_POST['team'])));
  48. $email = htmlentities(addslashes(htmlspecialchars($_POST['email'])));
  49.  
  50. $table = "authentification";
  51. $champ = "username";
  52.  
  53. $sql = new SQL();
  54. $user_exist = $sql->if_user_exist($agent, $table, $champ);
  55. If($user_exist == 0)
  56. {
  57. $nom_user = $sql->calcul_nombre($champ, $table);
  58. $ajout = $sql->add_user($agent, $password, $team, $email);
  59. $message = "User added";
  60. $_POST['username']="";
  61. }
  62. else
  63. {
  64. $message = "User already exist";
  65. }
  66. }
  67. else
  68. {
  69. $message = "Please choose a team";
  70. }
  71. }
  72. else
  73. {
  74. $message = "Email invalid";
  75. }
  76. }
  77. else
  78. {
  79. $message = "The second password has to be the same";
  80. }
  81. }
  82. else $message = "Please enter the confirmation of the new password";
  83. }
  84. else
  85. {
  86. $message = "Please enter a password";
  87. }
  88. }
  89. else
  90. {
  91. $message = "Please enter a username";
  92. }
  93. }
  94. }
  95.  
  96.  
  97. if($_POST['modification'] == "modify_user")
  98. {
  99. //$message = $_POST['agent2']; gets the id number of the agent to change
  100.  
  101. if($_POST['reset_pwd'] == "yes")
  102. {
  103.  
  104.  
  105.  
  106.  
  107. // I verify if the agent enter the first new password
  108. if((( $_POST['passwordnew1'])!=""))
  109. {
  110.  
  111.  
  112. // I verify if the agent enter the second new password
  113. if((( $_POST['passwordnew2'])!=""))
  114. {
  115.  
  116.  
  117.  
  118. // I verify if the agent enter the same new 2 passwords
  119. if(($_POST['passwordnew1'])==$_POST['passwordnew2'])
  120. {
  121. // I fetch the information
  122.  
  123. $password1 = md5(htmlentities(addslashes(htmlspecialchars($_POST['passwordnew1']))));
  124. $password2 = md5(htmlentities(addslashes(htmlspecialchars($_POST['passwordnew2']))));
  125. $agent = $_POST['agent2'];
  126.  
  127. // I create the SQL Object
  128. $sql = new SQL();
  129. // $message = $password1;
  130. // I verify if the old password in the DB is the same as the one entered
  131. //$old_pwd = $sql->if_good_old_password($agent, $old_password);
  132.  
  133. // If the password entered is good
  134. //if($old_pwd==1)
  135. //{
  136. $ajout = $sql->reset_password($agent, $password1);
  137.  
  138. //}
  139. }
  140. else
  141. {
  142. $message = "The second password has to be the same";
  143. }
  144. }
  145. }
  146.  
  147. }
  148. }
  149.  
  150.  
  151. }
  152.  
  153. $graph = new Graphique();
  154. $tracker = FALSE;
  155. $fiel_autofocus = "username";
  156. $haut_page = $graph->haut_page($tracker, $fiel_autofocus);
  157.  
  158. ?>
  159.  
  160. <form action="add_usertest.php" method="post" name="form_onload">
  161. <table align="center" class="table_entree_add_user">
  162.  
  163. <tr>
  164. <td colspan="2" align="center">
  165. <div class="titre">About Users</div>
  166. <?php echo $_SESSION["login"] ?>
  167. </td>
  168. </tr>
  169. <tr><td colspan="2"><hr></td></tr>
  170. <tr><td colspan="2"><br></td></tr>
  171. <tr>
  172. <td colspan="2">
  173. <label><input class="input_radio" type="radio" name="modification" value="add_user" /><b>Add user</b><br /></label>
  174. </td>
  175. </tr>
  176. <tr>
  177. <td class="padding-left">
  178. <span class="etoile">*</span> User Name:
  179. </td>
  180. <td class="padding-left">
  181. <input type="text" name="username" <?php if(isset($_POST["username"])){ echo 'value="'.$_POST["username"].'"';} ?> />
  182. </td>
  183. </tr>
  184. <tr><td colspan="2"><br></td></tr>
  185. <tr>
  186. <td class="padding-left">
  187. <span class="etoile">*</span> Password :
  188. </td>
  189. <td class="padding-left">
  190. <input type="password" name="password1" />
  191. </td>
  192. </tr>
  193. <tr><td colspan="2"><br></td></tr>
  194. <tr>
  195. <td class="padding-left">
  196. <span class="etoile">*</span> Please confirm the password :
  197. </td>
  198. <td class="padding-left">
  199. <input type="password" name="password2" />
  200. </td>
  201. </tr>
  202. <tr><td colspan="2"><br></td></tr>
  203. <tr>
  204. <td class="padding-left">
  205. <span class="etoile">*</span> Email address:
  206. </td>
  207. <td class="padding-left">
  208. <input type="text" name="email" class="taille_select"/>
  209. </td>
  210. </tr>
  211. <tr><td colspan="2"><br></td></tr>
  212. <tr>
  213. <td class="padding-left">
  214. <span class="etoile">*</span> Team :
  215. </td>
  216. <td class="padding-left">
  217. <?php
  218.  
  219. $sql = new SQL();
  220. $table = "team";
  221. $champ = "num_equipe";
  222. $order_by = "num_equipe";
  223. $nb_team = $sql->calcul_nombre($champ, $table);
  224.  
  225. $num_equipe_equipe = $sql->infos_equipes($champ, $table, $order_by);
  226. //print_r($num_equipe_equipe);
  227.  
  228. $champ = "nom_equipe";
  229. $order_by = "num_equipe";
  230. $nom_equipe_equipe = $sql->infos_equipes($champ, $table, $order_by);
  231. //print_r($nom_equipe_equipe);
  232.  
  233. echo ' <select name="team" id="team" Value="Please choose a Team" class="taille_select">
  234. <option value="0">Please choose a Team</option>';
  235.  
  236. for($i = 0; $i < $nb_team; $i++)
  237. {
  238. if($nom_equipe_equipe[$i] != "Administrator")
  239. {
  240. echo '<option value="'.$num_equipe_equipe[$i].'">Team '.$num_equipe_equipe[$i].' - '.$nom_equipe_equipe[$i].'</option>';
  241. }
  242. else
  243. {
  244. echo '<option value="'.$num_equipe_equipe[$i].'">'.$nom_equipe_equipe[$i].'</option>';
  245. }
  246. }
  247.  
  248. echo '</select>';
  249.  
  250. ?>
  251.  
  252. </td>
  253. </tr>
  254. <tr><td colspan="2"><br></td></tr>
  255.  
  256. <tr>
  257. <td colspan="2">
  258. <label><input class="input_radio" type="radio" name="modification" value="modify_user" /><b>Modify user<b><br /></label>
  259. </td>
  260. </tr>
  261. <tr>
  262. <td class="padding-left">
  263. <span class="etoile">*</span> Please select user :
  264. </td>
  265. <td class="padding-left">
  266. <?php
  267.  
  268. $sql = new SQL();
  269. $table = "authentification";
  270.  
  271. $champ1 = "username";
  272. $champ2 = "email";
  273.  
  274. $order_by1 = "username";
  275. $order_by2 = "id";
  276. $nb_user = $sql->calcul_nombre($champ1, $table);
  277. $nom_user = $sql->infos_equipes($champ1, $table, $order_by1);
  278. $email_user = $sql->infos_equipes($champ2, $table, $order_by2);
  279. //print_r($nom_equipe_equipe);
  280.  
  281. $champ = "id";
  282. $order_by = "username";
  283. $id = $sql->infos_equipes($champ, $table, $order_by);
  284. //print_r($id);
  285.  
  286. echo ' <select name="agent2" id="agent2" Value="Please choose the Agent" class="taille_select">
  287. <option value="0">Please choose the Agent</option>';
  288.  
  289. for($i = 0; $i < $nb_user; $i++)
  290. {
  291. echo '<option value="'.$id[$i].'" >'.$nom_user[$i].'</option>';
  292. }
  293.  
  294. echo '</select>';
  295.  
  296. ?>
  297.  
  298. </td>
  299. </tr>
  300. <tr><td colspan="2"><br></td></tr>
  301. <tr>
  302. <td class="padding-left">
  303. <span class="etoile">*</span> Reset password?
  304. </td>
  305. <td class="padding-left">
  306. <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>
  307. <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>
  308. </td>
  309. </tr>
  310. <tr><td colspan="2"><br></td></tr>
  311.  
  312.  
  313. <tr>
  314. <td class="padding-left">
  315. <span class="etoile">*</span> New password:
  316. </td>
  317. <td class="padding-left">
  318. <input type="password" name="passwordnew1" />
  319. </td>
  320. </tr>
  321. <tr><td colspan="2"><br></td></tr>
  322. <tr>
  323. <td class="padding-left">
  324. <span class="etoile">*</span> Confirm the new one :
  325. </td>
  326. <td class="padding-left">
  327. <input type="password" name="passwordnew2" />
  328. </td>
  329. </tr>
  330.  
  331.  
  332.  
  333. <tr>
  334.  
  335. <tr><td colspan="2"><br></td></tr>
  336.  
  337. <td colspan="2">
  338. <label><input class="input_radio" type="radio" name="modification" value="delete_user" /><b>Delete user - Under Test do not Use<b><br /></label>
  339. </td>
  340. </tr>
  341. <tr>
  342. <td class="padding-left">
  343. <span class="etoile">*</span> Please select user :
  344. </td>
  345. <td class="padding-left">
  346. <?php
  347.  
  348. $sql = new SQL();
  349. $table = "authentification";
  350.  
  351. $champ1 = "username";
  352. $champ2 = "email";
  353.  
  354. $order_by1 = "username";
  355. $order_by2 = "id";
  356. $nb_user = $sql->calcul_nombre($champ1, $table);
  357. $nom_user = $sql->infos_equipes($champ1, $table, $order_by1);
  358. $email_user = $sql->infos_equipes($champ2, $table, $order_by2);
  359. //print_r($nom_equipe_equipe);
  360.  
  361. $champ = "id";
  362. $order_by = "username";
  363. $id = $sql->infos_equipes($champ, $table, $order_by);
  364. //print_r($id);
  365.  
  366. echo ' <select name="agent3" id="agent3" Value="Please choose the Agent" class="taille_select">
  367. <option value="0">Please choose the Agent</option>';
  368.  
  369. for($i = 0; $i < $nb_user; $i++)
  370. {
  371. echo '<option value="'.$id[$i].'" >'.$nom_user[$i].'</option>';
  372. }
  373.  
  374. echo '</select>';
  375.  
  376. ?>
  377.  
  378. </td>
  379. </tr>
  380. <tr><td colspan="2"><br></td></tr>
  381. <tr>
  382. <td class="padding-left">
  383. <span class="etoile">*</span> Are you sure?
  384. </td>
  385. <td class="padding-left">
  386. <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>
  387. <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>
  388.  
  389. </td>
  390. </tr>
  391.  
  392.  
  393. <tr><td colspan="2"><br></td></tr>
  394.  
  395.  
  396.  
  397.  
  398.  
  399. <tr><td colspan="2"><hr></td></tr>
  400. <tr><td colspan="2"><br></td></tr>
  401. <tr>
  402. <td colspan="2" align="center">
  403. <input class="bouton_envoyer" type="submit" name="submit" value="&nbsp;--> Apply <--&nbsp;" /> <br>
  404. </td>
  405. </tr>
  406. <tr><td colspan="2"><br></td></tr>
  407. </table>
  408. </form>
  409.  
  410. <?php if(isset($message)){echo '<div class="message">'.$message.'</div>' ;} ?>
  411.  
  412.  
  413.  
  414. </body>
  415.  
  416. <?php
  417. //$graph->pied_de_page();
  418. }
  419. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement