当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Uri_Http::factory方法代码示例

本文整理汇总了PHP中Zend_Uri_Http::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Uri_Http::factory方法的具体用法?PHP Zend_Uri_Http::factory怎么用?PHP Zend_Uri_Http::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Uri_Http的用法示例。


在下文中一共展示了Zend_Uri_Http::factory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter

 /**
  * Filters the YouTube video id from a URL and returns the id. Return an
  * empty string on an invalid URL.
  * 
  * @param string $value
  * @return string
  */
 public function filter($value)
 {
     try {
         $uri = Zend_Uri_Http::factory($value);
         if ($uri->valid()) {
             $query = $uri->getQueryAsArray();
             if (isset($query['v'])) {
                 return $query['v'];
             }
         }
     } catch (Zend_Uri_Exception $e) {
     }
     return '';
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:21,代码来源:YoutubeId.php

示例2: testSearchResult

 public function testSearchResult()
 {
     $object = new Zend_Service_Technorati_SearchResult($this->domElements->item(0));
     // check properties
     $this->assertTrue(is_string($object->getTitle()));
     $this->assertContains('El SDK de Android', $object->getTitle());
     $this->assertTrue(is_string($object->getExcerpt()));
     $this->assertContains('[ Android]', $object->getExcerpt());
     $this->assertTrue($object->getPermalink() instanceof Zend_Uri_Http);
     $this->assertEquals(Zend_Uri_Http::factory('http://blogs.eurielec.etsit.upm.es/miotroblog/?p=271'), $object->getPermalink());
     $this->assertTrue($object->getCreated() instanceof Zend_Date);
     $this->assertEquals(new Zend_Date('2007-11-14 22:18:04 GMT'), $object->getCreated());
     // check weblog
     $this->assertTrue($object->getWeblog() instanceof Zend_Service_Technorati_Weblog);
     $this->assertContains('Mi otro blog', $object->getWeblog()->getName());
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:16,代码来源:SearchResultTest.php

示例3: isValid

 /**
  * Checks if a username is a valid Twitter account by sending an HTTP
  * request to the profile page.
  * @param string $value
  * @return <type>
  */
 public function isValid($value)
 {
     $this->_setValue((string) $value);
     try {
         $uri = Zend_Uri_Http::factory(self::BASEURI . $value);
     } catch (Zend_Uri_Exception $e) {
         $this->_error(self::INVALID_ACCOUNT);
         return false;
     }
     $httpClient = new Zend_Http_Client($uri);
     $response = $httpClient->request();
     if ($response->getStatus() != '200') {
         $this->_error(self::INVALID_ACCOUNT);
         return false;
     }
     return true;
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:23,代码来源:TwitterAccount.php

示例4: _checkYoutubeApi

 /**
  * Does a request to the YouTube API.
  * @param string|int $id
  * @return boolean
  */
 protected function _checkYoutubeApi($id)
 {
     try {
         $uri = Zend_Uri_Http::factory(self::API_URL . $id);
         $httpClient = new Zend_Http_Client($uri);
         $response = $httpClient->request();
     } catch (Zend_Uri_Exception $e) {
         // the id is malformed
         return false;
     } catch (Zend_Http_Client_Adapter_Exception $e) {
         /**
          * Catch the timeout
          *
          * We do not know if the video is valid and are unable to check
          * so we assume it is OK.
          */
         return true;
     }
     return $response->getStatus() == '200';
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:25,代码来源:YoutubeVideo.php

示例5: fromString

 /**
  * Generate a new Cookie object from a cookie string
  * (for example the value of the Set-Cookie HTTP header)
  *
  * @param string $cookieStr
  * @param Zend_Uri_Http|string $refUri Reference URI for default values (domain, path)
  * @param boolean $encodeValue Whether or not the cookie's value should be
  *                             passed through urlencode/urldecode
  * @return Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.
  */
 public static function fromString($cookieStr, $refUri = null, $encodeValue = true)
 {
     // Set default values
     if (is_string($refUri)) {
         $refUri = Zend_Uri_Http::factory($refUri);
     }
     $name = '';
     $value = '';
     $domain = '';
     $path = '';
     $expires = null;
     $secure = false;
     $parts = explode(';', $cookieStr);
     // If first part does not include '=', fail
     if (strpos($parts[0], '=') === false) {
         return false;
     }
     // Get the name and value of the cookie
     list($name, $value) = explode('=', trim(array_shift($parts)), 2);
     $name = trim($name);
     if ($encodeValue) {
         $value = urldecode(trim($value));
     }
     // Set default domain and path
     if ($refUri instanceof Zend_Uri_Http) {
         $domain = $refUri->getHost();
         $path = $refUri->getPath();
         $path = substr($path, 0, strrpos($path, '/'));
     }
     // Set other cookie parameters
     foreach ($parts as $part) {
         $part = trim($part);
         if (strtolower($part) == 'secure') {
             $secure = true;
             continue;
         }
         $keyValue = explode('=', $part, 2);
         if (count($keyValue) == 2) {
             list($k, $v) = $keyValue;
             switch (strtolower($k)) {
                 case 'expires':
                     if (($expires = strtotime($v)) === false) {
                         /**
                          * The expiration is past Tue, 19 Jan 2038 03:14:07 UTC
                          * the maximum for 32-bit signed integer. Zend_Date
                          * can get around that limit.
                          *
                          * @see Zend_Date
                          */
                         require_once 'Zend/Date.php';
                         $expireDate = new Zend_Date($v);
                         $expires = $expireDate->getTimestamp();
                     }
                     break;
                 case 'path':
                     $path = $v;
                     break;
                 case 'domain':
                     $domain = $v;
                     break;
                 default:
                     break;
             }
         }
     }
     if ($name !== '') {
         $ret = new self($name, $value, $domain, $expires, $path, $secure);
         $ret->encodeValue = $encodeValue ? true : false;
         return $ret;
     } else {
         return false;
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:83,代码来源:Cookie.php

示例6: fromString

 /**
  * Generate a new Cookie object from a cookie string
  * (for example the value of the Set-Cookie HTTP header)
  *
  * @param string $cookieStr
  * @param Zend_Uri_Http|string $ref_uri Reference URI for default values (domain, path)
  * @return Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.
  */
 public static function fromString($cookieStr, $ref_uri = null)
 {
     // Set default values
     if (is_string($ref_uri)) {
         $ref_uri = Zend_Uri_Http::factory($ref_uri);
     }
     $name = '';
     $value = '';
     $domain = '';
     $path = '';
     $expires = null;
     $secure = false;
     $parts = explode(';', $cookieStr);
     // If first part does not include '=', fail
     if (strpos($parts[0], '=') === false) {
         return false;
     }
     // Get the name and value of the cookie
     list($name, $value) = explode('=', trim(array_shift($parts)), 2);
     $name = trim($name);
     $value = urldecode(trim($value));
     // Set default domain and path
     if ($ref_uri instanceof Zend_Uri_Http) {
         $domain = $ref_uri->getHost();
         $path = $ref_uri->getPath();
         $path = substr($path, 0, strrpos($path, '/'));
     }
     // Set other cookie parameters
     foreach ($parts as $part) {
         $part = trim($part);
         if (strtolower($part) == 'secure') {
             $secure = true;
             continue;
         }
         $keyValue = explode('=', $part, 2);
         if (count($keyValue) == 2) {
             list($k, $v) = $keyValue;
             switch (strtolower($k)) {
                 case 'expires':
                     $expires = strtotime($v);
                     break;
                 case 'path':
                     $path = $v;
                     break;
                 case 'domain':
                     $domain = $v;
                     break;
                 default:
                     break;
             }
         }
     }
     if ($name !== '') {
         return new Zend_Http_Cookie($name, $value, $domain, $expires, $path, $secure);
     } else {
         return false;
     }
 }
开发者ID:Orchild,项目名称:mt,代码行数:66,代码来源:Cookie.php

示例7: setUri

 /**
  * Set the URI for the next request
  *
  * @param Zend_Uri_Http|string $uri
  */
 public function setUri($uri)
 {
     if (is_string($uri) && Zend_Uri_Http::check($uri)) {
         $uri = Zend_Uri_Http::factory($uri);
     }
     if ($uri instanceof Zend_Uri_Http) {
         // We have no ports, set the defaults
         if (!$uri->getPort()) {
             $uri->setPort($uri->getScheme() == 'https' ? 443 : 80);
         }
         $this->uri = $uri;
     } else {
         throw new Zend_Http_Exception('Passed parameter is not a valid HTTP URI.');
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:Abstract.php

示例8: deleteCookies

 /**
  * Delete a cookie according to it's name and domain. If no name is specified,
  * all cookies from this domain will be cleared out.
  *
  * @param string|Zend_Uri_Http $domain
  * @param string $cookie_name 
  * @return boolean true if cookie was deleted.
  */
 public function deleteCookies($domain, $cookie_name = null)
 {
     $ret = false;
     $path = '/';
     if ($domain instanceof Zend_Uri_Http) {
         $path = dirname($domain->getPath());
         $domain = $domain->getHost();
     } elseif (is_string($domain) && Zend_Uri_Http::check($domain)) {
         $domain = Zend_Uri_Http::factory($domain);
         $path = dirname($domain->getPath());
         $domain = $domain->getHost();
     }
     // If we have a cookie's name, delete only this one
     if (isset($cookie_name) && isset($this->cookies[$domain][$path][$cookie_name])) {
         unset($this->cookies[$domain][$path][$cookie_name]);
         $ret = true;
         // If we only got a URI, clear all cookies matching this URI.
     } else {
         $cookies = $this->_matchPath($this->_matchDomain($domain), $path);
         foreach ($cookies as $cookie) {
             if (isset($this->cookies[$cookie->getDomain()][$cookie->getPath])) {
                 unset($this->cookies[$cookie->getDomain()][$cookie->getPath]);
                 $ret = true;
                 if (count($this->cookies[$cookie->getDomain()]) == 0) {
                     unset($this->cookies[$cookie->getDomain()]);
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:39,代码来源:Cookiejar.php

示例9: isValid

 /**
  * Checks if a url is within the set domain and/or subdomain.
  * @param string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     try {
         $uri = Zend_Uri_Http::factory($value);
     } catch (Zend_Uri_Exception $e) {
         $this->_error(self::INVALID);
         return false;
     }
     // Explode the base and subdomains for our valid and input domains
     list($validBase, $validSub) = $this->_splitHost($this->_domain);
     list($inputBase, $inputSub) = $this->_splitHost($uri->getHost());
     if ($validBase != $inputBase) {
         $this->_error(self::OUTSIDE_DOMAIN);
         return false;
     }
     // See if we need to validate the subdomain
     if ($this->_validateSubdomain) {
         if ($validSub != $inputSub) {
             $this->_error(self::OUTSIDE_DOMAIN);
             return false;
         }
     }
     return true;
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:30,代码来源:Domain.php

示例10: factory

 /**
  * Generate a new Cookie object from a cookie string 
  * (for example the value of the Set-Cookie HTTP header)
  *
  * @param string $cookieStr
  * @param Zend_Uri_Http|string $ref_uri Reference URI for default values (domain, path)
  * @return Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.
  */
 public static function factory($cookieStr, $ref_uri = null)
 {
     // Set default values
     if (is_string($ref_uri)) {
         $ref_uri = Zend_Uri_Http::factory($ref_uri);
     }
     $name = null;
     $value = null;
     $expires = null;
     $domain = null;
     $path = null;
     $secure = false;
     if ($ref_uri instanceof Zend_Uri_Http) {
         $domain = $ref_uri->getHost();
         $path = dirname($ref_uri->getPath());
     }
     foreach (explode(';', $cookieStr) as $part) {
         $part = trim($part);
         if (strtolower($part) == 'secure') {
             $secure = true;
             continue;
         }
         list($k, $v) = explode('=', $part);
         if (isset($k) && isset($v)) {
             switch ($k) {
                 case 'expires':
                     $expires = strtotime($v);
                     break;
                 case 'path':
                     $path = $v;
                     break;
                 case 'domain':
                     $domain = $v;
                     break;
                 default:
                     $name = $k;
                     $value = $v;
                     break;
             }
         }
     }
     if ($name && isset($value)) {
         return new Zend_Http_Cookie($name, $value, $domain, $expires, $path, $secure);
     } else {
         return false;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:55,代码来源:Cookie.php

示例11: testRelativePathRedirect

 public function testRelativePathRedirect()
 {
     $client = $this->_prepareClient('testRelativeRedirections');
     $client->setParameterGet('redirect', 'relpath');
     $client->setMaxRedirects(1);
     $res = $client->request('GET');
     // Get the new expected path
     $uri = Zend_Uri_Http::factory($this->baseuri);
     $uri->setPort(80);
     $uri->setPath($uri->getPath() . 'path/to/fake/file.ext');
     $uri = $uri->__toString();
     $this->assertEquals("{$uri}?redirect=relpath", $client->getUri(true), "The new location is not as expected: {$client->getUri(true)}");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:ClientTest.php

示例12: filterBefore

 protected function filterBefore(Mage_Api2_Model_Request $request, Mage_Api2_Model_Response $response)
 {
     // Add generic CORS headers - this is not the 'right' way to do this, but Magento has no CORS support in Mage_Api2
     $response->setHeader('Access-Control-Allow-Origin', '*', true);
     $response->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE', true);
     $response->setHeader('Access-Control-Allow-Headers', 'Content-Type', true);
     $response->setHeader('Access-Control-Max-Age', '86400', true);
     // Support credentials
     $response->setHeader('Access-Control-Allow-Credentials', 'true', true);
     $origin = $request->getHeader('Origin');
     if ($origin) {
         try {
             $origin = Zend_Uri_Http::factory($origin);
             $response->setHeader('Access-Control-Allow-Origin', $origin->getUri(), true);
         } catch (Exception $e) {
             // NOOP
         }
     }
     Mage::dispatchEvent('api2_server_filter_before', ['request' => $request, 'response' => $response]);
 }
开发者ID:aoepeople,项目名称:aoe_api2,代码行数:20,代码来源:Server.php


注:本文中的Zend_Uri_Http::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。