示例#1
0
 function CallAs($user, $command, $parameters = array())
 {
     if ($user == FALSE) {
         $cmd = array($this->user, $this->pass);
     } else {
         $cmd = array($user, $this->user . ':' . $this->pass);
     }
     array_push($cmd, $command);
     array_push($cmd, $parameters);
     fputs($this->socket, itype_fromphp($cmd) . "\n");
     $line = fgets($this->socket, 128000);
     if ($line === false) {
         //die('Transport layer error occured in the RPC system: fgets() failed.');
         $result = 'Transport layer error occured in the RPC system: fgets() failed.';
     }
     $line = str_replace(array("\r", "\n"), array("", ""), $line);
     $parsedResponse = itype_parse($line);
     if ($parsedResponse[0] == 'empty') {
         //die('IType parsing error occured in RPC system when parsing the string "' . $line . '"');
         $response = $line;
     }
     $response = itype_flat($parsedResponse);
     if (IsError($response)) {
         $code = GetCode($response);
         if ($code != 'RPC_ERROR') {
             //die('Runtime error occured in the RPC system: [' . $code . '] ' . GetResult($response));
             $response = $code;
         }
     }
     return $response;
 }
示例#2
0
function itype_tophp($value)
{
    return itype_flat(itype_parse($value));
}