require_once("internal/source.lib.php");
$orderBy = "servername";
$entriesPerPage=30;
$page = 1;
if ( isset($_REQUEST['sort']) ) {
$orderBy = $_REQUEST['sort'];
}
if ( isset($_REQUEST['page']) ) {
$page = (int)$_REQUEST['page'];
if ( $page <= 0 ) {
$page = 1;
}
}
switch ( $orderBy ) {
case "clanname":
$orderBy = "`clan`.`name` ASC,`serverListQueryInfoLast`.`name` ASC";
break;
case "occupation":
$orderBy = "(`serverListQueryInfoLast`.`clientsConnected`-`serverListQueryInfoLast`.`bots`) DESC, `serverListQueryInfoLast`.`bots` DESC,`serverListQueryInfoLast`.`clientsMaximum` DESC";
break;
case "servername":
default:
$orderBy = "`serverListQueryInfoLast`.`name` ASC,`clan`.`name` ASC";
break;
}
$countryList = $db->fetchAll("SELECT SQL_CACHE IF( `country`.`nativeName` NOT LIKE '', `country`.`nativeName` , `country`.`name` ) AS `name` , `country`.`isoCode2` AS `isoCode2` , `country`.`icon` AS `icon`, COUNT(`serverList`.`id`) AS `number`
FROM `serverList` , `country`
WHERE `serverList`.`countryId` = `country`.`id`
GROUP BY `country`.`id`
ORDER BY `name`");
$gameList = $db->fetchAll("SELECT SQL_CACHE `game` , `directory` , COUNT( `id` ) AS `number`
FROM `serverListQueryInfoLast`
WHERE `game` NOT LIKE ''
AND `directory` NOT LIKE ''
GROUP BY `directory`
ORDER BY `serverListQueryInfoLast`.`game` ASC");
$mapList = $db->fetchAll("SELECT SQL_CACHE `map` , COUNT( `id` ) AS `number`
FROM `serverListQueryInfoLast`
WHERE `map` NOT LIKE ''
GROUP BY `map`");
//die("SELECT `serverList`.*,`clan`.`name` AS `clanName`,`clan`.`homepage` AS `clanHomepage` FROM `serverList` LEFT JOIN `clan` ON (`serverList`.`clanId`=`clan`.`id`) LEFT JOIN `serverListQueryInfoLast` ON (`serverList`.`id`=`serverListQueryInfoLast`.`serverListId`) WHERE `enabled`=1 AND `type`='source' ORDER BY ".$orderBy." LIMIT ".(($page-1)*$entriesPerPage).",".$entriesPerPage);
$serverList = $db->fetchAll("SELECT SQL_CALC_FOUND_ROWS `serverList` . * , `country`.`isoCode2` AS `countryCode` , `country`.`name` AS `countryName` , `country`.`nativeName` AS `countryNativeName` , `country`.`icon` AS `countryIcon` , `clan`.`name` AS `clanName` , `clan`.`homepage` AS `clanHomepage`
FROM `serverList`
LEFT JOIN `clan` ON ( `serverList`.`clanId` = `clan`.`id` )
LEFT JOIN `serverListQueryInfoLast` ON ( `serverList`.`id` = `serverListQueryInfoLast`.`serverListId` )
LEFT JOIN `country` ON ( `country`.`id` = `serverList`.`countryId` )
WHERE `serverList`.`enabled` =1
AND `serverList`.`type` = 'source'
AND `serverListQueryInfoLast`.`name` NOT LIKE ''
AND DATE_SUB(NOW(), INTERVAL 2 DAY) < `serverList`.`lastMasterServerUpdate`
ORDER BY ".$orderBy."
LIMIT ".(($page-1)*$entriesPerPage).",".$entriesPerPage);
/*
echo "SELECT SQL_CALC_FOUND_ROWS `serverList` . * , `country`.`isoCode2` AS `countryCode` , `country`.`name` AS `countryName` , `country`.`nativeName` AS `countryNativeName` , `country`.`icon` AS `countryIcon` , `clan`.`name` AS `clanName` , `clan`.`homepage` AS `clanHomepage`
FROM `serverList`
LEFT JOIN `clan` ON ( `serverList`.`clanId` = `clan`.`id` )
LEFT JOIN `serverListQueryInfoLast` ON ( `serverList`.`id` = `serverListQueryInfoLast`.`serverListId` )
LEFT JOIN `country` ON ( `country`.`id` = `serverList`.`countryId` )
WHERE `serverList`.`enabled` =1
AND `serverList`.`type` = 'source'
AND `serverListQueryInfoLast`.`name` NOT LIKE ''
AND DATE_SUB(NOW(), INTERVAL 2 DAY) < `serverList`.`lastMasterServerUpdate`
ORDER BY ".$orderBy."
LIMIT ".(($page-1)*$entriesPerPage).",".$entriesPerPage;
*/
$totalEntries = $db->fetchOne("SELECT FOUND_ROWS()");
$lastPage = 1;
if ( $totalEntries ) {
if ( count($totalEntries) > 0 ) {
$lastPage = ceil($totalEntries/$entriesPerPage);
}
}
$pageList = range(1,$lastPage);
//new_serverListQueryInfoLast
foreach ( $serverList as &$server ) {
// echo $server['ip'].":".$server['port']."
";
$server['object'] = new gameSourceServer($server['ip'],$server['port']);
$server['object']->query(3600*24);
$server['info'] = &$server['object']->info;
// $server['clients'] = &$server['object']->clients;
// echo "
";var_dump($server['info']);echo ""; } //echo "
";var_dump($serverList);echo ""; $smarty->assign("totalEntries",$totalEntries); $smarty->assign("lastPage",$lastPage); $smarty->assign("pageList",$pageList); $smarty->assign("serverList",$serverList); $smarty->assign("expire","600"); $smarty->assign("refresh","600"); $smarty->assign("title","Serverliste"); $smarty->display("source/server.tpl");