| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * This module contains the HTTP fetcher interface 5 * 6 * PHP versions 4 and 5 7 * 8 * LICENSE: See the COPYING file included in this distribution. 9 * 10 * @package OpenID 11 * @author JanRain, Inc. <openid@janrain.com> 12 * @copyright 2005-2008 Janrain, Inc. 13 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 14 */ 15 16 // Do not allow direct access 17 defined( '_JEXEC' ) or die( 'Restricted access' ); 18 19 /** 20 * Require logging functionality 21 */ 22 require_once "Auth/OpenID.php"; 23 24 define('Auth_OpenID_FETCHER_MAX_RESPONSE_KB', 1024); 25 define('Auth_OpenID_USER_AGENT', 26 'php-openid/'.Auth_OpenID_VERSION.' (php/'.phpversion().')'); 27 28 class Auth_Yadis_HTTPResponse { 29 function Auth_Yadis_HTTPResponse($final_url = null, $status = null, 30 $headers = null, $body = null) 31 { 32 $this->final_url = $final_url; 33 $this->status = $status; 34 $this->headers = $headers; 35 $this->body = $body; 36 } 37 } 38 39 /** 40 * This class is the interface for HTTP fetchers the Yadis library 41 * uses. This interface is only important if you need to write a new 42 * fetcher for some reason. 43 * 44 * @access private 45 * @package OpenID 46 */ 47 class Auth_Yadis_HTTPFetcher { 48 49 var $timeout = 20; // timeout in seconds. 50 51 /** 52 * Return whether a URL can be fetched. Returns false if the URL 53 * scheme is not allowed or is not supported by this fetcher 54 * implementation; returns true otherwise. 55 * 56 * @return bool 57 */ 58 function canFetchURL($url) 59 { 60 if ($this->isHTTPS($url) && !$this->supportsSSL()) { 61 Auth_OpenID::log("HTTPS URL unsupported fetching %s", 62 $url); 63 return false; 64 } 65 66 if (!$this->allowedURL($url)) { 67 Auth_OpenID::log("URL fetching not allowed for '%s'", 68 $url); 69 return false; 70 } 71 72 return true; 73 } 74 75 /** 76 * Return whether a URL should be allowed. Override this method to 77 * conform to your local policy. 78 * 79 * By default, will attempt to fetch any http or https URL. 80 */ 81 function allowedURL($url) 82 { 83 return $this->URLHasAllowedScheme($url); 84 } 85 86 /** 87 * Does this fetcher implementation (and runtime) support fetching 88 * HTTPS URLs? May inspect the runtime environment. 89 * 90 * @return bool $support True if this fetcher supports HTTPS 91 * fetching; false if not. 92 */ 93 function supportsSSL() 94 { 95 trigger_error("not implemented", E_USER_ERROR); 96 } 97 98 /** 99 * Is this an https URL? 100 * 101 * @access private 102 */ 103 function isHTTPS($url) 104 { 105 return (bool)preg_match('/^https:\/\//i', $url); 106 } 107 108 /** 109 * Is this an http or https URL? 110 * 111 * @access private 112 */ 113 function URLHasAllowedScheme($url) 114 { 115 return (bool)preg_match('/^https?:\/\//i', $url); 116 } 117 118 /** 119 * @access private 120 */ 121 function _findRedirect($headers) 122 { 123 foreach ($headers as $line) { 124 if (strpos(strtolower($line), "location: ") === 0) { 125 $parts = explode(" ", $line, 2); 126 return $parts[1]; 127 } 128 } 129 return null; 130 } 131 132 /** 133 * Fetches the specified URL using optional extra headers and 134 * returns the server's response. 135 * 136 * @param string $url The URL to be fetched. 137 * @param array $extra_headers An array of header strings 138 * (e.g. "Accept: text/html"). 139 * @return mixed $result An array of ($code, $url, $headers, 140 * $body) if the URL could be fetched; null if the URL does not 141 * pass the URLHasAllowedScheme check or if the server's response 142 * is malformed. 143 */ 144 function get($url, $headers) 145 { 146 trigger_error("not implemented", E_USER_ERROR); 147 } 148 } 149 150 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |