public function query($method, $parameters = null)
 {
     $request = xmlrpc_encode_request($method, $parameters);
     $headers = array("Content-type: text/xml", "Content-length: " . strlen($request));
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $this->url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
     if ($this->timeout) {
         curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
     }
     $rawResponse = curl_exec($curl);
     $curlErrno = curl_errno($curl);
     $curlError = curl_error($curl);
     curl_close($curl);
     if ($curlErrno) {
         throw new NetworkException($curlError, $curlErrno);
     }
     $result = xmlrpc_decode($rawResponse);
     if (xmlrpc_is_fault($result)) {
         throw new NetworkException($result['faultString'], $result['faultCode']);
     }
     return $result;
 }
 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;
 }
Example #3
0
 static function get_request($method, $params = CJ_EMPTY_VALUE, $params2 = CJ_EMPTY_VALUE, $params3 = CJ_EMPTY_VALUE, $params4 = CJ_EMPTY_VALUE, $params5 = CJ_EMPTY_VALUE)
 {
     if ($params == CJ_EMPTY_VALUE) {
         $request = xmlrpc_encode_request("joomdle_" . $method, array(), array('encoding' => 'utf8'));
     } else {
         if ($params2 == CJ_EMPTY_VALUE) {
             $request = xmlrpc_encode_request("joomdle_" . $method, array($params), array('encoding' => 'utf8'));
         } else {
             if ($params3 == CJ_EMPTY_VALUE) {
                 $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2), array('encoding' => 'utf8'));
             } else {
                 if ($params4 == CJ_EMPTY_VALUE) {
                     $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3), array('encoding' => 'utf8'));
                 } else {
                     if ($params5 == CJ_EMPTY_VALUE) {
                         $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3, $params4), array('encoding' => 'utf8'));
                     } else {
                         $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3, $params4, $params5), array('encoding' => 'utf8'));
                     }
                 }
             }
         }
     }
     return $request;
 }
Example #4
0
 /**
  * send xml data to OpenNebula RPC server
  * @param $method
  * @param $argument
  */
 function rpc_send($method, $argument)
 {
     //Using the XML-RPC extension to format the XML package
     $request = xmlrpc_encode_request($method, $argument);
     $req = curl_init($this->service_url);
     //Using the cURL extension to send it off,  first creating a custom header block
     $headers = array();
     array_push($headers, "Content-Type: text/xml");
     array_push($headers, "Content-Length: " . strlen($request));
     array_push($headers, "\r\n");
     //URL to post to
     curl_setopt($req, CURLOPT_URL, $this->service_url);
     //Setting options for a secure SSL based xmlrpc server
     curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($req, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($req, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($req, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($req, CURLOPT_POSTFIELDS, $request);
     //Finally run
     $response = curl_exec($req);
     //Close the cURL connection
     curl_close($req);
     //Decoding the response to be displayed
     $result = xmlrpc_decode($response);
     return $result;
 }
Example #5
0
 static function get_request($method, $params = CJ_EMPTY_VALUE, $params2 = CJ_EMPTY_VALUE, $params3 = CJ_EMPTY_VALUE, $params4 = CJ_EMPTY_VALUE, $params5 = CJ_EMPTY_VALUE)
 {
     $comp_params = JComponentHelper::getParams('com_joomdle');
     switch ($comp_params->get('moodle_version')) {
         case 20:
             if ($params == CJ_EMPTY_VALUE) {
                 $request = xmlrpc_encode_request("joomdle_" . $method, array(), array('encoding' => 'utf8'));
             } else {
                 if ($params2 == CJ_EMPTY_VALUE) {
                     $request = xmlrpc_encode_request("joomdle_" . $method, array($params), array('encoding' => 'utf8'));
                 } else {
                     if ($params3 == CJ_EMPTY_VALUE) {
                         $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2), array('encoding' => 'utf8'));
                     } else {
                         if ($params4 == CJ_EMPTY_VALUE) {
                             $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3), array('encoding' => 'utf8'));
                         } else {
                             if ($params5 == CJ_EMPTY_VALUE) {
                                 $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3, $params4), array('encoding' => 'utf8'));
                             } else {
                                 $request = xmlrpc_encode_request("joomdle_" . $method, array($params, $params2, $params3, $params4, $params5), array('encoding' => 'utf8'));
                             }
                         }
                     }
                 }
             }
             break;
         case 19:
             $request = xmlrpc_encode_request("auth/joomdle/auth.php/{$method}", array($params, $params2, $params3, $params4, $params5));
             //, array ('encoding' => 'utf8'));
             break;
     }
     return $request;
 }
