本文整理汇总了PHP中Server::setAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::setAddress方法的具体用法?PHP Server::setAddress怎么用?PHP Server::setAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::setAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ServerPulse
function ServerPulse()
{
$server = new Server();
//Get server address
$server->setAddress($_SERVER['REMOTE_ADDR']);
//Grab input
$server->setPort($_REQUEST["port"]);
$server->setName($_REQUEST["name"]);
$server->setVersion($_REQUEST["version"]);
$server->setPrivateKey($_REQUEST["fingerprint"]);
$server->setMaxClients($_REQUEST["max"]);
$server->setPublic($_REQUEST["public"]);
$server->setPasswordProtected($_REQUEST["passwordProtected"]);
$server->setAllowGuests($_REQUEST["allowGuests"]);
$server->setUserCount($_REQUEST["users"]);
$server->setUserList($_REQUEST["players"]);
$server->setMotd($_REQUEST["motd"]);
$server->setGameMode($_REQUEST["gamemode"]);
//Update (or create) server record
return Server::updateServer($server);
}
示例2: getServerList
public static function getServerList()
{
//Grab connection object
$mysqli = Utility::getSQLConnection();
$sql = "SELECT server_id, address, port, version, name, private_key, key_hash, ";
$sql .= "max_clients, public, password_protected, allow_guests, user_count, ";
$sql .= "user_list, motd, game_mode, last_heartbeat_date, created_date ";
$sql .= "FROM servers ";
$sql .= "WHERE last_heartbeat_date > (NOW() - INTERVAL 8 HOUR) ";
$sql .= "ORDER BY last_heartbeat_date DESC";
//Prepare query to find server
$stmt = $mysqli->prepare($sql);
if ($mysqli->errno) {
trigger_error($mysqli->error, E_USER_ERROR);
}
//Run query
$stmt->execute();
if ($mysqli->errno) {
$stmt->close();
unset($stmt);
trigger_error($mysqli->error, E_USER_ERROR);
}
$stmt->bind_result($serverId, $address, $port, $version, $name, $privateKey, $keyHash, $maxClients, $public, $passwordProtected, $allowGuests, $userCount, $userList, $motd, $gameMode, $lastHeartbeatDate, $createdDate);
$serverList = array();
while ($stmt->fetch()) {
$server = new Server();
//Fill server object
$server->setServerId($serverId);
$server->setAddress($address);
$server->setPort($port);
$server->setVersion($version);
$server->setName($name);
$server->setPrivateKey($privateKey);
$server->setPublicKey($keyHash);
$server->setMaxClients($maxClients);
$server->setPublic($public);
$server->setPasswordProtected($passwordProtected);
$server->setAllowGuests($allowGuests);
$server->setUserCount($userCount);
$server->setUserList($userList);
$server->setMotd($motd);
$server->setGameMode($gameMode);
$server->setLastHeartbeatDate($lastHeartbeatDate);
$server->setCreatedDate($createdDate);
$serverList[] = $server;
}
$stmt->close();
unset($stmt);
return $serverList;
}