コード例 #1
0
ファイル: MongoClient.php プロジェクト: J3FF3/phpdaemon
 /**
  * Sends authenciation packet
  * @param array Hash of properties (dbname,  user,  password,  nonce)
  * @param mixed Callback called when response received
  * @param string Optional. Distribution key
  * @return void
  */
 public function auth($p, $callback, $key = '')
 {
     if (!isset($p['opts'])) {
         $p['opts'] = 0;
     }
     $query = array('authenticate' => 1, 'user' => $p['user'], 'nonce' => $p['nonce'], 'key' => MongoClient::getAuthKey($p['user'], $p['password'], $p['nonce']));
     $packet = pack('V', $p['opts']) . $p['dbname'] . '.$cmd' . "" . pack('VV', 0, -1) . bson_encode($query) . (isset($p['fields']) ? bson_encode($p['fields']) : '');
     $reqId = $this->request($key, self::OP_QUERY, $packet, true);
     $this->requests[$reqId] = array($p['dbname'], $callback, true);
 }