<?php
    $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 LastSeen ASC");
    $topRegionStatement->execute(array(time() - 600)); 

    while($row = $topRegionStatement->fetch())
    {
        if(ping($row['Hostname'], $row['Port']))
        {
            RegionManager::setOnlineTime($row['UUID']);
            continue;
        }

        RegionManager::removeRegion($row['UUID']);
    }

?>