function drawMachines() { $cli = new XML_RPC_Client('/RPCSERVER', 'localhost', 5000); $msg = new XML_RPC_Message('listMachines'); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $machines = $resp->value(); $i = $machines->arraysize(); #$i = 1; while ($i--) { $m = XML_RPC_decode($machines->arraymem($i)); echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'> <ul id='menu'>\n <li ><p>{$m}\n <span id='span{$m}'>\n <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n <input type='submit' value='Save'>\n\n <input id='sName{$m}' type='text' value='SUT_NAME' style='text-align:right; clear:both; float:left; width:12em;'/>\n <input id='sValue{$m}' type='text' value='Value'/>\n\n\n "; $params = array(new XML_RPC_Value($m, 'string')); $msg = new XML_RPC_Message('getConfig', $params); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $cfgTable = $resp->value(); $j = $cfgTable->arraysize(); while ($j--) { $cfgEntry = $cfgTable->arraymem($j); $cfgEntry->structreset(); $symbol = XML_RPC_decode($cfgEntry->structmem("symbol")); $value = XML_RPC_decode($cfgEntry->structmem("val")); echo "<b>{$symbol}</b>"; echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n"; } echo "\n\n </span></p>\n </li>\n </ul>\n\n</form>"; } }
function drawMachines() { $cli = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]); $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct"); $msg = new XML_RPC_Message('listMachines', array($req)); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $machines = $resp->value(); $i = $machines->arraysize(); while ($i--) { $m = XML_RPC_decode($machines->arraymem($i)); echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'>\n <ul class='menu' >\n <li >\n <p onclick='javascript:toggleSpan(\"span{$m}\");' >{$m}<br/><span id='span{$m}'>{$m}\n <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n <input type='submit' value='Save'><br style='clear:both'>\n <a href='setup_machine.php?machine={$m}'><em class='butt'>Setup</em></a>\n <a href='start_manager.php?machine={$m}'><input type='button' value='StartManager'></a><br>\n\n <input id='sName{$m}' type='text' value='SUT_NAME' style='clear:both; float:left; width:25%;'/>\n <input id='sValue{$m}' type='text' value='Value'/><br>"; $params = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string'), "sut_machine" => new XML_RPC_Value($m, 'string')), "struct"); $msg = new XML_RPC_Message('getConfig', array($params)); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $cfgTable = $resp->value(); $j = $cfgTable->arraysize(); while ($j--) { $cfgEntry = $cfgTable->arraymem($j); $cfgEntry->structreset(); $symbol = XML_RPC_decode($cfgEntry->structmem("symbol")); $value = XML_RPC_decode($cfgEntry->structmem("val")); echo "<b>{$symbol}</b>"; echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n"; } echo " </span></p>\n </li> </ul> </form>"; } }
public function onLoad($param) { parent::onLoad($param); if (!$this->isPostBack) { $deviceId = $this->Request["deviceId"]; $cmd = $this->db->createCommand("SELECT * FROM `hr_horux_media` WHERE id_device=:id"); $cmd->bindParameter(":id", $deviceId, PDO::PARAM_STR); $row = $cmd->query(); $row = $row->read(); require_once 'XML/RPC.php'; $client = new XML_RPC_Client("RPC2", $row["ip"], $row["port"]); $msg = new XML_RPC_Message("horuxInfoDisplay.getMediaList"); @($response = $client->send($msg)); if ($response) { if (!$response->faultCode()) { $v = $response->value(); $result = explode(",", html_entity_decode($v->scalarval())); $media = array(); foreach ($result as $k => $v) { $media[] = array("Value" => $v, "Text" => $v); } $this->media->DataTextField = 'Text'; $this->media->DataValueField = 'Value'; $this->media->DataSource = $media; $this->media->dataBind(); if (count($media) > 0) { $this->media->setSelectedIndex(0); } } else { $content_error = "ERROR - "; $content_error .= "Code: " . $response->faultCode() . " Reason '" . $response->faultString() . "'<br/>"; } } } }
/** * function that takes an address object and gets the latitude / longitude for this * address. Note that at a later stage, we could make this function also clean up * the address into a more valid format * * @param object $address * * @return boolean true if we modified the address, false otherwise * @static */ function format(&$values) { require_once 'CRM/Utils/Address.php'; // we need a valid zipcode, state and country, else we ignore if (!CRM_Utils_Array::value('postal_code', $values) && !CRM_Utils_Array::value('state_province', $values) && !CRM_Utils_Array::value('country', $values)) { return false; } if ($values['country'] != 'United States') { return false; } $string = CRM_Utils_Address::format($values); $string = str_replace("\n", ', ', $string); if (!$string) { return false; } $params = array(new XML_RPC_Value($string, 'string')); $message = new XML_RPC_Message('geocode', $params); $client = new XML_RPC_Client($GLOBALS['_CRM_UTILS_GEOCODE_RPC']['_uri'], $GLOBALS['_CRM_UTILS_GEOCODE_RPC']['_server']); $response = $client->send($message); if (!$response && !$response->faultCode()) { return false; } $data = XML_RPC_decode($response->value()); if (!CRM_Utils_Array::value(0, $data)) { return false; } $data = $data[0]; $values['geo_code_1'] = $data['lat']; $values['geo_code_2'] = $data['long']; return true; }
/** * @access private * @static */ function sendRPC($method, $params = array()) { global $mwBlockerHost, $mwBlockerPort, $mwBlockerDebug; $client = new XML_RPC_Client('/Blocker', $mwBlockerHost, $mwBlockerPort); if ($mwBlockerDebug) { $client->debug = true; } $rpcParams = array_map(array('MWBlocker', 'outParam'), $params); $message = new XML_RPC_Message($method, $rpcParams); wfSuppressWarnings(); $start = wfTime(); $result = $client->send($message); $delta = wfTime() - $start; wfRestoreWarnings(); $debug = sprintf("MWBlocker::sendRPC for %s took %0.2fms\n", $method, $delta * 1000.0); wfDebug($debug); if ($mwBlockerDebug) { echo $debug; } if (!is_object($result)) { throw new MWException("Unknown XML-RPC error"); } elseif ($result->faultCode()) { throw new MWException($result->faultCode() . ': ' . $result->faultString()); } else { $value = $result->value(); return $value->getval(); } }
/** * Method to get a specific wiki page in HTML * * @param string $pagename * @return string HTML */ public function grabTracWikiPageHTML($pagename) { $msg = new XML_RPC_Message('wiki.getPageHTML', array(new XML_RPC_Value($pagename, "string"))); $cli = new XML_RPC_Client($this->tracURL, $this->tracServ); $cli->setDebug(0); // send the request message $resp = $cli->send($msg); if (!$resp) { throw new customException($this->objLanguage->languageText("mod_filters_commserr", "filters") . ": " . $cli->errstr); exit; } if (!$resp->faultCode()) { $val = $resp->value(); $val = XML_RPC_decode($val); if (is_array($val)) { return $val['faultString']; } else { return $val; } } else { /* * Display problems that have been gracefully caught and * reported by the xmlrpc server class. */ throw new customException($this->objLanguage->languageText("mod_filters_faultcode", "filters") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_filters_faultreason", "filters") . ": " . $resp->faultString()); } }
/** * This is the core XML-RPC client it takes the parameters passed in and bundles them up * and sends them as an XML-RPC request to the origin server, which processes them against * the central database and passes the results back to this client * * @param string $function The name of the remote origin function to be called * @param array $params An array of the parameters to be passed to the origin function * @return mixed The decoded response from the origin server */ function getFromOrigin($function, $params) { /** * @package MaxDal * @subpackage Delivery * @author Chris Nutting <*****@*****.**> * */ $conf = $GLOBALS['_MAX']['CONF']; // Create an XML-RPC client to talk to the XML-RPC server $client = new XML_RPC_Client($conf['origin']['script'], $conf['origin']['host'], $conf['origin']['port']); $message = new XML_RPC_Message($function, array()); // Add the parameters to the message $message->addParam(new XML_RPC_Value($params, $GLOBALS['XML_RPC_String'])); // Send the XML-RPC message to the server $response = $client->send($message, $conf['origin']['timeout'], $conf['origin']['protocol']); if (!$response || $response->faultCode() != 0) { if (defined('OA_DELIVERY_CACHE_FUNCTION_ERROR')) { return OA_DELIVERY_CACHE_FUNCTION_ERROR; } else { return null; } } else { // Decode the serialized response $value = $response->value(); $value = $value->scalarval(); $value = unserialize($value); } return $value; }
/** * Method to get a specific wiki page in HTML * * @param string $pagename * @return string HTML */ public function fullGraph() { $msg = new XML_RPC_Message('dlGraphFull'); $pserv = $this->objSysConfig->getValue('package_server', 'packages'); $purl = $this->objSysConfig->getValue('package_url', 'packages'); $cli = new XML_RPC_Client($purl, $pserv); $cli->setDebug(0); // send the request message $resp = $cli->send($msg); if (!$resp) { throw new customException($this->objLanguage->languageText("mod_filters_commserr", "filters") . ": " . $cli->errstr); exit; } if (!$resp->faultCode()) { $val = $resp->value(); $val = XML_RPC_decode($val); if (is_array($val)) { return $val['faultString']; } else { return $val; } } else { /* * Display problems that have been gracefully caught and * reported by the xmlrpc server class. */ throw new customException($this->objLanguage->languageText("mod_filters_faultcode", "filters") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_filters_faultreason", "filters") . ": " . $resp->faultString()); } }
public function onReloadDisplay($sender, $param) { require_once 'XML/RPC.php'; $client = new XML_RPC_Client("RPC2", "localhost", 7000); $msg = new XML_RPC_Message("horuxInfoDisplay.reload"); @($response = $client->send($msg)); }
function createPublisher($sessionId, $publisherName) { // Add new Publisher $oPublisher = new XML_RPC_VALUE(array('agencyid' => new XML_RPC_Value(1, 'int'), 'publisherName' => new XML_RPC_Value($publisherName, 'string'), 'contactName' => new XML_RPC_Value('Ian', 'string'), 'emailAddress' => new XML_RPC_Value('*****@*****.**', 'string'), 'username' => new XML_RPC_Value('rishad', 'string'), 'password' => new XML_RPC_Value('rishad', 'string')), 'struct'); $aParams1 = array(new XML_RPC_Value($sessionId, 'string'), $oPublisher); $oMessage1 = new XML_RPC_Message('addPublisher', $aParams1); $oClient1 = new XML_RPC_Client($this->publisherRpcWebServiceUrl, $this->xmlRpcHost); $oResponse1 = $oClient1->send($oMessage1); $publisherID = $this->returnXmlRpcResponseData($oResponse1); echo 'Publisher' . $publisherID . '<br>'; return $publisherID; }
function get_firmware_version($return_php = true) { global $g; $versioncheck_base_url = "www.pfsense.com"; $versioncheck_path = "/pfSense/xmlrpc.php"; $params = array("pkg" => 'all', "info" => array('version', 'name')); $msg = new XML_RPC_Message('pfsense.get_pkgs', array(php_value_to_xmlrpc($params))); $cli = new XML_RPC_Client($versioncheck_path, $versioncheck_base_url); $resp = $cli->send($msg); $raw_versions = $resp->value(); return xmlrpc_value_to_php($raw_versions); }
function get_firmware_version($return_php = true) { global $g; $versioncheck_base_url = "packages.pfsense.org"; $versioncheck_path = "/xmlrpc.php"; $params = array("pkg" => 'all', "info" => array('version', 'name'), "freebsd_version" => "10", "freebsd_machine" => "amd64"); $msg = new XML_RPC_Message('pfsense.get_pkgs', array(php_value_to_xmlrpc($params))); $cli = new XML_RPC_Client($versioncheck_path, $versioncheck_base_url); $resp = $cli->send($msg); $raw_versions = $resp->value(); return xmlrpc_value_to_php($raw_versions); }
protected function setData() { $cmd = $this->db->createCommand("SELECT * FROM hr_horux_media_media WHERE id=:id"); $cmd->bindParameter(":id", $this->id->Value, PDO::PARAM_INT); $query = $cmd->query(); if ($query) { $data = $query->read(); $this->id->Value = $data['id']; $this->name->Text = $data['name']; $deviceId = $data['id_device']; $cmd = $this->db->createCommand("SELECT * FROM `hr_horux_media` WHERE id_device=:id"); $cmd->bindParameter(":id", $deviceId, PDO::PARAM_STR); $row = $cmd->query(); $row = $row->read(); require_once 'XML/RPC.php'; $client = new XML_RPC_Client("RPC2", $row["ip"], $row["port"]); $msg = new XML_RPC_Message("horuxInfoDisplay.getMediaList"); @($response = $client->send($msg)); if ($response) { if (!$response->faultCode()) { $v = $response->value(); $result = explode(",", html_entity_decode($v->scalarval())); $media = array(); foreach ($result as $k => $v) { $media[] = array("Value" => $v, "Text" => $v); } $this->media->DataTextField = 'Text'; $this->media->DataValueField = 'Value'; $this->media->DataSource = $media; $this->media->dataBind(); if (count($media) > 0) { $this->media->setSelectedValue($data['path']); } } else { $content_error = "ERROR - "; $content_error .= "Code: " . $response->faultCode() . " Reason '" . $response->faultString() . "'<br/>"; } } $this->during->Text = $data['time']; if ($data['type'] == "IMAGE") { $this->picture->setChecked(true); } if ($data['type'] == "MOVIE") { $this->movie->setChecked(true); } } }
function fetchData($username, $password) { $rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net'); $rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string"))); // Error Checking howto ??? $result = $rpc->send($rpc_message); $value = $result->value(); $userinfo = xml_rpc_decode($value); if ($userinfo['password'] == md5($password)) { $this->activeUser = $userinfo['handle']; foreach ($userinfo as $uk => $uv) { $this->_auth_obj->setAuthData($uk, $uv); } return true; } return false; }
function sendPing() { if (!$this->Commonping_Target) { return false; } // parse URL $parsedURL = parse_url($this->Commonping_Target); // send ping $client = new XML_RPC_Client($parsedURL["path"], $parsedURL["host"], 80); $this->Server_Response = $client->send($this->Ping_XML); // result if (get_class($this->Server_Response) == strtolower("XML_RPC_Response") && $this->Server_Response->faultCode() == false) { return true; } else { return false; } }
function authenticate($username, $password) { /* check it's livejournal.com */ $email = ''; $struct = new XML_RPC_Value(array('username' => new XML_RPC_Value($username, 'string'), 'hpassword' => new XML_RPC_Value(md5($password), 'string')), 'struct'); $message = new XML_RPC_Message('LJ.XMLRPC.login'); $message->addparam($struct); $client = new XML_RPC_Client('/interface/xmlrpc', 'www.livejournal.com', 80); $result = $client->send($message, 5); if ($result && !$result->faultCode()) { /* Carefuly noting that no LJ API returns the email address, */ /* because they suck. */ return true; } else { return false; } }
/** * Check for spam links * * @param string $post post to check for spam * @return boolean true = spam found, false = no spam * * Note: Also returns 'false' in case of problems communicating with SLV. * Error messages are logged in Geeklog's error.log * */ function CheckForSpam($post) { global $_SPX_CONF; require_once 'XML/RPC.php'; $retval = false; if (empty($post)) { return $retval; } $links = $this->prepareLinks($post); if (empty($links)) { return $retval; } if (!isset($_SPX_CONF['timeout'])) { $_SPX_CONF['timeout'] = 5; // seconds } if ($this->_verbose) { SPAMX_log("Sending to SLV: {$links}"); } $params = array(new XML_RPC_Value($links, 'string')); $msg = new XML_RPC_Message('slv', $params); $cli = new XML_RPC_Client('/slv.php', 'http://www.linksleeve.org'); if ($this->_debug) { $client->setDebug(1); } $resp = $cli->send($msg, $_SPX_CONF['timeout']); if (!$resp) { COM_errorLog('Error communicating with SLV: ' . $cli->errstr . '; Message was ' . $msg->serialize()); } else { if ($resp->faultCode()) { COM_errorLog('Error communicating with SLV. Fault code: ' . $resp->faultCode() . ', Fault reason: ' . $resp->faultString() . '; Message was ' . $msg->serialize()); } else { $val = $resp->value(); // note that SLV returns '1' for acceptable posts and '0' for spam if ($val->scalarval() != '1') { $retval = true; SPAMX_log("SLV: spam detected"); } else { if ($this->_verbose) { SPAMX_log("SLV: no spam detected"); } } } } return $retval; }
/** * The function that actually sends an XML-RPC request to the server, handles * errors accordingly and returns the appropriately decoded data sent as response * from the server. * * @param XML_RPC_Message $request An appropriately encoded XML-RPC message * that needs to be sent as a request to the * server. * @param XML_RPC_Client $client The XML-RPC client as which the request * is to be sent. * * @return Array The appropriately decoded response sent by the server. */ public static function sendRequest($request, $client) { $response = $client->send($request); if (!$response) { throw new Services_Blogging_Exception('XML-RPC communication error: ' . $client->errstr); } else { if ($response->faultCode() != 0) { throw new Services_Blogging_Exception($response->faultString(), $response->faultCode()); } } $value = XML_RPC_Decode($response->value()); if (!is_array($value) || !isset($value['faultCode'])) { return $value; } else { throw new Services_Blogging_Exception($value['faultString'], $value['faultCode']); } }
function get_firmware_version($return_php = true) { global $g; $versioncheck_base_url = "packages.pfsense.org"; $versioncheck_path = "/xmlrpc.php"; if (isset($config['system']['alt_firmware_url']['enabled']) and isset($config['system']['alt_firmware_url']['versioncheck_base_url'])) { $versioncheck_base_url = $config['system']['alt_firmware_url']['versioncheck_base_url']; } $params = array("platform" => "pfSense", "firmware" => array("version" => "0.62.5", "branch" => "stable"), "kernel" => array("version" => "5.4"), "base" => array("version" => "5.4")); print_r($params); $msg = new XML_RPC_Message('pfsense.get_firmware_version', array(php_value_to_xmlrpc($params))); print "Formed message.\n"; $cli = new XML_RPC_Client($versioncheck_path, $versioncheck_base_url); print "Formed client.\n"; $cli->setDebug(1); $resp = $cli->send($msg); print "Message sent.\n"; $raw_versions = $resp->value(); return xmlrpc_value_to_php($raw_versions); }
function UPMS_getNextVersion($aServer) { // Create the XML-RPC message $message = new XML_RPC_Message('OXUPMS.getNextID'); // Create an XML-RPC client to talk to the XML-RPC server $client = new XML_RPC_Client($aServer['path'], $aServer['host'], $aServer['port']); $client->debug = 0; // Send the XML-RPC message to the server $response = $client->send($message, 60, 'http'); // Was the response OK? if ($response && $response->faultCode() == 0) { $result = XML_RPC_decode($response->value()); return $result; } else { if ($response->faultCode() > 0) { $result = $response->faultString(); } } return $result; }
public function grabWikiPage($pagename, $wikiname, $url = '/index.php?module=api', $serv = 'fsiu.uwc.ac.za') { $msg = new XML_RPC_Message('chiswiki.getPage', array(new XML_RPC_Value($pagename, "string"), new XML_RPC_Value($wikiname, "string"))); $cli = new XML_RPC_Client($url, $serv); $cli->setDebug(0); // send the request message $resp = $cli->send($msg); if (!$resp) { throw new customException($this->objLanguage->languageText("mod_filters_commserr", "filters") . ": " . $cli->errstr); exit; } if (!$resp->faultCode()) { $val = $resp->value(); return $val->serialize($val); } else { /* * Display problems that have been gracefully caught and * reported by the xmlrpc server class. */ throw new customException($this->objLanguage->languageText("mod_filters_faultcode", "filters") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_filters_faultreason", "filters") . ": " . $resp->faultString()); } }
function undorg_isDisposableHost($input) { $params = array(new XML_RPC_Value($input, 'string')); $msg = new XML_RPC_Message('isDisposableHost', $params); $cli = new XML_RPC_Client('/services/xmlrpc/isDisposableHost/index.php', 'www.undisposable.org'); $resp = $cli->send($msg); if (!$resp) { echo 'Communication error: ' . $cli->errstr; exit; } if (!$resp->faultCode()) { $val = $resp->value(); return $val->getVal(); } else { /* * Display problems that have been gracefully cought and * reported by the xmlrpc.php script. */ // echo 'Fault Code: ' . $resp->faultCode() . "\n"; // echo 'Fault Reason: ' . $resp->faultString() . "\n"; return false; } }
function authenticate($username, $password) { $email = ''; $message = new XML_RPC_Message('blogger.getUserInfo', array(new XML_RPC_Value('XXXXXXXXXXXX', 'string'), new XML_RPC_Value($username, 'string'), new XML_RPC_Value($password, 'string'))); $client = new XML_RPC_Client('/api/', 'www.blogger.com', 80); $result = $client->send($message, 5, 'http'); if ($result && $result->faultString() == '') { // Get the email address: $value = $result->value(); // Blogger return faultcode = 0 for a login fail. // which the lib doesn't handle. Hence horrible stuff. $f = $value->structmem('faultString'); if ($f) { return false; } else { $value = $value->structmem('email'); $this->email = $value->scalarVal(); return true; } } else { return false; } }
function translate($lemma) { $lemma = strtolower($lemma); $targetLang = 'en'; $sourceLang = 'id'; $params = array(new XML_RPC_Value($lemma, 'string'), new XML_RPC_Value($sourceLang, 'string'), new XML_RPC_Value($targetLang, 'string'), new XML_RPC_Value(20, 'int')); $msg = new XML_RPC_Message('suggest3', $params); $cli = new XML_RPC_Client('/RPC2', 'open-tran.eu'); $resp = $cli->send($msg); if ($resp) { if (!$resp->faultCode()) { $val = $resp->value(); $data = XML_RPC_decode($val); foreach ($data as $value) { $matched = false; $text = strtolower(strip_tags($value['text'])); if (is_array($value['projects'])) { foreach ($value['projects'] as $orig) { if (strtolower(strip_tags($orig['orig_phrase'])) == $text) { $matched = true; break; } } } if ($matched) { $translation .= ($translation ? '; ' : '') . $text; } } } } if ($translation) { $ret = array('ref_source' => 'open-tran.eu', 'lemma' => $lemma, 'translation' => $translation); } // var_dump($ret); // die('<br /><br />a'); return $ret; }
/** * get node status * * @param array $data * @return node status id or FALSE */ function perform($data = FALSE) { // map methode related node date fields $methodeField = array('latestModified' => 'modifydate', 'latestPublished' => 'pubdate'); // start rpc client $client = new XML_RPC_Client("{$data['domainPath']}{$data['rpcServer']}", $data['domain'], $data['port']); //$client->setDebug(1); // set rpc methode and parameters $msg = new XML_RPC_Message($data['methode'], array(new XML_RPC_Value($data['authUser'], "string"), new XML_RPC_Value($data['authPasswd'], "string"), new XML_RPC_Value($data['numArticles'], "int"))); $response = $client->send($msg); if (!$response->faultCode()) { $data['error'] = false; $content = $response->value(); $max = $content->arraysize(); for ($i = 0; $i < $max; $i++) { // get element of the array $rec = $content->arraymem($i); // get the associative array value $data['result'][$i]['date'] = $rec->structmem($methodeField[$methode]); $data['result'][$i]['date'] = $article_date->scalarval(); $data['result'][$i]['overtitle'] = $rec->structmem('overtitle'); $data['result'][$i]['overtitle'] = $overtitle->scalarval(); $data['result'][$i]['id_article'] = $rec->structmem('id_article'); $data['result'][$i]['id_article'] = $id_article->scalarval(); $data['result'][$i]['title'] = $rec->structmem('title'); $data['result'][$i]['title'] = $title->scalarval(); $data['result'][$i]['subtitle'] = $rec->structmem('subtitle'); $data['result'][$i]['subtitle'] = $subtitle->scalarval(); $data['result'][$i]['description'] = $rec->structmem('description'); $data['result'][$i]['description'] = $description->scalarval(); } } else { $data['error'] = true; trigger_error('RPC call fault. \\nCode: ' . $response->faultCode() . '\\nReason: ' . $response->faultString(), E_USER_WARNING); } }
$url = "http://{$newvoucher['vouchersyncdbip']}"; } $execcmd = <<<EOF \t\t\t\t\$toreturn = array(); \t\t\t\t\$toreturn['voucher'] = \$config['voucher']['{$cpzone}']; \t\t\t\tunset(\$toreturn['vouchersyncport'], \$toreturn['vouchersyncpass'], \$toreturn['vouchersyncusername'], \$toreturn['vouchersyncdbip']); EOF; /* assemble xmlrpc payload */ $params = array(XML_RPC_encode($newvoucher['vouchersyncpass']), XML_RPC_encode($execcmd)); $port = $newvoucher['vouchersyncport']; log_error("voucher XMLRPC sync data {$url}:{$port}."); $msg = new XML_RPC_Message('pfsense.exec_php', $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass']); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); $input_errors[] = $error; } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, "250"); $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); $input_errors[] = $error; } else { log_error("The Captive Portal voucher database has been synchronized with {$url}:{$port} (pfsense.exec_php)."); }
function call($method) { $_args = $args = func_get_args(); $server_channel = $this->config->get('default_channel'); $channel = $this->_registry->getChannel($server_channel); if (!PEAR::isError($channel)) { $mirror = $this->config->get('preferred_mirror'); if ($channel->getMirror($mirror)) { if ($channel->supports('xmlrpc', $method, $mirror)) { $server_channel = $server_host = $mirror; // use the preferred mirror $server_port = $channel->getPort($mirror); } elseif (!$channel->supports('xmlrpc', $method)) { return $this->raiseError("Channel {$server_channel} does not " . "support xml-rpc method {$method}"); } } if (!isset($server_host)) { if (!$channel->supports('xmlrpc', $method)) { return $this->raiseError("Channel {$server_channel} does not support " . "xml-rpc method {$method}"); } else { $server_host = $server_channel; $server_port = $channel->getPort(); } } } else { return $this->raiseError("Unknown channel '{$server_channel}'"); } array_unshift($_args, $server_channel); // cache by channel $this->cache = $this->getCache($_args); $cachettl = $this->config->get('cache_ttl'); // If cache is newer than $cachettl seconds, we use the cache! if ($this->cache !== null && $this->cache['age'] < $cachettl) { return $this->cache['content']; } $fp = false; if (extension_loaded("xmlrpc")) { $result = call_user_func_array(array(&$this, 'call_epi'), $args); if (!PEAR::isError($result)) { $this->saveCache($_args, $result); } return $result; } elseif (!($fp = fopen('XML/RPC.php', 'r', true))) { return $this->raiseError("For this remote PEAR operation you need to load the xmlrpc extension or install XML_RPC"); } include_once 'XML/RPC.php'; if ($fp) { fclose($fp); } array_shift($args); $username = $this->config->get('username'); $password = $this->config->get('password'); $eargs = array(); foreach ($args as $arg) { $eargs[] = $this->_encode($arg); } $f = new XML_RPC_Message($method, $eargs); if ($this->cache !== null) { $maxAge = '?maxAge=' . $this->cache['lastChange']; } else { $maxAge = ''; } $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; if ($proxy = parse_url($this->config->get('http_proxy'))) { $proxy_host = isset($proxy['host']) ? $proxy['host'] : null; if (isset($proxy['scheme']) && $proxy['scheme'] == 'https') { $proxy_host = 'https://' . $proxy_host; } $proxy_port = isset($proxy['port']) ? $proxy['port'] : 8080; $proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null; $proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null; } $shost = $server_host; if ($channel->getSSL()) { $shost = "https://{$shost}"; } $c = new XML_RPC_Client('/' . $channel->getPath('xmlrpc') . $maxAge, $shost, $server_port, $proxy_host, $proxy_port, $proxy_user, $proxy_pass); if ($username && $password) { $c->setCredentials($username, $password); } if ($this->config->get('verbose') >= 3) { $c->setDebug(1); } $r = $c->send($f); if (!$r) { return $this->raiseError("XML_RPC send failed"); } $v = $r->value(); if ($e = $r->faultCode()) { if ($e == $GLOBALS['XML_RPC_err']['http_error'] && strstr($r->faultString(), '304 Not Modified') !== false) { return $this->cache['content']; } return $this->raiseError($r->faultString(), $e); } $result = XML_RPC_decode($v); $this->saveCache($_args, $result); return $result; }
public function getCoreZip($modName) { $msg = new XML_RPC_Message('getEngineUpgrade'); $cli = new XML_RPC_Client($this->mirrorurl, $this->mirrorserv, $this->port, $this->proxy['proxy_host'], $this->proxy['proxy_port'], $this->proxy['proxy_user'], $this->proxy['proxy_pass']); $cli->setDebug(0); // send the request message $resp = $cli->send($msg); //log_debug($resp); if (!$resp) { throw new customException($this->objLanguage->languageText("mod_packages_commserr", "packages") . ": " . $cli->errstr); exit; } if (!$resp->faultCode()) { $val = $resp->value(); return $val->serialize($val); } else { /* * Display problems that have been gracefully caught and * reported by the xmlrpc server class. */ throw new customException($this->objLanguage->languageText("mod_packages_faultcode", "packages") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_packages_faultreason", "packages") . ": " . $resp->faultString()); } }
} //include XMLRPC for php. (uses PEAR !) require_once "XML/RPC.php"; require_once "xmlrpcpln.php"; //connect to the server $XMLRPC = new XML_RPC_Client("/", $_SESSION["server"], 80); $XMLRPC->setCredentials($_SESSION["user"], sha1("irate" . sha1($_SESSION["pass"]))); // if there's a rating to do if (!empty($_REQUEST["rate_id"])) { $action = "irate.rate"; if ($_REQUEST["rate_rating"] == "-1") { //if -1 given, unrate the track $action = "irate.unrate"; } $msg = new XML_RPC_Message($action, array(XML_RPC_PLN::php2xmlrpc(array(array("id" => $_REQUEST["rate_id"], "rating" => $_REQUEST["rate_rating"]))))); $XMLRPC->send($msg); echo "<!-- XMLRPC CALL : \n" . $msg->serialize() . "\n -->"; //debug } //ask for all the previous ratings $msg = new XML_RPC_Message("irate.getRatings"); $rep = $XMLRPC->send($msg); $rated_tracks = XML_RPC_PLN::xmlrpc2php($rep->value()); echo "<!-- XMLRPC CALL : \n" . $msg->serialize() . "\n -->"; //debug //for each rated track, get metadata for ($i = 0; $i < count($rated_tracks); $i++) { $tracks_ids[$i] = array("id" => $rated_tracks[$i]["id"]); } $msg = new XML_RPC_Message("irate.getInfo", array(XML_RPC_PLN::php2xmlrpc($tracks_ids))); $rep = $XMLRPC->send($msg);
/** * Method to get a blog post from the metaweblog api * * @param string array $ar An array of parseable parameters * @param void * @return string */ private function getBlogPost($ar) { // get the server and url from the params if (isset($ar['server'])) { $this->server = $ar['server']; } else { $this->server = '127.0.0.1'; } if (isset($this->objExpar->endpoint)) { $this->url = $this->objExpar->endpoint . '/index.php?module=api'; } else { $this->url = '/index.php?module=api'; } // OK now get the post ID from the filter text. if (isset($ar['postid'])) { $this->postid = $ar['postid']; } else { $this->postid = NULL; } $params = array(new XML_RPC_Value($this->postid, "string"), new XML_RPC_Value('username', "string"), new XML_RPC_Value('password', "string")); // Create the message. $msg = new XML_RPC_Message('metaWeblog.getPost', $params); $cli = new XML_RPC_Client($this->url, $this->server, $this->port, $this->proxy['proxy_host'], $this->proxy['proxy_port'], $this->proxy['proxy_user'], $this->proxy['proxy_pass']); $cli->setDebug(0); // Send the request message. $resp = $cli->send($msg); if (!$resp) { throw new customException($this->objLanguage->languageText("mod_packages_commserr", "packages") . ": " . $cli->errstr); exit; } if (!$resp->faultCode()) { $val = $resp->value(); $xml = $val->serialize($val); $data = simplexml_load_string($xml); return $data->struct->member->value->string; } else { // Display problems that have been gracefully caught and // reported by the xmlrpc server class. throw new customException($this->objLanguage->languageText("mod_packages_faultcode", "packages") . ": " . $resp->faultCode() . $this->objLanguage->languageText("mod_packages_faultreason", "packages") . ": " . $resp->faultString()); } }