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