send() public method

public send ( $msg, $timeout, $method = 'http' )
Exemplo n.º 1
1
 function callRemote($method)
 {
     // Curl is required so generate a fault if curl functions cannot be found.
     if (!$this->curl) {
         return array('faultCode' => -1, 'faultString' => 'Curl functions are unavailable.');
     }
     // The first argument will always be the method name while all remaining arguments need
     // to be passed along with the call.
     $args = func_get_args();
     array_shift($args);
     if ($this->xmlrpc) {
         // If php has xmlrpc support use the built in functions.
         $request = xmlrpc_encode_request($method, $args);
         $result = $this->__xmlrpc_call($request);
         $decodedResult = xmlrpc_decode($result);
     } else {
         // If no xmlrpc support is found, use the phpxmlrpc library. This involves containing
         // all variables inside the xmlrpcval class.
         $encapArgs = array();
         foreach ($args as $arg) {
             $encapArgs[] = $this->__phpxmlrpc_encapsulate($arg);
         }
         $msg = new xmlrpcmsg($method, $encapArgs);
         $client = new xmlrpc_client($this->url);
         $client->verifypeer = false;
         $result = $client->send($msg);
         if ($result->errno) {
             $decodedResult = array('faultCode' => $result->errno, 'faultString' => $result->errstr);
         } else {
             $decodedResult = php_xmlrpc_decode($result->value());
         }
     }
     return $decodedResult;
 }
 public function testCurlKAErr()
 {
     if (!function_exists('curl_init')) {
         $this->markTestSkipped('CURL missing: cannot test curl keepalive errors');
         return;
     }
     $m = new xmlrpcmsg('examples.stringecho', array(new xmlrpcval('hello', 'string')));
     // test 2 calls w. keepalive: 1st time connection ko, second time ok
     $this->client->server .= 'XXX';
     $this->client->keepalive = true;
     $r = $this->client->send($m, 5, 'http11');
     // in case we have a "universal dns resolver" getting in the way, we might get a 302 instead of a 404
     $this->assertTrue($r->faultCode() === 8 || $r->faultCode() == 5);
     // now test a successful connection
     $server = explode(':', $this->args['LOCALSERVER']);
     if (count($server) > 1) {
         $this->client->port = $server[1];
     }
     $this->client->server = $server[0];
     $this->client->path = $this->args['URI'];
     $r = $this->client->send($m, 5, 'http11');
     $this->assertEquals(0, $r->faultCode());
     $ro = $r->value();
     is_object($ro) && $this->assertEquals('hello', $ro->scalarVal());
 }
