Guest User

Untitled

a guest
Jan 8th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2. include_once('header.php');
  3. require_once('inc/inc_user.php');
  4. require_once("inc/inc_context.php");
  5.  
  6. if (Context::IsLogged())
  7. {
  8. header("HTTP/1.1 301 Moved Permanently");
  9. header("Location: taikhoan.php");
  10. }
  11.  
  12. // Logout
  13. if(isset($_GET["act"]))
  14. {
  15. $refer_url = 'index.php';
  16. if(isset($_GET["refer"]))
  17. {
  18. $refer_url = $_GET["refer"];
  19. }
  20. if($_GET["act"] == "logout"){
  21. Context::Destroy();
  22. header("HTTP/1.1 301 Moved Permanently");
  23. header("Location: $refer_url");
  24.  
  25. }
  26. }
  27.  
  28. if(isset($_POST["btnDangNhap"]))
  29. {
  30. $username = $_POST['txtUsername'];
  31. $password = $_POST['txtPassword'];
  32.  
  33. $u = new User(-1, $username, $password, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, '', 0, 0);
  34. if($u->Login() == true)
  35. {
  36. $_SESSION["IsLogin"] = 1; // đã đăng nhập
  37. date_default_timezone_set('Asia/Ho_Chi_Minh');
  38. $_SESSION["Login_Time"] = date('Y-m-d H:i:s');
  39. $_SESSION["Login_IP"] = getIP();
  40. $_SESSION["CurrentUser"] = (array)User::GetInfo($username);
  41.  
  42. $refer_url = 'taikhoan.php';
  43. if(isset($_GET["refer"]))
  44. {
  45. $refer_url = $_GET["refer"];
  46. }
  47. header("HTTP/1.1 301 Moved Permanently");
  48. header("Location: $refer_url");
  49. }
  50. else
  51. {
  52. echo "<script type='text/javascript'>alert('Đăng nhập thất bại!');</script>";
  53. }
  54. }
  55.  
  56. ?>
  57.  
  58. <div id="sidebar" class="fleft">
  59. <div id="box-login" class="box-1">
  60. <div>
  61. <div class="fleft"><span class="text-1">Account</span></div>
  62. <div class="fright">
  63. <a href="dangky.php" class="link-1 text-1">Register</a>
  64. <span class="link-1">&nbsp;|&nbsp;</span>
  65. <a href="" class="link-1 text-1">Forgot password</a>
  66. </div>
  67.  
  68. <div class="clearfix"></div>
  69. </div>
  70. <form method="POST" action="" accept-charset="UTF-8" id="frmLogin" name="frmLogin">
  71. <div class="m-t-small">
  72. <input type="text" name="txtUsername" id="txtUsername" class="input-1" placeholder="Account" maxlength="32">
  73. </div>
  74. <div class="m-t-small">
  75. <input type="password" name="txtPassword" id="txtPassword" class="input-1" placeholder="password">
  76. </div>
  77. <div class="m-t-small">
  78. <div class="fright">
  79. <button type="submit" name="btnDangNhap" class="btn-1">Login</button>
  80. </div>
  81. <div class="clearfix"></div>
  82. </div>
  83. </form>
  84. </div>
  85. <div class="social">
  86. <a href="" class="google fleft"></a>
  87. <a href="" class="facebook fright"></a>
  88. <div class="clearfix"></div>
  89. </div>
  90. </div>
  91. <div id="content-container" class="fright">
  92. <div class="campaign-registry"></div>
  93. </div>
  94. <div class="clearfix"></div>
  95.  
  96. <?php
  97. include_once('footer.php');
Add Comment
Please, Sign In to add comment