コード例 #1
0
ファイル: lgsl_class.php プロジェクト: eistr2n/lansuite
 function lgsl_query_group($options = array())
 {
     if (!is_array($options)) {
         exit("LGSL PROBLEM: lgsl_query_group OPTIONS MUST BE ARRAY");
     }
     global $lgsl_config;
     lgsl_database();
     $request = isset($options['request']) ? $options['request'] : "s";
     $zone = isset($options['zone']) ? intval($options['zone']) : 0;
     $hide_offline = isset($options['hide_offline']) ? intval($options['hide_offline']) : intval($lgsl_config['hide_offline'][$zone]);
     $random = isset($options['random']) ? intval($options['random']) : intval($lgsl_config['random'][$zone]);
     $type = empty($options['type']) ? "" : preg_replace("/[^a-z0-9_]/", "_", strtolower($options['type']));
     $game = empty($options['game']) ? "" : preg_replace("/[^a-z0-9_]/", "_", strtolower($options['game']));
     $mysql_order = empty($random) ? "`cache_time` ASC" : "rand()";
     $server_limit = empty($random) ? 0 : $random;
     $mysql_where = array("`disabled`=0");
     if ($zone != 0) {
         $mysql_where[] = "FIND_IN_SET('{$zone}',`zone`)";
     }
     if ($type != "") {
         $mysql_where[] = "`type`='{$type}'";
     }
     $mysql_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE " . implode(" AND ", $mysql_where) . " ORDER BY {$mysql_order}";
     $mysql_result = mysql_query($mysql_query) or die(mysql_error());
     $server_list = array();
     while ($mysql_row = mysql_fetch_array($mysql_result, MYSQL_ASSOC)) {
         if (strpos($request, "c") === FALSE && lgsl_timer("check")) {
             $request .= "c";
         }
         $server = lgsl_query_cached("", "", "", "", "", $request, $mysql_row['id']);
         if ($hide_offline && empty($server['b']['status'])) {
             continue;
         }
         if ($game && $game != preg_replace("/[^a-z0-9_]/", "_", strtolower($server['s']['game']))) {
             continue;
         }
         $server_list[] = $server;
         if ($server_limit && count($server_list) >= $server_limit) {
             break;
         }
     }
     return $server_list;
 }
コード例 #2
0
ファイル: lgsl_cron.php プロジェクト: Kayomani/Obsidian
 |                                                                                                            |
 |                      [ LIVE GAME SERVER LIST ] [ © RICHARD PERRY FROM GREYCUBE.COM ]                       |
 |                                                                                                            |
 |    Released under the terms and conditions of the GNU General Public License Version 3 (http://gnu.org)    |
 |                                                                                                            |
 \-----------------------------------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------------------------------------+
require "lgsl_class.php";
lgsl_database();
//------------------------------------------------------------------------------------------------------------+
// CRON SETTINGS:
@set_time_limit(3600);
// MAXIMUM TIME THE CRON IS ALLOWED TO TAKE
$lgsl_config['cache_time'] = 60;
// HOW OLD CACHE MUST BE BEFORE IT NEEDS REFRESHING
$request = "sep";
// WHAT TO PRE-CACHE: [s] = BASIC INFO [e] = SETTINGS [p] = PLAYERS
//------------------------------------------------------------------------------------------------------------+
echo "<pre>STARTING [ TIME LIMIT: " . ini_get("max_execution_time") . " ] [ CACHE TIME: {$lgsl_config['cache_time']} ]\r\n\r\n";
//------------------------------------------------------------------------------------------------------------+
$mysql_query = "SELECT `type`,`ip`,`c_port`,`q_port`,`s_port` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE `disabled`=0 ORDER BY `cache_time` ASC";
$mysql_result = mysql_query($mysql_query) or die(mysql_error());
while ($mysql_row = mysql_fetch_array($mysql_result, MYSQL_ASSOC)) {
    echo str_pad(lgsl_timer("taken"), 8, " ") . ":" . str_pad($mysql_row['type'], 15, " ") . ":" . str_pad($mysql_row['ip'], 30, " ") . ":" . str_pad($mysql_row['c_port'], 6, " ") . ":" . str_pad($mysql_row['q_port'], 6, " ") . ":" . str_pad($mysql_row['s_port'], 12, " ") . "\r\n";
    lgsl_query_cached($mysql_row['type'], $mysql_row['ip'], $mysql_row['c_port'], $mysql_row['q_port'], $mysql_row['s_port'], $request);
    flush();
    ob_flush();
}
//------------------------------------------------------------------------------------------------------------+
echo "\r\nFINISHED</pre>";
//------------------------------------------------------------------------------------------------------------+