Exemplo n.º 3
0
function pingWeblogs($name, $url, $server)
{
    global $Paths;
    if (strpos($server, "http://") === false) {
        $server = "http://" . $server;
    }
    $server = parse_url($server);
    if ($server['path'] == "") {
        $server['path'] = "/";
    }
    if ($server['port'] == "") {
        $server['port'] = "80";
    }
    printf("<p><b>%s:%s%s</b>:<br />", $server['host'], $server['port'], $server['path']);
    flush();
    $client = new xmlrpc_client($server['path'], $server['host'], $server['port']);
    $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url)));
    $result = $client->send($message);
    if (!$result || $result->faultCode()) {
        echo "<br />Pivot says: could not send ping. Check if you set the server address correctly, or else the server may be temporarily down. This happens sometimes, and if this error occurs out of the blue, it's likely that it will go away in a few hours or days. <br /></p>";
        echo "<!-- \n";
        print_r($result);
        echo "\n -->\n\n\n";
        return false;
    }
    $msg = $result->serialize();
    $msg = preg_replace('#.*<name>message</name>[^<]*<value>(.*?)</value>.*#si', '$1', $msg);
    // Stripping off any tags in the message value - typically the string element
    $msg = strip_tags($msg);
    $msg = escape($msg);
    echo "Server said: <i>'{$msg}'</i><br /></p>";
    return true;
}
function um_xml_rpc_client_call($server_host, $server_path, $server_port, $proxy, $proxy_port, $proxy_user, $proxy_pass, $function, $parameters)
{
    $msg = new xmlrpcmsg($function, $parameters);
    $client = new xmlrpc_client($server_path, $server_host, $server_port);
    $client->setProxy($proxy, $proxy_port, $proxy_user, $proxy_pass);
    if (defined('XMLRPC_DEBUG')) {
        $client->setDebug(XMLRPC_DEBUG);
    }
    $result = $client->send($msg, XMLRPC_TIMEOUT, '');
    if (!$result) {
        trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $client->errstr);
        return 0;
    }
    switch ($result->faultCode()) {
        case 0:
            break;
        case 5:
            trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $result->faultString());
            return 0;
        default:
            trigger_error('<strong>Open Update Manager</strong> XML-RPC error. ' . $result->faultString());
            return 0;
    }
    return $result;
}
function phpAds_checkForUpdates($already_seen = 0, $send_sw_data = true)
{
    global $phpAds_config, $phpAds_updatesServer;
    global $xmlrpcerruser;
    // Create client object
    $client = new xmlrpc_client($phpAds_updatesServer['script'], $phpAds_updatesServer['host'], $phpAds_updatesServer['port']);
    $params = array(new xmlrpcval($GLOBALS['phpAds_productname'], "string"), new xmlrpcval($phpAds_config['config_version'], "string"), new xmlrpcval($already_seen, "string"), new xmlrpcval($phpAds_config['updates_dev_builds'] ? 'dev' : '', "string"), new xmlrpcval($phpAds_config['instance_id'], "string"));
    if ($send_sw_data) {
        // Prepare software data
        $params[] = phpAds_xmlrpcEncode(array('os_type' => php_uname('s'), 'os_version' => php_uname('r'), 'webserver_type' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^(.*?)/.*$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'webserver_version' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^.*?/(.*?)(?: .*)?$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'db_type' => $GLOBALS['phpAds_dbmsname'], 'db_version' => phpAds_dbResult(phpAds_dbQuery("SELECT VERSION()"), 0, 0), 'php_version' => phpversion(), 'php_sapi' => ucfirst(php_sapi_name()), 'php_extensions' => get_loaded_extensions(), 'php_register_globals' => (bool) ini_get('register_globals'), 'php_magic_quotes_gpc' => (bool) ini_get('magic_quotes_gpc'), 'php_safe_mode' => (bool) ini_get('safe_mode'), 'php_open_basedir' => (bool) strlen(ini_get('open_basedir')), 'php_upload_tmp_readable' => (bool) is_readable(ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR)));
    }
    // Create XML-RPC request message
    $msg = new xmlrpcmsg("Openads.Sync", $params);
    // Send XML-RPC request message
    if ($response = $client->send($msg, 10)) {
        // XML-RPC server found, now checking for errors
        if (!$response->faultCode()) {
            $ret = array(0, phpAds_xmlrpcDecode($response->value()));
            // Prepare cache
            $cache = $ret[1];
        } else {
            $ret = array($response->faultCode(), $response->faultString());
            // Prepare cache
            $cache = false;
        }
        // Save to cache
        phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_config'] . "\n\t\t\tSET\n\t\t\t\tupdates_cache = '" . addslashes(serialize($cache)) . "',\n\t\t\t\tupdates_timestamp = " . time() . "\n\t\t");
        return $ret;
    }
    return array(-1, 'No response from the server');
}
Exemplo n.º 6
0
function connect()
{
    global $oerpuser, $oerppwd, $dbname, $server_url, $client;
    if (isset($_COOKIE["user_id"]) == true) {
        if ($_COOKIE["user_id"] > 0) {
            return $_COOKIE["user_id"];
        }
    }
    try {
        $sock = new xmlrpc_client($server_url . 'common');
        $msg = new xmlrpcmsg('login');
        $msg->addParam(new xmlrpcval($dbname, "string"));
        $msg->addParam(new xmlrpcval($oerpuser, "string"));
        $msg->addParam(new xmlrpcval($oerppwd, "string"));
        $resp = $sock->send($msg);
        $val = $resp->value();
        $id = $val->scalarval();
    } catch (Exception $ex) {
        print "Unable to authenticate to openERP " . $ex->getMessage() . "\n";
    }
    setcookie("user_id", $id, time() + 3600);
    if ($id > 0) {
        return $id;
    } else {
        return -1;
    }
}
Exemplo n.º 7
0
 /**
  * @method methodCaller
  * @description Builds XML and Sends the Call
  * @param string $service
  * @param array $callArray
  * @return int|mixed|string
  * @throws iSDKException
  */
 public function methodCaller($service, $callArray)
 {
     /* Set up the call */
     $call = new xmlrpcmsg($service, $callArray);
     if ($service != 'DataService.getTemporaryKey') {
         array_unshift($call->params, $this->encKey);
     }
     /* Send the call */
     $now = time();
     $start = microtime();
     $result = $this->client->send($call);
     $stop = microtime();
     /* Check the returned value to see if it was successful and return it */
     if (!$result->faultCode()) {
         if ($this->loggingEnabled == 1) {
             $this->log(array('Method' => $service, 'Call' => $callArray, 'Start' => $start, 'Stop' => $stop, 'Now' => $now, 'Result' => $result, 'Error' => 'No', 'ErrorCode' => 'No Error Code Received'));
         }
         return $result->value();
     } else {
         if ($this->loggingEnabled == 1) {
             $this->log(array('Method' => $service, 'Call' => $callArray, 'Start' => $start, 'Stop' => $stop, 'Now' => $now, 'Result' => $result, 'Error' => 'Yes', 'ErrorCode' => "ERROR: " . $result->faultCode() . " - " . $result->faultString()));
         }
         if ($this->debug == "kill") {
             die("ERROR: " . $result->faultCode() . " - " . $result->faultString());
         } elseif ($this->debug == "on") {
             return "ERROR: " . $result->faultCode() . " - " . $result->faultString();
         } elseif ($this->debug == "throw") {
             throw new iSDKException($result->faultString(), $result->faultCode());
         } elseif ($this->debug == "off") {
             //ignore!
         }
     }
 }
Exemplo n.º 8
0
 function xmlrpcCall($url, $method, $params)
 {
     // xmlrpc encode parameters
     for ($i = 0; $i < count($params); $i++) {
         if (get_class($params[$i]) != 'xmlrpcval') {
             $params[$i] = xmlrpc_encode($params[$i]);
         }
     }
     // send request
     $message = new xmlrpcmsg($method, $params);
     debug("XML-RPC message", $message->serialize());
     $addr = parse_url($url);
     $client = new xmlrpc_client($url, $addr['host'], $addr['port']);
     //if($debug)
     //  $client->setDebug(1);
     debug("XML-RPC", "call to " . $url);
     $response = $client->send($message);
     // process response
     debug("XML-RPC Response", $response->serialize());
     if (!$response) {
         debug("No response", "probably host is unreachable");
     } elseif ($response->faultCode() != 0) {
         // there was an error
         debug("Error response: ", $response->faultCode() . "  " . $response->faultString());
     } else {
         $retval = $response->value();
         if ($retval) {
             $retval = xmlrpc_decode($retval);
         }
         debug("Response", $retval);
         return $retval;
     }
     return NULL;
 }
Exemplo n.º 9
0
 /**
  * Compiles and sends the Shopatron RPC
  * @param   Varien_Event_Observer $observer
  * @return  MikeRoyer_Shopatron_Model_Observer
  */
 public function SendRPC($observer)
 {
     $server = new xmlrpc_client('/xmlServer.php', 'www.shopatron.com', 80);
     $message = $this->compileRPC();
     $result = $server->send($message);
     // For secure transmission -- did not work for me
     // $result = $server->send($message, 30, 'https');
     $this->DoResult($result, $message);
 }
