15a8d6e48SMichael Große<?php 25a8d6e48SMichael Große 35a8d6e48SMichael Große 45a8d6e48SMichael Großenamespace dokuwiki\HTTP; 55a8d6e48SMichael Große 65a8d6e48SMichael Große 75a8d6e48SMichael Große 85a8d6e48SMichael Große/** 95a8d6e48SMichael Große * Adds DokuWiki specific configs to the HTTP client 105a8d6e48SMichael Große * 115a8d6e48SMichael Große * @author Andreas Goetz <cpuidle@gmx.de> 12*8a10b6f0SElan Ruusamäe * @link https://www.dokuwiki.org/devel:httpclient 135a8d6e48SMichael Große */ 145a8d6e48SMichael Großeclass DokuHTTPClient extends HTTPClient { 155a8d6e48SMichael Große 165a8d6e48SMichael Große /** 175a8d6e48SMichael Große * Constructor. 185a8d6e48SMichael Große * 195a8d6e48SMichael Große * @author Andreas Gohr <andi@splitbrain.org> 205a8d6e48SMichael Große */ 215a8d6e48SMichael Große public function __construct(){ 225a8d6e48SMichael Große global $conf; 235a8d6e48SMichael Große 245a8d6e48SMichael Große // call parent constructor 255a8d6e48SMichael Große parent::__construct(); 265a8d6e48SMichael Große 275a8d6e48SMichael Große // set some values from the config 285a8d6e48SMichael Große $this->proxy_host = $conf['proxy']['host']; 295a8d6e48SMichael Große $this->proxy_port = $conf['proxy']['port']; 305a8d6e48SMichael Große $this->proxy_user = $conf['proxy']['user']; 315a8d6e48SMichael Große $this->proxy_pass = conf_decodeString($conf['proxy']['pass']); 325a8d6e48SMichael Große $this->proxy_ssl = $conf['proxy']['ssl']; 335a8d6e48SMichael Große $this->proxy_except = $conf['proxy']['except']; 345a8d6e48SMichael Große 355a8d6e48SMichael Große // allow enabling debugging via URL parameter (if debugging allowed) 365a8d6e48SMichael Große if($conf['allowdebug']) { 375a8d6e48SMichael Große if( 385a8d6e48SMichael Große isset($_REQUEST['httpdebug']) || 395a8d6e48SMichael Große ( 405a8d6e48SMichael Große isset($_SERVER['HTTP_REFERER']) && 415a8d6e48SMichael Große strpos($_SERVER['HTTP_REFERER'], 'httpdebug') !== false 425a8d6e48SMichael Große ) 435a8d6e48SMichael Große ) { 445a8d6e48SMichael Große $this->debug = true; 455a8d6e48SMichael Große } 465a8d6e48SMichael Große } 475a8d6e48SMichael Große } 485a8d6e48SMichael Große 495a8d6e48SMichael Große 505a8d6e48SMichael Große /** 515a8d6e48SMichael Große * Wraps an event around the parent function 525a8d6e48SMichael Große * 535a8d6e48SMichael Große * @triggers HTTPCLIENT_REQUEST_SEND 545a8d6e48SMichael Große * @author Andreas Gohr <andi@splitbrain.org> 555a8d6e48SMichael Große */ 565a8d6e48SMichael Große /** 575a8d6e48SMichael Große * @param string $url 585a8d6e48SMichael Große * @param string|array $data the post data either as array or raw data 595a8d6e48SMichael Große * @param string $method 605a8d6e48SMichael Große * @return bool 615a8d6e48SMichael Große */ 625a8d6e48SMichael Große public function sendRequest($url,$data='',$method='GET'){ 635a8d6e48SMichael Große $httpdata = array('url' => $url, 645a8d6e48SMichael Große 'data' => $data, 655a8d6e48SMichael Große 'method' => $method); 665a8d6e48SMichael Große $evt = new \Doku_Event('HTTPCLIENT_REQUEST_SEND',$httpdata); 675a8d6e48SMichael Große if($evt->advise_before()){ 685a8d6e48SMichael Große $url = $httpdata['url']; 695a8d6e48SMichael Große $data = $httpdata['data']; 705a8d6e48SMichael Große $method = $httpdata['method']; 715a8d6e48SMichael Große } 725a8d6e48SMichael Große $evt->advise_after(); 735a8d6e48SMichael Große unset($evt); 745a8d6e48SMichael Große return parent::sendRequest($url,$data,$method); 755a8d6e48SMichael Große } 765a8d6e48SMichael Große 775a8d6e48SMichael Große} 78