本文整理汇总了PHP中Zend_Uri_Http::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Uri_Http::fromString方法的具体用法?PHP Zend_Uri_Http::fromString怎么用?PHP Zend_Uri_Http::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Uri_Http
的用法示例。
在下文中一共展示了Zend_Uri_Http::fromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _requireValidSchacHomeOrganization
protected function _requireValidSchacHomeOrganization($responseAttributes)
{
if (!isset($responseAttributes[self::URN_MACE_TERENA_SCHACHOMEORG])) {
return self::URN_MACE_TERENA_SCHACHOMEORG . " missing in attributes!";
}
$schacHomeOrganizationValues = $responseAttributes[self::URN_MACE_TERENA_SCHACHOMEORG];
if (count($schacHomeOrganizationValues) === 0) {
return self::URN_MACE_TERENA_SCHACHOMEORG . " has no values";
}
if (count($schacHomeOrganizationValues) > 1) {
return self::URN_MACE_TERENA_SCHACHOMEORG . " has too many values";
}
$schacHomeOrganization = $schacHomeOrganizationValues[0];
$reservedSchacHomeOrganization = $this->_isReservedSchacHomeOrganization($schacHomeOrganization);
if ($reservedSchacHomeOrganization === TRUE) {
return self::URN_MACE_TERENA_SCHACHOMEORG . " is reserved for another IdP!";
}
$validHostName = false;
try {
$uri = Zend_Uri_Http::fromString('http://' . $schacHomeOrganization);
$validHostName = $uri->validateHost($schacHomeOrganization);
} catch (Zend_Validate_Exception $e) {
}
if (!$validHostName) {
return self::URN_MACE_TERENA_SCHACHOMEORG . " is not a valid hostname!";
}
// Passed all the checks, valid SHO!
return false;
}
示例2: _getWechatOAuthUrl
private function _getWechatOAuthUrl($appid, $scope, $callbackurl, $state)
{
$client = Zend_Uri_Http::fromString("https://open.weixin.qq.com/connect/oauth2/authorize");
$client->addReplaceQueryParameters(array("appid" => $appid, "redirect_uri" => $callbackurl, "response_type" => "code", "scope" => $scope, "sate" => $state));
$client->setFragment("wechat_redirect");
return $client->getUri();
}
示例3: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if the $value is a valid url that starts with http(s)://
* and the hostname is a valid TLD
*
* @param string $value
* @throws Zend_Validate_Exception if a fatal error occurs for validation process
* @return boolean
*/
public function isValid($value)
{
if (!is_string($value)) {
$this->_error(self::INVALID_URL);
return false;
}
$this->_setValue($value);
//get a Zend_Uri_Http object for our URL, this will only accept http(s) schemes
try {
$uriHttp = Zend_Uri_Http::fromString($value);
} catch (Zend_Uri_Exception $e) {
$this->_error(self::INVALID_URL);
return false;
}
//if we have a valid URI then we check the hostname for valid TLDs, and not local urls
$hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS); //do not allow local hostnames, this is the default
if (!$hostnameValidator->isValid($uriHttp->getHost())) {
$this->_error(self::INVALID_URL);
return false;
}
return true;
}
示例4: testSimpleFromString
public function testSimpleFromString()
{
$uri = 'http://www.zend.com';
$obj = Zend_Uri_Http::fromString($uri);
$this->assertEquals($uri, $obj->getUri(), 'getUri() returned value that differs from input');
}
示例5: regenerateMediaFiles
/**
* Delete content of media/js and media/css folders to refresh with updated compressed/minified js/css content
* If disabled, the updates are done each time an original file is updated. Can be resource overload on live website.
*
* @param Mage_Core_Model_Observer $observer
*/
public function regenerateMediaFiles($observer)
{
if (Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && (Mage::getStoreConfigFlag('uioptimization/csscompression/enabled') || Mage::getStoreConfigFlag('uioptimization/jscompression/enabled'))) {
// Clean up media/css and media/js folders and recreate the folders if necessary
try {
Mage::getModel('core/design_package')->cleanMergedJsCss();
Mage::dispatchEvent('clean_media_cache_after');
} catch (Exception $e) {
Mage::logException($e);
return;
}
$stores = Mage::app()->getStores();
foreach ($stores as $id => $v) {
$url = Zend_Uri_Http::fromString(Mage::app()->getStore($id)->getBaseUrl());
// Recreate the js and css compressed file by using the normal process
try {
$curl = new Zend_Http_Client_Adapter_Curl();
$curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
$curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
$curl->connect($url->getHost(), $url->getPort(), Mage_Core_Model_Store::isCurrentlySecure());
$curl->write(Zend_Http_Client::GET, $url);
$curl->close();
Mage::log('[Diglin_UIOptimization_Model_Observer] Update media js/css content for the different stores', ZEND_LOG::DEBUG);
} catch (Exception $e) {
Mage::logException($e);
return;
}
}
}
}
示例6: _processRequest
/**
* Process oauth related protocol information and return as an array
*
* @param string $authHeaderValue
* @param string $contentTypeHeader
* @param string $requestBodyString
* @param string $requestUrl
* @return array
* merged array of oauth protocols and request parameters. eg :
* <pre>
* array (
* 'oauth_version' => '1.0',
* 'oauth_signature_method' => 'HMAC-SHA1',
* 'oauth_nonce' => 'rI7PSWxTZRHWU3R',
* 'oauth_timestamp' => '1377183099',
* 'oauth_consumer_key' => 'a6aa81cc3e65e2960a4879392445e718',
* 'oauth_signature' => 'VNg4mhFlXk7%2FvsxMqqUd5DWIj9s%3D'
* )
* </pre>
*/
protected function _processRequest($authHeaderValue, $contentTypeHeader, $requestBodyString, $requestUrl)
{
$protocolParams = [];
if (!$this->_processHeader($authHeaderValue, $protocolParams)) {
return [];
}
if ($contentTypeHeader && 0 === strpos($contentTypeHeader, \Zend_Http_Client::ENC_URLENCODED)) {
$protocolParamsNotSet = !$protocolParams;
parse_str($requestBodyString, $protocolBodyParams);
foreach ($protocolBodyParams as $bodyParamName => $bodyParamValue) {
if (!$this->_isProtocolParameter($bodyParamName)) {
$protocolParams[$bodyParamName] = $bodyParamValue;
} elseif ($protocolParamsNotSet) {
$protocolParams[$bodyParamName] = $bodyParamValue;
}
}
}
$protocolParamsNotSet = !$protocolParams;
$queryString = \Zend_Uri_Http::fromString($requestUrl)->getQuery();
$this->_extractQueryStringParams($protocolParams, $queryString);
if ($protocolParamsNotSet) {
$this->_fetchProtocolParamsFromQuery($protocolParams, $queryString);
}
// Combine request and header parameters
return $protocolParams;
}
示例7: getUrl
/**
* Generate a redirect URL from the allowable parameters and configured
* values.
*
* @return string
*/
public function getUrl()
{
$params = $this->assembleParams();
$uri = Zend_Uri_Http::fromString($this->_consumer->getUserAuthorizationUrl());
$uri->setQuery($this->_httpUtility->toEncodedQueryString($params));
return $uri->getUri();
}
示例8: getEndpoint
/**
* Gets the provided endpoint
*
* @return Zend_Uri_Http
*/
public function getEndpoint()
{
if (empty($this->_endpoint)) {
$this->_endpoint = Zend_Uri_Http::fromString(self::ENDPOINT_URL);
}
return $this->_endpoint;
}
示例9: __construct
/**
* 初始化趣乐平台地址
*
* @param string $url
*/
public function __construct($url = null)
{
if (empty($url)) {
$this->_uri = self::$_defaultUri;
} else {
$this->_uri = Zend_Uri_Http::fromString($url);
}
}
示例10: __construct
/**
* Constructor
*/
public function __construct()
{
$this->_config = new binumi_config();
// We have to use the fromString method because the 'host' we pass in
// may actually contain a port (e.g. 'blah.com:8080' not just 'blah.com')
// so we can't just pass it to Zend_Uri_Http.setHost(), like one might
// expect
$url = $this->_config->get_scheme() . '://' . $this->_config->get_host();
$this->_uri = Zend_Uri_Http::fromString($url);
}
示例11: execute
public function execute($request)
{
$this->forward404Unless($request->hasParameter('url'));
try {
$zendUri = Zend_Uri_Http::fromString($request->getParameter('url'));
} catch (Exception $e) {
return sfView::ERROR;
}
$this->url = $zendUri->getUri();
$this->proxys = sfConfig::get('op_mobile_proxys');
}
示例12: getWebsiteUri
/**
* Retrieves and parses the charity's Website URL.
*
* @return Zend_Uri_Http The parsed URL
*/
public function getWebsiteUri()
{
if ($uri = $this->getModel()->getWebsite()) {
try {
return Zend_Uri_Http::fromString($uri);
} catch (Lucky_Donations_Exception $e) {
return '';
}
} else {
return false;
}
}
示例13: normaliseBaseSignatureUrl
public function normaliseBaseSignatureUrl($url)
{
$uri = Zend_Uri_Http::fromString($url);
if ($uri->getScheme() == 'http' && $uri->getPort() == '80') {
$uri->setPort('');
} elseif ($uri->getScheme() == 'https' && $uri->getPort() == '443') {
$uri->setPort('');
}
$uri->setQuery('');
$uri->setFragment('');
$uri->setHost(strtolower($uri->getHost()));
return $uri->getUri(true);
}
示例14: testSparqlWithDbPediaEndpoint
/**
* Test if the Erfurt_Store_Adapter_Sparql resolves the graph URI to the correct service.
*/
public function testSparqlWithDbPediaEndpoint()
{
$options = array('serviceUrl' => 'http://dbpedia.org/sparql', 'graphs' => array('http://dbpedia.org'));
$adapter = new Erfurt_Store_Adapter_Sparql($options);
// Use HTTP Client test adapter
$httpAdapter = new Erfurt_TestHelper_Http_ClientAdapter();
$httpAdapter->setResponse(new Zend_Http_Response(200, array('Content-type' => 'application/sparql-results+xml'), file_get_contents($this->_dataDir . 'sparqlDBpediaLeipzig.srx')));
$adapter->setHttpAdapter($httpAdapter);
$sparql = 'SELECT ?p ?o FROM <http://dbpedia.org> WHERE {<http://dbpedia.org/resource/Leipzig> ?p ?o} LIMIT 10';
$result = $adapter->sparqlQuery($sparql);
$serviceUrl = Zend_Uri_Http::fromString('http://dbpedia.org/sparql');
$requestUrl = $httpAdapter->getLastRequestUri();
$this->assertTrue(is_array($result));
$this->assertEquals($serviceUrl->getHost(), $requestUrl->getHost());
$this->assertEquals($serviceUrl->getPath(), $requestUrl->getPath());
$this->assertEquals(10, count($result));
}
示例15: routeStartup
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
/** @var $request \Zend_Controller_Request_Http */
if (!$request->isGet()) {
return;
}
$host = 'http://' . $request->getHttpHost();
$uri = \Zend_Uri_Http::fromString($host . $request->getRequestUri());
$query = $uri->getQueryAsArray();
if (!isset($query['_escaped_fragment_'])) {
return;
}
$path = $uri->getPath() . ltrim($query['_escaped_fragment_'], '/');
$uri->setPath($path);
unset($query['_escaped_fragment_']);
$uri->setQuery($query);
$request->setRequestUri(str_replace($host, '', $uri->getUri()));
$request->setPathInfo();
}