Exemplo n.º 10
0
 function shutdown()
 {
     $function = new xmlrpcmsg('control.shutdown', array(php_xmlrpc_encode((string) $this->ktid), php_xmlrpc_encode((string) $this->authToken)));
     $result =& $this->client->send($function);
     if ($result->faultCode()) {
         $this->error($result, 'shutdown');
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
function atheme($hostname, $port, $path, $sourceip, $username, $password, $service, $command, $params)
{
    $message = new xmlrpcmsg("atheme.login");
    $message->addParam(new xmlrpcval($username, "string"));
    $message->addParam(new xmlrpcval($password, "string"));
    $client = new xmlrpc_client($path, $hostname, $port);
    $response = $client->send($message);
    $session = NULL;
    if (!$response->faultCode()) {
        $session = explode("<string>", $response->serialize());
        $session = explode("</string", $session[1]);
        $session = $session[0];
    } else {
        return "Authorisation failed";
    }
    $message = new xmlrpcmsg("atheme.command");
    $message->addParam(new xmlrpcval($session, "string"));
    $message->addParam(new xmlrpcval($username, "string"));
    $message->addParam(new xmlrpcval($sourceip, "string"));
    $message->addParam(new xmlrpcval($service, "string"));
    $message->addParam(new xmlrpcval($command, "string"));
    if ($params != NULL) {
        if (sizeof($params) < 2) {
            foreach ($params as $param) {
                $message->addParam(new xmlrpcval($param, "string"));
            }
        } else {
            $firstparam = $params[0];
            $secondparam = "";
            for ($i = 1; $i < sizeof($params); $i++) {
                $secondparam .= $params[$i] . " ";
            }
            $message->addParam(new xmlrpcval($firstparam, "string"));
            $message->addParam(new xmlrpcval($secondparam, "string"));
        }
        $response = $client->send($message);
    }
    if (!$response->faultCode()) {
        return $response->serialize();
    } else {
        return "Command failed: " . $response->faultString();
    }
}
Exemplo n.º 12
0
 private function run($service, $command, $params)
 {
     if (!$this->ci->config->item('atheme_enabled')) {
         return;
     }
     $hostname = $this->ci->config->item('atheme_server');
     $port = $this->ci->config->item('atheme_port');
     $path = $this->ci->config->item('atheme_path');
     $username = $this->ci->config->item('atheme_username');
     $password = $this->ci->config->item('atheme_password');
     $sourceip = '127.0.0.1';
     $message = new xmlrpcmsg("atheme.login");
     $message->addParam(new xmlrpcval($username, "string"));
     $message->addParam(new xmlrpcval($password, "string"));
     $client = new xmlrpc_client($path, $hostname, $port);
     $response = $client->send($message);
     $session = NULL;
     if (!$response->faultCode()) {
         $session = explode("<string>", $response->serialize());
         $session = explode("</string", $session[1]);
         $session = $session[0];
     } else {
         return "Authorization failed";
     }
     $message = new xmlrpcmsg("atheme.command");
     $message->addParam(new xmlrpcval($session, "string"));
     $message->addParam(new xmlrpcval($username, "string"));
     $message->addParam(new xmlrpcval($sourceip, "string"));
     $message->addParam(new xmlrpcval($service, "string"));
     $message->addParam(new xmlrpcval($command, "string"));
     if ($params != NULL) {
         foreach ($params as $param) {
             $message->addParam(new xmlrpcval($param, "string"));
         }
         $response = $client->send($message);
     }
     if (!$response->faultCode()) {
         return $response->serialize();
     } else {
         return "Command failed: " . $response->faultString();
     }
 }
Exemplo n.º 13
0
 /**
  * Ping the pingomatic RPC service.
  */
 function ItemSendPing(&$params)
 {
     global $debug;
     $item_Blog = $params['Item']->get_Blog();
     $client = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
     $client->debug = $debug && $params['display'];
     $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url'))));
     $result = $client->send($message);
     $params['xmlrpcresp'] = $result;
     return true;
 }
Exemplo n.º 14
0
 function &send($msg, $timeout = 0, $method = '')
 {
     if (empty($method)) {
         $method = $this->method;
     }
     if ($method != 'file' and $method != 'unix' and $method != 'socket') {
         parent::send($msg, $timeout = 0, $method = '');
     } else {
         $r =& $this->sendPayloadUNIX($msg);
     }
     return $r;
 }
Exemplo n.º 15
0
 function send_message($name, $params, $url)
 {
     $msg = new xmlrpcmsg($name, $params);
     $client = new xmlrpc_client($url);
     $client->return_type = 'phpvals';
     $result = $client->send($msg);
     if (!$result->faultCode()) {
         return $result->value();
     } else {
         throw new SilkXmlRpcException($result->faultString(), $result->faultCode());
     }
 }
Exemplo n.º 16
0
 /**
  * Ping the b2evonet RPC service.
  */
 function ItemSendPing(&$params)
 {
     global $evonetsrv_host, $evonetsrv_port, $evonetsrv_uri;
     global $debug, $baseurl, $instance_name;
     $item_Blog = $params['Item']->get_Blog();
     $client = new xmlrpc_client($evonetsrv_uri, $evonetsrv_host, $evonetsrv_port);
     $client->debug = $debug == 2;
     $message = new xmlrpcmsg('b2evo.ping', array(new xmlrpcval($item_Blog->ID), new xmlrpcval($baseurl), new xmlrpcval($instance_name), new xmlrpcval($item_Blog->dget('name', 'xml')), new xmlrpcval($item_Blog->dget('url', 'xml')), new xmlrpcval($item_Blog->dget('locale', 'xml')), new xmlrpcval($params['Item']->dget('title', 'xml'))));
     $result = $client->send($message);
     $params['xmlrpcresp'] = $result;
     return true;
 }
Exemplo n.º 17
0
 public function updateFile($file)
 {
     $this->listHoruxGuiFile(".");
     $client = new xmlrpc_client("http://www.horux.ch/update/xml_rpc_update.php");
     $message = new xmlrpcmsg("getFile", array(new xmlrpcval($file, 'string'), new xmlrpcval("1.0", 'string')));
     $resp = $client->send($message);
     if ($resp->faultCode()) {
         return false;
     } else {
         $value = $resp->value();
         return base64_decode($value->scalarval());
     }
 }
Exemplo n.º 18
0
 public function send($item, $config)
 {
     $sql = "SELECT  `livejournal`\n                FROM    `posts`\n                WHERE   `link` = '" . mysql_real_escape_string($item['link']) . "'";
     $status = mysql_fetch_assoc(mysql_query($sql));
     if (!isset($status['livejournal'])) {
         $count = 0;
     } else {
         $count = 1;
     }
     if ($count == 0 or $status['livejournal'] == 0) {
         include_once "lib/xmlrpc.inc";
         $subj = $config['prefix'] . $item['title'];
         $url = $item['link'];
         $text = "<center>" . htmlspecialchars_decode($item['description']) . "</center>";
         /*
          Если вдруг захотим постить фотки задним числом.
          При включенни не будут попадать во френделенту.
         */
         /*
         $time    = explode("T", $item['atom']['updated']); // 2008-07-10T14:32:03.579+04:00
         $time_d  = explode("-", $time[0]);
         $time_t  = explode(":", $time[1]);
         
         $year = $time_d[0];
         $mon  = $time_d[1];
         $day  = $time_d[2];
         $hour = $time_t[0];
         $min  = $time_t[1];
         */
         /*
          Оставленно на случай включения постинга "задним" числом
         */
         $year = date('Y');
         $mon = date('m');
         $day = date('d');
         $hour = date('H');
         $min = date('i');
         $post = array("username" => new xmlrpcval($config['login'], "string"), "hpassword" => new xmlrpcval($config['password'], "string"), "event" => new xmlrpcval($text, "string"), "subject" => new xmlrpcval($subj, "string"), "security" => new xmlrpcval("usemask", "string"), "allowmask" => new xmlrpcval("1", "string"), "lineendings" => new xmlrpcval("unix", "string"), "props" => new xmlrpcval(array('opt_preformatted' => new xmlrpcval(true, "string")), "struct"), "year" => new xmlrpcval($year, "int"), "mon" => new xmlrpcval($mon, "int"), "day" => new xmlrpcval($day, "int"), "hour" => new xmlrpcval($hour, "int"), "min" => new xmlrpcval($min, "int"), "ver" => new xmlrpcval(1, "int"));
         $post2 = array(new xmlrpcval($post, "struct"));
         $f = new xmlrpcmsg('LJ.XMLRPC.postevent', $post2);
         $c = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80);
         $r = $c->send($f);
         if (!$r->faultCode()) {
             if ($count == 0) {
                 mysql_query("\n                                    INSERT INTO `posts`\n                                        (`link`, `livejournal`)\n                                    VALUES\n                                        ('" . mysql_real_escape_string($item['link']) . "', '1')\n                                ");
             } else {
                 mysql_query("\n                                    UPDATE `posts`\n                                    SET `livejournal` = '1'\n                                    WHERE `link` = '" . mysql_real_escape_string($item['link']) . "'\n                                    LIMIT 1;\n                                ");
             }
         }
     }
 }
Exemplo n.º 19
0
 function params($call)
 {
     if (isset($this->parms[$call])) {
         $answer[0] = $this->parms[$call];
         return $answer[0];
     }
     $msg = new xmlrpcmsg("system.methodSignature", array(php_xmlrpc_encode($call)));
     $client = new xmlrpc_client($this->ServerURL);
     $client->setDebug($this->DebugLevel);
     $response = $client->send($msg);
     $answer = php_xmlrpc_decode($response->value());
     $this->parms[$call] = $answer[0];
     return $answer[0];
 }
Exemplo n.º 20
0
 /**
  * Connects to the Mail API and calls the desired
  * function with the specified parameters
  * 
  * @param  method to invoke and parameters for the method
  * @return mixed
  */
 public function executeMethod($method, $params)
 {
     $host = getenv("MAILAPI_URL") ? getenv("MAILAPI_URL") : MAILAPI_ENDPOINT;
     $params['apikey'] = new xmlrpcval($this->apikey);
     $xmlrpcmsg = new xmlrpcmsg($method, array(new xmlrpcval($params, 'struct')));
     $xmlrpc_client = new xmlrpc_client($host);
     $xmlrpc_client->request_charset_encoding = "UTF-8";
     $xmlrpc_client->SetUserAgent(MAILAPI_PARTNER . "/PHP/v" . MAILAPI_VERSION);
     $response = $xmlrpc_client->send($xmlrpcmsg);
     if (!$response->faultCode()) {
         return php_xmlrpc_decode($response->value());
     } else {
         return new MAILAPI_Error($response->faultCode(), $response->faultString());
     }
 }
Exemplo n.º 21
0
 function dummyValidate($command, $la, $code)
 {
     $host = preg_replace('/^http.*\\/\\/([^\\/]*).*$/', '$1', AV_RPC_URL);
     $path = preg_replace('/^[^\\.]*\\.[^\\/]*(\\/.*)$/', '$1', AV_RPC_URL);
     $client = new xmlrpc_client($path, $host, 80);
     $message = new xmlrpcmsg("validate", array(new xmlrpcval($command, "string"), new xmlrpcval($la, "string"), new xmlrpcval(AV_LOGIN, "string"), new xmlrpcval(AV_PASSWD, "string"), new xmlrpcval($code, "string")));
     $response = $client->send($message, 0);
     //		var_dump ( $message );
     //var_dump ( $response );
     if ($response->faultCode()) {
         return false;
     }
     $resp_val = $response->value();
     $status = $resp_val->structmem("status");
     return $status->scalarval() == "OK";
 }
Exemplo n.º 22
0
 public function publish(&$errors)
 {
     $name = "abc";
     $format = new xmlrpcmsg('elgg.user.newUser', array(new xmlrpcval($name, "string")));
     $client = new xmlrpc_client("_rpc/RPC2.php", "tech2.severndelta.co.uk", 8091);
     $request = $client->send($format);
     $value = $request->value();
     if (!$request->faultCode()) {
         $this->published = true;
         $this->admin_owner = $request->serialize();
     } else {
         $errors[] = "Code: " . $request->faultCode() . " Reason '" . $request->faultString();
         return false;
     }
     return true;
 }
Exemplo n.º 23
0
 function sendXmlRpc($sMessage, $aParam)
 {
     $r_client = new xmlrpc_client(ADDR_XMLRPC_ENTERPOINT, ADDR_XMLRPC_SERVER, 80);
     foreach ($aParam as $k => $v) {
         $aParam[$k] = php_xmlrpc_encode($v);
     }
     $r_message = new xmlrpcmsg($sMessage, $aParam);
     //$c->setDebug(1);
     $response =& $r_client->send($r_message);
     if ($response->faultCode()) {
         return $response;
         return 'xmlrpc-error: ' . $file . ' [' . $r->faultCode() . '] ' . $r->faultString();
     }
     $value = $response->value();
     return php_xmlrpc_decode($value);
 }
Exemplo n.º 24
0
function GetRequest_XmlRpc_Lib($host, $port, $passwd, $request, $params)
{
    global $ConnectTimeout;
    $f = new xmlrpcmsg($request, ParamsLIB($params));
    $c = new xmlrpc_client('xmlrpc', $host, $port);
    $c->setCredentials('nzbget', $passwd);
    $c->setDebug(False);
    $r = $c->send($f, $ConnectTimeout);
    if (!$r->faultCode()) {
        //Got a valid result, decode into php variables
        return php_xmlrpc_decode($r->value());
    } else {
        //Got an error, print description
        trigger_error('RPC: method "' . $request . '", error ' . $r->faultCode() . ' - ' . $r->faultString());
    }
}
Exemplo n.º 25
0
 /**
  * Ping the pingomatic RPC service.
  */
 function ItemSendPing(&$params)
 {
     global $debug;
     global $outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password;
     $item_Blog = $params['Item']->get_Blog();
     $client = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
     $client->debug = $debug && $params['display'];
     // Set proxy for outgoing connections:
     if (!empty($outgoing_proxy_hostname)) {
         $client->setProxy($outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password);
     }
     $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url'))));
     $result = $client->send($message);
     $params['xmlrpcresp'] = $result;
     return true;
 }
Exemplo n.º 26
0
/**
 * Forward an xmlrpc request to another server, and return to client the response received.
 * @param xmlrpcmsg $m (see method docs below for a description of the expected parameters)
 * @return xmlrpcresp
 */
function forward_request($m)
{
    // create client
    $timeout = 0;
    $url = php_xmlrpc_decode($m->getParam(0));
    $c = new xmlrpc_client($url);
    if ($m->getNumParams() > 3) {
        // we have to set some options onto the client.
        // Note that if we do not untaint the received values, warnings might be generated...
        $options = php_xmlrpc_decode($m->getParam(3));
        foreach ($options as $key => $val) {
            switch ($key) {
                case 'Cookie':
                    break;
                case 'Credentials':
                    break;
                case 'RequestCompression':
                    $c->setRequestCompression($val);
                    break;
                case 'SSLVerifyHost':
                    $c->setSSLVerifyHost($val);
                    break;
                case 'SSLVerifyPeer':
                    $c->setSSLVerifyPeer($val);
                    break;
                case 'Timeout':
                    $timeout = (int) $val;
                    break;
            }
            // switch
        }
    }
    // build call for remote server
    /// @todo find a weay to forward client info (such as IP) to server, either
    /// - as xml comments in the payload, or
    /// - using std http header conventions, such as X-forwarded-for...
    $method = php_xmlrpc_decode($m->getParam(1));
    $pars = $m->getParam(2);
    $m = new xmlrpcmsg($method);
    for ($i = 0; $i < $pars->arraySize(); $i++) {
        $m->addParam($pars->arraymem($i));
    }
    // add debug info into response we give back to caller
    xmlrpc_debugmsg("Sending to server {$url} the payload: " . $m->serialize());
    return $c->send($m, $timeout);
}
Exemplo n.º 27
0
/**
* Initiate the execution of a testcase through XML Server RPCs.
* All the object instantiations are done here.
* XML-RPC Server Settings need to be configured using the custom fields feature.
* Three fields each for testcase level and testsuite level are required.
* The fields are: server_host, server_port and server_path.
* Precede 'tc_' for custom fields assigned to testcase level.
*
* @param $testcase_id: The testcase id of the testcase to be executed
* @param $tree_manager: The tree manager object to read node values and testcase and parent ids.
* @param $cfield_manager: Custom Field manager object, to read the XML-RPC server params.
* @return map:
*         keys: 'result','notes','message'
*         values: 'result' -> (Pass, Fail or Blocked)
*                 'notes' -> Notes text
*                 'message' -> Message from server
*/
function executeTestCase($testcase_id, $tree_manager, $cfield_manager)
{
    //Fetching required params from the entire node hierarchy
    $server_params = $cfield_manager->getXMLServerParams($testcase_id);
    $ret = array('result' => AUTOMATION_RESULT_KO, 'notes' => AUTOMATION_NOTES_KO, 'message' => '');
    $server_host = "";
    $server_port = "";
    $server_path = "";
    $do_it = false;
    if ($server_params != null or $server_params != "") {
        $server_host = $server_params["xml_server_host"];
        $server_port = $server_params["xml_server_port"];
        $server_path = $server_params["xml_server_path"];
        if (!is_null($server_host) || !is_null($server_path)) {
            $do_it = true;
        }
    }
    if ($do_it) {
        // Make an object to represent our server.
        // If server config objects are null, it returns an array with appropriate values
        // (-1 for executions results, and fault code and error message for message.
        $xmlrpc_client = new xmlrpc_client($server_path, $server_host, $server_port);
        $tc_info = $tree_manager->get_node_hierarchy_info($testcase_id);
        $testcase_name = $tc_info['name'];
        //Create XML-RPC Objects to pass on to the the servers
        $myVar1 = new xmlrpcval($testcase_name, 'string');
        $myvar2 = new xmlrpcval($testcase_id, 'string');
        $messageToServer = new xmlrpcmsg('ExecuteTest', array($myVar1, $myvar2));
        $serverResp = $xmlrpc_client->send($messageToServer);
        $myResult = AUTOMATION_RESULT_KO;
        $myNotes = AUTOMATION_NOTES_KO;
        if (!$serverResp) {
            $message = lang_get('test_automation_server_conn_failure');
        } elseif ($serverResp->faultCode()) {
            $message = lang_get("XMLRPC_error_number") . $serverResp->faultCode() . ": " . $serverResp->faultString();
        } else {
            $message = lang_get('test_automation_exec_ok');
            $arrayVal = $serverResp->value();
            $myResult = $arrayVal->arraymem(0)->scalarval();
            $myNotes = $arrayVal->arraymem(1)->scalarval();
        }
        $ret = array('result' => $myResult, 'notes' => $myNotes, 'message' => $message);
    }
    //$do_it
    return $ret;
}
Exemplo n.º 28
0
function getPostsForAccount($accesscode, $password)
{
    $f = new xmlrpcmsg("pb.getPostsForAccount", array(new xmlrpcval($accesscode, "string"), new xmlrpcval($password, "string")));
    $c = new xmlrpc_client("/pbapi/xmlrpc.php", "www.phoneblogz.com", 80);
    $r = $c->send($f, 1);
    $arrResults = array();
    if ($r->faultCode() != 0) {
        $arrResults = array("error" => $r->faultString());
    } else {
        $v = $r->value();
        $u = $v->scalarval();
        // Go through the structs
        for ($i = 0; $i < count($u); ++$i) {
            $arr = $u[$i]->scalarval();
            array_push($arrResults, array("messageid" => $arr["messageid"]->scalarval(), "userno" => $arr["userno"]->scalarval(), "username" => $arr["username"]->scalarval(), "timeleft" => $arr["timeleft"]->scalarval(), "callerid" => $arr["callerid"]->scalarval(), "processed" => $arr["processed"]->scalarval()));
        }
    }
    return $arrResults;
}
Exemplo n.º 29
0
 function call($url, $method, $params)
 {
     // xmlrpc encode parameters
     for ($i = 0; $i < count($params); $i++) {
         if (get_class($params[$i]) != 'xmlrpcval') {
             $params[$i] = xmlrpc_encoder($params[$i]);
         }
     }
     // send request
     $message = new xmlrpcmsg($method, $params);
     if ($this->debug) {
         //  $this->display_xml($message->serialize());
         print "<PRE>" . htmlentities($message->serialize()) . "</PRE>\n";
         //("XML-RPC message:\n $message->serialize()",0);
     }
     $addr = parse_url($url);
     $client = new xmlrpc_client($url, $addr['host'], $addr['port'], $this->connTimeout, $this->recvTimeout);
     if ($this->debug) {
         $client->setDebug(1);
     }
     debug("XML-RPC", "call to " . $url);
     $response = $client->send($message);
     if ($this->debug) {
         print "<PRE>" . htmlentities($response->serialize()) . "</PRE>\n";
     }
     // process response
     //debug("XML-RPC Response", $response->serialize());
     if (!$response) {
         addError("No response: probably host is unreachable");
     } elseif ($response->faultCode() > 0) {
         // there was an error
         addError("Error response: " . $response->faultCode() . "  " . $response->faultString());
     } else {
         $retval = $response->value();
         if ($retval) {
             $retval = xmlrpc_decoder($retval);
         }
         //debug("Response", $retval);
         return $retval;
     }
     return NULL;
 }
Exemplo n.º 30
0
 public function update()
 {
     global $config;
     $host = $config['host'];
     $port = $config['port'];
     $user = $config['user'];
     $passwd = $config['passwd'];
     $f = new xmlrpcmsg("status", "");
     //echo "<PRE>Sending the following request:<BR>" . htmlentities($f->serialize()) . "</PRE>\n";
     $c = new xmlrpc_client("", $host, $port);
     $c->setCredentials($user, $passwd);
     $c->setDebug(0);
     $r = $c->send($f);
     if (!$r->faultCode()) {
         //Got a valid result, decode into php variables
         return php_xmlrpc_decode($r->value());
     } else {
         return array('code' => $r->faultCode(), 'reason' => $r->faultString());
     }
 }