本文整理汇总了PHP中xmlrpc_client::setProxy方法的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_client::setProxy方法的具体用法?PHP xmlrpc_client::setProxy怎么用?PHP xmlrpc_client::setProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpc_client
的用法示例。
在下文中一共展示了xmlrpc_client::setProxy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: um_xml_rpc_client_call
function um_xml_rpc_client_call($server_host, $server_path, $server_port, $proxy, $proxy_port, $proxy_user, $proxy_pass, $function, $parameters)
{
$msg = new xmlrpcmsg($function, $parameters);
$client = new xmlrpc_client($server_path, $server_host, $server_port);
$client->setProxy($proxy, $proxy_port, $proxy_user, $proxy_pass);
if (defined('XMLRPC_DEBUG')) {
$client->setDebug(XMLRPC_DEBUG);
}
$result = $client->send($msg, XMLRPC_TIMEOUT, '');
if (!$result) {
trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $client->errstr);
return 0;
}
switch ($result->faultCode()) {
case 0:
break;
case 5:
trigger_error('<strong>Open Update Manager</strong> Server comunication error. ' . $result->faultString());
return 0;
default:
trigger_error('<strong>Open Update Manager</strong> XML-RPC error. ' . $result->faultString());
return 0;
}
return $result;
}
示例2: ItemSendPing
/**
* Ping the pingomatic RPC service.
*/
function ItemSendPing(&$params)
{
global $debug;
global $outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password;
$item_Blog = $params['Item']->get_Blog();
$client = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
$client->debug = $debug && $params['display'];
// Set proxy for outgoing connections:
if (!empty($outgoing_proxy_hostname)) {
$client->setProxy($outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password);
}
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url'))));
$result = $client->send($message);
$params['xmlrpcresp'] = $result;
return true;
}
示例3: ItemSendPing
/**
* Send a ping to the configured service.
*/
function ItemSendPing(&$params)
{
global $debug;
global $outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password;
$url = $this->parse_ping_url($this->Settings->get('ping_service_url'));
$Item = $params['Item'];
$item_Blog = $Item->get_Blog();
$client = new xmlrpc_client($url['path'], $url['host'], $url['port']);
$client->debug = $debug && $params['display'];
// Set proxy for outgoing connections:
if (!empty($outgoing_proxy_hostname)) {
$client->setProxy($outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password);
}
if ($this->Settings->get('ping_service_extended')) {
$message = new xmlrpcmsg("weblogUpdates.extendedPing", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url')), new xmlrpcval($Item->get_permanent_url()), new xmlrpcval($item_Blog->get('atom_url'))));
} else {
$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($item_Blog->get('name')), new xmlrpcval($item_Blog->get('url'))));
}
$result = $client->send($message);
$params['xmlrpcresp'] = $result;
return true;
}
示例4: wordpress_get_options
function wordpress_get_options($xmlrpcurl, $username, $password, $blogid = 0, $proxyipports = "")
{
global $globalerr;
$client = new xmlrpc_client($xmlrpcurl);
$client->setSSLVerifyPeer(false);
$params[] = new xmlrpcval($blogid);
$params[] = new xmlrpcval($username);
$params[] = new xmlrpcval($password);
$msg = new xmlrpcmsg("wp.getOptions", $params);
if (is_array($proxyipports)) {
$proxyipport = $proxyipports[array_rand($proxyipports)];
} elseif ($proxyipports != "") {
$proxyipport = $proxyipports;
} else {
$proxyipport = "";
}
if ($proxyipport != "") {
if (preg_match("/@/", $proxyipport)) {
$proxyparts = explode("@", $proxyipport);
$proxyauth = explode(":", $proxyparts[0]);
$proxyuser = $proxyauth[0];
$proxypass = $proxyauth[1];
$proxy = explode(":", $proxyparts[1]);
$proxyip = $proxy[0];
$proxyport = $proxy[1];
$client->setProxy($proxyip, $proxyport, $proxyuser, $proxypass);
} else {
$proxy = explode(":", $proxyipport);
$proxyip = $proxy[0];
$proxyport = $proxy[1];
$client->setProxy($proxyip, $proxyport);
}
}
$r = $client->send($msg);
if ($r === false) {
$globalerr = "XMLRPC ERROR - Could not send xmlrpc message";
return false;
}
if (!$r->faultCode()) {
return php_xmlrpc_decode($r->value());
} else {
$globalerr = "XMLRPC ERROR - Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'";
}
return false;
}
示例5: _sendRequest
/**
* @brief Actually send the request to the cloudcache API server.
*
* @param namespace Namespace of the request
* @param rpcMsg XML-RPC message Object containing the actual request
*
* @return Reply from the server
*/
private function _sendRequest($namespace, $rpcMsg)
{
$this->lastRpcRequest = $rpcMsg;
// Initialize the XML-RPL client
$rpcClient = new xmlrpc_client($this->apiURI . $namespace, $this->apiURL, $this->port, $this->httpMethod);
if (file_exists(dirname(__FILE__) . '/proxy.inc.php')) {
include dirname(__FILE__) . '/proxy.inc.php';
$rpcClient->setProxy($proxy->host, $proxy->port, $proxy->username, $proxy->password);
}
// Send the message
$this->lastRpcResponse = $rpcClient->send($rpcMsg);
return !$this->getLastFaultCode() ? php_xmlrpc_decode($this->lastRpcResponse->value()) : false;
}
示例6: antispam_poll_abuse
/**
* Request abuse list from central blacklist.
*
* @return boolean true = success, false = error
*/
function antispam_poll_abuse()
{
global $Messages, $Settings, $baseurl, $debug, $antispamsrv_host, $antispamsrv_port, $antispamsrv_uri;
global $outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password;
// Construct XML-RPC client:
load_funcs('xmlrpc/model/_xmlrpc.funcs.php');
$client = new xmlrpc_client($antispamsrv_uri, $antispamsrv_host, $antispamsrv_port);
// yura: I commented this because xmlrpc_client prints the debug info on screen and it breaks header_redirect()
// $client->debug = $debug;
// Set proxy for outgoing connections:
if (!empty($outgoing_proxy_hostname)) {
$client->setProxy($outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password);
}
// Get datetime from last update, because we only want newer stuff...
$last_update = $Settings->get('antispam_last_update');
// Encode it in the XML-RPC format
$Messages->add(T_('Latest update timestamp') . ': ' . $last_update, 'note');
$startat = mysql2date('Ymd\\TH:i:s', $last_update);
//$startat = iso8601_encode( mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)) );
// Construct XML-RPC message:
$message = new xmlrpcmsg('b2evo.pollabuse', array(new xmlrpcval(0, 'int'), new xmlrpcval('annonymous', 'string'), new xmlrpcval('nopassrequired', 'string'), new xmlrpcval($startat, 'dateTime.iso8601'), new xmlrpcval(0, 'int')));
$Messages->add(sprintf(T_('Requesting abuse list from %s...'), $antispamsrv_host), 'note');
$result = $client->send($message);
if ($ret = xmlrpc_logresult($result, $Messages, false)) {
// Response is not an error, let's process it:
$response = $result->value();
if ($response->kindOf() == 'struct') {
// Decode struct:
$response = xmlrpc_decode_recurse($response);
if (!isset($response['strings']) || !isset($response['lasttimestamp'])) {
$Messages->add(T_('Incomplete reponse.'), 'error');
$ret = false;
} else {
// Start registering strings:
$value = $response['strings'];
if (count($value) == 0) {
$Messages->add(T_('No new blacklisted strings are available.'), 'note');
} else {
// We got an array of strings:
$Messages->add(T_('Adding strings to local blacklist:'), 'note');
foreach ($value as $banned_string) {
if (antispam_create($banned_string, 'central')) {
// Creation successed
$Messages->add(T_('Adding:') . ' «' . $banned_string . '»: ' . T_('OK.'), 'note');
} else {
// Was already handled
$Messages->add(T_('Adding:') . ' «' . $banned_string . '»: ' . T_('Not necessary! (Already handled)'), 'note');
antispam_update_source($banned_string, 'central');
}
}
// Store latest timestamp:
$endedat = date('Y-m-d H:i:s', iso8601_decode($response['lasttimestamp']));
$Messages->add(T_('New latest update timestamp') . ': ' . $endedat, 'note');
$Settings->set('antispam_last_update', $endedat);
$Settings->dbupdate();
}
$Messages->add(T_('Done.'), 'success');
}
} else {
$Messages->add(T_('Invalid response.'), 'error');
$ret = false;
}
}
return $ret;
}
示例7: b2evonet_get_updates
/**
* Get updates from b2evolution.net
*
* @param boolean useful when trying to upgrade to a release that has just been published (in the last 12 hours)
* @return NULL|boolean True if there have been updates, false on error,
* NULL if the user has turned off updates.
*/
function b2evonet_get_updates($force_short_delay = false)
{
global $allow_evo_stats;
// Possible values: true, false, 'anonymous'
global $DB, $debug, $evonetsrv_host, $evonetsrv_port, $evonetsrv_uri, $servertimenow, $evo_charset;
global $Messages, $Settings, $baseurl, $instance_name, $app_name, $app_version, $app_date;
global $Debuglog;
global $Timer;
global $outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password;
if (!isset($allow_evo_stats)) {
// Set default value:
$allow_evo_stats = true;
// allow (non-anonymous) stats
}
if ($allow_evo_stats === false) {
// Get outta here:
return NULL;
}
if ($debug == 2) {
$update_every = 8;
$attempt_every = 3;
} elseif ($force_short_delay) {
$update_every = 180;
// 3 minutes
$attempt_every = 60;
// 1 minute
} else {
$update_every = 3600 * 12;
// 12 hours
$attempt_every = 3600 * 4;
// 4 hours
}
// Note: do not put $baseurl in here since it would cause too frequently updates, when you have the same install with different $baseurls.
// Everytime this method gets called on another baseurl, there's a new check for updates!
$version_id = $instance_name . ' ' . $app_name . ' ' . $app_version . ' ' . $app_date;
// This is the last version we checked against the server:
$last_version_checked = $Settings->get('evonet_last_version_checked');
$servertime_last_update = $Settings->get('evonet_last_update');
$servertime_last_attempt = $Settings->get('evonet_last_attempt');
if ($last_version_checked == $version_id) {
// Current version has already been checked, don't check too often:
if ($servertime_last_update > $servertimenow - $update_every) {
// The previous update was less than 12 hours ago, skip this
// echo 'recent update';
return false;
}
if ($servertime_last_attempt > $servertimenow - $attempt_every) {
// The previous update attempt was less than 4 hours ago, skip this
// This is so all b2evo's don't go crazy if the server ever is down
// echo 'recent attempt';
return false;
}
}
$Timer->resume('evonet: check for updates');
$Debuglog->add(sprintf('Getting updates from %s.', $evonetsrv_host), 'evonet');
if ($debug) {
$Messages->add(sprintf(T_('Getting updates from %s.'), $evonetsrv_host), 'note');
}
$Settings->set('evonet_last_attempt', $servertimenow);
$Settings->dbupdate();
// Construct XML-RPC client:
load_funcs('xmlrpc/model/_xmlrpc.funcs.php');
$client = new xmlrpc_client($evonetsrv_uri, $evonetsrv_host, $evonetsrv_port);
if ($debug > 1) {
$client->debug = 1;
}
// Set proxy for outgoing connections:
if (!empty($outgoing_proxy_hostname)) {
$client->setProxy($outgoing_proxy_hostname, $outgoing_proxy_port, $outgoing_proxy_username, $outgoing_proxy_password);
}
// Run system checks:
load_funcs('tools/model/_system.funcs.php');
// Get system stats to display:
$system_stats = get_system_stats();
// Construct XML-RPC message:
$message = new xmlrpcmsg('b2evo.getupdates', array(new xmlrpcval($allow_evo_stats === 'anonymous' ? md5($baseurl) : $baseurl, 'string'), new xmlrpcval($instance_name, 'string'), new xmlrpcval($app_name, 'string'), new xmlrpcval($app_version, 'string'), new xmlrpcval($app_date, 'string'), new xmlrpcval(array('this_update' => new xmlrpcval($servertimenow, 'string'), 'last_update' => new xmlrpcval($servertime_last_update, 'string'), 'mediadir_status' => new xmlrpcval($system_stats['mediadir_status'], 'int'), 'install_removed' => new xmlrpcval($system_stats['install_removed'] == 'ok' ? 1 : 0, 'int'), 'evo_charset' => new xmlrpcval($system_stats['evo_charset'], 'string'), 'evo_blog_count' => new xmlrpcval($system_stats['evo_blog_count'], 'int'), 'cachedir_status' => new xmlrpcval($system_stats['cachedir_status'], 'int'), 'cachedir_size' => new xmlrpcval($system_stats['cachedir_size'], 'int'), 'general_pagecache_enabled' => new xmlrpcval($system_stats['general_pagecache_enabled'] ? 1 : 0, 'int'), 'blog_pagecaches_enabled' => new xmlrpcval($system_stats['blog_pagecaches_enabled'], 'int'), 'db_version' => new xmlrpcval($system_stats['db_version'], 'string'), 'db_utf8' => new xmlrpcval($system_stats['db_utf8'] ? 1 : 0, 'int'), 'php_uid' => new xmlrpcval($system_stats['php_uid'], 'int'), 'php_uname' => new xmlrpcval($system_stats['php_uname'], 'string'), 'php_gid' => new xmlrpcval($system_stats['php_gid'], 'int'), 'php_gname' => new xmlrpcval($system_stats['php_gname'], 'string'), 'php_version' => new xmlrpcval($system_stats['php_version'], 'string'), 'php_reg_globals' => new xmlrpcval($system_stats['php_reg_globals'] ? 1 : 0, 'int'), 'php_allow_url_include' => new xmlrpcval($system_stats['php_allow_url_include'] ? 1 : 0, 'int'), 'php_allow_url_fopen' => new xmlrpcval($system_stats['php_allow_url_fopen'] ? 1 : 0, 'int'), 'php_upload_max' => new xmlrpcval($system_stats['php_upload_max'], 'int'), 'php_post_max' => new xmlrpcval($system_stats['php_post_max'], 'int'), 'php_memory' => new xmlrpcval($system_stats['php_memory'], 'int'), 'php_mbstring' => new xmlrpcval($system_stats['php_mbstring'] ? 1 : 0, 'int'), 'php_xml' => new xmlrpcval($system_stats['php_xml'] ? 1 : 0, 'int'), 'php_imap' => new xmlrpcval($system_stats['php_imap'] ? 1 : 0, 'int'), 'php_opcode_cache' => new xmlrpcval($system_stats['php_opcode_cache'], 'string'), 'gd_version' => new xmlrpcval($system_stats['gd_version'], 'string')), 'struct')));
$result = $client->send($message);
if ($ret = xmlrpc_logresult($result, $Messages, false)) {
// Response is not an error, let's process it:
$response = $result->value();
if ($response->kindOf() == 'struct') {
// Decode struct:
$response = xmlrpc_decode_recurse($response);
/**
* @var AbstractSettings
*/
global $global_Cache;
foreach ($response as $key => $data) {
$global_Cache->set($key, serialize($data));
}
$global_Cache->delete('evonet_updates');
// Cleanup
$global_Cache->dbupdate();
//.........这里部分代码省略.........