function validateCookie(&$userId, &$domainId, &$charId) { $domainInfo = getDomainInfo($domainId); global $DBHost, $RingDBUserName, $RingDBPassword, $AcceptUnknownUser; if (!isset($_COOKIE["ryzomId"])) { echo "Cookie not found<BR>"; return false; } // read the ip and compare with client ip $cookie = $_COOKIE["ryzomId"]; echo "Cookie is {$cookie}<BR>"; sscanf($cookie, "%02X%02X%02X%02X", $b0, $b1, $b2, $b3); $addr = $b0 + ($b1 << 8) + ($b2 << 16) + ($b3 << 24); printf("Addr is %X<BR>", $addr); $addrStr = long2ip($addr); echo "addrStr is {$addrStr}<br>"; if ($_SERVER["REMOTE_ADDR"] != $addrStr) { echo "Client ip don't match cookie<BR>"; return false; } // check the cookie in the database $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die("Can't connect to database host:{$DBHost} user:{$RingDBUserName}"); mysqli_select_db($link, $domainInfo['ring_db_name']) or die("Can't access to the table dbname:" . $domainInfo['ring_db_name']); $cookie = mysqli_real_escape_string($link, $cookie); $query = "SELECT user_id, current_status, current_domain_id FROM ring_users where cookie='{$cookie}'"; $result = mysqli_query($link, $query) or die("Can't execute the query: " . $query); if (mysqli_num_rows($result) == 0) { echo "Can't find cookie {$cookie} in database<BR>"; return false; } $row = mysqli_fetch_assoc($result); if ($row["current_status"] != "cs_logged" && $row["current_status"] != "cs_online") { echo "User {$row['user_id']} is not looged or online<BR>"; return false; } $userId = $row["user_id"]; $domainId = $row["current_domain_id"]; // $charId = ($userId*16) + (getCharSlot()) & 0xf; $charId = $userId * 16 + getCharSlot(); return true; }
/** * Display the list of mainland shards * This is a candidate to the callback $getShardListCallback */ function displayAllShards(&$onlineShardsBySessionId) { // Get the userId and domainId back $domainId = -1; if (!validateCookie($userId, $domainId, $charId)) { echo "Invalid cookie !"; die; } // List all shards of the domain, including offline ones global $DBName; mysql_select_db($DBName) or die("Can't access to the db dbname:{$DBName}"); $query = "select * from shard where domain_id = {$domainId}"; $resShards = mysql_query($query) or die("Can't execute the query: " . $query . " " . mysql_error()); echo "Select a shard to join:<br>"; //echo "<form name='far_tp' action='join_shard.php' method='post'>"; while ($rowShard = mysql_fetch_array($resShards)) { $mainlandSessionId = $rowShard['FixedSessionId']; $isOnline = isset($onlineShardsBySessionId[$mainlandSessionId]); // Radio button not supported by Client's html component. Instead: one form (button) per shard. //echo "<input type='radio' name='destSessionId' value='".$mainlandSessionId."' ".($isOnline?"":"disabled ")."/>".$rowShard['Name']." (".($isOnline?"online with $nbOnlinePlayers players":"offline").", version ".$rowShard['Version'].")<br>"; echo "<form name='far_tp_" . $rowShard['ShardId'] . "' action='join_shard.php' method='post'>"; echo "<input type='hidden' name='destSessionId' value='" . $mainlandSessionId . "' />"; echo "<input type='hidden' name='charSlot' value='" . getCharSlot() . "'>"; echo " " . $rowShard['Name'] . " " . $rowShard['ShardId'] . " (" . ($isOnline ? $onlineShardsBySessionId[$mainlandSessionId] . " online)" : "offline)"); if ($isOnline) { echo "<input type='submit' name='button' value='Teleport' />"; } echo "</form><br>"; } //echo "<input type='submit' name='button' value='Teleport' />"; //echo "</form></font>"; exit; }
$charName = mysqli_real_escape_string($link, $_POST['charName']); $query = "select char_id, char_name from characters where char_name = '{$charName}'"; $result = mysqli_query($link, $query) or die("Can't execute the query: " . $query); if (mysqli_num_rows($result) == 0) { echo "<h1>Can't find the character " . $_POST["charName"] . "<h1>"; } else { $row = mysqli_fetch_assoc($result); $currentSession = $row['char_id']; $currentchar = $row['char_name']; // send the invitation info to the session manager $invitePioneer = new InvitePioneerCb(); $res = ""; $invitePioneer->connect($RSMHost, $RSMPort, $res); // $rsmProxy = new CRingSessionManagerWebProxy; // TODO: not sure it works with a char slot > 0 $invitePioneer->inviteCharacter($userId * 16 + getCharSlot(), $_POST["sessionId"], $row[0], $_POST["mode"]); echo "wait result..."; // wait the the return message // $rsmSkel = new CRingSessionManagerWebSkel; if (!$invitePioneer->waitCallback()) { echo "<h2>No response from server</h2><br>"; } else { echo "Result received..."; } } } else { // buid a form to gather info about the character to invite echo "<h1>Invite a player in the session " . $_POST["sessionId"] . "</h1>"; echo "<form action='invite_pioneer.php' method='post'>Type in character name:<br>"; echo "<input type='text' name='charName' value=''>"; echo "<input type='submit' name='button' value='Invite'>";