Beispiel #1
0
 function invoke($funcname, &$args, $byRef = false)
 {
     $result = $this->_key_exchange();
     if (is_a($result, 'PHPRPC_Error')) {
         return $result;
     }
     $request = "phprpc_func={$funcname}";
     if (count($args) > 0) {
         $request .= "&phprpc_args=" . base64_encode($this->_encrypt(PHPRPC::serialize_fix($args), 1));
     }
     $request .= "&phprpc_encrypt={$this->_encryptMode}";
     if (!$byRef) {
         $request .= "&phprpc_ref=false";
     }
     $request = str_replace('+', '%2B', $request);
     $result = $this->_post($request);
     if (is_a($result, 'PHPRPC_Error')) {
         return $result;
     }
     $phprpc_errno = 0;
     $phprpc_errstr = NULL;
     if (isset($result['phprpc_errno'])) {
         $phprpc_errno = intval($result['phprpc_errno']);
     }
     if (isset($result['phprpc_errstr'])) {
         $phprpc_errstr = base64_decode($result['phprpc_errstr']);
     }
     $this->_warning = new PHPRPC_Error($phprpc_errno, $phprpc_errstr);
     if (array_key_exists('phprpc_output', $result)) {
         $this->_output = base64_decode($result['phprpc_output']);
         if ($this->_server['version'] >= 3) {
             $this->_output = $this->_decrypt($this->_output, 3);
         }
     } else {
         $this->_output = '';
     }
     if (array_key_exists('phprpc_result', $result)) {
         if (array_key_exists('phprpc_args', $result)) {
             $arguments = unserialize($this->_decrypt(base64_decode($result['phprpc_args']), 1));
             for ($i = 0; $i < count($arguments); $i++) {
                 $args[$i] = $arguments[$i];
             }
         }
         $result = unserialize($this->_decrypt(base64_decode($result['phprpc_result']), 2));
     } else {
         $result = $this->_warning;
     }
     return $result;
 }