Exemple #1
0
 /**
  * Définition de l'Uri
  *
  * @param string $uri
  * @throws Zend_Service_Exception si l'uri est invalide
  */
 public function setUri($uri)
 {
     if (!Zend_Uri::check($uri)) {
         throw new Zend_Service_Exception('URL invalide');
     }
     $this->uri = $uri;
 }
 /**
  * Handles campaign redirects on
  * controller_action_layout_generate_blocks_after
  *
  * @param Varien_Object $observer
  */
 public function handleCampaignsRedirect($observer)
 {
     if (!Mage::helper('factfinder')->isEnabled('campaigns') || Mage::registry('current_product') && !Mage::helper('factfinder_campaigns')->canShowCampaignsOnProduct()) {
         return;
     }
     if ((!Mage::registry('current_layer') || !Mage::helper('factfinder')->isEnabled('catalog_navigation')) && !Mage::registry('current_product')) {
         return;
     }
     if (Mage::registry('current_product')) {
         $product = Mage::registry('current_product');
         $ids = array($product->getData(Mage::helper('factfinder_campaigns')->getIdFieldName()));
         $handler = Mage::getModel('factfinder_campaigns/handler_product', $ids);
     } else {
         $handler = Mage::getSingleton('factfinder_campaigns/handler_search');
     }
     $redirect = $handler->getRedirect();
     if ($redirect) {
         // handle relative urls
         if (!Zend_Uri::check($redirect)) {
             $redirect = Mage::getBaseUrl() . $redirect;
         }
         $response = Mage::app()->getResponse();
         $response->setRedirect($redirect);
         $response->sendResponse();
         exit;
     }
 }
Exemple #3
0
 public static function watermark(array &$optionValues, XenForo_DataWriter $optionDw, $optionId)
 {
     if ($optionId !== 'sonnbXG_watermark') {
         return true;
     }
     if (!empty($optionValues['enabled'])) {
         switch ($optionValues['overlay']) {
             case 'image':
                 if (!Zend_Uri::check($optionValues['url']) && !is_file($optionValues['url'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_image_not_valid'), $optionId);
                     return false;
                 }
                 break;
             case 'text':
                 if (!self::isTextColorValid($optionValues['textColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_text_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!self::isBgColorValid($optionValues['bgColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_bg_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!empty($optionValues['font']) && !is_file($optionValues['font'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_font_path_not_valid'), $optionId);
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
Exemple #4
0
 /** Check that the URL is valid
  * @access private
  * @param string $url to validate
  * @return string $url
  */
 private function checkUrl($url)
 {
     if (!Zend_Uri::check($url)) {
         throw new Pas_Exception_Url(self::INVALIDURL);
     }
     return $url;
 }
Exemple #5
0
 public function getColorizedImage($image_id, $color)
 {
     $color = str_replace('#', '', $color);
     $id = md5(implode('+', array($image_id, $color)));
     $url = '';
     $image = new Media_Model_Library_Image();
     if (is_numeric($image_id)) {
         $image->find($image_id);
         if (!$image->getId()) {
             return $url;
         }
         if (!$image->getCanBeColorized()) {
             $color = null;
         }
         $path = $image->getLink();
         $path = Media_Model_Library_Image::getBaseImagePathTo($path);
     } else {
         if (!Zend_Uri::check($image_id) and stripos($image_id, Core_Model_Directory::getBasePathTo()) === false) {
             $path = Core_Model_Directory::getBasePathTo($image_id);
         } else {
             $path = $image_id;
         }
     }
     try {
         $image = new Core_Model_Lib_Image();
         $image->setId($id)->setPath($path)->setColor($color)->colorize();
         $url = $image->getUrl();
     } catch (Exception $e) {
         $url = '';
     }
     return $url;
 }
 /**
  * Callback to check extra-parameters.
  *
  * @internal The availability will be ckecked just before import.
  *
  * @param string $value The value to check.
  * @return boolean
  */
 public static function validateUri($uri)
 {
     if (empty($uri)) {
         return false;
     }
     $scheme = parse_url($uri, PHP_URL_SCHEME);
     // The check is done via the server for external urls.
     if (in_array($scheme, array('http', 'https', 'ftp', 'sftp'))) {
         return Zend_Uri::check($uri);
     }
     // Unknown or unmanaged scheme.
     if ($scheme != 'file' && $uri[0] != '/') {
         return false;
     }
     // Check the security setting.
     $settings = Zend_Registry::get('archive_folder');
     if ($settings->local_folders->allow != '1') {
         return false;
     }
     // Check the base path.
     $basepath = $settings->local_folders->base_path;
     $realpath = realpath($basepath);
     if ($basepath !== $realpath || strlen($realpath) <= 2) {
         return false;
     }
     // Check the uri.
     if ($settings->local_folders->check_realpath == '1') {
         if (strpos(realpath($uri), $realpath) !== 0 || !in_array(substr($uri, strlen($realpath), 1), array('', '/'))) {
             return false;
         }
     }
     // The uri is allowed.
     return true;
 }
 public function savedomainAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (!empty($datas['domain'])) {
                 $datas['domain'] = trim(str_replace(array('https', 'http', '://'), '', $datas['domain']));
                 $parts = explode('/', $datas['domain']);
                 $datas['domain'] = !empty($parts[0]) ? $parts[0] : null;
                 $url = 'http://' . $datas['domain'];
                 if (!Zend_Uri::check($url)) {
                     throw new Exception($this->_('Please enter a valid address'));
                 } else {
                     if (addslashes($this->getRequest()->getBaseUrl()) == addslashes($url)) {
                         throw new Exception($this->_('Please enter a valid address'));
                     }
                 }
             } else {
                 $datas['domain'] = null;
             }
             $this->getApplication()->setDomain($datas['domain'])->save();
             $html = array('success' => '1', 'success_message' => $this->_('Infos successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0, 'domain' => $this->getApplication()->getDomain(), 'application_url' => $this->getApplication()->getUrl());
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage());
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
 /**
  * Verifies config to make sure the Updater should run.
  * 1. It has not been configured yet
  * 2. Or it has been enabled at some point
  *
  * @param XenForo_Dependencies_Abstract $dependencies
  * @param string $apiUrl
  * @param string|null $addOnId
  * @throws XenForo_Exception
  */
 public static function onInitDependencies(XenForo_Dependencies_Abstract $dependencies, $apiUrl, $addOnId = null)
 {
     if (get_class($dependencies) !== 'XenForo_Dependencies_Admin') {
         // do nothing unless user are in AdminCP
         return;
     }
     if (XenForo_Application::$versionId < 1020000) {
         // only run if XenForo is at least 1.2.0
         return;
     }
     if (!Zend_Uri::check($apiUrl)) {
         throw new XenForo_Exception(sprintf('$apiUrl is invalid: %s', $apiUrl));
     }
     $addOnId = self::_getAddOnId($addOnId);
     $config = self::_getConfig($addOnId, $apiUrl);
     if (!empty($config['configured']) && empty($config['enabled'])) {
         // admin has turned it off, bye bye
         return;
     }
     if (!isset($GLOBALS[self::KEY])) {
         $GLOBALS[self::KEY] = array('version' => array(), 'onPreRoute' => array(), 'setupMethod' => array());
     }
     $GLOBALS[self::KEY]['version'][$apiUrl][self::$_version] = __CLASS__;
     if (!isset($GLOBALS[self::KEY]['onPreRoute'][$apiUrl])) {
         $GLOBALS[self::KEY]['onPreRoute'][$apiUrl] = create_function('$fc', __CLASS__ . '::onPreRoute($fc, ' . var_export($config, true) . ');');
         XenForo_CodeEvent::addListener('front_controller_pre_route', $GLOBALS[self::KEY]['onPreRoute'][$apiUrl]);
     }
 }
Exemple #9
0
 /**
  * Set the callback URL to be used by Publishers or Subscribers when
  * communication with the Hub Server
  *
  * @param string $url
  */
 public function setCallbackUrl($url)
 {
     if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) {
         require_once 'Zend/Feed/Pubsubhubbub/Exception.php';
         throw new Zend_Feed_Pubsubhubbub_Exception('Invalid parameter "url"' . ' of "' . $url . '" must be a non-empty string and a valid' . 'URL');
     }
     $this->_callbackUrl = $url;
 }
Exemple #10
0
 public function renderTagImage(array $tag, array $rendererStates)
 {
     $rendered = parent::renderTagImage($tag, $rendererStates);
     if (Zend_Uri::check($rendered)) {
         $this->_found[] = array('image', $rendered);
     }
     return '';
 }
Exemple #11
0
 /**
  * Cast to HTTP query string
  *
  * @param  mixed $url
  * @param  Zend_Oauth_Config_ConfigInterface $config
  * @param  null|array $params
  * @return string
  */
 public function toQueryString($url, Zend_Oauth_Config_ConfigInterface $config, array $params = null)
 {
     if (!Zend_Uri::check($url)) {
         throw new Zend_Oauth_Exception('\'' . $url . '\' is not a valid URI');
     }
     $params = $this->_httpUtility->assembleParams($url, $config, $params);
     return $this->_httpUtility->toEncodedQueryString($params);
 }
Exemple #12
0
 /**
  * Verifies that the provided string is a valid URL
  *
  * @param string $url
  *
  * @return boolean
  */
 public static function verifyUri(&$uri, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (Zend_Uri::check($uri)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_enter_valid_url'), $fieldName);
     return false;
 }
Exemple #13
0
 protected function _verifyRedirectUri(&$redirectUri)
 {
     if (!Zend_Uri::check($redirectUri)) {
         $this->error(new XenForo_Phrase('bdapi_redirect_uri_must_be_valid'), 'redirect_uri');
         return false;
     }
     return true;
 }
Exemple #14
0
 /**
  * Validates if a string is valid as a sitemap location
  *
  * @link http://www.sitemaps.org/protocol.php#locdef <loc>
  *
  * @param  string  $value  value to validate
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (!is_string($value)) {
         return false;
     }
     return Zend_Uri::check($value);
 }
Exemple #15
0
 public function isValid($value)
 {
     if (!Zend_Uri::check($value)) {
         $this->_error(self::INVALID_URL);
         return false;
     }
     return true;
 }
Exemple #16
0
 public function __construct($linkString, $canPrependFull = true)
 {
     if ($canPrependFull) {
         // we have to verify this because caller may not know that all relative urls are forced to absolute by us
         $canPrependFull = !Zend_Uri::check($linkString);
     }
     parent::__construct($linkString, $canPrependFull);
 }
 /**
  * Checks whether URL to be shortened is valid
  *
  * @param string $url
  * @throws Zend_Service_ShortUrl_Exception When URL is not valid
  */
 protected function _validateUri($url)
 {
     require_once 'Zend/Uri.php';
     if (!Zend_Uri::check($url)) {
         require_once 'Zend/Service/ShortUrl/Exception.php';
         throw new Zend_Service_ShortUrl_Exception(sprintf('The url "%s" is not valid and cannot be shortened', $url));
     }
 }
 public function _saveFeed($datas)
 {
     $html = '';
     try {
         // Test s'il y a une erreur dans la saisie
         if (empty($datas['title'])) {
             throw new Exception($this->_('Please enter a title'));
         }
         if (empty($datas['link']) or !Zend_Uri::check($datas['link'])) {
             throw new Exception($this->_('Please enter a valid url'));
         }
         // Test s'il y a un value_id
         if (empty($datas['value_id'])) {
             throw new Exception($this->_('An error occurred while saving your RSS feed'));
         }
         if (!isset($datas['picture'])) {
             $datas['picture'] = 0;
         }
         // Récupère l'option_value en cours
         $option_value = new Application_Model_Option_Value();
         $option_value->find($datas['value_id']);
         $isNew = true;
         $html = '';
         $feed = new Rss_Model_Feed();
         $feeds = new Rss_Model_Feed();
         $feeds = $feeds->findAll(array(), 'position DESC');
         if ($feeds->count() > 0) {
             $last_position = $feeds->seek($feeds->count() - 1)->current()->getPosition();
         } else {
             $last_position = 0;
         }
         // Si un id est passé en paramètre
         if (!empty($datas['feed_id'])) {
             // Charge le flux
             $feed->find($datas['feed_id']);
             // Si le flux existe mais qu'il n'appartient pas à cette option_value
             if ($feed->getId() and $feed->getValueId() != $option_value->getId()) {
                 // Envoi l'erreur
                 throw new Exception($this->_('An error occurred while saving your RSS feed'));
             }
             $isNew = !$feed->getId();
             $last_position = $feed->getPosition();
         }
         if (!empty($last_position)) {
             $datas["position"] = $last_position + 1;
         } else {
             $datas["position"] = 0;
         }
         $feed->setData($datas)->save();
         $html = array('success' => 1, 'success_message' => $this->_('RSS feed successfully saved'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0);
         if ($isNew) {
             $html['row_html'] = $this->getLayout()->addPartial('row_' . $feed->getId(), 'admin_view_default', 'rss/application/feed/edit/row.phtml')->setCurrentFeed($feed)->setCurrentOptionValue($option_value)->toHtml();
         }
     } catch (Exception $e) {
         $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
     }
     return $html;
 }
Exemple #19
0
 protected function getFiletime($uri)
 {
     if (Zend_Uri::check($uri)) {
         $config = array('adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_NOBODY => true));
         $client = new Zend_Http_Client($uri, $config);
         return strtotime($client->request('GET')->getHeader('last-modified'));
     }
     return filemtime($this->_path . '/' . basename($uri));
 }
Exemple #20
0
 public function getParamUri($name, $required = true)
 {
     $request = $this->getRequest()->getQuery();
     if (isset($request[$name]) && Zend_Uri::check($request[$name]) && $required) {
         return @$request[$name];
     } else {
         die("Missing required parameter: " . $name . " = [URI]");
     }
 }
Exemple #21
0
 public function isValid($value)
 {
     $this->_setValue($value);
     $valid = Zend_Uri::check($value);
     if (!$valid) {
         $this->_error(self::MSG_URI);
     }
     return $valid;
 }
 public function validate(array $attributes)
 {
     if (empty($attributes[$this->_attributeName])) {
         return true;
     }
     $attributeValues = $attributes[$this->_attributeName];
     switch ($this->_options) {
         case 'URN':
             $urnValidator = new EngineBlock_Validator_Urn();
             foreach ($attributeValues as $attributeValue) {
                 if (!$urnValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URN, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'HostName':
             $hostnameValidator = new Zend_Validate_Hostname();
             foreach ($attributeValues as $attributeValue) {
                 if (!$hostnameValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_HOSTNAME, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URL':
             foreach ($attributeValues as $attributeValue) {
                 if (!Zend_Uri::check($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URI':
             $uriValidator = new EngineBlock_Validator_Uri();
             foreach ($attributeValues as $attributeValue) {
                 if (!$uriValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URI, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'EmailAddress':
             $emailValidator = new Zend_Validate_EmailAddress();
             foreach ($attributeValues as $attributeValue) {
                 if (!$emailValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_EMAIL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         default:
             throw new EngineBlock_Exception("Unknown validate option '{$this->_options}' for attribute validation");
     }
     return true;
 }
Exemple #23
0
 public function isValid($value)
 {
     $this->_setValue($value);
     if (Zend_Uri::check($value)) {
         return true;
     } else {
         $this->_error(self::MSG_URI);
         return false;
     }
 }
Exemple #24
0
 public function isValid($value)
 {
     $valid = Zend_Uri::check($value);
     if ($valid) {
         return true;
     } else {
         $this->_error(self::NOT_URI);
         return false;
     }
 }
Exemple #25
0
 /**
  * (non-PHPdoc)
  * @see Zend_Validate_Interface::isValid()
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     if (!Zend_Uri::check($value)) {
         $this->_error(self::INVALID_URL);
         return false;
     }
     return true;
 }
Exemple #26
0
 /**
  * Check stream value
  * @param string $sValue
  * @return string
  * @throws AM_Model_Db_Element_Data_Exception
  */
 protected function _addStream($sValue)
 {
     $sValue = (string) $sValue;
     if (!Zend_Uri::check($sValue)) {
         throw new AM_Model_Db_Element_Data_Exception(sprintf('Wrong parameter "%s" given', self::DATA_KEY_STREAM));
     }
     //Remove all resources keys from element
     $this->delete(self::DATA_KEY_RESOURCE);
     return $sValue;
 }
Exemple #27
0
 /**
  * Set Token
  *
  * @param string $token
  * @return Zend_Mobile_Push_Message_Mpns
  * @throws Zend_Mobile_Push_Message_Exception
  */
 public function setToken($token)
 {
     if (!is_string($token)) {
         throw new Zend_Mobile_Push_Message_Exception('$token is not a string');
     }
     if (!Zend_Uri::check($token)) {
         throw new Zend_Mobile_Push_Message_Exception('$token is not a valid URI');
     }
     return parent::setToken($token);
 }
Exemple #28
0
 public function isValid($value)
 {
     $value = iconv('UTF-8', 'ASCII//TRANSLIT', $value);
     $valid = Zend_Uri::check($value);
     if ($valid) {
         return true;
     } else {
         $this->_error(self::MSG_URL);
         return false;
     }
 }
    /**
     * Gets the cached thumbnail for a URL
     *
     * @param string $url
     *
     * @return array
     */
    public function getThumbnailByUrl($url)
    {
        if (!$url || !Zend_Uri::check($url)) {
            throw new InvalidArgumentException('Invalid URL');
        }
        return $this->_getDb()->fetchRow('
			SELECT *
			FROM xf_thumbnail_proxy_waindigo
			WHERE url_hash = ?
		', md5($url));
    }
 public function __construct()
 {
     $id = $this->getRequest()->getParam('id');
     $uri = Mage::getStoreConfig("externlinks/default/menu_link{$id}");
     // validate input parameter
     if (!Zend_Uri::check($uri)) {
         $uri = '';
         //$this->addException("Expecting a valid 'uri' parameter");
     }
     $this->setTmpUrl($uri);
 }