/** * 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()); } }
/** * 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()); } }
/** * 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 * */ public 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) { $cli->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; }
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); }
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()); } }
if (isset($_REQUEST['addarticle'])) { if (!in_array($_REQUEST['articleId'], $sendarticles)) { $sendarticles[] = $_REQUEST['articleId']; } } if (isset($_REQUEST['cleararticles'])) { $sendarticles = array(); } $structures = $structlib->list_structures(0, -1, 'pageName_asc', $find); $smarty->assign_by_ref('structures', $structures['data']); $msg = ''; if (isset($_REQUEST['send'])) { check_ticket('send-objects'); // Create XMLRPC object $client = new XML_RPC_Client($_REQUEST['path'], $_REQUEST['site'], 80); $client->setDebug(isset($_REQUEST['dbg']) && $_REQUEST['dbg'] == 'on' ? true : false); foreach ($sendstructures as $structure) { $spages = $structlib->s_get_structure_pages($structure); $pos = 0; foreach ($spages as $spage) { $listPageNames[$spage['page_ref_id']] = $spage['pageName']; $page_info = $tikilib->get_page_info($spage['pageName']); $pos++; $searchMsg = new XML_RPC_Message('sendStructurePage', array(new XML_RPC_Value($_SERVER['SERVER_NAME'], 'string'), new XML_RPC_Value($_REQUEST['username'], 'string'), new XML_RPC_Value($_REQUEST['password'], 'string'), new XML_RPC_Value($spages[0]['pageName'], 'string'), new XML_RPC_Value($spage['parent_id'] ? $listPageNames[$spage['parent_id']] : $spage['pageName'], 'string'), new XML_RPC_Value($spage['pageName'], 'string'), new XML_RPC_Value(base64_encode($page_info['data']), 'string'), new XML_RPC_Value($page_info['comment'], 'string'), new XML_RPC_Value($page_info['description'], 'string'), new XML_RPC_Value($pos, 'string'), new XML_RPC_Value($spage['page_alias'], 'string'))); $result = $client->send($searchMsg); if (!$result) { $errorMsg = tra('Cannot login to server maybe the server is down'); $msg .= $errorMsg; } else { if (!$result->faultCode()) { $msg .= tra('Page') . ': ' . $spage['pageName'] . ' ' . tra('successfully sent') . '<br />';
/** * Send a pingback. * * @param array $data (optional) An array of pingback data. * * @access public * @see autodiscover() */ function send($data = null) { if ($data !== null) { $res = $this->setFromArray($data); if (PEAR::isError($res)) { return $res; } } // Find the whether if source and target is equal or not. if (strstr($this->_data['sourceURI'], $this->_data['targetURI'])) { return PEAR::raiseError('Target URI is equal with source URI'); } // pingback URI set if (empty($this->_data['pingbackURI'])) { $res = Services_Pingback::autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } else { if (empty($res)) { return PEAR::raiseError('Target URI is not a pingback-enabled resource'); } } $this->_data['pingbackURI'] = $res; } // Prepare an XML-RPC Message. $eArgs = array(XML_RPC_encode($this->_data['sourceURI']), XML_RPC_encode($this->_data['targetURI'])); $msg = new XML_RPC_Message('pingback.ping', $eArgs); // Prepare full path of URI to conforms XML_RPC_Client parameter. $url = new Net_URL($this->_data['pingbackURI']); $path = $url->path; $querystring = $url->getQueryString(); if (!empty($querystring)) { $path .= '?' . $querystring; } $cli = new XML_RPC_Client($path, $url->protocol . '://' . $url->host, $url->port); $cli->setDebug((int) $this->_options['debug']); // save the current error handling in buffer for restore. $default_error_mode = $GLOBALS['_PEAR_default_error_mode']; $default_error_options = $GLOBALS['_PEAR_default_error_options']; // Set error mode to callback, since XML_RPC doesn't return error object on failure. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'XML_RPC_ErrorCallback')); $res = $cli->send($msg, (int) $this->_options['timeout']); // Cacth the error if any. if ($this->_isXML_RPC_Error()) { return $this->_XML_RPC_Error; } $val = $res->value(); if (!is_object($val) || !is_a($val, 'XML_RPC_value')) { return PEAR::raiseError('Response Error: ' . $res->faultString()); } // restore the current error handling. PEAR::setErrorHandling($default_error_mode, $default_error_options); return XML_RPC_decode($val); }
function validatePDF_2($magic, $callback_URL, $fileID, $file) { global $hotdir, $max_processing_seconds, $INP, $NPDF_ERR, $NPDF, $ORIG_ERR, $ORIG_OK, $PROC_ERR, $PROC_OK, $REP_ERR, $REP_OK, $INP_absolute, $xmlrpc, $DEBUG; ignore_user_abort(); // function may take a long time set_time_limit($max_processing_seconds + 10); // does not work in safe mode ini_set("max_execution_time", $max_processing_seconds + 10); // does not work in safe mode if ($DEBUG) { informAdmin("DEBUG: called validatePDF_2( {$magic}, {$callback_URL}, {$fileID}, {$file} )"); } // security issue $file = basename($file); // to avoid s.th. like '../../../etc/passwd' // wait for pitstop to process the file $file_log = "{$file}_log.pdf"; // PitStop names reports like this $start_time = time(); while (file_exists(cleanPath("{$hotdir}/{$INP}/{$file}")) && $start_time + $max_processing_seconds > time()) { clearstatcache(); sleep(5); } // MISCONCEPTION - PitStop removes the input file before all other files have been written to disk. Especially the Report takes longer. // wait for report to appear $report_present = false; while (!$report_present && $start_time + $max_processing_seconds > time()) { clearstatcache(); $report_present = file_exists(cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$REP_OK}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}")); sleep(5); } if ($start_time + $max_processing_seconds <= time()) { // cleanup - not all files will be present, thus neglect warnings cleanup($file); informAdmin("validation tooks too long. PitStop server not running? HotDir is '{$hotdir}' and input folder is named '{$INP}'"); return false; // validation tooks too long } sleep(5); // let PitStop write all files clearstatcache(); $valid = 2; // validation was aborted // PitStop has removed the file, now check the result if (file_exists(cleanPath("{$hotdir}/{$NPDF}/{$file}"))) { $reportFileName = cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}"); $valid = false; } if (file_exists(cleanPath("{$hotdir}/{$ORIG_ERR}/{$file}"))) { $reportFileName = cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}"); $valid = false; } if (file_exists(cleanPath("{$hotdir}/{$ORIG_OK}/{$file}"))) { $reportFileName = cleanPath("{$hotdir}/{$REP_OK}/{$file_log}"); $valid = true; } if ($valid === 2) { // cleanup - not all files will be present, thus neglect warnings cleanup($file); informAdmin("validation was aborted. Input file was removed, but result is not present."); return false; } if ($DEBUG) { if ($valid) { $temp = "pdf file is valid"; } else { $temp = "file is not valid"; } informAdmin("DEBUG: validation process completed.\n{$temp}"); } // PitStop may produce reports with 350 pages and more. These reports can be as large as 8 MiB. // If pdftk (http://www.pdftk.com) is available, truncate the report; otherwise do not send, if too large $data = truncate_pdf($reportFileName); // call the callback function to announce results of validation $server = parse_url($callback_URL); $server['port'] = $server['port'] ? $server['port'] : 80; if ($xmlrpc['pear']) { // use XML_RPC impl. to contact the callback function, which in turn will commit the result to the database $client = new XML_RPC_Client($server['path'], $server['host'], $server['port']); $params = array(new XML_RPC_Value($data, 'base64'), new XML_RPC_Value($valid, 'boolean'), new XML_RPC_Value($magic, 'int'), new XML_RPC_Value($fileID, 'int')); $xmlrpc_message = new XML_RPC_Message('validatePDF_callback', $params); if ($DEBUG) { $client->setDebug(1); ob_start(); } $client->send($xmlrpc_message); if ($DEBUG) { informAdmin("server reports:\n" . ob_get_contents()); ob_end_clean(); } } elseif ($xmlrpc['internal']) { // use internal impl. to contact the callback function, which in turn will commit the result to the database xmlrpc_set_type($data, "base64"); // converts the string to an object with encoding 'base64' $params = array($data, $valid, $magic, $fileID); $output = array('output_type' => 'php'); xu_rpc_http_concise(array(method => 'validatePDF_callback', args => $params, host => $server['host'], uri => $server['path'], port => $server['port'], debug => 0, output => $output)); } if ($DEBUG) { informAdmin("DEBUG: callback function validatePDF_callback() at {$callback_URL} was called."); } // cleanup - not all files will be present, thus neglect warnings cleanup($file); }
function intervalidate($remote, $user, $pass, $get_info = false) { global $tiki_key; $remote['path'] = preg_replace("/^\\/?/", "/", $remote['path']); $client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']); $client->setDebug(0); $msg = new XML_RPC_Message('intertiki.validate', array(new XML_RPC_Value($tiki_key, 'string'), new XML_RPC_Value($user, 'string'), new XML_RPC_Value($pass, 'string'), new XML_RPC_Value($get_info, 'boolean'))); $result = $client->send($msg); 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()); } }
function get_remote_user_by_cookie($hash) { global $prefs; include_once('XML/RPC.php'); $prefs['interlist'] = unserialize($prefs['interlist']); $remote = $prefs['interlist'][$prefs['feature_intertiki_mymaster']]; $client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']); $client->setDebug(0); $msg = new XML_RPC_Message( 'intertiki.cookiecheck', array( new XML_RPC_Value($prefs['tiki_key'], 'string'), new XML_RPC_Value($hash, 'string') ) ); $result = $client->send($msg); return $result; }
/** * get article data through rpc * * @param array $data */ function perform($data = FALSE) { // set default num articles to fetch if (!isset($data['numArticles'])) { $data['numArticles'] = 8; } // set default port if (!isset($data['port'])) { $data['port'] = 80; } // set default user if (!isset($data['query'])) { $data['query'] = ''; } // set default methode if (!isset($data['methode'])) { $data['methode'] = 'latestPublished'; } // set default user if (!isset($data['authUser'])) { $data['authUser'] = ''; } // set default user if (!isset($data['authPasswd'])) { $data['authPasswd'] = ''; } // methode map of article fields $methodeField = array('latestModified' => 'modifydate', 'latestPublished' => 'pubdate'); // start rpc client $client = new XML_RPC_Client($data['rpcServer'] . $data['query'], $data['domain'], $data['port']); if (isset($data['debug'])) { $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 $article_date = $rec->structmem($methodeField[$data['methode']]); $data['result'][$i]['date'] = $article_date->scalarval(); $overtitle = $rec->structmem('overtitle'); $data['result'][$i]['overtitle'] = $overtitle->scalarval(); $id_article = $rec->structmem('id_article'); $data['result'][$i]['id_article'] = $id_article->scalarval(); $title = $rec->structmem('title'); $data['result'][$i]['title'] = $title->scalarval(); $subtitle = $rec->structmem('subtitle'); $data['result'][$i]['subtitle'] = $subtitle->scalarval(); $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); } }
* installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.4' == '@' . 'package_version' . '@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path')); } require_once 'XML/RPC/Dump.php'; $debug = 0; $params = array(new XML_RPC_Value('php.net', 'string')); $msg = new XML_RPC_Message('domquery', $params); $client = new XML_RPC_Client('/api/xmlrpc', 'www.adamsnames.com'); $client->setDebug($debug); $resp = $client->send($msg); if (!$resp) { echo 'Communication error: ' . $client->errstr; exit(1); } if ($resp->faultCode()) { /* * 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"; exit(1); } $val = $resp->value();
function get_remote_user_by_cookie($hash) { global $prefs; include_once 'XML/RPC.php'; $prefs['interlist'] = unserialize($prefs['interlist']); $remote = $prefs['interlist'][$prefs['feature_intertiki_mymaster']]; // $fp=fopen('temp/interlogtest','a+');fputs($fp,"slave -- ".$hash." --\n");fclose($fp); $client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']); $client->setDebug(0); $msg = new XML_RPC_Message('intertiki.cookiecheck', array(new XML_RPC_Value($prefs['tiki_key'], 'string'), new XML_RPC_Value($hash, 'string'))); $result = $client->send($msg); return $result; }
function call($method) { $_args = $args = func_get_args(); $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']; } if (extension_loaded("xmlrpc")) { $result = call_user_func_array(array(&$this, 'call_epi'), $args); if (!PEAR::isError($result)) { $this->saveCache($_args, $result); } return $result; } if (!@(include_once "XML/RPC.php")) { return $this->raiseError("For this remote PEAR operation you need to install the XML_RPC package"); } array_shift($args); $server_host = $this->config->get('master_server'); $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 = @$proxy['host']; $proxy_port = @$proxy['port']; $proxy_user = @urldecode(@$proxy['user']); $proxy_pass = @urldecode(@$proxy['pass']); } $c = new XML_RPC_Client('/xmlrpc.php' . $maxAge, $server_host, 80, $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; }
// | (at your option) any later version. | // | | // | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to: | // | | // | Free Software Foundation, Inc. | // | 59 Temple Place - Suite 330 | // | Boston, MA 02111-1307, USA. | // +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ // // @(#) $Id: s.xmlrpc_client.php 1.3 03/01/16 01:47:32-00:00 jpm $ // include_once "../config.inc.php"; include_once APP_INC_PATH . "class.auth.php"; include_once APP_INC_PATH . "class.issue.php"; include_once APP_INC_PATH . "class.misc.php"; include_once APP_INC_PATH . "db_access.php"; include_once APP_PEAR_PATH . "XML_RPC/RPC.php"; $client = new XML_RPC_Client("/rpc/xmlrpc.php", "rabbit.impleo.net", 80); $client->setDebug(true); $params = array(new XML_RPC_Value(5, "int"), new XML_RPC_Value("Testando pelo XML-RPC", "string"), new XML_RPC_Value("descrição iria aqui", "string")); $msg = new XML_RPC_Message("addIssue", $params); $result = $client->send($msg); var_dump($result);
/** * Method to request a screenshot from the service * * @param string $url the url to be rendered * @return string $url the request return (md5 hash of the url) */ public function requestShotFromService($url) { if (!file_exists($this->objConfig->getContentBasePath() . 'apitmp/cache/')) { @mkdir($this->objConfig->getContentBasePath() . 'apitmp/cache/'); @chmod($this->objConfig->getContentBasePath() . 'apitmp/cache/', 0777); } @($params = array(new XML_RPC_Value($url, "string"))); // Construct the method call (message). $msg = new XML_RPC_Message('screenshot.requestShot', $params); // The server is the 2nd arg, the path to the API module is the 1st. $cli = new XML_RPC_Client($this->shoturl, $this->shotserv); //'/app/index.php?module=api', 'chameleon.uwc.ac.za'); // set the debug level to 0 for no debug, 1 for debug mode... $cli->setDebug(0); // bomb off the message to the server $resp = $cli->send($msg); if (!$resp) { return $url; } if (!$resp->faultCode()) { $val = $resp->value(); $val = XML_RPC_decode($val); // write the file back to the "cache" file_put_contents($this->objConfig->getContentBasePath() . '/apitmp/cache/' . md5($url) . '.png', base64_decode($val)); return $url; } else { log_debug("Screenshot service error..."); return $url; } }
/** * 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()); } }
function init_registration_prefs() { global $userlib, $prefs; if (!is_array($this->merged_prefs)) { // local tiki prefs $this->local_prefs = array('feature_antibot' => $prefs['feature_antibot'], 'lowercase_username' => $prefs['lowercase_username'], 'min_username_length' => $prefs['min_username_length'], 'max_username_length' => $prefs['max_username_length'], 'min_pass_length' => $prefs['min_pass_length'], 'username_pattern' => $prefs['username_pattern'], 'useRegisterPasscode' => $prefs['useRegisterPasscode'], 'validateEmail' => $prefs['validateEmail'], 'validateUsers' => $prefs['validateUsers'], 'validateRegistration' => $prefs['validateRegistration'], 'userTracker' => $prefs['userTracker'], 'user_register_prettytracker' => $prefs['user_register_prettytracker'], 'user_register_prettytracker_tpl' => $prefs['user_register_prettytracker_tpl']); // local groups $this->local_prefs['choosable_groups'] = array(); $listgroups = $userlib->get_groups(0, -1, 'groupName_asc', '', '', 'n'); $this->local_prefs['mandatoryChoiceGroups'] = true; foreach ($listgroups['data'] as $gr) { if ($gr['registrationChoice'] == 'y') { $this->local_prefs['choosable_groups'][] = $gr; if ($gr['groupName'] == 'Registered') { $this->local_prefs['mandatoryChoiceGroups'] = false; } } } if ($prefs['feature_intertiki'] == 'y' && !empty($prefs['feature_intertiki_mymaster'])) { include_once 'XML/RPC.php'; $remote = $prefs['interlist'][$prefs['feature_intertiki_mymaster']]; $client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']); $client->setDebug(0); $msg = new XML_RPC_Message('intertiki.getRegistrationPrefs', array(new XML_RPC_Value($prefs['tiki_key'], 'string'))); $result = $client->send($msg); if (!$result || $result->faultCode()) { return new RegistrationError('', 'Master returned an error : ' . ($result ? $result->faultString() : $result)); } $result = $result->value(); $result = XML_RPC_decode($result); if (isset($result['field']) && isset($result['msg'])) { // this is a RegistrationError $result = new RegistrationError($result['field'], $result['msg']); } $this->master_prefs = $result; if (is_a($result, 'RegistrationError')) { return $result; } // merge master and local $this->merged_prefs = array(); $this->merged_prefs['feature_antibot'] = $this->local_prefs['feature_antibot']; // slave choice $this->merged_prefs['lowercase_username'] = $this->local_prefs['lowercase_username'] == 'y' || $this->master_prefs['lowercase_username'] == 'y' ? 'y' : 'n'; $this->merged_prefs['min_username_length'] = $this->local_prefs['min_username_length'] > $this->master_prefs['min_username_length'] ? $this->local_prefs['min_username_length'] : $this->master_prefs['min_username_length']; $this->merged_prefs['max_username_length'] = $this->local_prefs['max_username_length'] < $this->master_prefs['max_username_length'] ? $this->local_prefs['max_username_length'] : $this->master_prefs['max_username_length']; $this->merged_prefs['username_pattern'] = $this->local_prefs['username_pattern']; // each will check for his prefs $this->merged_prefs['min_pass_length'] = $this->local_prefs['min_pass_length'] > $this->master_prefs['min_pass_length'] ? $this->local_prefs['min_pass_length'] : $this->master_prefs['min_pass_length']; if ($this->local_prefs['useRegisterPasscode'] == 'y' && $this->master_prefs['useRegisterPasscode'] == 'y') { return new RegistrationError('', 'Master and Slave require a passcode, only one must be set.'); } if ($this->local_prefs['useRegisterPasscode'] == 'y' && $this->master_prefs['useRegisterPasscode'] == 'y') { return new RegistrationError('', 'Master and Slave require a passcode, only one must be set.'); } $this->merged_prefs['validateEmail'] = $this->local_prefs['validateEmail']; $this->merged_prefs['validateUsers'] = $this->local_prefs['validateUsers']; $this->merged_prefs['validateRegistration'] = $this->local_prefs['validateRegistration']; $this->merged_prefs['userTracker'] = $this->local_prefs['userTracker']; $this->merged_prefs['user_register_prettytracker'] = $this->local_prefs['user_register_prettytracker']; $this->merged_prefs['user_register_prettytracker'] = $this->local_prefs['user_register_prettytracker']; $this->merged_prefs['choosable_groups'] = $this->local_prefs['choosable_groups']; $this->merged_prefs['mandatoryChoiceGroups'] = $this->local_prefs['mandatoryChoiceGroups']; } else { $this->merged_prefs = $this->local_prefs; $this->remote_prefs = $this->local_prefs; } } return $this->merged_prefs; }
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; }
$sendpages = array(); } if (isset($_REQUEST["addarticle"])) { if (!in_array($_REQUEST["articleId"], $sendarticles)) { $sendarticles[] = $_REQUEST["articleId"]; } } if (isset($_REQUEST["cleararticles"])) { $sendarticles = array(); } $msg = ''; if (isset($_REQUEST["send"])) { check_ticket('send-objects'); // Create XMLRPC object $client = new XML_RPC_Client($_REQUEST["path"], $_REQUEST["site"], 80); $client->setDebug(0); foreach ($sendpages as $page) { $page_info = $tikilib->get_page_info($page); if ($page_info) { $searchMsg = new XML_RPC_Message('sendPage', array(new XML_RPC_Value($_SERVER["SERVER_NAME"], "string"), new XML_RPC_Value($_REQUEST["username"], "string"), new XML_RPC_Value($_REQUEST["password"], "string"), new XML_RPC_Value($page, "string"), new XML_RPC_Value(base64_encode($page_info["data"]), "string"), new XML_RPC_Value($page_info["comment"], "string"), new XML_RPC_Value($page_info["description"], "string"))); $result = $client->send($searchMsg); if (!$result) { $errorMsg = 'Cannot login to server maybe the server is down'; $msg .= tra($errorMsg); } else { if (!$result->faultCode()) { $msg .= tra('Page') . ': ' . $page . tra(' successfully sent') . "<br />"; } else { $errorMsg = $result->faultString(); $msg .= tra('Page') . ': ' . $page . tra(' not sent') . '!' . "<br />"; $msg .= tra('Error: ') . $result->faultCode() . '-' . tra($errorMsg) . "<br />";
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)."); } if (!$input_errors) { $toreturn = XML_RPC_Decode($resp->value()); if (!is_array($toreturn)) { if ($toreturn == "Authentication failed") { $input_errors[] = "Could not synchronize the voucher database: Authentication Failed."; } } else {
function snort_do_xmlrpc_sync() { return; /* need to fix the bug which whipes out carp sync settings, etc */ global $config, $g; $syncxmlrpc = $config['installedpackages']['snort']['config'][0]['syncxmlrpc']; /* option enabled? */ if (!$syncxmlrpc) { return; } $carp =& $config['installedpackages']['carpsettings']['config'][0]; $password = $carp['password']; if (!$carp['synchronizetoip']) { return; } log_error("[SNORT] snort_xmlrpc_sync.php is starting."); $xmlrpc_sync_neighbor = $carp['synchronizetoip']; if ($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol']; $synchronizetoip .= "://"; } $port = $config['system']['webgui']['port']; /* if port is empty lets rely on the protocol selection */ if ($port == "") { if ($config['system']['webgui']['protocol'] == "http") { $port = "80"; } else { $port = "443"; } } $synchronizetoip .= $carp['synchronizetoip']; /* xml will hold the sections to sync */ $xml = array(); $xml['installedpackages']['snort'] =& $config['installedpackages']['snort']; $xml['installedpackages']['snortwhitelist'] =& $config['installedpackages']['snortwhitelist']; /* assemble xmlrpc payload */ $params = array(XML_RPC_encode($password), XML_RPC_encode($xml)); /* set a few variables needed for sync code borrowed from filter.inc */ $url = $synchronizetoip; $method = 'pfsense.restore_config_section'; /* Sync! */ log_error("Beginning Snort XMLRPC sync to {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials('admin', $password); if ($g['debug']) { $cli->setDebug(1); } /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "999"); if (!$resp) { $error = "A communications error occured while attempting Snort XMLRPC sync with {$url}:{$port}."; log_error($error); file_notice("sync_settings", $error, "Snort Settings Sync", ""); } elseif ($resp->faultCode()) { $error = "An error code was received while attempting Snort XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("sync_settings", $error, "Snort Settings Sync", ""); } else { log_error("Snort XMLRPC sync successfully completed with {$url}:{$port}."); } log_error("[SNORT] snort_xmlrpc_sync.php is ending."); }