Example #6
0
 public function __call($method, $params)
 {
     if (!function_exists('xmlrpc_encode_request')) {
         throw new \Exception("The php5-xmlrpc extension is not installed. Please install this to use this functionality");
     }
     $xml = xmlrpc_encode_request($method, $params);
     //\GO::debug($xml);
     if ($this->curl_hdl === null) {
         // Create cURL resource
         $this->curl_hdl = curl_init();
         // Configure options
         curl_setopt($this->curl_hdl, CURLOPT_URL, $this->uri);
         curl_setopt($this->curl_hdl, CURLOPT_HEADER, 0);
         curl_setopt($this->curl_hdl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($this->curl_hdl, CURLOPT_POST, true);
         curl_setopt($this->curl_hdl, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($this->curl_hdl, CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($this->curl_hdl, CURLOPT_TIMEOUT, 10);
         if (isset($this->_user)) {
             curl_setopt($this->curl_hdl, CURLOPT_USERPWD, $this->_user . ":" . $this->_pass);
         }
     }
     curl_setopt($this->curl_hdl, CURLOPT_POSTFIELDS, $xml);
     // Invoke RPC command
     $response = curl_exec($this->curl_hdl);
     $errorNo = curl_errno($this->curl_hdl);
     if ($errorNo) {
         throw new \Exception($this->_curlErrorCodes[$errorNo]);
     }
     //\GO::debug($response);
     $result = xmlrpc_decode_request($response, $method);
     return $result;
 }
 /** {@inheritdoc} */
 public function serialize($method, array $params = [])
 {
     $toBeVisited = [&$params];
     while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
         $type = gettype($value);
         if ($type === 'array') {
             foreach ($value as &$child) {
                 $toBeVisited[] =& $child;
             }
         } elseif ($type === 'object') {
             if ($value instanceof DateTime) {
                 $value = $value->format('Ymd\\TH:i:s');
                 xmlrpc_set_type($value, 'datetime');
             } elseif ($value instanceof Base64Interface) {
                 $value = $value->getDecoded();
                 xmlrpc_set_type($value, 'base64');
             } else {
                 $value = get_object_vars($value);
             }
         } elseif ($type === 'resource') {
             throw SerializationException::invalidType($value);
         }
         array_shift($toBeVisited);
     }
     return xmlrpc_encode_request($method, $params, ['encoding' => 'UTF-8', 'escaping' => 'markup', 'verbosity' => 'no_white_space']);
 }
Example #8
0
 function onStartNoticeSave($notice)
 {
     $args = $this->testArgs($notice);
     common_debug("Blogspamnet args = " . print_r($args, TRUE));
     $request = xmlrpc_encode_request('testComment', array($args));
     $context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml\r\n" . "User-Agent: " . $this->userAgent(), 'content' => $request)));
     $file = file_get_contents($this->baseUrl, false, $context);
     $response = xmlrpc_decode($file);
     if (xmlrpc_is_fault($response)) {
         throw new ServerException("{$response['faultString']} ({$response['faultCode']})", 500);
     } else {
         common_debug("Blogspamnet results = " . $response);
         if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) {
             throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500);
         } else {
             if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) {
                 throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400);
             } else {
                 if (preg_match('/^OK$/', $response)) {
                     // don't do anything
                 } else {
                     throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500);
                 }
             }
         }
     }
     return true;
 }
function xmlrpc_request($host, $port, $location, $function, &$request_data)
{
    /*
     * This method sends a very basic XML-RPC request. $host, $port, $location,
     * and $function are pretty simple. $request_data can be any PHP type,
     * and this function returns the PHP type of whatever the xmlrpc function
     * returns.
     *
     * WARNING: This function dies upon failure.
     */
    // Send request
    $request_xml = xmlrpc_encode_request($function, $request_data);
    // Split out response into headers, and xml
    $response = urlpost($host, $port, $location, $request_xml);
    $response_array = split("\r\n\r\n", $response, 2);
    $response_headers = split("\r\n", $response_array[0]);
    $response_xml = $response_array[1];
    $http_array = split(" ", $response_headers[0], 3);
    if ($http_array[1] != "200") {
        trigger_error("xmlrpc request failed: ({$http_array[1]}, {$http_array[2]}) at {$host}:{$port} using {$location}");
    } else {
        // Get native PHP types and return them for data.
        $response_data = xmlrpc_decode_request($response_xml, $function);
        return $response_data;
    }
}
Example #10
0
 /**
  * @method sendRequest
  * @param string $remoteMethod
  * @param array $params
  * @return HttpRequest_Response_Xml 
  */
 public function sendRequest($remoteMethod, array $params)
 {
     $this->error = NULL;
     $request = xmlrpc_encode_request($remoteMethod, $params);
     $this->body = $request;
     return $this->request('CUSTOMPOST', $request);
 }
 /**
  * Provede volani funkce na captcha server
  *
  * @param string $methodName nazev metody
  * @param array $params parametry
  *
  * @return mixed    vysledek volani
  */
 protected function _call($methodName, $params = [])
 {
     if (!function_exists('xmlrpc_encode_request')) {
         throw new Exception("PHP XMLRPC extension neni nainstalovana");
     }
     $ch = curl_init(sprintf('http://%s:%d', $this->_serverHostname, $this->_serverPort));
     if (!$ch) {
         throw new Exception("Chyba volani curl_init");
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_POST, TRUE);
     if ($this->_proxyHostname) {
         curl_setopt($ch, CURLOPT_PROXY, $this->_proxyHostname);
         curl_setopt($ch, CURLOPT_PROXYPORT, $this->_proxyPort);
     }
     curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: text/xml", "charset=UTF-8"]);
     $request = xmlrpc_encode_request($methodName, $params, ['encoding' => 'UTF-8']);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     $response = curl_exec($ch);
     if ($response === FALSE) {
         throw new Exception("Chyba volani curl_exec");
     }
     $info = curl_getinfo($ch);
     if ($info['http_code'] != 200) {
         throw new Exception("Chyba volani curl_exec. HTTP status code " . $info['http_code']);
     }
     $response = xmlrpc_decode($response, 'UTF-8');
     if (empty($response) || xmlrpc_is_fault($response)) {
         throw new Exception(sprintf("XMLRPC error: %s", print_r($response, TRUE)));
     }
     return $response;
 }
 function onStartNoticeSave($notice)
 {
     $args = $this->testArgs($notice);
     common_debug("Blogspamnet args = " . print_r($args, TRUE));
     $requestBody = xmlrpc_encode_request('testComment', array($args));
     $request = new HTTPClient($this->baseUrl, HTTPClient::METHOD_POST);
     $request->setHeader('Content-Type', 'text/xml');
     $request->setBody($requestBody);
     $httpResponse = $request->send();
     $response = xmlrpc_decode($httpResponse->getBody());
     if (xmlrpc_is_fault($response)) {
         throw new ServerException("{$response['faultString']} ({$response['faultCode']})", 500);
     } else {
         common_debug("Blogspamnet results = " . $response);
         if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) {
             throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500);
         } else {
             if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) {
                 throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400);
             } else {
                 if (preg_match('/^OK$/', $response)) {
                     // don't do anything
                 } else {
                     throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500);
                 }
             }
         }
     }
     return true;
 }
Example #13
0
 /**
  * Ping Blog Update Services
  *
  * @param array $options are name, website, url
  */
 function ping($options = array())
 {
     $type = 'REST';
     if (function_exists('xmlrpc_encode_request')) {
         $type = 'XML-RPC';
     }
     switch ($type) {
         case 'REST':
             // construct parameters
             $params = array('name' => $options['name'], 'url' => $options['url']);
             $params = array_map('rawurlencode', $params);
             $paramString = http_build_query($params);
             // Rest Update Ping Services
             foreach ($this->__services['rest'] as $serviceApi) {
                 $requestUrl = $serviceApi . '?' . $paramString;
                 $response = file_get_contents($requestUrl);
             }
             break;
         case 'XML-RPC':
             // construct parameters
             $params = array($options['name'], $options['website'], $options['url'], $options['feed']);
             $request = xmlrpc_encode_request("weblogUpdates.extendedPing", $params);
             $context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
             foreach ($this->__services['rpc'] as $endPoint) {
                 // Ping the services
                 $file = file_get_contents($endPoint, false, $context);
                 $response = xmlrpc_decode($file);
                 //no need to process the response
             }
             break;
     }
 }
Example #14
0
 /**
  * rpc_call function.
  * 
  * @access public
  * @param string $method. (default: '')
  * @param array $params. (default: array())
  * @return void
  */
 function rpc_call($method = '', $params = array())
 {
     $request = new WP_Http();
     if (function_exists('xmlrpc_encode_request')) {
         $params = xmlrpc_encode_request($method, $params);
     }
     return $request->request($this->getServiceUrl(), array('method' => 'POST', 'body' => $params));
 }
Example #15
0
 /**
  * Sends an XML RPC request to the XML RPC server
  * @param $methodName string Name of the XML RPC method to call
  * @param $params array Array of parameters to pass to the XML RPC method. Type is detected automatically. For a struct just encode an array within $params.
  * @return array Array of returned parameters
  */
 public function send($methodName, $params)
 {
     $request = xmlrpc_encode_request($methodName, $params);
     $response = $this->sendRequest($request);
     $response = xmlrpc_decode(trim($response));
     //Without the trim function returns null
     return $response;
 }
Example #16
0
 /**
  * Call server RPC method
  * 
  * @param string method name
  * @param array arguments
  * @return string
  */
 function __call($function, $argv)
 {
     $request = xmlrpc_encode_request($function, $argv);
     $headers = array('Content-Type: text/xml', 'Content-Length: ' . strlen($request) . "\r\n\r\n" . $request);
     $this->SetHeaders($headers);
     $this->Fetch($this->Host, array(), true);
     return xmlrpc_decode($this->Result);
 }
 public function request($function, array $parameters = null)
 {
     $request = \xmlrpc_encode_request($function, $parameters);
     $context = \stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
     $file = \file_get_contents($this->imgSeekUrl . '/RPC', false, $context);
     $response = \xmlrpc_decode($file);
     return $response;
 }
Example #18
0
 /**
  * @param string URL
  * @param string method to call
  * @param string method's arguments
  */
 function __construct($url, $method, $params)
 {
     if (!function_exists('xmlrpc_encode_request')) {
         return Error::raise(_t('xmlrpc extension not found'));
     }
     $this->url = $url;
     $this->method = $method;
     $this->params = $params;
     $this->request_body = xmlrpc_encode_request($method, $params);
 }
Example #19
0
 /**
  * Replacement for "xmlrpc_encode_request"
  * @param $psString
  * @param array $parrArray
  * @return string
  * @author Progi1984
  */
 private function fnXmlRpcEncodeRequest($psString, array $parrArray)
 {
     if ($this->extPHPXMLRPC == true) {
         return xmlrpc_encode_request($psString, $parrArray);
     } else {
         $psReturn = '<?xml version="1.0" encoding="iso-8859-1"?>';
         $psReturn .= '<methodCall><methodName>' . $psString . '</methodName><params/></methodCall>';
         return $psReturn;
     }
 }
Example #20
0
 public function call($method, $params = null)
 {
     $postData = xmlrpc_encode_request($method, $params);
     $httpHeader = array('Content-Type: text/xml;charset=UTF-8');
     $curlResult = CURL::post($this->url, $postData, $httpHeader);
     if ($curlResult === 'Error') {
         return [];
     }
     return xmlrpc_decode($curlResult);
 }
 public static function sendPingback($from, $to, $server){
   $request = xmlrpc_encode_request('pingback.ping', array($from,  $to));
   $curl = curl_init($server);
   curl_setopt($curl, CURLOPT_POST, true);
   curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   $response = curl_exec($curl);
   curl_close($curl);
   return $response;
 }
 public static function sendPingback($endpoint, $source, $target)
 {
     $payload = xmlrpc_encode_request('pingback.ping', array($source, $target));
     $response = static::_post($endpoint, $payload, array('Content-type: application/xml'));
     if (is_array(xmlrpc_decode($response))) {
         return false;
     } elseif (is_string($response) && !empty($response)) {
         return true;
     }
 }
Example #23
0
/**
 * Get the remote machine's SSL Cert
 *
 * @param  string  $uri     The URI of a file on the remote computer, including
 *                          its http:// or https:// prefix
 * @return string           A PEM formatted SSL Certificate.
 */
function mnet_get_public_key($uri, $application = null)
{
    global $CFG, $MNET;
    // The key may be cached in the mnet_set_public_key function...
    // check this first
    $key = mnet_set_public_key($uri);
    if ($key != false) {
        return $key;
    }
    if (empty($application)) {
        $application = get_record('mnet_application', 'name', 'moodle');
    }
    $rq = xmlrpc_encode_request('system/keyswap', array($CFG->wwwroot, $MNET->public_key, $application->name), array("encoding" => "utf-8"));
    $ch = curl_init($uri . $application->xmlrpc_server_url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Moodle');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $rq);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8"));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $res = xmlrpc_decode(curl_exec($ch));
    // check for curl errors
    $curlerrno = curl_errno($ch);
    if ($curlerrno != 0) {
        debugging("Request for {$uri} failed with curl error {$curlerrno}");
    }
    // check HTTP error code
    $info = curl_getinfo($ch);
    if (!empty($info['http_code']) and $info['http_code'] != 200) {
        debugging("Request for {$uri} failed with HTTP code " . $info['http_code']);
    }
    curl_close($ch);
    if (!is_array($res)) {
        // ! error
        $public_certificate = $res;
        $credentials = array();
        if (strlen(trim($public_certificate))) {
            $credentials = openssl_x509_parse($public_certificate);
            $host = $credentials['subject']['CN'];
            if (strpos($uri, $host) !== false) {
                mnet_set_public_key($uri, $public_certificate);
                return $public_certificate;
            } else {
                debugging("Request for {$uri} returned public key for different URI - {$host}");
            }
        } else {
            debugging("Request for {$uri} returned empty response");
        }
    } else {
        debugging("Request for {$uri} returned unexpected result");
    }
    return false;
}
Example #24
0
function ping_broadcast_notice($notice)
{
    if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) {
        return true;
    }
    # Array of servers, URL => type
    $notify = common_config('ping', 'notify');
    $profile = $notice->getProfile();
    $tags = ping_notice_tags($notice);
    foreach ($notify as $notify_url => $type) {
        switch ($type) {
            case 'xmlrpc':
            case 'extended':
                $req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), common_local_url('userrss', array('nickname' => $profile->nickname)), $tags));
                $request = HTTPClient::start();
                $request->setConfig('connect_timeout', common_config('ping', 'timeout'));
                $request->setConfig('timeout', common_config('ping', 'timeout'));
                try {
                    $httpResponse = $request->post($notify_url, array('Content-Type: text/xml'), $req);
                } catch (Exception $e) {
                    common_log(LOG_ERR, "Exception pinging {$notify_url}: " . $e->getMessage());
                    continue;
                }
                if (!$httpResponse || mb_strlen($httpResponse->getBody()) == 0) {
                    common_log(LOG_WARNING, "XML-RPC empty results for ping ({$notify_url}, {$notice->id}) ");
                    continue;
                }
                $response = xmlrpc_decode($httpResponse->getBody());
                if (is_array($response) && xmlrpc_is_fault($response)) {
                    common_log(LOG_WARNING, "XML-RPC error for ping ({$notify_url}, {$notice->id}) " . "{$response['faultString']} ({$response['faultCode']})");
                } else {
                    common_log(LOG_INFO, "Ping success for {$notify_url} {$notice->id}");
                }
                break;
            case 'get':
            case 'post':
                $args = array('name' => $profile->nickname, 'url' => common_local_url('showstream', array('nickname' => $profile->nickname)), 'changesURL' => common_local_url('userrss', array('nickname' => $profile->nickname)));
                $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
                if ($type === 'get') {
                    $result = $fetcher->get($notify_url . '?' . http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
                } else {
                    $result = $fetcher->post($notify_url, http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
                }
                if ($result->status != '200') {
                    common_log(LOG_WARNING, "Ping error for '{$notify_url}' ({$notice->id}): " . "{$result->body}");
                } else {
                    common_log(LOG_INFO, "Ping success for '{$notify_url}' ({$notice->id}): " . "'{$result->body}'");
                }
                break;
            default:
                common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
        }
    }
    return true;
}
Example #25
0
 /**
  * Ping
  *
  * @param string $siteName
  * @param string $homepage
  * @param string $url
  * @param string $rss
  * @param string $encoding
  * @return boolean
  */
 public function ping($siteName, $homepage, $url, $rss, $encoding = 'UTF-8')
 {
     $request = xmlrpc_encode_request('weblogUpdates.extendedPing', array($siteName, $homepage, $url, $rss), ['encoding' => $encoding]);
     $response = $this->post($this->serverUrl, $request);
     $result = strpos($response, "<boolean>0</boolean>") ? true : false;
     if ($result) {
         \Yii::getLogger()->log('Ping Yandex success.', Logger::LEVEL_WARNING);
     } else {
         \Yii::getLogger()->log('Ping Yandex failure.', Logger::LEVEL_WARNING);
     }
 }
Example #26
0
 /**
  * Run an XMLRPC command. Name should be a query name and params an array of parameters, eg:
  * $this->raw("checkAuthentication", ["adam", "qwerty"]);
  * If successful returns back an array of useful information.
  *
  * Note that $params["id"] is reserved for query ID, you may set it to something if you wish.
  * If you do, the same ID will be passed back with the reply from Anope.
  *
  * @param $name
  * @param $params
  * @return array|null
  */
 public function run($name, $params)
 {
     $xmlquery = xmlrpc_encode_request($name, $params);
     $context = stream_context_create(["http" => ["method" => "POST", "header" => "Content-Type: text/xml", "content" => $xmlquery]]);
     $inbuf = file_get_contents($this->host, false, $context);
     $response = xmlrpc_decode($inbuf);
     if ($response) {
         return $response;
     }
     return null;
 }
 /**
  * Calls the method on the server with the given parameters
  *
  * @param  string $method       The method name
  * @param  array  $parameters   The argument parameters for the method
  *
  * @return string
  */
 protected function call($method, array $parameters = array())
 {
     $request = xmlrpc_encode_request($method, $parameters);
     $context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
     $contents = $this->fileRetriever->retrieveContents($this->getDSN(), $context);
     $response = xmlrpc_decode($contents);
     if ($response && is_array($response) && xmlrpc_is_fault($response)) {
         trigger_error("xmlrpc: {$response['faultString']} ({$response['faultCode']})");
     }
     return $response;
 }
Example #28
0
 function normalValidate($command, $la, $code)
 {
     $request = xmlrpc_encode_request("validate", array($command, $la, AV_LOGIN, AV_PASSWD, $code));
     $context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
     $file = file_get_contents(AV_RPC_URL, false, $context);
     $response = xmlrpc_decode($file);
     if (xmlrpc_is_fault($response)) {
         return false;
     }
     return $response['status'] == "OK";
 }
Example #29
0
 function send_request($requestname, $params)
 {
     $request = xmlrpc_encode_request($requestname, $params);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
     $results = curl_exec($ch);
     curl_close($ch);
     return $results;
 }
 public function __call($method, $params)
 {
     if ($this->namespace) {
         $method = $this->namespace . '.' . $method;
     }
     $this->request->setRawPostData(xmlrpc_encode_request($method, $params));
     $response = $this->request->send();
     if ($response->getResponseCode() != 200) {
         throw new Exception($response->getBody(), $response->getResponseCode());
     }
     return xmlrpc_decode($response->getBody(), 'utf-8');
 }