本文整理匯總了PHP中server::get_server_list方法的典型用法代碼示例。如果您正苦於以下問題:PHP server::get_server_list方法的具體用法?PHP server::get_server_list怎麽用?PHP server::get_server_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類server
的用法示例。
在下文中一共展示了server::get_server_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepare
public function prepare()
{
global $db;
$this->template = "server_search";
$this->tab = 'server';
require_once 'classes/server.php';
if ($this->request['search']) {
$req = $this->request['search'];
if (strpos($req, ':')) {
list($ip, $port) = explode(":", $req);
$wheres[] = '(ip = %s AND port = %s)';
$whargs[] = $ip;
$whargs[] = $port;
} else {
$wheres[] = 'ip LIKE %s';
$whargs[] = '%' . $req . '%';
}
// name search
$wheres[] = 's.name LIKE %s';
$whargs[] = '%' . $req . '%';
// tag search
$wheres[] = 'tags LIKE %s';
$whargs[] = '%' . $req . '%';
$where = implode(' OR ', $wheres);
$q = $this->request['search'];
$db->query("SELECT ip, port FROM tf2_servers s WHERE " . $where, $whargs);
//echo mysql_error();
if ($db->num_rows() == 1) {
$row = $db->fetch_array();
header(sprintf('Location: /server/%s:%s', $row['ip'], $row['port']));
exit;
}
if (!$db->num_rows()) {
page::error("Spy sappin my search results", "Sorry to <i>pop in</i> unannounced, but that server you were looking for?\r\n\t\t\t\tIt's nowhere to be found. I'm not saying one of my sappers didn't have anything to do with it, but mind the charred\r\n\t\t\t\tbits of computer on the floor.", array('image' => "spy"));
}
//$db->debug=true;
foreach ($whargs as $wh) {
$cleanargs[] = "'" . mysql_real_escape_string($wh) . "'";
}
$query = vsprintf('SELECT s.ip, s.port, s.name, s.map_id, m.name AS map_name, s.players, s.max_players, bots FROM tf2_servers s LEFT JOIN tf2_maps m ON s.map_id=m.id WHERE ' . $where . ' LIMIT 50', $cleanargs);
$this->params['list'] = server::get_server_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label'), 'player_label' => array('func' => 'player_label', 'param' => '%d/%d')), 'query' => $query));
$this->title = sprintf("Search: %s", htmlspecialchars($this->request[0]));
}
}