本文整理汇总了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]));
}
}