mothh9

stats.php

May 14th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | None | 0 0
  1. <?php
  2. // checking for minimum PHP version
  3. if (version_compare(PHP_VERSION, '5.3.7', '<')) {
  4.     exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !");
  5. } else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
  6.     // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
  7.     // (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
  8.     require_once("libraries/password_compatibility_library.php");
  9. }
  10.  
  11. // include the configs / constants for the database connection
  12. require_once("config/db.php");
  13.  
  14. // load the login class
  15. require_once("classes/Login.php");
  16.  
  17. // create a login object. when this object is created, it will do all login/logout stuff automatically
  18. // so this single line handles the entire login process. in consequence, you can simply ...
  19. $login = new Login();
  20.  
  21. // ... ask if we are logged in here:
  22. if ($login->isUserLoggedIn() == true) {
  23.     // the user is logged in. you can do whatever you want here.
  24. $session = $_SESSION['user_name'];
  25. $sqlusers = mysql_query("SELECT * FROM users WHERE user_name = '$session'");
  26. $fetchusers = mysql_fetch_assoc($sqlusers);
  27. if($fetchusers['user_type'] == '2'){
  28. ?>
  29. <div class="font3">Statistics</div>
  30. You can see the statistics here.
  31. <?php
  32. $useramount = mysql_num_rows(mysql_query('SELECT * FROM users'));
  33. $listingamount = mysql_num_rows(mysql_query('SELECT * FROM list'));
  34. $sqlvotes = mysql_query("SELECT SUM(*) FROM list");
  35. $votestotal = mysql_fetch_assoc($sqlvotes);
  36.  
  37.  
  38. echo'<table>';
  39. echo'<tr><td>';
  40. echo'*:';
  41. echo'</td><td>';
  42. echo'Amount:';
  43. echo'</td></tr>';
  44. echo'<tr><td>';
  45. echo'Users';
  46. echo'</td><td>';
  47. echo $useramount;
  48. echo'</td></tr>';
  49. echo'<tr><td>';
  50. echo'Listings';
  51. echo'</td><td>';
  52. echo $listingamount;
  53. echo'</td></tr>';
  54. echo'<tr><td>';
  55. echo'Votes';
  56. echo'</td><td>';
  57. echo $votestotal['votes'];
  58. echo'</td></tr>';
  59. echo'</table>';
  60. }
  61. else{
  62.     echo'You need to be an admin to do this.';
  63. }
  64. }
  65. else{
  66.     echo'You need to be logged in to do this.';
  67. }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment