Advertisement
Guest User

Untitled

a guest
Apr 17th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['rBtn'])){
  3. $sql = $odb->prepare("DELETE FROM `keys` WHERE `number` = :id");
  4. $sql->execute(array(':id' => $id));
  5. header('location: users.php');
  6. }
  7. if(isset($_POST['updateBtn'])){
  8. $update = false;
  9. if($username != $_POST['api']){
  10. if(ctype_alnum($_POST['api']) && strlen($_POST['api']) >= 4 && strlen($_POST['api']) <= 35){
  11. $SQL = $odb->prepare("UPDATE `apikey`.`users` SET `apikey` = :api WHERE `users`.`ID` = :id");
  12. $SQL->execute(array(':api' => $_POST['api'], ':apikey' => $id));
  13. $update = true;
  14. $username = $_POST['username'];
  15. } else {
  16. echo '<div class="alert alert-danger"><p>Key has to be alphanumeric 4 > 35</p></div>';
  17. }
  18. }
  19. if(!empty($_POST['password'])){
  20. $SQL = $odb->prepare("UPDATE `users` SET `password` = :password WHERE `ID` = :id");
  21. $SQL->execute(array(':password' => SHA1($_POST['password']), ':id' => $id));
  22. $update = true;
  23. $password = SHA1($_POST['password']);
  24. }
  25. if($email != $_POST['email']){
  26. if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
  27. $SQL = $odb->prepare("UPDATE `users` SET `email` = :email WHERE `ID` = :id");
  28. $SQL->execute(array(':email' => $_POST['email'], ':id' => $id));
  29. $update = true;
  30. $email = $_POST['email'];
  31. } else {
  32. echo '<div class="alert alert-danger"><p>You entered an invalid email!</p></div>';
  33. }
  34. }
  35. if($rank != $_POST['rank']){
  36. $SQL = $odb->prepare("UPDATE `users` SET `rank` = :rank WHERE `ID` = :id");
  37. $SQL->execute(array(':rank' => $_POST['rank'], ':id' => $id));
  38. $update = true;
  39. $rank = $_POST['rank'];
  40. }
  41. if($membership != $_POST['plan']){
  42. if($_POST['plan'] == 0){
  43. $SQL = $odb->prepare("UPDATE `users` SET `expire` = '0', `membership` = '0' WHERE `ID` = :id");
  44. $SQL->execute(array(':id' => $id));
  45. $update = true;
  46. $membership = $_POST['plan'];
  47. } else {
  48. $getPlanInfo = $odb->prepare("SELECT `unit`,`length` FROM `plans` WHERE `ID` = :plan");
  49. $getPlanInfo->execute(array(':plan' => $_POST['plan']));
  50. $plan = $getPlanInfo->fetch(PDO::FETCH_ASSOC);
  51. $unit = $plan['unit'];
  52. $length = $plan['length'];
  53. $newExpire = strtotime("+{$length} {$unit}");
  54. $updateSQL = $odb->prepare("UPDATE `users` SET `expire` = :expire, `membership` = :plan WHERE `id` = :id");
  55. $updateSQL->execute(array(':expire' => $newExpire, ':plan' => $_POST['plan'], ':id' => $id));
  56. $update = true;
  57. $membership = $_POST['plan'];
  58. }
  59. }
  60. if($status != $_POST['status']){
  61. $SQL = $odb->prepare("UPDATE `users` SET `status` = :status WHERE `ID` = :id");
  62. $SQL->execute(array(':status' => $_POST['status'], ':id' => $id));
  63. $update = true;
  64. $status = $_POST['status'];
  65. }
  66. if($update == true){
  67. echo '<div class="alert alert-success"><p>The key has been updated. You will be taken back to the key-manager!</p></div>';
  68. echo '<meta http-equiv="refresh" content="2;url=edit-user-api.php">';
  69. } else {
  70. echo '<div class="alert alert-danger"><p>Nothing seems to have changed..</p></div>';
  71. }
  72.  
  73. }
  74. if(isset($_POST['clearlBtn'])){
  75. $SQL = $odb->prepare("DELETE FROM `loginip` WHERE `username` = :username");
  76. $SQL->execute(array(':username' => $username));
  77. echo '<div class="alert alert-success"><p>Login logs were deleted from the account.</p></div>';
  78. }
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement