本文整理汇总了PHP中Zend_Uri::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Uri::setConfig方法的具体用法?PHP Zend_Uri::setConfig怎么用?PHP Zend_Uri::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Uri
的用法示例。
在下文中一共展示了Zend_Uri::setConfig方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
Zend_Uri::setConfig(array('allow_unwise' => true));
$check = Zend_Uri::check($value);
Zend_Uri::setConfig(array('allow_unwise' => false));
if (!$check) {
$this->_error(self::INVALID_URL);
return false;
}
return true;
}
示例2: _load
protected function _load()
{
if (!isset($this->_options[0])) {
throw new Exceptions_SeotoasterWidgetException('Rss feed url should be specified');
}
$scheme = 'http';
$feeds = array();
//little hack for options, needs to be somthing better
if (preg_match('~^https?$~', $this->_options[0])) {
$scheme = array_shift($this->_options);
$this->_options[0] = ltrim($this->_options[0], '/');
}
$feedUrl = $scheme . '://' . str_replace(' ', '+', html_entity_decode($this->_options[0]));
$maxResult = isset($this->_options[1]) ? $this->_options[1] : self::RSS_RESULT_COUNT;
Zend_Uri::setConfig(array('allow_unwise' => true));
if (!Zend_Uri::check($feedUrl)) {
throw new Exceptions_SeotoasterWidgetException('Rss feed url is not valid.');
}
Zend_Feed_Reader::setCache(Zend_Registry::get('cache'));
Zend_Feed_Reader::useHttpConditionalGet();
try {
$rss = Zend_Feed_Reader::import($feedUrl);
} catch (Exception $e) {
return $e->getMessage();
}
$i = 0;
foreach ($rss as $item) {
if ($i == $maxResult) {
break;
}
$feeds[] = array('title' => $item->getTitle(), 'link' => $item->getLink(), 'description' => Tools_Text_Tools::cutText(strip_tags($item->getDescription()), isset($this->_options[2]) ? $this->_options[2] : self::RSS_DESC_LENGTH), 'pubDate' => $item->getDateCreated(), 'content' => $item->getContent(), 'authors' => $item->getAuthors(), 'image' => $this->_getRssEntryImage($item->getContent()));
$i++;
}
$this->_view->useImage = isset($this->_options[3]) && $this->_options[3] == 'img' ? true : false;
$this->_view->feed = $feeds;
return $this->_view->render('rss.phtml');
}
示例3: testAllowUnwiseQueryString
/**
* Test that after setting 'allow_unwise' to true unwise characters are
* accepted
*
*/
public function testAllowUnwiseQueryString()
{
$unwise = array('http://example.com/?q={', 'http://example.com/?q=}', 'http://example.com/?q=|', 'http://example.com/?q=\\', 'http://example.com/?q=^', 'http://example.com/?q=`');
Zend_Uri::setConfig(array('allow_unwise' => true));
foreach ($unwise as $uri) {
$this->assertTrue(Zend_Uri::check($uri), "failed for URI {$uri}");
}
Zend_Uri::setConfig(array('allow_unwise' => false));
}
示例4: checkValid_URL
/**
* Check valid URL
*
* @param string $aURL
* @param bool $allow_unwise //Allow to use in a URL "not smart symbols" -> "{", "}", "|", "\", "^", "`"
* @return bool
*/
static function checkValid_URL($aURL, $allow_unwise = false)
{
//----------------
Zend_Uri::setConfig(array('allow_unwise' => $allow_unwise));
return Zend_Uri::check($aURL);
}
示例5: testSetConfigInvalid
/**
* Tests that Zend_Uri::setConfig() throws Zend_Uri_Exception if no array
* nor Zend_Config is given as first parameter
*
* @group ZF-5578
* @expectedException Zend_Uri_Exception
*/
public function testSetConfigInvalid()
{
Zend_Uri::setConfig('This should cause an exception');
}
示例6: checkLinkToRedirect
/**
*
* Checks if there is a link to redirect after sign in ...
* It has to be a internal link, so it won't accept
* if it makes the user goes to somewhere else instead
*/
public function checkLinkToRedirect()
{
$config = self::$_registry->get("config");
$redirectAfterLogin = filter_input(INPUT_GET, "redirect_after_login", FILTER_UNSAFE_RAW);
if ($redirectAfterLogin && $redirectAfterLogin != null) {
$testLink = $redirectAfterLogin;
} else {
if (isset($_SERVER['HTTP_REFERER'])) {
$router = Zend_Controller_Front::getInstance()->getRouter();
if ($router->getCurrentRouteName() == "login") {
$referer = $_SERVER['HTTP_REFERER'];
$partialLink = explode("?redirect_after_login=", $referer, 2);
if (!isset($partialLink[1])) {
return false;
} else {
$testLink = $partialLink[1];
}
}
} else {
return false;
}
}
// the redirection link must start with a '/' and
// must not end up in the redirector again
// or be in another host (avoids the use of @)
$thisPage = explode("?", $_SERVER['REQUEST_URI'], 2);
$thisPage = $thisPage[0];
if (mb_substr($testLink, 0, 1) == '/' && !mb_strpos($testLink, "@") && $thisPage != $testLink) {
// @todo HTTPS support
$redirTo = "http://" . $config['webhost'] . $testLink;
Zend_Uri::setConfig(array('allow_unwise' => true));
if (Zend_Uri::check($redirTo)) {
$testUri = Zend_Uri::factory($redirTo);
$path = $testUri->getPath();
Zend_Uri::setConfig(array('allow_unwise' => false));
return $path;
}
}
return false;
}