public function __construct($socket, $index, $address)
 {
     // set private variables
     $this->socket = $socket;
     $this->index = $index;
     $this->ip = $address['ip'];
     $this->port = $address['port'];
     // create challenge
     $this->challenge = tools::generateRandomString(10);
     // create session
     $this->session = tools::generateRandomInt(5);
     // send challenge to client
     $response = gamespy::xor_this('\\lc\\1\\challenge\\' . $this->challenge . '\\id\\1') . '\\final\\';
     tools::log('server: ' . '\\lc\\1\\challenge\\' . $this->challenge . '\\id\\1' . '\\final\\');
     socket_write($this->socket, $response);
     tools::log('initializing new client (' . $this->ip . ':' . $this->port . ')');
 }
예제 #2
0
 /**
  * 
  * @param type $ex
  * @return boolean
  */
 public function gs_getprofile($ex)
 {
     if (isset($ex[array_search('sesskey', $ex) + 1]) and isset($ex[array_search('profileid', $ex) + 1])) {
         $profileID = $ex[array_search('profileid', $ex) + 1];
         $id = $ex[array_search('id', $ex) + 1];
         $query = "SELECT * FROM users WHERE id='" . intval($profileID) . "' LIMIT 0,1";
         $sql = database::query($query);
         if (database::num_rows($sql) == 1) {
             $row = database::fetch_object($sql);
             $response = '\\pi\\' . '\\profileid\\' . $profileID . '\\nick\\' . $row->name . '\\userid\\' . $profileID . '\\email\\' . $row->email . '\\sig\\' . tools::generateRandomString(32) . '\\uniquenick\\' . $row->name . '\\pid\\0' . '\\firstname\\' . '\\lastname\\' . '\\countrycode\\US' . '\\birthday\\16844722' . '\\lon\\0.000000' . '\\lat\\0.000000' . '\\loc\\' . '\\id\\' . $id . '\\final\\';
             tools::log("server: " . $response);
             socket_write($this->socket, $response);
         } else {
             return false;
         }
     }
     return true;
 }