1*4e3e87e4SAndreas Gohr<?php 2*4e3e87e4SAndreas Gohr 3*4e3e87e4SAndreas Gohr 4*4e3e87e4SAndreas Gohrnamespace dokuwiki\plugin\upgrade\HTTP; 5*4e3e87e4SAndreas Gohr 6*4e3e87e4SAndreas Gohr 7*4e3e87e4SAndreas Gohr 8*4e3e87e4SAndreas Gohr/** 9*4e3e87e4SAndreas Gohr * Adds DokuWiki specific configs to the HTTP client 10*4e3e87e4SAndreas Gohr * 11*4e3e87e4SAndreas Gohr * @author Andreas Goetz <cpuidle@gmx.de> 12*4e3e87e4SAndreas Gohr */ 13*4e3e87e4SAndreas Gohrclass DokuHTTPClient extends HTTPClient { 14*4e3e87e4SAndreas Gohr 15*4e3e87e4SAndreas Gohr /** 16*4e3e87e4SAndreas Gohr * Constructor. 17*4e3e87e4SAndreas Gohr * 18*4e3e87e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 19*4e3e87e4SAndreas Gohr */ 20*4e3e87e4SAndreas Gohr public function __construct(){ 21*4e3e87e4SAndreas Gohr global $conf; 22*4e3e87e4SAndreas Gohr 23*4e3e87e4SAndreas Gohr // call parent constructor 24*4e3e87e4SAndreas Gohr parent::__construct(); 25*4e3e87e4SAndreas Gohr 26*4e3e87e4SAndreas Gohr // set some values from the config 27*4e3e87e4SAndreas Gohr $this->proxy_host = $conf['proxy']['host']; 28*4e3e87e4SAndreas Gohr $this->proxy_port = $conf['proxy']['port']; 29*4e3e87e4SAndreas Gohr $this->proxy_user = $conf['proxy']['user']; 30*4e3e87e4SAndreas Gohr $this->proxy_pass = conf_decodeString($conf['proxy']['pass']); 31*4e3e87e4SAndreas Gohr $this->proxy_ssl = $conf['proxy']['ssl']; 32*4e3e87e4SAndreas Gohr $this->proxy_except = $conf['proxy']['except']; 33*4e3e87e4SAndreas Gohr 34*4e3e87e4SAndreas Gohr // allow enabling debugging via URL parameter (if debugging allowed) 35*4e3e87e4SAndreas Gohr if($conf['allowdebug']) { 36*4e3e87e4SAndreas Gohr if( 37*4e3e87e4SAndreas Gohr isset($_REQUEST['httpdebug']) || 38*4e3e87e4SAndreas Gohr ( 39*4e3e87e4SAndreas Gohr isset($_SERVER['HTTP_REFERER']) && 40*4e3e87e4SAndreas Gohr strpos($_SERVER['HTTP_REFERER'], 'httpdebug') !== false 41*4e3e87e4SAndreas Gohr ) 42*4e3e87e4SAndreas Gohr ) { 43*4e3e87e4SAndreas Gohr $this->debug = true; 44*4e3e87e4SAndreas Gohr } 45*4e3e87e4SAndreas Gohr } 46*4e3e87e4SAndreas Gohr } 47*4e3e87e4SAndreas Gohr 48*4e3e87e4SAndreas Gohr 49*4e3e87e4SAndreas Gohr /** 50*4e3e87e4SAndreas Gohr * Wraps an event around the parent function 51*4e3e87e4SAndreas Gohr * 52*4e3e87e4SAndreas Gohr * @triggers HTTPCLIENT_REQUEST_SEND 53*4e3e87e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 54*4e3e87e4SAndreas Gohr */ 55*4e3e87e4SAndreas Gohr /** 56*4e3e87e4SAndreas Gohr * @param string $url 57*4e3e87e4SAndreas Gohr * @param string|array $data the post data either as array or raw data 58*4e3e87e4SAndreas Gohr * @param string $method 59*4e3e87e4SAndreas Gohr * @return bool 60*4e3e87e4SAndreas Gohr */ 61*4e3e87e4SAndreas Gohr public function sendRequest($url,$data='',$method='GET'){ 62*4e3e87e4SAndreas Gohr $httpdata = array('url' => $url, 63*4e3e87e4SAndreas Gohr 'data' => $data, 64*4e3e87e4SAndreas Gohr 'method' => $method); 65*4e3e87e4SAndreas Gohr $evt = new \Doku_Event('HTTPCLIENT_REQUEST_SEND',$httpdata); 66*4e3e87e4SAndreas Gohr if($evt->advise_before()){ 67*4e3e87e4SAndreas Gohr $url = $httpdata['url']; 68*4e3e87e4SAndreas Gohr $data = $httpdata['data']; 69*4e3e87e4SAndreas Gohr $method = $httpdata['method']; 70*4e3e87e4SAndreas Gohr } 71*4e3e87e4SAndreas Gohr $evt->advise_after(); 72*4e3e87e4SAndreas Gohr unset($evt); 73*4e3e87e4SAndreas Gohr return parent::sendRequest($url,$data,$method); 74*4e3e87e4SAndreas Gohr } 75*4e3e87e4SAndreas Gohr 76*4e3e87e4SAndreas Gohr} 77*4e3e87e4SAndreas Gohr 78