mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-09 06:35:42 +12:00
add playersonline.php
This commit is contained in:
parent
e52ac7c8a9
commit
8e2802052c
4 changed files with 99 additions and 6 deletions
|
@ -145,7 +145,7 @@ function ajaxDone(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadplayers() {
|
function loadplayers() {
|
||||||
ajax('web/playersonline.php?id=588112','PLAYERS');
|
<?php echo("ajax('web/playersonline.php?id=".htmlspecialchars($_SESSION['PLAYER_ID'], ENT_QUOTES)."','PLAYERS');"); ?>
|
||||||
window.setTimeout("loadplayers()", 30000); //reload player list every millisecs
|
window.setTimeout("loadplayers()", 30000); //reload player list every millisecs
|
||||||
}
|
}
|
||||||
window.setTimeout("loadplayers()", 10); ///load player list first time quick
|
window.setTimeout("loadplayers()", 10); ///load player list first time quick
|
||||||
|
|
|
@ -12,7 +12,38 @@ function GenHmacMessage(string $data, string $channel)
|
||||||
return $hmac;
|
return $hmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoPlayersOnlineInServer($database)
|
function getPlayerList($database)
|
||||||
|
{
|
||||||
|
include('config.php');
|
||||||
|
$dbname = $database;
|
||||||
|
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||||
|
$onlineUsers = mysqli_query($connect, "SELECT * FROM OnlineUsers");
|
||||||
|
|
||||||
|
$users_on = [];
|
||||||
|
|
||||||
|
|
||||||
|
while ($row = $onlineUsers->fetch_row()) {
|
||||||
|
$arr = [ ['id' => $row[0], 'admin' => ($row[1] == 'YES'), 'mod' => ($row[2] == 'YES'), 'subbed' => ($row[3] == 'YES'), 'new' => ($row[4] == 'YES')] ];
|
||||||
|
$users_on = array_merge($users_on, $arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $users_on;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkUserBuddy($database, $yourId, $friendsId)
|
||||||
|
{
|
||||||
|
include('config.php');
|
||||||
|
$dbname = $database;
|
||||||
|
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||||
|
$stmt = $connect->prepare("SELECT COUNT(1) FROM BuddyList WHERE (Id=? AND IdFriend=?) OR (Id=? AND IdFriend=?)");
|
||||||
|
$stmt->bind_param("iiii", $yourId, $friendsId, $friendsId, $yourId);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
return $result->fetch_row()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getNoPlayersOnlineInServer($database)
|
||||||
{
|
{
|
||||||
include('config.php');
|
include('config.php');
|
||||||
$dbname = $database;
|
$dbname = $database;
|
||||||
|
@ -21,7 +52,7 @@ function getNoPlayersOnlineInServer($database)
|
||||||
return $onlineUsers->fetch_row()[0];
|
return $onlineUsers->fetch_row()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoSubbedPlayersOnlineInServer($database)
|
function getNoSubbedPlayersOnlineInServer($database)
|
||||||
{
|
{
|
||||||
include('config.php');
|
include('config.php');
|
||||||
$dbname = $database;
|
$dbname = $database;
|
||||||
|
|
|
@ -1 +1,32 @@
|
||||||
<B>3 players<BR>online now:</B><BR>BackInTime <FONT SIZE=-2 COLOR=660000>[new]</FONT><BR>Banaja<BR>Mudkip <FONT SIZE=-2 COLOR=660000>[new]</FONT><BR><I><FONT COLOR=BLUE>(0 buddies)</FONT></I><BR><FONT COLOR=222222 SIZE=-1><I>This list refreshes every 30 seconds.</I></FONT>
|
<?php
|
||||||
|
include("config.php");
|
||||||
|
include("crosserver.php");
|
||||||
|
include("common.php");
|
||||||
|
$id = -1;
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$id = intval($_GET['id']);
|
||||||
|
}
|
||||||
|
$on = getPlayerList($dbname);
|
||||||
|
$numbOn = count($on);
|
||||||
|
$budsOn = 0;
|
||||||
|
?>
|
||||||
|
<B><?php echo($numbOn)?> players<BR>online now:</B><?php
|
||||||
|
|
||||||
|
for($i = 0; $i < $numbOn; $i++){
|
||||||
|
$name = get_username($on[$i]['id']);
|
||||||
|
$admin = $on[$i]['admin'];
|
||||||
|
$mod = $on[$i]['mod'];
|
||||||
|
$subbed = $on[$i]['subbed'];
|
||||||
|
$new = $on[$i]['new'];
|
||||||
|
$bud = checkUserBuddy($dbname, $id ,$on[$i]['id']);
|
||||||
|
|
||||||
|
echo("<BR>");
|
||||||
|
if($bud) { echo('<B><FONT COLOR=BLUE>'); echo(htmlspecialchars($name)); echo('</FONT></B>'); $budsOn++; }
|
||||||
|
else if($admin) { echo('<B><FONT COLOR=RED>'); echo(htmlspecialchars($name)); echo('</FONT></B>'); }
|
||||||
|
else if($mod) { echo('<B><FONT COLOR=GREEN>'); echo(htmlspecialchars($name)); echo('</FONT></B>'); }
|
||||||
|
else { echo(htmlspecialchars($name)); }
|
||||||
|
|
||||||
|
if($new) { echo(' <FONT SIZE=-2 COLOR=660000>[new]</FONT>'); };
|
||||||
|
|
||||||
|
}
|
||||||
|
?><BR><I><FONT COLOR=BLUE>(<?php echo($budsOn); ?> buddies)</FONT></I><BR><FONT COLOR=222222 SIZE=-1><I>This list refreshes every 30 seconds.</I></FONT>
|
|
@ -12,7 +12,38 @@ function GenHmacMessage(string $data, string $channel)
|
||||||
return $hmac;
|
return $hmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoPlayersOnlineInServer($database)
|
function getPlayerList($database)
|
||||||
|
{
|
||||||
|
include('config.php');
|
||||||
|
$dbname = $database;
|
||||||
|
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||||
|
$onlineUsers = mysqli_query($connect, "SELECT * FROM OnlineUsers");
|
||||||
|
|
||||||
|
$users_on = [];
|
||||||
|
|
||||||
|
|
||||||
|
while ($row = $onlineUsers->fetch_row()) {
|
||||||
|
$arr = [ ['id' => $row[0], 'admin' => ($row[1] == 'YES'), 'mod' => ($row[2] == 'YES'), 'subbed' => ($row[3] == 'YES'), 'new' => ($row[4] == 'YES')] ];
|
||||||
|
$users_on = array_merge($users_on, $arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $users_on;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkUserBuddy($database, $yourId, $friendsId)
|
||||||
|
{
|
||||||
|
include('config.php');
|
||||||
|
$dbname = $database;
|
||||||
|
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||||
|
$stmt = $connect->prepare("SELECT COUNT(1) FROM BuddyList WHERE (Id=? AND IdFriend=?) OR (Id=? AND IdFriend=?)");
|
||||||
|
$stmt->bind_param("iiii", $yourId, $friendsId, $friendsId, $yourId);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
return $result->fetch_row()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getNoPlayersOnlineInServer($database)
|
||||||
{
|
{
|
||||||
include('config.php');
|
include('config.php');
|
||||||
$dbname = $database;
|
$dbname = $database;
|
||||||
|
@ -21,7 +52,7 @@ function getNoPlayersOnlineInServer($database)
|
||||||
return $onlineUsers->fetch_row()[0];
|
return $onlineUsers->fetch_row()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoSubbedPlayersOnlineInServer($database)
|
function getNoSubbedPlayersOnlineInServer($database)
|
||||||
{
|
{
|
||||||
include('config.php');
|
include('config.php');
|
||||||
$dbname = $database;
|
$dbname = $database;
|
||||||
|
|
Loading…
Add table
Reference in a new issue