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