Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. error_reporting(E_ALL ^ E_DEPRECATED); // debugging.
  5.  
  6. include 'webinc/099111110102105103/100097116097098097115101/connect.php';
  7.  
  8. require '115101099117114105116121/security.php';
  9.  
  10. //require '102117110099116105111110115/functions.php';
  11.  
  12. function getrow($q)
  13. {
  14. global $db;
  15. $checkquery = $db->query($q);
  16.  
  17. if($checkquery === FALSE) {
  18. die($db->error()); //Error handling better.
  19. }
  20.  
  21. $result = $db->fetch_array($checkquery);
  22. return $result;
  23. }
  24.  
  25. function redirect_not_logged()
  26. {
  27. global $db;
  28. $username = $db->real_escape_string(trim($_SESSION['username']));
  29. $password = $db->real_escape_string(trim($_SESSION['password']));
  30.  
  31. $check = getrow("SELECT * FROM accounts WHERE accountName='$username' && accountPassword='$password'");
  32. $id = $check['accountID'];
  33. $query = $db->query("SELECT * FROM `accounts` WHERE accountID = $id");
  34. while($row = $db->fetch_array($query))
  35. {
  36. $online = $row['accountStatus'];
  37. }
  38. if($online == 0)
  39. {
  40. echo " Not Logged In ";
  41.  
  42. }
  43.  
  44. }
  45.  
  46. $logged_in = 0;
  47. if(isset($_SESSION['username']) && isset($_SESSION['password'])){
  48.  
  49. $username = $db->real_escape_string(trim($_SESSION['username']));
  50. $username = $db->real_escape_string(trim($_SESSION['password']));
  51.  
  52. $check = getrow("SELECT * FROM accounts WHERE accountName='$username' && accountPassword='$password'");
  53. if(isset($check['accountID'])){
  54. $logged_in = 1;
  55. if(isset($_GET['logout'])){
  56. unset($_SESSION['username']);
  57. unset($_SESSION['password']);
  58. $db->query("UPDATE accounts SET accountStatus=0 WHERE accountName='$username'");
  59. $db->query("UPDATE accounts SET accountLastLogin=now() WHERE accountName='$username'"); //Update LastOnline
  60. header('location: index.php');
  61. }
  62. }
  63. }
  64.  
  65. ob_end_flush();
  66.  
  67. ?>
  68.  
  69.  
  70. //// CONNECT
  71.  
  72. $db = new mysqli('127.0.0.1', 'root', '', 'ltsgolearn');
  73.  
  74. // echo $db->connect_errno; -> debugging.
  75.  
  76. if($db->connect_errno){
  77. //echo $db->connect_error; -> debugging.
  78. die('Sorry, we are haveing some problems.');
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement