/** * Call a method * @param string Method name, automatically gets "grav." prepended to it * @param Array List of named arguments */ protected function call($method, $params = array()) { #$params = array_map('XML_RPC_encode', $params); $params = array_merge($params, array('apikey' => $this->apikey)); $msg = new XML_RPC_Message("grav.{$method}", array(XML_RPC_encode($params))); $response = $this->client()->send($msg); if (!$response->faultCode()) { $value = $response->value(); $value = XML_RPC_decode($value); return $value; } else { throw new GravatarException($response->faultString(), $response->faultCode()); } }
function UPMS_registerVersion($aServer, $id = 0, $name = 'unknown', $comments = '') { // Prepare variables $aParams = array('user_name' => $name, 'changeset_id' => $id, 'comments' => $comments); // Create the XML-RPC message $message = new XML_RPC_Message('OXUPMS.registerID', array(XML_RPC_encode($aParams))); // 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) { $response = XML_RPC_decode($response->value()); return $response; } return array('id' => 'unregistered', 'user' => 'unregistered', 'comments' => 'unregistered'); }
function sxr_call($host, $port, $path, $func, $params) { debug(XMLRPC, "SXR calling {$func} via http://{$host}:{$port}/{$path}"); global $sxr_clients; $key = "{$host}:{$port}/{$path}"; if (!array_key_exists($key, $sxr_clients)) { $sxr_clients[$key] = new XML_RPC_Client($path, $host, $port); } $p = array(); if (is_array($params)) { foreach ($params as $i) { array_push($p, XML_RPC_encode($i)); } } else { $p[0] = $params; } $req = new XML_RPC_Message($func, $p); $resp = $sxr_clients[$key]->send($req); if ($resp->faultCode()) { return FALSE; } else { return XML_RPC_decode($resp->value()); } }
function checkForUpdates($aParams) { require_once 'XML/RPC.php'; $message = new XML_RPC_Message('OXPS.checkForUpdate', array(XML_RPC_encode($aParams))); $aConf = $GLOBALS['_MAX']['CONF']['pluginUpdatesServer']; $client = new XML_RPC_Client($aConf['path'] . '/xmlrpc.php', $aConf['host'], $aConf['httpPort']); $client->debug = 0; // Send the XML-RPC message to the server $response = $client->send($message, 60, 'http'); // Assign the response code strings if ($response && $response->faultCode() == 0) { $response = XML_RPC_decode($response->value()); switch ($response['status']) { case 0: if (substr($response['downloadurl'], 0, 7) == '{local}') { $response['downloadurl'] = str_replace('{local}', $aConf['host'], $response['downloadurl']); } $aResult[] = '<a href="http://' . $response['downloadurl'] . '" target="_blank">Download Now</a>'; break; } return $response; } else { $this->_logError($response->fs); return false; } }
/** * @copyright 2005-2008 OpenPNE Project * @license http://www.php.net/license/3_01.txt PHP License 3.01 */ function xmlrpc_get_response($params) { return new XML_RPC_Response(XML_RPC_encode($params)); }
function XML_RPC_encode($php_val) { global $XML_RPC_Boolean; global $XML_RPC_Int; global $XML_RPC_Double; global $XML_RPC_String; global $XML_RPC_Array; global $XML_RPC_Struct; $type = gettype($php_val); $XML_RPC_val = new XML_RPC_value(); switch ($type) { case "array": case "object": $arr = array(); while (list($k, $v) = each($php_val)) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addStruct($arr); break; case "integer": $XML_RPC_val->addScalar($php_val, $XML_RPC_Int); break; case "double": $XML_RPC_val->addScalar($php_val, $XML_RPC_Double); break; case "string": case "NULL": $XML_RPC_val->addScalar($php_val, $XML_RPC_String); break; // <G_Giunta_2001-02-29> // Add support for encoding/decoding of booleans, since they are supported in PHP // <G_Giunta_2001-02-29> // Add support for encoding/decoding of booleans, since they are supported in PHP case "boolean": $XML_RPC_val->addScalar($php_val, $XML_RPC_Boolean); break; // </G_Giunta_2001-02-29> // </G_Giunta_2001-02-29> case "unknown type": default: $XML_RPC_val = false; break; } return $XML_RPC_val; }
/** * This function sends a method call to a specified service. * * @param string $method The name of the remote method to call. * @param mixed $data The data to send to the web service. * @return mixed The response from the server or false in the event of failure. */ function _send($method, $data) { $dataMessage = array(); foreach ($data as $element) { if (is_object($element) && is_subclass_of($element, 'OA_Info')) { $dataMessage[] = XmlRpcUtils::getEntityWithNotNullFields($element); } else { $dataMessage[] = XML_RPC_encode($element); } } $message = new XML_RPC_Message($method, $dataMessage); $client =& $this->_getClient(); // Send the XML-RPC message to the server. $response = $client->send($message, $this->timeout, $this->ssl ? 'https' : 'http'); // Check for an error response. if ($response && $response->faultCode() == 0) { $result = XML_RPC_decode($response->value()); } else { trigger_error('XML-RPC Error (' . $response->faultCode() . '): ' . $response->faultString() . ' in method ' . $method . '()', E_USER_ERROR); } return $result; }
function getRecentPosts($message) { $args = $this->_params_to_args($message); if (count($args) != 4) { return new XML_RPC_Response(0, midcom_connection::get_error(), 'Invalid arguments.'); } if ($args[0] != $this->_content_topic->guid) { return new XML_RPC_Response(0, midcom_connection::get_error(), 'Blog ID does not match this folder.'); } if (!midcom::get('auth')->login($args[1], $args[2])) { return new XML_RPC_Response(0, midcom_connection::get_error(), 'Authentication failed.'); } midcom::get('auth')->initialize(); $response = array(); $qb = midcom_db_article::new_query_builder(); $qb->set_limit($args[3]); $qb->add_constraint('topic', '=', $this->_content_topic->id); $qb->add_order('metadata.published', 'DESC'); $articles = $qb->execute(); foreach ($articles as $article) { if (!$this->_datamanager->autoset_storage($article)) { // This article has something wrong, skip it continue; } $arg = $article->name ? $article->name : $article->guid; if ($this->_config->get('view_in_url')) { $link = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "view/{$arg}/"; } else { $link = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "{$arg}/"; } if (array_key_exists('categories', $this->_datamanager->types)) { $categories = $this->_datamanager->types['categories']->selection; } else { $categories = array(); } $response_array = array('postid' => new XML_RPC_Value($article->guid, 'string'), 'title' => new XML_RPC_Value($article->title, 'string'), 'permaLink' => new XML_RPC_Value(midcom::get('permalinks')->create_permalink($article->guid), 'string'), 'link' => new XML_RPC_Value($link, 'string'), 'description' => new XML_RPC_Value($article->content, 'string'), 'mt_excerpt' => new XML_RPC_Value($article->abstract, 'string'), 'dateCreated' => new XML_RPC_Value(gmdate("Ymd\\TH:i:s\\Z", $article->metadata->published), 'dateTime.iso8601'), 'categories' => XML_RPC_encode($categories)); if ($this->_positioning) { $object_position = new org_routamc_positioning_object($article); $coordinates = $object_position->get_coordinates(); $response_array['georss:point'] = new XML_RPC_Value("{$coordinates['latitude']} {$coordinates['longitude']}", 'string'); } $response[] = new XML_RPC_Value($response_array, 'struct'); } return new XML_RPC_Response(new XML_RPC_Value($response, 'array')); }
function get_notices_xmlrpc($raw_params) { global $g, $xmlrpc_g; $params = xmlrpc_params_to_php($raw_params); if (!xmlrpc_auth($params)) { xmlrpc_authfail(); return $xmlrpc_g['return']['authfail']; } if (!function_exists("get_notices")) { require "notices.inc"; } if (!$params) { $toreturn = get_notices(); } else { $toreturn = get_notices($params); } $response = new XML_RPC_Response(XML_RPC_encode($toreturn)); return $response; }
/** * Call XMLRPC method from central * for set campaign data from oap * Input - array data and ids campains from oap * * The $aCampaigns array format * * Array * ( * [21] => Array * ( * [id] => 2 * [invocationCode] => '' * [deliveredCount] => 50 * ) * [45] => Array * ( * [id] => 5 * [invocationCode] => '' * [deliveredCount] => 0 * ) * ) * * @param array $aCampaigns */ function setCampaignsProperties($aCampaigns) { return $this->oRpc->callNoAuth('setCampaignsProperties', array(XML_RPC_encode($aCampaigns))); }
/** * Connect to OpenX Sync to check for updates * * @param float $already_seen Only check for updates newer than this value. * @return array An array of two items: * * Item 0 is the XML-RPC error code. Meanings: * -2 => The admin user has disabled update checking * -1 => No response from the server * 0 - 799 => XML-RPC library error codes * 0 => No error * 800 => No updates * 801+ => Error codes from the remote XML-RPC server * * Item 1 is either the error message (item 1 != 0), or an array containing update info */ function checkForUpdates($already_seen = 0) { global $XML_RPC_erruser; if (!$this->aConf['sync']['checkForUpdates']) { // Checking for updates has been disabled by the admin user, // so do not communicate with the OpenX server that provides // the details of what upgrades are available - just return // an 800 "error" $aReturn = array(-2, 'Check for updates has been disabled by the OpenX administrator.'); return $aReturn; } // Should this server's technology stack be shared with OpenX? $shareTechStack = false; if ($this->aConf['sync']['shareStack']) { $shareTechStack = true; } // Should this server's aggregate impression and click statistcs // be shared with OpenX? $shareStats = false; if ($this->aConf['sync']['shareData']) { $shareStats = true; } // Create the XML-RPC client object $client = OA_Central::getXmlRpcClient($this->_conf); // Prepare the parameters required for the XML-RPC call to // obtain if an update is available for this OpenX installation $params = array(new XML_RPC_Value(MAX_PRODUCT_NAME, 'string'), new XML_RPC_Value($this->getConfigVersion(OA_Dal_ApplicationVariables::get('oa_version')), 'string'), new XML_RPC_Value($already_seen, 'string'), new XML_RPC_Value('', 'string'), new XML_RPC_Value(OA_Dal_ApplicationVariables::get('platform_hash'), 'string')); // Has the OpenX admin user kindly agreed to share the technology // stack that OpenX is running on, so that OpenX can monitor what // technology stacks the community users, to help with supporting // OpenX? $aTechStack = array('data' => false); if ($shareTechStack) { // Thanks, OpenX admin user! You're a star! Prepare the // technology stack data and add it to the XML-RPC call if ($this->oDbh->dbsyntax == 'mysql') { $dbms = 'MySQL'; } else { if ($this->oDbh->dbsyntax == 'pgsql') { $dbms = 'PostgreSQL'; } else { $dbms = 'UnknownSQL'; } } $aTechStack = array('os_type' => php_uname('s'), 'os_version' => php_uname('r'), 'webserver_type' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^(.*?)/.*$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'webserver_version' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^.*?/(.*?)(?: .*)?$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'db_type' => $dbms, 'db_version' => $this->oDbh->queryOne("SELECT VERSION()"), 'php_version' => phpversion(), 'php_sapi' => ucfirst(php_sapi_name()), 'php_extensions' => get_loaded_extensions(), 'php_register_globals' => (bool) ini_get('register_globals'), 'php_magic_quotes_gpc' => (bool) ini_get('magic_quotes_gpc'), 'php_safe_mode' => (bool) ini_get('safe_mode'), 'php_open_basedir' => (bool) strlen(ini_get('open_basedir')), 'php_upload_tmp_readable' => (bool) is_readable(ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR)); } $params[] = XML_RPC_Encode($aTechStack); // Has the OpenX admin user kindly agreed to share their // aggregate impression and click statistics to help // OpenX monitor what sizes of OpenX installations exist // (to ensure OpenX scales to appropriate sizes), and also // so that the total community size can be shown in the // Dashboard? $aStats = array(); if ($shareStats) { // Thanks, OpenX admin user! You're a star! Prepare the // aggregate impression and click statistics data and // add it to the XML-RPC call foreach ($this->buildStats() as $k => $v) { $aStats[$k] = XML_RPC_encode($v); } } $params[] = new XML_RPC_Value($aStats, 'struct'); // Add the OpenX package Origin ID, if appropriate $originID = ''; $originFile = MAX_PATH . '/etc/origin.txt'; if (file_exists($originFile) && is_readable($originFile)) { $rOriginFile = @fopen($originFile, 'r'); if ($rOriginFile !== false) { $originID = fread($rOriginFile, 32); fclose($rOriginFile); } if ($originID === false) { $originID = ''; } } $params[] = new XML_RPC_Value($originID, 'string'); // Add the registered email address $params[] = new XML_RPC_Value(OA_Dal_ApplicationVariables::get('sync_registered_email'), 'string'); // Create the XML-RPC request message $msg = new XML_RPC_Message("OpenX.Sync", $params); // Send the XML-RPC request message if ($response = $client->send($msg, 10)) { // XML-RPC server found, now checking for errors if (!$response->faultCode()) { // No fault! Woo! Get the response and return it! $aReturn = array(0, XML_RPC_Decode($response->value())); // Prepare cache $cache = $aReturn[1]; // Update last run OA_Dal_ApplicationVariables::set('sync_last_run', date('Y-m-d H:i:s')); } else { // Boo! An error! (Well, maybe - it it's 800, yay!) $aReturn = array($response->faultCode(), $response->faultString()); // Prepare cache $cache = false; // Update last run if ($response->faultCode() == 800) { OA_Dal_ApplicationVariables::set('sync_last_run', date('Y-m-d H:i:s')); } } OA_Dal_ApplicationVariables::set('sync_cache', serialize($cache)); OA_Dal_ApplicationVariables::set('sync_timestamp', time()); return $aReturn; } $aReturn = array(-1, 'No response from the remote XML-RPC server.'); return $aReturn; }
function get_remote_log() { global $config, $g, $postfix_dir; $curr_time = time(); $log_time = date('YmdHis', $curr_time); #get protocol if ($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol'] . "://"; } #get port $port = $config['system']['webgui']['port']; #if port is empty lets rely on the protocol selection if ($port == "") { $port = $config['system']['webgui']['protocol'] == "http" ? "80" : "443"; } $synchronizetoip .= $sync_to_ip; if (is_array($config['installedpackages']['postfixsync'])) { foreach ($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh) { $sync_to_ip = $sh['ipaddress']; $sync_type = $sh['sync_type']; $password = $sh['password']; $file = '/var/db/postfix/' . $server . '.sql'; #get remote data if ($sync_type == 'fetch') { $url = $synchronizetoip . $sync_to_ip; print "{$sync_to_ip} {$url}, {$port}\n"; $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/www/postfix.php');\n"; $execcmd .= '$toreturn=get_sql(' . $log_time . ');'; /* assemble xmlrpc payload */ $params = array(XML_RPC_encode($password), XML_RPC_encode($execcmd)); log_error("postfix get sql data from {$sync_to_ip}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials('admin', $password); #$cli->setDebug(1); $resp = $cli->send($msg, "250"); $a = $resp->value(); $errors = 0; #var_dump($sql); foreach ($a as $b) { foreach ($b as $c) { foreach ($c as $d) { foreach ($d as $e) { $update = unserialize($e['string']); print $update['day'] . "\n"; if ($update['day'] != "") { create_db($update['day'] . ".db"); if ($debug = true) { print $update['day'] . " writing from remote system to db..."; } $dbhandle = sqlite_open($postfix_dir . '/' . $update['day'] . ".db", 0666, $error); #file_put_contents("/tmp/".$key.'-'.$update['day'].".sql",gzuncompress(base64_decode($update['sql'])), LOCK_EX); $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error); if (!$ok) { $errors++; die("Cannot execute query. {$error}\n" . $update['sql'] . "\n"); } else { if ($debug = true) { print "ok\n"; } } sqlite_close($dbhandle); } } } } } if ($errors == 0) { $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/www/postfix.php');\n"; $execcmd .= 'flush_sql(' . $log_time . ');'; /* assemble xmlrpc payload */ $params = array(XML_RPC_encode($password), XML_RPC_encode($execcmd)); log_error("postfix flush sql buffer file from {$sync_to_ip}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials('admin', $password); #$cli->setDebug(1); $resp = $cli->send($msg, "250"); } } } } }
/** * Set RPC type for variable with default values. * * @access private * * @param string $type * @param mixed $variable * * @return XML_RPC_Value or false */ function _setRPCTypeWithDefaultValues($type, $variable) { switch ($type) { case 'struct': if (is_null($variable)) { $variable = array(); } return XML_RPC_encode($variable); case 'array': if (is_null($variable)) { $variable = array(); } return XML_RPC_encode($variable); case 'string': if (is_null($variable)) { $variable = ''; } return new XML_RPC_Value($variable, $GLOBALS['XML_RPC_String']); case 'integer': if (is_null($variable)) { $variable = 0; } return new XML_RPC_Value($variable, $GLOBALS['XML_RPC_Int']); case 'float': case 'double': if (is_null($variable)) { $variable = 0.0; } return new XML_RPC_Value($variable, $GLOBALS['XML_RPC_Double']); case 'date': $dateVariable = null; if (isset($variable)) { if (!is_string($variable)) { Max::raiseError('Date for statistics should be represented as string'); exit; } if (!empty($variable)) { $dateVariable = date('Ymd\\TH:i:s', strtotime($variable)); } } return new XML_RPC_Value($dateVariable, $GLOBALS['XML_RPC_DateTime']); } Max::raiseError('Unsupported Xml Rpc type \'' . $type . '\''); exit; }
/** * @param $params * @return XML_RPC_Response */ function register_user($params) { global $tikilib, $prefs, $registrationlib, $logslib; $key = $params->getParam(0); $key = $key->scalarval(); if (!isset($prefs['known_hosts'][$key]) or $prefs['known_hosts'][$key]['ip'] != $tikilib->get_ip_address()) { $msg = tra('Invalid server key'); if ($prefs['intertiki_errfile']) { logit($prefs['intertiki_errfile'], $msg, $key, INTERTIKI_BADKEY, $prefs['known_hosts'][$key]['name']); } $logslib->add_log('intertiki', $msg . ' from ' . $prefs['known_hosts'][$key]['name'], $login); return new XML_RPC_Response(0, 101, $msg); } if (!isset($prefs['known_hosts'][$key]['allowusersregister']) || $prefs['known_hosts'][$key]['allowusersregister'] != 'y') { return new XML_RPC_Response(0, 101, 'Users are not allowed to register via intertiki on this master.'); } require_once 'lib/registration/registrationlib.php'; $result = $registrationlib->register_new_user_from_intertiki(XML_RPC_decode($params->getParam(1))); return new XML_RPC_Response(XML_RPC_encode($result)); }
/** * A method to perform a call to the OAC XML-RPC server * * @param string $methodName The RPC method name * @param int $authType Type of required authentication, see constants * @param array $aParams Array of XML_RPC_Values * @return mixed The returned value or PEAR_Error on error */ function call($methodName, $authType, $aParams = null, $recursionLevel = 0) { $aPref = $GLOBALS['_MAX']['PREF']; $oMsg = new XML_RPC_Message('oac.' . $methodName); $oMsg->remove_extra_lines = $this->remove_extra_lines; $aHeader = array('protocolVersion' => OA_DAL_CENTRAL_PROTOCOL_VERSION, 'ph' => OA_Dal_ApplicationVariables::get('platform_hash')); if ($authType & OA_DAL_CENTRAL_AUTH_M2M) { if (empty($this->oCentral)) { MAX::raiseError('M2M authentication used with a non M2M-enabled OA_Central object'); } $aHeader['accountId'] = (int) $this->oCentral->accountId; $aHeader['m2mPassword'] = OA_Dal_Central_M2M::getM2MPassword($this->oCentral->accountId); if (empty($aHeader['m2mPassword']) || isset($GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId]) && $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] == true) { // No password stored, connect! $result = $this->oCentral->connectM2M(); if (PEAR::isError($result)) { return $result; } $aHeader['m2mPassword'] = $result; } } if ($authType & OA_DAL_CENTRAL_AUTH_SSO) { $aHeader['ssoUsername'] = $this->ssoUsername; $aHeader['ssoPassword'] = $this->ssoPassword; } if ($authType & OA_DAL_CENTRAL_AUTH_CAPTCHA) { $aHeader['ssoCaptcha'] = isset($_REQUEST['captcha-value']) ? $_REQUEST['captcha-value'] : ''; $aHeader['ssoCaptchaRandom'] = isset($_REQUEST['captcha-random']) ? $_REQUEST['captcha-random'] : ''; } $oMsg->addParam(XML_RPC_encode($aHeader)); if (is_array($aParams)) { foreach ($aParams as $oParam) { $oMsg->addParam($oParam); } } OA::disableErrorHandling(); $oResponse = $this->oXml->send($oMsg, OAC_RPC_TIMEOUT); OA::enableErrorHandling(); if (!$oResponse) { return new PEAR_Error('XML-RPC connection error', OA_CENTRAL_ERROR_XML_RPC_CONNECTION_ERROR); } if ($oResponse->faultCode() || $oResponse->faultString()) { // Deal with particular response codes at Rpc level, avoiding endless recursion if (!$recursionLevel) { switch ($oResponse->faultCode()) { case OA_CENTRAL_ERROR_PLATFORM_DOES_NOT_EXIST: OA::disableErrorHandling(); $oSync = new OA_Sync(); $oSync->checkForUpdates(); OA::enableErrorHandling(); return $this->call($methodName, $authType, $aParams, ++$recursionLevel); case OA_CENTRAL_ERROR_ERROR_NOT_AUTHORIZED: if (!($authType & OA_DAL_CENTRAL_AUTH_M2M)) { break; } else { // Go with OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID } case OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID: // OAP was asked to connect the account to get a password // Set clear the password and retry (old password is in DB in case of problems with receiving new one) $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] = true; return $this->call($methodName, $authType, $aParams, ++$recursionLevel, true); case OA_CENTRAL_ERROR_M2M_PASSWORD_EXPIRED: $result = $this->_reconnectM2M(); if (PEAR::isError($result)) { return $result; } return $this->call($methodName, $authType, $aParams, ++$recursionLevel); } } return new PEAR_Error($oResponse->faultString(), $oResponse->faultCode()); } $ret = XML_RPC_decode($oResponse->value()); // handling unknown server errors // this may happen due to difference in Java/PHP XML-RPC handling errors if (is_array($ret) && (isset($ret['faultCode']) || isset($ret['faultCode']))) { return new PEAR_Error('Unknown server error', OA_CENTRAL_ERROR_SERVER_ERROR); } return $ret; }
/** * This method retrieves a banner from a remote OpenX installation using XML-RPC * * @param string $what The "what" parameter, see docs for more info * @param int $campaignid The campaign id to fetch banners from, 0 means any campaign * @param string $target The HTML <a href> target * @param string $source The "source" parameter, see docs for more info * @param bool $withText Wheter or not to show the text under a banner * @param array $context The "context" parameter, see docs for more info * * @return array */ function view($what = '', $campaignid = 0, $target = '', $source = '', $withText = false, $context = array()) { global $XML_RPC_String, $XML_RPC_Boolean; global $XML_RPC_Array, $XML_RPC_Struct; global $XML_RPC_Int; // Prepare variables $aServerVars = array('remote_addr' => 'REMOTE_ADDR', 'remote_host' => 'REMOTE_HOST', 'request_uri' => 'REQUEST_URI', 'https' => 'HTTPS', 'server_name' => 'SERVER_NAME', 'http_host' => 'HTTP_HOST', 'accept_language' => 'HTTP_ACCEPT_LANGUAGE', 'referer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT', 'via' => 'HTTP_VIA', 'forwarded' => 'HTTP_FORWARDED', 'forwarded_for' => 'HTTP_FORWARDED_FOR', 'x_forwarded' => 'HTTP_X_FORWARDED', 'x_forwarded_for' => 'HTTP_X_FORWARDED_FOR', 'client_ip' => 'HTTP_CLIENT_IP'); // Create environment array $aRemoteInfo = array(); foreach ($aServerVars as $xmlVar => $varName) { if (isset($_SERVER[$varName])) { $aRemoteInfo[$xmlVar] = $_SERVER[$varName]; } } // Add cookies $aRemoteInfo['cookies'] = $_COOKIE; // Encode context $xmlContext = array(); foreach ($context as $contextValue) { $xmlContext[] = XML_RPC_encode($contextValue); } // Create the XML-RPC message $message = new XML_RPC_Message('openads.view', array(XML_RPC_encode($aRemoteInfo), new XML_RPC_Value($what, $XML_RPC_String), new XML_RPC_Value($campaignid, $XML_RPC_Int), new XML_RPC_Value($target, $XML_RPC_String), new XML_RPC_Value($source, $XML_RPC_String), new XML_RPC_Value($withText, $XML_RPC_Boolean), new XML_RPC_Value($xmlContext, $XML_RPC_Array))); // Create an XML-RPC client to talk to the XML-RPC server $client = new XML_RPC_Client($this->path, $this->host, $this->port); // Send the XML-RPC message to the server $response = $client->send($message, $this->timeout, $this->ssl ? 'https' : 'http'); // Was the response OK? if ($response && $response->faultCode() == 0) { $response = XML_RPC_decode($response->value()); if (isset($response['cookies']) && is_array($response['cookies'])) { foreach ($response['cookies'] as $cookieName => $cookieValue) { setcookie($cookieName, $cookieValue[0], $cookieValue[1]); } } unset($response['cookies']); return $response; } return array('html' => '', 'bannerid' => 0, 'campaignid' => 0); }
function get_remote_log() { global $config, $g, $postfix_dir; $curr_time = time(); $log_time = date('YmdHis', $curr_time); if (is_array($config['installedpackages']['postfixsync'])) { $synctimeout = $config['installedpackages']['postfixsync']['config'][0]['synctimeout'] ?: '250'; foreach ($config['installedpackages']['postfixsync']['config'][0]['row'] as $sh) { // Get remote data for enabled fetch hosts if ($sh['enabless'] && $sh['sync_type'] == 'fetch') { $sync_to_ip = $sh['ipaddress']; $port = $sh['syncport']; $username = $sh['username'] ?: 'admin'; $password = $sh['password']; $protocol = $sh['syncprotocol']; $file = '/var/db/postfix/' . $server . '.sql'; $error = ''; $valid = TRUE; if ($password == "") { $error = "Password parameter is empty. "; $valid = FALSE; } if ($protocol == "") { $error = "Protocol parameter is empty. "; $valid = FALSE; } if (!is_ipaddr($sync_to_ip) && !is_hostname($sync_to_ip) && !is_domain($sync_to_ip)) { $error .= "Misconfigured Replication Target IP Address or Hostname. "; $valid = FALSE; } if (!is_port($port)) { $error .= "Misconfigured Replication Target Port. "; $valid = FALSE; } if ($valid) { // Take care of IPv6 literal address if (is_ipaddrv6($sync_to_ip)) { $sync_to_ip = "[{$sync_to_ip}]"; } $url = "{$protocol}://{$sync_to_ip}"; print "{$sync_to_ip} {$url}, {$port}\n"; $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/www/postfix.php');\n"; $execcmd .= '$toreturn = get_sql(' . $log_time . ');'; /* Assemble XMLRPC payload. */ $params = array(XML_RPC_encode($password), XML_RPC_encode($execcmd)); log_error("[postfix] Fetching sql data from {$sync_to_ip}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); //$cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); $a = $resp->value(); $errors = 0; //var_dump($sql); foreach ($a as $b) { foreach ($b as $c) { foreach ($c as $d) { foreach ($d as $e) { $update = unserialize($e['string']); print $update['day'] . "\n"; if ($update['day'] != "") { create_db($update['day'] . ".db"); if ($debug) { print $update['day'] . " writing from remote system to db..."; } $dbhandle = sqlite_open($postfix_dir . '/' . $update['day'] . ".db", 0666, $error); //file_put_contents("/tmp/" . $key . '-' . $update['day'] . ".sql", gzuncompress(base64_decode($update['sql'])), LOCK_EX); $ok = sqlite_exec($dbhandle, gzuncompress(base64_decode($update['sql'])), $error); if (!$ok) { $errors++; die("Cannot execute query. {$error}\n" . $update['sql'] . "\n"); } elseif ($debug) { print "ok\n"; } sqlite_close($dbhandle); } } } } } if ($errors == 0) { $method = 'pfsense.exec_php'; $execcmd = "require_once('/usr/local/www/postfix.php');\n"; $execcmd .= 'flush_sql(' . $log_time . ');'; /* Assemble XMLRPC payload. */ $params = array(XML_RPC_encode($password), XML_RPC_encode($execcmd)); log_error("[postfix] Flushing sql buffer file from {$sync_to_ip}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($username, $password); //$cli->setDebug(1); $resp = $cli->send($msg, $synctimeout); } } else { log_error("[postfix] Fetch sql database from '{$sync_to_ip}' aborted due to the following error(s): {$error}"); } } } log_error("[postfix] Fetch sql database completed."); } }
/** * Takes native php types and encodes them into XML_RPC PHP object format. * * Feature creep -- could support more types via optional type argument. * * @author Dan Libby <*****@*****.**> **/ function XML_RPC_encode($php_val) { global $XML_RPC_Boolean; global $XML_RPC_Int; global $XML_RPC_Double; global $XML_RPC_String; global $XML_RPC_Array; global $XML_RPC_Struct; $type = gettype($php_val); $XML_RPC_val = new XML_RPC_Value(); switch ($type) { case "array": $keys = array_keys($php_val); $count = count($php_val); $firstkey = $keys[0]; $lastkey = $keys[$count - 1]; if ($firstkey === 0 && is_int($lastkey) && $lastkey + 1 == $count) { $is_continuous = true; $expected = 0; foreach ($keys as $actual) { if ($actual != $expected) { $is_continuous = false; break; } $expected++; } if ($is_continuous) { $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addArray($arr); break; } } // fall though if not numerical and continuous // fall though if not numerical and continuous case "object": $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addStruct($arr); break; case "integer": $XML_RPC_val->addScalar($php_val, $XML_RPC_Int); break; case "double": $XML_RPC_val->addScalar($php_val, $XML_RPC_Double); break; case "string": case "NULL": $XML_RPC_val->addScalar($php_val, $XML_RPC_String); break; // <G_Giunta_2001-02-29> // Add support for encoding/decoding of booleans, since they are supported in PHP // <G_Giunta_2001-02-29> // Add support for encoding/decoding of booleans, since they are supported in PHP case "boolean": $XML_RPC_val->addScalar($php_val, $XML_RPC_Boolean); break; // </G_Giunta_2001-02-29> // </G_Giunta_2001-02-29> case "unknown type": default: $XML_RPC_val = false; break; } return $XML_RPC_val; }
*/ require_once 'XML/RPC.php'; } else { if (substr(dirname(__FILE__), -9, -6) != 'XML') { echo "The parent directory must be named 'XML'.\n"; exit; } ini_set('include_path', '../../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path')); /** * Get the needed class from the parent directory */ require_once '../RPC.php'; } $input = "First lfs\n\nSecond crlfs\r\n\r\nThird crs\r\rFourth line"; $expect_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<methodCall>\n\n<methodName>nada</methodName>\n\n<params>\n\n<param>\n\n<value><string>First lfs\n\nSecond crlfs\n\nThird crs\n\nFourth line</string></value>\n\n</param>\n\n</params>\n\n</methodCall>\n\n"; $expect_not_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<methodCall>\n\n<methodName>nada</methodName>\n\n<params>\n\n<param>\n\n<value><string>First lfs\n\n\n\nSecond crlfs\n\n\n\nThird crs\n\n\n\nFourth line</string></value>\n\n</param>\n\n</params>\n\n</methodCall>\n\n"; $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input))); $msg->createPayload(); if ($msg->payload == $expect_removed) { echo "passed\n"; } else { echo "PROBLEM\n"; } $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input))); $msg->remove_extra_lines = false; $msg->createPayload(); if ($msg->payload == $expect_not_removed) { echo "passed\n"; } else { echo "PROBLEM\n"; }
/** * 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); }
/** * XMLRPC methods wrapper * Encode XMLRPC request message, send it, receive and decode response. * * @param method string, method name * @param gettedPars array, returned by func_get_args() in called method * * @return array, PHP hash with response */ public function callMethod($method, $gettedPars) { $parr = array(); $XML_RPC_val = new XML_RPC_Value(); foreach ($this->mdefs[$method]['p'] as $i => $p) { $parr[$p] = new XML_RPC_Value(); if ($this->mdefs[$method]['t'][$i] == 'array') { $parr[$p] = XML_RPC_encode($gettedPars[$i]); } else { $parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]); } } $XML_RPC_val->addStruct($parr); $fullmethod = $this->mdefs[$method]['m']; $msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val)); if ($this->verbose) { echo "parr:\n"; var_dump($parr); echo "message:\n"; echo $msg->serialize() . "\n"; } $this->client->setDebug($this->debug); $res = $this->client->send($msg); if (!$res) { return $this->client->errstr; } if ($res->faultCode() > 0) { return PEAR::raiseError("XR_CcClient::{$method}:" . $res->faultString() . " " . $res->faultCode() . "\n", $res->faultCode(), PEAR_ERROR_RETURN); } if ($this->verbose) { echo "result:\n"; echo $res->serialize(); } $val = $res->value(); $resp = XML_RPC_decode($res->value()); return $resp; }
/** * A function to handle XML-RPC advertisement view requests. 2.0 version * * @deprecated * * @param XML_RPC_Message $params * @return XML_RPC_Response */ function OA_Delivery_XmlRpc_View_PAN($params) { // Extract the remote_info parameter $remoteInfoXmlRpcValue = $params->getParam(0); $remote_info = XML_RPC_Decode($params->getParam(0)); // Add empty cookies array $remote_info['cookies'] = array(); // Create environment array $remoteInfoXmlRpcValue = XML_RPC_encode($remote_info); // Extract the context param if ($params->getNumParams() > 6) { $contextXmlRpcValue = $params->getParam(6); } else { $contextXmlRpcValue = new XML_RPC_Value(array(), $XML_RPC_Array); } // Recreate XML-RPC message $msg = new XML_RPC_Message('phpAds.view', array($remoteInfoXmlRpcValue, $params->getParam(1), $params->getParam(2), $params->getParam(3), $params->getParam(4), $params->getParam(5), $contextXmlRpcValue)); // Relay call to openads.view $xmlResponse = OA_Delivery_XmlRpc_View($msg); // Check for errors as-is return $xmlResponse; }
function register_new_user_to_intertiki($registration, $from_intertiki) { global $prefs; 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.registerUser', array(new XML_RPC_Value($prefs['tiki_key'], 'string'), XML_RPC_encode($registration))); $result = $client->send($msg); if (!$result || $result->faultCode()) { return new RegistrationError('intertiki', 'Master returned an error : ' . ($result ? $result->faultString() : $result)); } $result = $result->value(); $result = XML_RPC_decode($result); if (array_key_exists('field', $result) && array_key_exists('msg', $result)) { // this is a RegistrationError $result = new RegistrationError($result['field'], $result['msg']); } return $result; }
if (is_array($config['system']) && is_array($config['system']['webgui']) && !empty($config['system']['webgui']['protocol']) && $config['system']['webgui']['protocol'] == "https") { $protocol = "https"; } if ($protocol == "https" || $newvoucher['vouchersyncport'] == "443") { $url = "https://{$newvoucher['vouchersyncdbip']}"; } else { $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();
function report_bug($raw_params) { /* give us access to XML listtags */ global $listtags; $listtags = array('bug'); /* where do we stuff the bug reports? */ $path_to_bugfile = '../bugreports/reports.xml'; /* get our params */ $params = array_shift(xmlrpc_params_to_php($raw_params)); $bugfile = parse_xml_config_raw($path_to_bugfile, 'bugfile'); if ($params['desc']) { if ($params['name']) { $toput['name'] = $params['name']; } if ($params['email']) { $toput['email'] = $params['email']; } $toput['desc'] = $params['desc']; $toput['config'] = base64_encode($params['config']); $toput['rules'] = base64_encode($params['rules']); $toput['time'] = time(); $bugfile['bugs']['bug'][] = $toput; $xmlout = dump_xml_config_raw($bugfile, 'bugfile'); $fout = fopen($path_to_bugfile, "w"); fwrite($fout, $xmlout); fclose($fout); return new XML_RPC_Response(XML_RPC_encode(true)); } else { return new XML_RPC_Response(XML_RPC_encode(false)); } return new XML_RPC_Response(XML_RPC_encode(false)); }
/** * Converts native PHP types into an XML_RPC_Value object * * @param mixed $php_val the PHP value or variable you want encoded * * @return object the XML_RPC_Value object */ function XML_RPC_encode($php_val) { global $XML_RPC_Boolean, $XML_RPC_Int, $XML_RPC_Double, $XML_RPC_String, $XML_RPC_Array, $XML_RPC_Struct; $type = gettype($php_val); $XML_RPC_val = new XML_RPC_Value(); switch ($type) { case 'array': if (empty($php_val)) { $XML_RPC_val->addArray($php_val); break; } $tmp = array_diff(array_keys($php_val), range(0, count($php_val) - 1)); if (empty($tmp)) { $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addArray($arr); break; } // fall though if it's not an enumerated array // fall though if it's not an enumerated array case 'object': $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addStruct($arr); break; case 'integer': $XML_RPC_val->addScalar($php_val, $XML_RPC_Int); break; case 'double': $XML_RPC_val->addScalar($php_val, $XML_RPC_Double); break; case 'string': case 'NULL': $XML_RPC_val->addScalar($php_val, $XML_RPC_String); break; case 'boolean': // Add support for encoding/decoding of booleans, since they // are supported in PHP // by <G_Giunta_2001-02-29> $XML_RPC_val->addScalar($php_val, $XML_RPC_Boolean); break; case 'unknown type': default: $XML_RPC_val = false; } return $XML_RPC_val; }
function OA_Delivery_XmlRpc_View_PAN($params) { $remoteInfoXmlRpcValue = $params->getParam(0); $remote_info = XML_RPC_Decode($params->getParam(0)); $remote_info['cookies'] = array(); $remoteInfoXmlRpcValue = XML_RPC_encode($remote_info); if ($params->getNumParams() > 6) { $contextXmlRpcValue = $params->getParam(6); } else { $contextXmlRpcValue = new XML_RPC_Value(array(), $XML_RPC_Array); } $msg = new XML_RPC_Message('phpAds.view', array($remoteInfoXmlRpcValue, $params->getParam(1), $params->getParam(2), $params->getParam(3), $params->getParam(4), $params->getParam(5), $contextXmlRpcValue)); $xmlResponse = OA_Delivery_XmlRpc_View($msg); return $xmlResponse; }
/** * Converts native PHP types into an XML_RPC_Value object * * @param mixed $php_val the PHP value or variable you want encoded * * @return object the XML_RPC_Value object */ function XML_RPC_encode($php_val) { $type = gettype($php_val); $XML_RPC_val = new XML_RPC_Value(); switch ($type) { case 'array': if (empty($php_val)) { $XML_RPC_val->addArray($php_val); break; } $tmp = array_diff(array_keys($php_val), range(0, count($php_val) - 1)); if (empty($tmp)) { $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addArray($arr); break; } // fall though if it's not an enumerated array // fall though if it's not an enumerated array case 'object': $arr = array(); foreach ($php_val as $k => $v) { $arr[$k] = XML_RPC_encode($v); } $XML_RPC_val->addStruct($arr); break; case 'integer': $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_Int']); break; case 'double': $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_Double']); break; case 'string': case 'NULL': if ($GLOBALS['XML_RPC_func_ereg']('^[0-9]{8}\\T{1}[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}$', $php_val)) { $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_DateTime']); } elseif ($GLOBALS['XML_RPC_auto_base64'] && $GLOBALS['XML_RPC_func_ereg']("[^ -~\t\r\n]", $php_val)) { // Characters other than alpha-numeric, punctuation, SP, TAB, // LF and CR break the XML parser, encode value via Base 64. $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_Base64']); } else { $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_String']); } break; case 'boolean': // Add support for encoding/decoding of booleans, since they // are supported in PHP // by <G_Giunta_2001-02-29> $XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_Boolean']); break; case 'unknown type': default: $XML_RPC_val = false; } return $XML_RPC_val; }
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."); }