Advertisement
Guest User

Untitled

a guest
May 26th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <script type="text/javascript">
  5. function disablebackbutton(){
  6. window.history.forward();
  7. }
  8. disablebackbutton();
  9. </script>
  10. </head>
  11. <body>
  12. <form name="loginform" method="post" action="<?php echo __PROJECT_LINK__; ?>/php/login_exec.php">
  13. <div class="modal-body">
  14. <div class="form-horizontal">
  15. <div class="form-group">
  16. <label class="control-label">
  17. <?php
  18. if( isset($_SESSION['ERRMsg_ARR']) && is_array($_SESSION['ERRMsg_ARR']) && count($_SESSION['ERRMsg_ARR']) >0 ) {
  19. echo '<ul class="err">';
  20. foreach($_SESSION['ERRMsg_ARR'] as $msg) {
  21. echo '<span class="label label-warning" style="margin-left: 5px;">',$msg,'</span>';
  22. }
  23. echo '</ul>';
  24. unset($_SESSION['ERRMsg_ARR']);
  25. }
  26. ?>
  27. </label>
  28. </div>
  29. <div class="subnav subnav-fixed nav navbar" style="margin-top: 10px; margin-right: 10px; margin-left: 10px;">
  30. <ul class="nav nav-pills">
  31. <li style="margin-top: 10px;">
  32. <span class="label label-default" style="margin-left: 22px;">Username</span>
  33. <input type="text" id="inputUserName" name="username" placeholder="Username" style="margin-left: 5px;">
  34. </li>
  35. <li style="margin-top: 10px;">
  36. <span class="label label-default" style="margin-left: 22px;">Password</span>
  37. <input type="password" id="inputPassword" name="password" placeholder="Password" style="margin-left: 5px;">
  38. </li>
  39. <li style="margin-top: 10px; margin-bottom: 10px;">
  40. </li>
  41. </ul>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="modal-footer">
  46. <!--?php $this->btnLogLogin->Render();?-->
  47. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  48. <button type="submit" class="btn btn-primary">Sign In</button>
  49. </div>
  50. </form>
  51. </body>
  52. </html>
  53.  
  54. <?php
  55. //Start session
  56. if (session_status() == PHP_SESSION_NONE) {
  57. session_start();
  58. }
  59. //Include database connection details
  60. require_once('connection.php');
  61.  
  62. //Array to store validation errors
  63. $errmsg_arr = array();
  64.  
  65. //Validation error flag
  66. $errflag = false;
  67.  
  68. //Function to sanitize values received from the form. Prevents SQL injection
  69. function clean($str) {
  70. $str = @trim($str);
  71. if(get_magic_quotes_gpc()) {
  72. $str = stripslashes($str);
  73. }
  74. return mysql_real_escape_string($str);
  75. }
  76. if(isset($_POST['username']))
  77. {
  78. //Sanitize the POST values
  79. $username = ($_POST['username']);
  80. $password = ($_POST['password']);
  81.  
  82. //Input Validations
  83. if($username == '') {
  84. $errmsg_arr[] = 'Username missing';
  85. $errflag = true;
  86. }
  87. if($password == '') {
  88. $errmsg_arr[] = 'Password missing';
  89. $errflag = true;
  90. }
  91.  
  92. //If there are input validations, redirect back to the login form
  93. if($errflag==true) {
  94. $_SESSION['ERRMsg_ARR'] = $errmsg_arr;
  95. session_write_close();
  96. header("location:../index.php");
  97. exit();
  98. }
  99.  
  100. //Create query
  101. $qry="SELECT * FROM admin WHERE user_name='$username' AND password='$password'";
  102. $result=mysql_query($qry);
  103.  
  104. //Check whether the query was successful or not
  105. if($result) {
  106. if(mysql_num_rows($result)) {
  107. while($row = mysql_fetch_array($result))
  108. {
  109. if($row['User_Status']=="Active"){
  110. $expire=time()+60*60*24*30; //1month
  111. setcookie("User_id", $row['User_id'], $expire);
  112. $name = $row['full_name'];
  113. $parts = explode(" ", $name);
  114. $lastname = array_pop($parts);
  115. $firstname = implode(" ", $parts);
  116. $_SESSION['USER'] = $firstname;
  117. $_SESSION['UID'] = $row['User_id'];
  118. $_SESSION['URights'] = $row['Rights'];
  119. header("location:../welcome.php");
  120. }
  121. else{
  122. $errmsg_arr[] = 'User Status is Block. Please contact your Administrator.';
  123. $errflag = true;
  124. if($errflag) {
  125. $_SESSION['ERRMsg_ARR'] = $errmsg_arr;
  126. session_write_close();
  127. header("location: ../index.php");
  128. exit();
  129. }
  130. }
  131. }
  132. }
  133. else {
  134. //Login failed
  135. $errmsg_arr[] = 'Username and Password not found';
  136. $errflag = true;
  137. if($errflag) {
  138. $_SESSION['ERRMsg_ARR'] = $errmsg_arr;
  139. session_write_close();
  140. header("location: ../index.php");
  141. exit();
  142. }
  143. }
  144. }else {
  145. die("Query failed");
  146. }
  147. }
  148. ?>
  149.  
  150. <?php include 'qcubed.inc.php'; ?>
  151. <?php
  152. $User_Name = $_SESSION['USER'];
  153. ?>
  154. <html>
  155.  
  156. <head>
  157. <title>Welcome</title>
  158. </head>
  159. <body>
  160. <h1>Welcome <?php echo $User_Name; ?></h1>
  161. <h2><a href = "<?php echo __PROJECT_LINK__; ?>/Info.php">Info</a></h2>
  162. <h2><a href = "<?php echo __PROJECT_LINK__; ?>/php/logout.php">Sign Out</a></h2>
  163. </body>
  164. </html>
  165.  
  166. <?php include '../../qcubed.inc.php';?>
  167. <!DOCTYPE html>
  168. <html lang="en">
  169. <head>
  170. <title><?php echo __PROJECT_TITLE__; ?> - Full Info</title>
  171. <script type="text/javascript">
  172. function disablebackbutton(){
  173. window.history.forward();
  174. }
  175. disablebackbutton();
  176. </script>
  177. </head>
  178. <?php
  179. if(isset($_SESSION['UID']) && $_SESSION['UID'] != "")
  180. {
  181. //Task to do
  182. $User_Name = $_SESSION['USER'];
  183. ?>
  184. <body>
  185. <h1>Info about <?php echo $User_Name; ?></h1>
  186. <h2><a href = "<?php echo __PROJECT_LINK__; ?>/php/logout.php">Sign Out</a></h2>
  187. </body>
  188. <?php
  189. }
  190. else{
  191. //redirect URL
  192. ?>
  193. <script>
  194. alert('You must Login first.');
  195. window.location.href='../../index.php';
  196. </script>";
  197. <?php
  198.  
  199. exit();
  200. }
  201. ?>
  202.  
  203. </html>
  204.  
  205. <?php
  206. //session_write_close();
  207. session_start(); # NOTE THE SESSION START
  208. $expire=time()-60*60*24*30; //1month
  209. if(isset($_COOKIE['User_id'])):
  210. setcookie('User_id', '', $expire, '/');
  211. endif;
  212. unset($_SESSION['UID']);
  213. unset($_SESSION['USER']);
  214. unset($_SESSION['URights']);
  215. unset($_SESSION['UReg']);
  216. $_SESSION = array();
  217. foreach(array_keys($_SESSION) as $k) unset($_SESSION[$k]);
  218. session_unset();
  219. session_destroy();
  220. header("location: ../index.php");
  221. exit(); # NOTE THE EXIT
  222. ?>
  223.  
  224. <script type="text/javascript">
  225. function disablebackbutton(){
  226. window.history.forward();
  227. }
  228. disablebackbutton();
  229. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement