Return Logged-in Players
Posted: Wed Jan 20, 2010 12:55 pm
Hey guys,
I've made a small script to show in a table all the players but I can't figure out how to add a field to check whether the player is currently logged on or not, any help??..here's my code:
I've made a small script to show in a table all the players but I can't figure out how to add a field to check whether the player is currently logged on or not, any help??..here's my code:
Code: Select all
// API $url and $pw values set here
include "api.php" $fields="Player,Title,Level,RealName,PW,Location,Email,Balance,RingChips,LastReset,Avatar,Logins,FirstLogin,LastLogin,Gender";
$params = "Password=" . $pw . "&Command=AccountsList&Fields=".$fields;
$api = Poker_API($url,$params,true);
$result = $api["Result"];
if ($result == "Error") die("Error: " . $api["Error"]);
// Display results in an html table.
?>
<table width="100%">
<thead>
<tr>
<th width="40px"><a href="#">ID<img src="img/icons/arrow_down_mini.gif" width="16" height="16" align="absmiddle" /></a></th>
<th><a href="#">Player</a></th>
<th><a href="#">Real Name</a></th>
<th><a href="#">Balance</a></th>
<th><a href="#">Email</a></th>
<th><a href="#">Logins</a></th>
<th><a href="#">Last Login</a></th>
<th>Logged-in</th>
</tr>
</thead>
<?php
$accounts = $api["Accounts"];
for ($i = 1; $i <= $accounts; $i++)
{
$player = $api["Player" . $i];
$chips = number_format($api["Balance" . $i]);
$realname=$api["RealName" . $i];
$email=$api["Email".$i];
$logins=$api["Logins".$i];
$lastlogin=$api["LastLogin".$i];
$islog=isLogged($player);
echo "<tr><td class='a-center'>$i</td><td><a href='poker\player_edit.php?player=$player' class='thickbox'>$player</a></td><td>$realname</td><td>$chips</td><td>$email</td><td>$logins</td><td>$lastlogin</td><td>$islog</td></tr>\r\n";
}
echo "</tbody></table><br>\r\n";
function isLogged($player){
$params = "Password=$pw&Command=ConnectionsList&Fields=Player";
$api2 = Poker_API($url,$params,true);
$found = false;
$connections = $api2["Connections"];
for ($i = 1; $i <= $connections; $i++)
{
if (strcasecmp($player,$api2["Player" . $i])==0)
{
$found=true;
}
}
return $found;
}
?>