当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP_Request::setProxy方法代码示例

本文整理汇总了PHP中HTTP_Request::setProxy方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request::setProxy方法的具体用法?PHP HTTP_Request::setProxy怎么用?PHP HTTP_Request::setProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP_Request的用法示例。


在下文中一共展示了HTTP_Request::setProxy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Retrieves a file from cache if it exists, otherwise retreive from net,
  * add to cache, and return from cache.
  *
  * @param  string   URL to WSDL
  * @param  array    proxy parameters
  * @param  int      expected MD5 of WSDL URL
  * @access public
  * @return string  data
  */
 function get($wsdl_fname, $proxy_params = array(), $cache = 0)
 {
     $cachename = $md5_wsdl = $file_data = '';
     if ($this->_cacheUse) {
         // Try to retrieve WSDL from cache
         $cachename = SOAP_WSDL_Cache::_cacheDir() . '/' . md5($wsdl_fname) . ' .wsdl';
         if (file_exists($cachename)) {
             $wf = fopen($cachename, 'rb');
             if ($wf) {
                 // Reading cached file
                 $file_data = fread($wf, filesize($cachename));
                 $md5_wsdl = md5($file_data);
                 fclose($wf);
             }
             if ($cache) {
                 if ($cache != $md5_wsdl) {
                     return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname);
                 }
             } else {
                 $fi = stat($cachename);
                 $cache_mtime = $fi[8];
                 //print cache_mtime, time()
                 if ($cache_mtime + $this->_cacheMaxAge < time()) {
                     // expired
                     $md5_wsdl = '';
                     // refetch
                 }
             }
         }
     }
     if (!$md5_wsdl) {
         // Not cached or not using cache. Retrieve WSDL from URL
         // is it a local file?
         // this section should be replace by curl at some point
         if (!preg_match('/^(https?|file):\\/\\//', $wsdl_fname)) {
             if (!file_exists($wsdl_fname)) {
                 return $this->_raiseSoapFault("Unable to read local WSDL {$wsdl_fname}", $wsdl_fname);
             }
             if (function_exists('file_get_contents')) {
                 $file_data = file_get_contents($wsdl_fname);
             } else {
                 $file_data = implode('', file($wsdl_fname));
             }
         } else {
             $uri = explode('?', $wsdl_fname);
             $rq = new HTTP_Request($uri[0], $proxy_params);
             // the user agent HTTP_Request uses fouls things up
             if (isset($uri[1])) {
                 $rq->addRawQueryString($uri[1]);
             }
             if (isset($proxy_params['proxy_host']) && isset($proxy_params['proxy_port']) && isset($proxy_params['proxy_user']) && isset($proxy_params['proxy_pass'])) {
                 $rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port'], $proxy_params['proxy_user'], $proxy_params['proxy_pass']);
             } elseif (isset($proxy_params['proxy_host']) && isset($proxy_params['proxy_port'])) {
                 $rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port']);
             }
             $result = $rq->sendRequest();
             if (PEAR::isError($result)) {
                 return $this->_raiseSoapFault("Unable to retrieve WSDL {$wsdl_fname}," . $rq->getResponseCode(), $wsdl_fname);
             }
             $file_data = $rq->getResponseBody();
             if (!$file_data) {
                 return $this->_raiseSoapFault("Unable to retrieve WSDL {$wsdl_fname}, no http body", $wsdl_fname);
             }
         }
         $md5_wsdl = md5($file_data);
         if ($this->_cacheUse) {
             $fp = fopen($cachename, "wb");
             fwrite($fp, $file_data);
             fclose($fp);
         }
     }
     if ($this->_cacheUse && $cache && $cache != $md5_wsdl) {
         return $this->_raiseSoapFault("WSDL Checksum error!", $wsdl_fname);
     }
     return $file_data;
 }
开发者ID:nidhhoggr,项目名称:mycoachingoffice,代码行数:86,代码来源:WSDL.php

示例2: export_datas_to_repo

function export_datas_to_repo()
{
    $file = "/etc/artica-postfix/smtp.hacks.export.db";
    if (!is_file($file)) {
        echo "{$file} no such file\n";
        return;
    }
    include_once "HTTP/Request.php";
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $datas = $sock->GET_INFO("ArticaProxySettings");
    $ini->loadString($datas);
    $ArticaProxyServerEnabled = $ini->_params["PROXY"]["ArticaProxyServerEnabled"];
    $ArticaProxyServerName = $ini->_params["PROXY"]["ArticaProxyServerName"];
    $ArticaProxyServerPort = $ini->_params["PROXY"]["ArticaProxyServerPort"];
    $ArticaProxyServerUsername = $ini->_params["PROXY"]["ArticaProxyServerUsername"];
    $ArticaProxyServerUserPassword = $ini->_params["PROXY"]["ArticaProxyServerUserPassword"];
    $req = new HTTP_Request("http://www.articatech.net/smtphack-import.php");
    $req->setURL("http://www.articatech.net/smtphack-import.php");
    $req->setMethod('POST');
    if ($ArticaProxyServerEnabled == "yes") {
        $req->setProxy($ArticaProxyServerName, $ArticaProxyServerPort, $ArticaProxyServerUsername, $ArticaProxyServerUserPassword);
    }
    $req->addPostData('xyz', time());
    $result = $req->addFile('smtp-hack-file', $file, 'multipart/form-data');
    //	$req->sendRequest();
    if (PEAR::isError($result)) {
        echo $result->getMessage();
    } else {
        $response = $req->sendRequest();
        if (PEAR::isError($response)) {
            echo $response->getMessage();
            return false;
        }
        if (preg_match("#SUCCESS#", $req->getResponseBody())) {
            if ($GLOBALS["DEBUG"]) {
                echo "Central server success\n" . $req->getResponseBody() . "\n";
            }
            return true;
        }
        if ($GLOBALS["DEBUG"]) {
            echo "Central server failed\n" . $req->getResponseBody() . "\n";
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:45,代码来源:exec.smtp-hack.export.php


注:本文中的HTTP_Request::setProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。