Jump to content

Login Script AddOn


CBaZ

Recommended Posts

I want to add how many admins are currently online and available just to be able to tell the number.

 

Also I want to be able to tell all the usernames that are connected at one time if you are familiar with this

 

I will try to provide my code as much as i possibly can to make it work for my login script

 

please let me know asap...

 

 

Link to comment
https://forums.phpfreaks.com/topic/56508-login-script-addon/
Share on other sites

I have a timestamp for regular users but no time stamp for admins let's see

permission 0 is for regulars

admin have permission 1 I am seeing the right totals for how many users are in that table just not the right amount currently logged in.

 

<?php

 

include("dbinfo.php");

 

// Set length of session to twenty minutes

define("SESSION_LENGTH", 20);

 

$sConn = @mysql_connect($dbServer, $dbUser, $dbPass)

or die("Couldnt connect to database");

 

$dbConn = @mysql_select_db($dbName, $sConn)

or die("Couldnt select database $dbName");

 

 

$timeMax = time() - (60* SESSION_LENGTH);

 

$result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax'");

 

$usersOnline = mysql_result($result, 0, 0);

$connect = mysql_connect("localhost", "user", "pw") or die("Could not connect to database: " . mysql_error());

mysql_select_db("db", $connect) or die("Could not select database");

$result2 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '0'");

$row = mysql_fetch_array($result2);

 

$result3 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '1'");

$row2 = mysql_fetch_array($result3);

 

echo "ATM:" . ($usersOnline != 1 ? "" : "") . " $usersOnline Admin" . ($usersOnline != 1 ? "s" : "") ." / $row2[count]" . ", " . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." / $row[count]" . ". ";

Link to comment
https://forums.phpfreaks.com/topic/56508-login-script-addon/#findComment-279098
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.