Guest User

Untitled

a guest
Dec 6th, 2018
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. if($_SESSION['email'] == 'admin17598@outlook.com'){
  2. echo 'a link to a file that i will use to insert and update my tables'
  3. }
  4.  
  5. <?php
  6. require_once '../../db.php';
  7. session_start();
  8.  
  9. if( $_SESSION['logged_in'] != 1 || $_SESSION['email'] != 'admin17598@outlook.com'){
  10.  
  11. $_SESSION['message'] = "Algo deu errado :/";
  12. header("location: ../error.php");
  13. exit;
  14.  
  15. }else {
  16. $username = $_SESSION['username'];
  17. }
  18. ?>
  19.  
  20. <?php
  21.  
  22. if($_SERVER['REQUEST_METHOD'] == 'POST'){
  23.  
  24. $email = trim($_POST['email']);
  25.  
  26. try{
  27. $ckeckEmail = $conn->prepare("SELECT `email` FROM users WHERE `email` = :email");
  28. $ckeckEmail->bindValue(':email', $email);
  29. $ckeckEmail->execute();
  30. $user = $ckeckEmail->fetch(PDO::FETCH_ASSOC);
  31. $RowCount = $ckeckEmail->rowCount();
  32. } catch (PDOerrorInfo $e){}
  33.  
  34. if( $RowCount == 0 ){
  35. // User doesn't exist
  36. $_SESSION['message'] = "Não existe um usuário com este e-mail.";
  37. header("location: error.php");
  38. exit;
  39.  
  40. } else{ // User exists
  41.  
  42. if( password_verify($_POST['password'], $user['password'])){
  43. $_SESSION['email'] = $user['email'];
  44. $_SESSION['user_id'] = $user['user_id'];
  45. $_SESSION['first_name'] = $user['first_name'];
  46. $_SESSION['last_name'] = $user['last_name'];
  47. $_SESSION['username'] = $user['username'];
  48. $_SESSION['img'] = $user['img'];
  49. $_SESSION['capa'] = $user['capa'];
  50. $_SESSION['logged_in'] = true;
  51. header("location: ../?p=profile");
  52. exit;
  53. } else {
  54. $_SESSION['message'] = "Password is incorrect";
  55. header("location: error.php");
  56. exit;
  57. }
  58. }
  59. }
  60.  
  61. $conn = NULL;
  62.  
  63. <?php
  64.  
  65. $img = rand(1,44);
  66. $capa = rand(1,36);
  67. $first_name = trim($_POST['first_name']);
  68. $last_name = trim($_POST['last_name']);
  69. $username = trim($_POST['username']);
  70. $email = trim($_POST['email']);
  71. $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
  72. $hash = md5( rand(0,1000) );
  73.  
  74. // Check if user with that email already exists
  75. $result = $conn->prepare("SELECT `email` FROM users WHERE `email` = :email");
  76. $result->bindParam(':email', $email);
  77. $result->execute();
  78. $RowCount = $result->rowCount();
  79.  
  80. if ( $RowCount > 0 ) {
  81. $_SESSION['message'] = 'Já existe um usuário com este e-mail!';
  82. header("location: error.php");
  83. exit;
  84. }
  85. else {
  86. $sql = "INSERT INTO users (dataR, ultima_atividade, first_name, last_name, username, img, capa, email, password, hash) VALUES (NOW(), NOW(), :first_name, :last_name, :username, :img, :capa, :email, :password, :hash)";
  87. $sql = $conn->prepare($sql);
  88. $sql->bindParam(':first_name', $first_name);
  89. $sql->bindParam(':last_name', $last_name);
  90. $sql->bindParam(':username', $username);
  91. $sql->bindParam(':img', $img);
  92. $sql->bindParam(':capa', $capa);
  93. $sql->bindParam(':email', $email);
  94. $sql->bindParam(':password', $password);
  95. $sql->bindParam(':hash', $hash);
  96. $sql->execute();
  97. $_SESSION['message'] = 'You account was created!';
  98. header("location: success.php");
  99. }
  100. $conn = NULL;
  101.  
  102. <li class="pt-1 pb-2 liInfUs">
  103. <h6>Nome: <?php echo htmlentities($first_name, ENT_QUOTES, 'UTF-8', false).' '.htmlentities($last_name, ENT_QUOTES, 'UTF-8', false); ?></h6>
  104. <h6 class="quicksand300">Email: <?php echo htmlentities($email, ENT_QUOTES, 'UTF-8', false); ?></h6>
  105. </li>
  106. <?php if($_SESSION['email'] == 'admin17598@outlook.com'){
  107. $countUserOLN = $conn->query("SELECT * FROM users WHERE ultima_atividade >= NOW()-600");
  108. $rstq = $countUserOLN->rowCount();
  109. $countUserAll = $conn->query("SELECT * FROM users");
  110. $rstAll = $countUserAll->rowCount();
  111. ?>
  112. <li class="d-flex">
  113. <h6 class="mr-3"><a href="verify/criar/painel.php" style="color: #21D3FF">Painel</a></h6>
  114. <h6 class="quicksand300 mr-3">Users: <?php echo $rstAll ?></h6>
  115. <h6 class="quicksand300">Online: <?php echo $rstq ?></h6>
  116. </li>
  117. <?php } ?>
Add Comment
Please, Sign In to add comment