DidNotCompute Posted April 15, 2014 Posted April 15, 2014 Here's a Users Online mod I made for the Panther script. SQL ALTER TABLE `users` ADD `last_online` INT( 10 ) NOT NULL ; Add this to the end of mods/globals.php $current_time = time(); $db->query("UPDATE `users` SET `last_online` = $current_time WHERE `id` = $uid"); In the "mods" directory add the folder "users_online" and create the main.php file <?php include_once('mods/globals.php'); if (array_key_exists('option', $_GET)) { $option = abs(intval($_GET['option'])); $valid_options = array("1", "2", "3", "4"); if(!in_array($option, $valid_options)){ $time_minus = "600"; echo '<div class="alert alert-error">Select a valid option!</div>'; }else{ switch($option) { case 1: $time_minus = "600"; break; case 2: $time_minus = "3600"; break; case 3: $time_minus = "43200"; break; case 4: $time_minus = "86400"; break; }} } else { $time_minus = "600"; } $time_now = time() - $time_minus; $get_users_query = $db->query("SELECT `id`, `char_name`FROM `users` WHERE `last_online` > $time_now"); $users_online = mysqli_num_rows($get_users_query); ?> <h4>Users Online - <?php echo''.($users_online).''; ?></h4> <div align="center"> <a href="?option=1">Right Now</a> - <a href="?option=2">Past Hour</a> - <a href="?option=3">Past 12 Hours</a> - <a href="?option=4">Past 24 Hours</a> </div> <table class="table"> <tr><th><b>ID</b></th><th><b>Name</b></th></tr> <?php while ($get_users = mysqli_fetch_assoc($get_users_query)) { echo'<tr><td>'.($get_users['id']).'</td><td><a href="profile">'.($get_users['char_name']).'</a></td></tr>'; } ?> </table> You can view a demo at http://panther.x10.mx Email: demo Password: demo Feedback welcome. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.