Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // checking for minimum PHP version
- if (version_compare(PHP_VERSION, '5.3.7', '<')) {
- exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !");
- } else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
- // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
- // (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
- require_once("libraries/password_compatibility_library.php");
- }
- // include the configs / constants for the database connection
- require_once("config/db.php");
- // load the login class
- require_once("classes/Login.php");
- // create a login object. when this object is created, it will do all login/logout stuff automatically
- // so this single line handles the entire login process. in consequence, you can simply ...
- $login = new Login();
- // ... ask if we are logged in here:
- if ($login->isUserLoggedIn() == true) {
- // the user is logged in. you can do whatever you want here.
- $session = $_SESSION['user_name'];
- $sqlusers = mysql_query("SELECT * FROM users WHERE user_name = '$session'");
- $fetchusers = mysql_fetch_assoc($sqlusers);
- if($fetchusers['user_type'] == '2'){
- ?>
- <div class="font3">Statistics</div>
- You can see the statistics here.
- <?php
- $useramount = mysql_num_rows(mysql_query('SELECT * FROM users'));
- $listingamount = mysql_num_rows(mysql_query('SELECT * FROM list'));
- $sqlvotes = mysql_query("SELECT SUM(*) FROM list");
- $votestotal = mysql_fetch_assoc($sqlvotes);
- echo'<table>';
- echo'<tr><td>';
- echo'*:';
- echo'</td><td>';
- echo'Amount:';
- echo'</td></tr>';
- echo'<tr><td>';
- echo'Users';
- echo'</td><td>';
- echo $useramount;
- echo'</td></tr>';
- echo'<tr><td>';
- echo'Listings';
- echo'</td><td>';
- echo $listingamount;
- echo'</td></tr>';
- echo'<tr><td>';
- echo'Votes';
- echo'</td><td>';
- echo $votestotal['votes'];
- echo'</td></tr>';
- echo'</table>';
- }
- else{
- echo'You need to be an admin to do this.';
- }
- }
- else{
- echo'You need to be logged in to do this.';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment