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


PHP JFilterInput::getInstance方法代码示例

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


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

示例1: check

 /** 
  * overloaded check function 
  */
 function check()
 {
     // filter malicious code
     $ignoreList = array('params', 'description');
     $ignore = is_array($ignoreList);
     $filter =& JFilterInput::getInstance();
     foreach ($this->getProperties() as $k => $v) {
         if ($ignore && in_array($k, $ignoreList)) {
             continue;
         }
         $this->{$k} = $filter->clean($this->{$k});
     }
     /** check for valid name */
     if (trim($this->name) == '') {
         $this->_error = JText::_('Gallery name');
         return false;
     }
     /** check for existing name */
     $query = "SELECT id" . "\n FROM #__rsgallery2_galleries" . "\n WHERE name = '" . $this->name . "'" . "\n AND parent = " . $this->parent;
     $this->_db->setQuery($query);
     $xid = intval($this->_db->loadResult());
     if ($xid && $xid != intval($this->id)) {
         $this->_error = JText::_('There is a gallery already with that name, please try again.');
         return false;
     }
     return true;
 }
开发者ID:realityking,项目名称:rsgallery2,代码行数:30,代码来源:galleries.class.php

示例2: render

 /**
  * Render the document
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  string   The rendered data
  *
  * @since   11.1
  */
 public function render($cache = false, $params = array())
 {
     // If no error object is set return null
     if (!isset($this->_error)) {
         return;
     }
     //Set the status header
     JResponse::setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage()));
     $file = 'error.php';
     // check template
     $directory = isset($params['directory']) ? $params['directory'] : 'templates';
     $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system';
     if (!file_exists($directory . '/' . $template . '/' . $file)) {
         $template = 'system';
     }
     //set variables
     $this->baseurl = JURI::base(true);
     $this->template = $template;
     $this->debug = isset($params['debug']) ? $params['debug'] : false;
     $this->error = $this->_error;
     // load
     $data = $this->_loadTemplate($directory . '/' . $template, $file);
     parent::render();
     return $data;
 }
开发者ID:Radek-Suski,项目名称:joomla-platform,代码行数:35,代码来源:error.php

示例3: testGetVarFromDataSet

 /**
  * @dataProvider getVarData
  * @covers JRequest::getVar
  * @covers JRequest::_cleanVar
  * @covers JRequest::_stripSlashesRecursive
  */
 public function testGetVarFromDataSet($name, $default, $hash, $type, $mask, $expect, $filterCalls)
 {
     jimport('joomla.environment.request');
     $filter = JFilterInput::getInstance();
     $filter->mockReset();
     if (count($filterCalls)) {
         foreach ($filterCalls as $info) {
             $filter->mockSetUp($info[0], $info[1], $info[2], $info[3]);
         }
     }
     /*
      * Get the variable and check the value.
      */
     $actual = JRequest::getVar($name, $default, $hash, $type, $mask);
     $this->assertEquals($expect, $actual, 'Non-cached getVar');
     /*
      * Repeat the process to check caching (the JFilterInput mock should not
      * get called unless the default is being used).
      */
     $actual = JRequest::getVar($name, $default, $hash, $type, $mask);
     $this->assertEquals($expect, $actual, 'Cached getVar');
     if (($filterOK = $filter->mockTearDown()) !== true) {
         $this->fail('JFilterInput not called as expected:' . print_r($filterOK, true));
     }
 }
开发者ID:rvsjoen,项目名称:joomla-platform,代码行数:31,代码来源:JRequestGetVarTest.php

示例4: create

 public static function create($source = null, $filter = null)
 {
     if (is_null($filter)) {
         $filter = JFilterInput::getInstance(array(), array(), 1, 1, 0);
     }
     return $input = new JInput($source, array('filter' => $filter));
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:7,代码来源:input.php

示例5: delete

 /**
  * Method to delete the images
  *
  * @access	public
  * @return int
  */
 public function delete($type)
 {
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get some data from the request
     $images = $this->getImages($type);
     $folder = $this->map[$type]['folder'];
     $count = count($images);
     $fail = 0;
     if ($count) {
         foreach ($images as $image) {
             if ($image !== JFilterInput::getInstance()->clean($image, 'path')) {
                 JError::raiseWarning(100, JText::_('COM_JEM_HOUSEKEEPING_UNABLE_TO_DELETE') . ' ' . htmlspecialchars($image, ENT_COMPAT, 'UTF-8'));
                 $fail++;
                 continue;
             }
             $fullPath = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/' . $image);
             $fullPaththumb = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/small/' . $image);
             if (is_file($fullPath)) {
                 JFile::delete($fullPath);
                 if (JFile::exists($fullPaththumb)) {
                     JFile::delete($fullPaththumb);
                 }
             }
         }
     }
     $deleted = $count - $fail;
     return $deleted;
 }
开发者ID:JKoelman,项目名称:JEM-3,代码行数:36,代码来源:housekeeping.php

示例6: ajaxAddFeatured

 /**
  * Feature the given user
  *
  * @param  int $memberId userid to feature
  * @return [type]           [description]
  */
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $config = CFactory::getConfig();
             $limit = $config->get('featured' . FEATURED_USERS . 'limit', 10);
             if ($featured->add($memberId, $my->id) === true) {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
             } else {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_LIMIT_REACHED_FEATURED', $member->getDisplayName(), $limit);
             }
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     $json = array();
     $json['title'] = ' ';
     $json['html'] = $html;
     die(json_encode($json));
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:38,代码来源:search.php

示例7: expression

 public static function expression($calculation, $formId)
 {
     $return = '';
     $pattern = '#{(.*?):value}#is';
     $expression = $calculation->expression;
     $filter = JFilterInput::getInstance();
     preg_match_all($pattern, $calculation->expression, $matches);
     if ($matches) {
         foreach ($matches[0] as $i => $match) {
             $field = $filter->clean($matches[1][$i] . "_" . $formId, 'cmd');
             $return .= "\t total" . $field . " = 0;\n";
             $return .= "\t values" . $field . " = rsfp_getValue(" . $formId . ", '" . $matches[1][$i] . "');\n";
             $return .= "\t if (typeof values" . $field . " == 'object') { \n";
             $return .= "\t\t for(i=0;i<values" . $field . ".length;i++) {\n";
             $return .= "\t\t\t thevalue = values" . $field . "[i]; \n";
             $return .= "\t\t\t if (isset(RSFormProPrices['" . $formId . "_" . $matches[1][$i] . "'])) { \n";
             $return .= "\t\t\t\t total" . $field . " += isset(RSFormProPrices['" . $formId . "_" . $matches[1][$i] . "'][thevalue]) ? parseFloat(RSFormProPrices['" . $formId . "_" . $matches[1][$i] . "'][thevalue]) : 0; \n";
             $return .= "\t\t\t }\n";
             $return .= "\t\t }\n";
             $return .= "\t } else { \n";
             $return .= "\t\t total" . $field . " += (values" . $field . ".indexOf(',') == -1 && values" . $field . ".indexOf('.') == -1) ? parseFloat(values" . $field . ") :  parseFloat(rsfp_toNumber(values" . $field . ",'" . self::escape(RSFormProHelper::getConfig('calculations.decimal')) . "','" . self::escape(RSFormProHelper::getConfig('calculations.thousands')) . "')); \n";
             $return .= "\t } \n";
             $return .= "\t total" . $field . " = !isNaN(total" . $field . ") ? total" . $field . " : 0; \n\n";
             $expression = str_replace($match, 'total' . $field, $expression);
         }
         $return .= "\n\t grandTotal" . $calculation->id . $formId . " = " . $expression . ";\n";
         $return .= "\t document.getElementById('" . $calculation->total . "').value = number_format(grandTotal" . $calculation->id . $formId . "," . (int) RSFormProHelper::getConfig('calculations.nodecimals') . ",'" . self::escape(RSFormProHelper::getConfig('calculations.decimal')) . "','" . self::escape(RSFormProHelper::getConfig('calculations.thousands')) . "'); \n\n";
     }
     return $return;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:30,代码来源:calculations.php

示例8: getInstance

	/**
	 * Returns a session storage handler object, only creating it if it doesn't already exist.
	 *
	 * @param   string  $name     The session store to instantiate
	 * @param   array   $options  Array of options
	 *
	 * @return  JSessionStorage
	 *
	 * @since   11.1
	 */
	public static function getInstance($name = 'none', $options = array())
	{
		$name = strtolower(JFilterInput::getInstance()->clean($name, 'word'));

		if (empty(self::$instances[$name]))
		{
			$class = 'JSessionStorage' . ucfirst($name);

			if (!class_exists($class))
			{
				$path = __DIR__ . '/storage/' . $name . '.php';

				if (file_exists($path))
				{
					require_once $path;
				}
				else
				{
					// No attempt to die gracefully here, as it tries to close the non-existing session
					jexit('Unable to load session storage class: ' . $name);
				}
			}

			self::$instances[$name] = new $class($options);
		}

		return self::$instances[$name];
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:38,代码来源:storage.php

示例9: onJotcacheRecache

 function onJotcacheRecache($starturl, $jcplugin, $jcparams, $jcstates)
 {
     $plgParams = $this->params;
     if ($jcplugin != 'crawlerext') {
         return;
     }
     $this->baseUrl = $starturl;
     $params = JComponentHelper::getParams('com_jotcache');
     $database = JFactory::getDBO();
     /* @var $query JDatabaseQuery */
     $query = $database->getQuery(true);
     $query->update($database->quoteName('#__jotcache'))->set($database->quoteName('agent') . ' = ' . $database->quote(0));
     $database->setQuery($query)->query();
     $this->logging = $params->get('recachelog', 0) == 1 ? true : false;
     if ($this->logging) {
         JLog::add(sprintf('....running in plugin %s', $jcplugin), JLog::INFO, 'jotcache.recache');
     }
     $noHtmlFilter = JFilterInput::getInstance();
     $depth = $noHtmlFilter->clean($jcstates['depth'], 'int');
     $depth++;
     $activeBrowsers = BrowserAgents::getActiveBrowserAgents();
     $this->hits = array();
     $ret = '';
     foreach ($activeBrowsers as $browser => $def) {
         $agent = $def[1] . ' jotcache \\r\\n';
         $ret = $this->crawl_page($starturl, $browser, $agent, $depth);
         if ($ret == 'STOP') {
             break;
         }
     }
     return array("crawlerext", $ret, $this->hits);
 }
开发者ID:naka211,项目名称:myloyal,代码行数:32,代码来源:crawlerext.php

示例10: ajaxAddFeatured

 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $actions = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     return $objResponse->sendResponse();
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:29,代码来源:search.php

示例11: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN, 'backupid' => null);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $tag = $filter->clean($defConfig['tag'], 'cmd');
     $backupid = $filter->clean($defConfig['backupid'], 'cmd');
     // Set the active profile
     $session = $this->container->session;
     // Try to set the profile from the setup parameters
     if (!empty($profile)) {
         $profile = max(1, $profile);
         // Make sure $profile is a positive integer >= 1
         $session->set('profile', $profile);
         define('AKEEBA_PROFILE', $profile);
     }
     /** @var \Akeeba\Backup\Site\Model\Backup $model */
     $model = $this->container->factory->model('Backup')->tmpInstance();
     $model->setState('tag', $tag);
     $model->setState('backupid', $backupid);
     $array = $model->stepBackup(false);
     if ($array['Error'] != '') {
         throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
     }
     // BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
     $statistics = Factory::getStatistics();
     $array['BackupID'] = $statistics->getId();
     // Remote clients expect a boolean, not an integer.
     $array['HasRun'] = $array['HasRun'] === 0;
     return $array;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:42,代码来源:StepBackup.php

示例12: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'name' => '', 'connection' => array(), 'test' => true);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $name = $filter->clean($defConfig['name'], 'string');
     $connection = $filter->clean($defConfig['connection'], 'array');
     $test = $filter->clean($defConfig['test'], 'bool');
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     if (empty($connection) || !isset($connection['host']) || !isset($connection['driver']) || !isset($connection['database']) || !isset($connection['user']) || !isset($connection['password'])) {
         throw new \RuntimeException('Connection information missing or incomplete', 500);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var MultipleDatabases $model */
     $model = $this->container->factory->model('MultipleDatabases')->tmpInstance();
     if ($test) {
         $result = $model->test($connection);
         if (!$result['status']) {
             throw new \RuntimeException('Connection test failed: ' . $result['message'], 500);
         }
     }
     return $model->setFilter($name, $connection);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:41,代码来源:SetIncludedDB.php

示例13: getInstance

 /**
  * Returns a session storage handler object, only creating it if it doesn't already exist.
  *
  * @param   string  $name     The session store to instantiate
  * @param   array   $options  Array of options
  *
  * @return  JSessionStorage
  *
  * @since   11.1
  * @throws  JSessionExceptionUnsupported
  */
 public static function getInstance($name = 'none', $options = array())
 {
     $name = strtolower(JFilterInput::getInstance()->clean($name, 'word'));
     if (empty(self::$instances[$name])) {
         /** @var JSessionStorage $class */
         $class = 'JSessionStorage' . ucfirst($name);
         if (!class_exists($class)) {
             $path = __DIR__ . '/storage/' . $name . '.php';
             if (!file_exists($path)) {
                 throw new JSessionExceptionUnsupported('Unable to load session storage class: ' . $name);
             }
             JLoader::register($class, $path);
             // The class should now be loaded
             if (!class_exists($class)) {
                 throw new JSessionExceptionUnsupported('Unable to load session storage class: ' . $name);
             }
         }
         // Validate the session storage is supported on this platform
         if (!$class::isSupported()) {
             throw new JSessionExceptionUnsupported(sprintf('The %s Session Storage is not supported on this platform.', $name));
         }
         self::$instances[$name] = new $class($options);
     }
     return self::$instances[$name];
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:36,代码来源:storage.php

示例14: save

 /**
  * Method to save data
  * (non-PHPdoc)
  * @see F0FController::save()
  */
 public function save()
 {
     //security check
     JSession::checkToken() or die('Invalid Token');
     $app = JFactory::getApplication();
     $model = $this->getModel('configurations');
     $data = $app->input->getArray($_POST);
     $task = $this->getTask();
     $token = JSession::getFormToken();
     unset($data['option']);
     unset($data['task']);
     unset($data['view']);
     unset($data[$token]);
     if ($task == 'populatedata') {
         $this->getPopulatedData($data);
     }
     $db = JFactory::getDbo();
     $config = J2Store::config();
     $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES ';
     jimport('joomla.filter.filterinput');
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     $conditions = array();
     foreach ($data as $metakey => $value) {
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         //now clean up the value
         if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') {
             $value = $app->input->get($metakey, '', 'raw');
             $clean_value = $filter->clean($value, 'html');
         } else {
             $clean_value = $filter->clean($value, 'string');
         }
         $config->set($metakey, $clean_value);
         $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')';
     }
     $query .= implode(',', $conditions);
     try {
         $db->setQuery($query);
         $db->execute();
         //update currencies
         F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->updateCurrencies(false);
         $msg = JText::_('J2STORE_CHANGES_SAVED');
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $msgType = 'Warning';
     }
     switch ($task) {
         case 'apply':
             $url = 'index.php?option=com_j2store&view=configuration';
             break;
         case 'populatedata':
             $url = 'index.php?option=com_j2store&view=configuration';
             break;
         case 'save':
             $url = 'index.php?option=com_j2store&view=cpanels';
             break;
     }
     $this->setRedirect($url, $msg, $msgType);
 }
开发者ID:davetheapple,项目名称:oakencraft,代码行数:65,代码来源:configurations.php

示例15: saveOne

 public function saveOne($metakey, $value)
 {
     $db = JFactory::getDbo();
     $config = J2Store::config();
     $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES ';
     jimport('joomla.filter.filterinput');
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     $conditions = array();
     if (is_array($value)) {
         $value = implode(',', $value);
     }
     // now clean up the value
     if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') {
         $value = $app->input->get($metakey, '', 'raw');
         $clean_value = $filter->clean($value, 'html');
     } else {
         $clean_value = $filter->clean($value, 'string');
     }
     $config->set($metakey, $clean_value);
     $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')';
     $query .= implode(',', $conditions);
     try {
         $db->setQuery($query);
         $db->execute();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:davetheapple,项目名称:oakencraft,代码行数:29,代码来源:config.php


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