Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. <?php
  2. //include config
  3. require_once('includes/adminconfig.php');
  4.  
  5. //check if already logged in move to home page
  6. if( $user->is_logged_in() ){ header('Location: home.php'); }
  7.  
  8. //process login form if submitted
  9. if(isset($_POST['submit'])){
  10.  
  11. $username = $_POST['username'];
  12. $password = $_POST['password'];
  13.  
  14. if($user->login($username,$password)){
  15. $_SESSION['username'] = $username;
  16. header('Location: home.php');
  17. exit;
  18.  
  19. } else {
  20. $error[] = 'Wrong username or password or your account has not been activated.';
  21.  
  22. }
  23.  
  24. }//end if submit
  25.  
  26. ?>
  27.  
  28. <div class="container-fluid clearfix">
  29.  
  30. <div class="registrationContent">
  31. <div class="registrationHeader">
  32. <form method="post" action="" autocomplete="off">
  33. <img class="center img-responsive" src="login.png" alt="Login Logo">
  34. </div>
  35. <!--registrationHeader-->
  36. <br>
  37. <div class="row inputWrapper ">
  38. <div class="col-md-12">
  39. <div class="col-md-12">
  40. <div class="left-inner-addon ">
  41. <i class="fa fa-user"></i>
  42. <input type="text" name="username" id="username" class="form-control" placeholder="Username">
  43. </div>
  44. <br>
  45. </div>
  46. <div class="col-md-12 ">
  47. <div class="left-inner-addon ">
  48. <i class="fa fa-key"></i>
  49. <input type="password" name="password" id="password" class="form-control" placeholder="Password">
  50. </div>
  51. <br>
  52. </div>
  53.  
  54. <br>
  55. <p class=""> <span><a href="reset.php">Go Back to Main Site.</a></span></p>
  56. </div>
  57.  
  58.  
  59. </div>
  60. <div class="registrationButtonPlaseholder">
  61. <button type="submit" name="submit" class="btn btn-default btn-df float-button-dark waves-effect waves-button waves-float waves-dark">Login</button>
  62. </div>
  63.  
  64. <br>
  65.  
  66.  
  67. </form>
  68. </div>
  69.  
  70. <?php
  71. //include config
  72. require_once('includes/config.php');
  73.  
  74. //check if already logged in move to home page
  75. if( $user->is_logged_in() ){ header('Location: index.php'); }
  76.  
  77. //process login form if submitted
  78. if(isset($_POST['submit'])){
  79.  
  80. $username = $_POST['username'];
  81. $password = $_POST['password'];
  82.  
  83. if($user->login($username,$password)){
  84. $_SESSION['username'] = $username;
  85. header('Location: profile.php');
  86. exit;
  87.  
  88. } else {
  89. $error[] = 'Wrong username or password or your account has not been activated.';
  90.  
  91. }
  92.  
  93. }//end if submit
  94.  
  95. ?>
  96. <div class="form-group ">
  97. <div class="col-xs-12">
  98. <input class="form-control" id="username" name="username" type="text" placeholder="Username" value="<?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1">
  99. </div>
  100. </div>
  101. <div class="form-group">
  102. <div class="col-xs-12">
  103. <input class="form-control" type="password" id="password" name="password" placeholder="Password">
  104. </div>
  105. </div>
  106. <div class="form-group ">
  107. <div class="col-md-7 col-xs-12 m-t-5 text-right"><a href="forgot.php" class="text-dark"><i class="fa fa-lock m-r-5"></i> Forgot your password?</a></div>
  108. </div>
  109. <div class="form-group text-center m-t-40">
  110. <div class="col-xs-12">
  111. <button class="btn btn-boom btn-login btn-lg btn-block text-uppercase waves-effect waves-light" name="submit" type="submit" >Log In</button>
  112. </div>
  113. </div>
  114. <div class="form-group m-t-30 m-b-0">
  115. <div class="col-sm-12 text-center">
  116. <p>Don't have an account? <a href="register.php" class="text-primary m-l-5"><b>Sign Up</b></a></p>
  117. </div>
  118. </div>
  119. </form>
  120. </div>
  121.  
  122. <?php
  123. //include config
  124. include('includes/adminconfig.php');
  125.  
  126.  
  127. if(isset($_GET['delete_id']))
  128. {
  129. $stmt_select = $DB_con->prepare('SELECT userprofile FROM users WHERE userid =:uid');
  130. $stmt_select->execute(array(':uid'=>$_GET['delete_id']));
  131. $imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC);
  132. unlink("user_images/".$imgRow['userprofile']);
  133. $stmt_delete = $DB_con->prepare('DELETE FROM users WHERE userid =:uid');
  134. $stmt_delete->bindParam(':uid',$_GET['delete_id']);
  135. $stmt_delete->execute();
  136. header("Location: home.php");
  137. }
  138.  
  139.  
  140. //if not logged in redirect to login page
  141. if(!$user->is_logged_in()){ header('Location: login.php?action=login'); }
  142.  
  143.  
  144. ?>
  145. <?php
  146. $stmt = $DB_con->prepare('SELECT userid, username, description, userprofile FROM users ORDER BY userid DESC');
  147. $stmt->execute();
  148. if($stmt->rowCount() > 0)
  149. {
  150. while($row=$stmt->fetch(PDO::FETCH_ASSOC))
  151. {
  152. extract($row);
  153. ?>
  154. <div class="col-xs-3">
  155. <h3 class="page-header" style="background-color:cadetblue" align="center"><?php echo $username."<br>".$description; ?></h3>
  156. <img src="uploads/<?php echo $row['userprofile']; ?>" class="img-rounded" width="250px" height="250px" /><hr>
  157. <p class="page-header" align="center">
  158. <span>
  159. <a class="btn btn-primary" href="editform.php?edit_id=<?php echo $row['userid']; ?>"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
  160. <a class="btn btn-warning" href="?delete_id=<?php echo $row['userid']; ?>" title="click for delete" onclick="return confirm('Are You Sure You Want To Delete This User?')"><span class="glyphicon glyphicon-trash"></span> Delete</a>
  161. </span>
  162. </p>
  163. </div>
  164. <?php
  165. }
  166. }
  167. else
  168. {
  169. ?>
  170. <div class="col-xs-12">
  171. <div class="alert alert-warning">
  172. <span class="glyphicon glyphicon-info-sign"></span>&nbsp; No Data Found.
  173. </div>
  174. </div>
  175. <?php
  176. }
  177. ?>
  178.  
  179. <?php
  180. ob_start();
  181. session_start();
  182.  
  183. //set timezone
  184. date_default_timezone_set('Europe/London');
  185.  
  186. //database credentials
  187. define('DBHOST','localhost');
  188. define('DBUSER','xxxxxxxx');
  189. define('DBPASS','xxxxxxxx');
  190. define('DBNAME','xxxxxxx');
  191.  
  192. //application address
  193. define('DIR','http://websiteaddress.com');
  194. define('SITEEMAIL','noreply@domain.com');
  195.  
  196. try {
  197.  
  198. //create PDO connection
  199. $db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS);
  200. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  201.  
  202. } catch(PDOException $e) {
  203. //show error
  204. echo '<p class="bg-danger">'.$e->getMessage().'</p>';
  205. exit;
  206. }
  207.  
  208. //include the user class, pass in the database connection
  209. include('classes/adminuser.php');
  210. include('classes/phpmailer/mail.php');
  211. $user = new User($db);
  212. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement