1
0
Fork 0
OpenSim.land/classen/RegionManager.php

45 lines
1.5 KiB
PHP

<?php
class RegionManager
{
private $allRegions = array();
function __construct($startRegion, $totalRegionCount)
{
global $RUNTIME;
$topRegionStatement = $RUNTIME['PDO']->prepare("SELECT regions.RegionName AS Name, regions.RegionUUID AS UUID, regions.RegionImage AS Image, regions.RegionOwner AS OwnerID, users.UserName AS OwnerName, onlinetimes.RegionLastSeen AS LastSeen, onlinetimes.RegionOnlineUser AS OnlineCount, regions.RegionVersion AS RegionVersion, regions.RegionHostname AS Hostname, regions.RegionPort AS Port FROM regions INNER JOIN onlinetimes ON regions.RegionUUID = onlinetimes.RegionUUID INNER JOIN users ON regions.RegionOwner = users.UserUUID WHERE onlinetimes.RegionLastSeen > ? ORDER BY OnlineCount DESC LIMIT ".$startRegion.", ".$totalRegionCount);
$topRegionStatement->execute(array(time() - 900));
while($row = $topRegionStatement->fetch())
{
array_push($this->allRegions, $row);
}
}
function getRegionCount()
{
return count($this->allRegions);
}
function getNextRegion()
{
return array_shift($this->allRegions);
}
public static function setOnlineTime($uuid)
{
global $RUNTIME;
$topRegionStatement = $RUNTIME['PDO']->prepare("UPDATE onlinetimes SET RegionLastSeen = ? WHERE RegionUUID = ?");
$topRegionStatement->execute(array(time(), $uuid));
}
public static function removeRegion($uuid)
{
global $RUNTIME;
$topRegionStatement = $RUNTIME['PDO']->prepare("DELETE FROM regions WHERE RegionUUID = ?");
$topRegionStatement->execute(array($uuid));
}
}
?>