本文整理汇总了PHP中JFilterInput类的典型用法代码示例。如果您正苦于以下问题:PHP JFilterInput类的具体用法?PHP JFilterInput怎么用?PHP JFilterInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JFilterInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($config = array())
{
parent::__construct($config);
$this->app = JFactory::getApplication();
// Get project id.
$this->projectId = $this->input->getUint('pid');
// Prepare log object
$registry = Joomla\Registry\Registry::getInstance('com_crowdfunding');
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get('logger.file');
$tableName = $registry->get('logger.table');
$file = JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . $fileName);
$this->log = new Prism\Log\Log();
$this->log->addAdapter(new Prism\Log\Adapter\Database(JFactory::getDbo(), $tableName));
$this->log->addAdapter(new Prism\Log\Adapter\File($file));
// Create an object that contains a data used during the payment process.
$this->paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->projectId;
$this->paymentProcess = $this->app->getUserState($this->paymentProcessContext);
// Prepare context
$filter = new JFilterInput();
$paymentService = JString::trim(JString::strtolower($this->input->getCmd('payment_service')));
$paymentService = $filter->clean($paymentService, 'ALNUM');
$this->context = JString::strlen($paymentService) > 0 ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
// Prepare params
$this->params = JComponentHelper::getParams('com_crowdfunding');
}
示例2: __construct
public function __construct($config = array())
{
parent::__construct($config);
$this->app = JFactory::getApplication();
// Get project ID.
$this->projectId = $this->input->getUint('pid');
// Prepare log object.
$this->log = new Prism\Log\Log();
// Set database log adapter if Joomla! debug is enabled.
if ($this->logTable !== null and $this->logTable !== '' and JDEBUG) {
$this->log->addAdapter(new Prism\Log\Adapter\Database(\JFactory::getDbo(), $this->logTable));
}
// Set file log adapter.
if ($this->logFile !== null and $this->logFile !== '') {
$file = \JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . basename($this->logFile));
$this->log->addAdapter(new Prism\Log\Adapter\File($file));
}
// Prepare context
$filter = new JFilterInput();
$paymentService = $filter->clean(trim(strtolower($this->input->getCmd('payment_service'))), 'ALNUM');
$this->context = Joomla\String\StringHelper::strlen($paymentService) > 0 ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
// Prepare params
$this->params = JComponentHelper::getParams('com_crowdfunding');
// Prepare container and some of the most used objects.
$this->container = Prism\Container::getContainer();
$this->prepareCurrency($this->container, $this->params);
$this->prepareMoneyFormatter($this->container, $this->params);
}
示例3: __construct
public function __construct($config = array())
{
parent::__construct($config);
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get project id.
$this->projectId = $this->input->getUint("pid");
// Prepare log object
$registry = JRegistry::getInstance("com_crowdfunding");
/** @var $registry Joomla\Registry\Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
$file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log = new ITPrismLog();
$this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
$this->log->addWriter(new ITPrismLogWriterFile($file));
// Create an object that contains a data used during the payment process.
$this->paymentProcessContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->projectId;
$this->paymentProcess = $app->getUserState($this->paymentProcessContext);
// Prepare context
$filter = new JFilterInput();
$paymentService = JString::trim(JString::strtolower($this->input->getCmd("payment_service")));
$paymentService = $filter->clean($paymentService, "ALNUM");
$this->context = !empty($paymentService) ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
// Prepare params
$this->params = JComponentHelper::getParams("com_crowdfunding");
}
示例4: _getSearchData
protected function _getSearchData()
{
// clean html tags
$filter = new JFilterInput();
$value = $filter->clean($this->_data->get('value', ''));
return empty($value) ? null : $value;
}
示例5: saveContentPrep
function saveContentPrep(&$row)
{
// Get submitted text from the request variables
$text = JRequest::getVar('text', '', 'post', 'string', JREQUEST_ALLOWRAW);
// Clean text for xhtml transitional compliance
$text = str_replace('<br>', '<br />', $text);
// Search for the {readmore} tag and split the text up accordingly.
$pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
$tagPos = preg_match($pattern, $text);
if ($tagPos == 0) {
$row->introtext = $text;
} else {
list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2);
}
// Filter settings
jimport('joomla.application.component.helper');
$config = JComponentHelper::getParams('com_content');
$user =& JFactory::getUser();
$gid = $user->get('gid');
$filterGroups = $config->get('filter_groups');
// convert to array if one group selected
if (!is_array($filterGroups) && (int) $filterGroups > 0) {
$filterGroups = array($filterGroups);
}
if (is_array($filterGroups) && in_array($gid, $filterGroups)) {
$filterType = $config->get('filter_type');
$filterTags = preg_split('#[,\\s]+#', trim($config->get('filter_tags')));
$filterAttrs = preg_split('#[,\\s]+#', trim($config->get('filter_attritbutes')));
switch ($filterType) {
case 'NH':
$filter = new JFilterInput();
break;
case 'WL':
$filter = new JFilterInput($filterTags, $filterAttrs, 0, 0, 0);
// turn off xss auto clean
break;
case 'BL':
default:
$filter = new JFilterInput($filterTags, $filterAttrs, 1, 1);
break;
}
$row->introtext = $filter->clean($row->introtext);
$row->fulltext = $filter->clean($row->fulltext);
} elseif (empty($filterGroups) && $gid != '25') {
// no default filtering for super admin (gid=25)
$filter = new JFilterInput(array(), array(), 1, 1);
$row->introtext = $filter->clean($row->introtext);
$row->fulltext = $filter->clean($row->fulltext);
}
return true;
}
示例6: notify
/**
* Catch the response from PayPal and store data about transaction/
*
* @todo Move sending mail functionality to plugins.
*/
public function notify()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite * */
$params = $app->getParams("com_virtualcurrency");
// Check for disabled payment functionality
if ($params->get("debug_payment_disabled", 0)) {
$error = JText::_("COM_VIRTUALCURRENCY_ERROR_PAYMENT_HAS_BEEN_DISABLED");
$error .= "\n" . JText::sprintf("COM_VIRTUALCURRENCY_TRANSACTION_DATA", var_export($_POST, true));
JLog::add($error);
return null;
}
// Clear the name of the payment gateway.
$filter = new JFilterInput();
$paymentService = $filter->clean(JString::trim(JString::strtolower($this->input->getCmd("payment_service"))));
$context = !empty($paymentService) ? 'com_virtualcurrency.notify.' . $paymentService : 'com_crowdfunding.notify';
// Save data
try {
// Events
$dispatcher = JEventDispatcher::getInstance();
// Event Notify
JPluginHelper::importPlugin('virtualcurrencypayment');
$results = $dispatcher->trigger('onPaymenNotify', array($context, &$params));
$transaction = null;
$currency = null;
if (!empty($results)) {
foreach ($results as $result) {
if (!empty($result) and isset($result["transaction"])) {
$transaction = JArrayHelper::getValue($result, "transaction");
$currency = JArrayHelper::getValue($result, "currency");
break;
}
}
}
// If there is no transaction data, the status might be pending or another one.
// So, we have to stop the script execution.
if (empty($transaction)) {
return;
}
// Event After Payment
$dispatcher->trigger('onAfterPayment', array($context, &$transaction, &$params, &$currency));
} catch (Exception $e) {
JLog::add($e->getMessage());
$input = "INPUT:" . var_export($app->input, true) . "\n";
JLog::add($input);
// Send notification about the error to the administrator.
$model = $this->getModel();
$model->sendMailToAdministrator();
}
}
示例7: getInstance
/**
* Get specific SMS gateway instance
*
* @return object gateway
*/
private function getInstance()
{
if (!isset($this->gateway)) {
$params = $this->getParams();
$gateway = $params->get('sms-gateway', 'kapow.php');
$input = new JFilterInput();
$gateway = $input->clean($gateway, 'CMD');
require_once JPATH_ROOT . '/components/com_fabrik/helpers/sms_gateways/' . JString::strtolower($gateway);
$gateway = JFile::stripExt($gateway);
$this->gateway = new $gateway();
$this->gateway->params = $params;
}
return $this->gateway;
}
示例8: safeAlias
/**
* Prepare safe profile alias.
*
* @param string $alias
* @param int $userId
*
* @return string
*/
public static function safeAlias($alias, $userId = 0)
{
$filter = new \JFilterInput();
$alias = \JString::strtolower($filter->clean($alias, 'ALNUM'));
// Check for valid alias.
$aliasValidator = new Validator\Profile\Alias(\JFactory::getDbo(), $alias, $userId);
if (!$aliasValidator->isValid()) {
if (!$alias) {
$alias = StringHelper::generateRandomString(16);
} else {
$alias .= mt_rand(10, 1000);
}
}
return $alias;
}
示例9: requestSent
function requestSent()
{
$jfbcRequestId = JRequest::getInt('jfbcId');
$fbRequestId = JRequest::getString('requestId');
$inToList = JRequest::getVar('to');
// Get the from user id from the request
$to = $inToList[0];
$requestInfo = JFBCFactory::provider('facebook')->api('/' . $fbRequestId . "_" . $to);
$fbFrom = $requestInfo['from']['id'];
// Not using the model, as we're doing a simple store.
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables');
$data = array();
$data['fb_request_id'] = $fbRequestId;
$data['fb_user_from'] = $fbFrom;
$data['jfbc_request_id'] = $jfbcRequestId;
$data['created'] = JFactory::getDate()->toSql();
$data['modified'] = null;
// $data['destination_url'] = JRequest::getString('destinationUrl');
foreach ($inToList as $fbTo) {
$row =& JTable::getInstance('JFBConnectNotification', 'Table');
$to = JFilterInput::clean($fbTo, 'ALNUM');
$data['fb_user_to'] = $to;
$row->save($data);
$point = new JFBConnectPoint();
$point->set('name', 'facebook.request.create');
$point->set('key', $to);
$point->award();
}
$app = JFactory::getApplication();
$app->close();
}
示例10: _loadEditor
/**
* Load the editor
*
* @access private
* @param array Associative array of editor config paramaters
* @since 1.5
*/
function _loadEditor($config = array())
{
//check if editor is already loaded
if (!is_null($this->_editor)) {
return;
}
jimport('joomla.filesystem.file');
// Build the path to the needed editor plugin
$name = JFilterInput::clean($this->_name, 'cmd');
$path = JPATH_SITE . DS . 'plugins' . DS . 'editors' . DS . $name . '.php';
if (!JFile::exists($path)) {
$message = JText::_('Cannot load the editor');
JCKHelper::error($message);
return false;
}
// Require plugin file
require_once $path;
// Build editor plugin classname
$name = 'plgEditor' . $this->_name;
if ($this->_editor = new $name($this, $config)) {
// load plugin parameters
$this->initialise();
JPluginHelper::importPlugin('editors-xtd');
}
}
示例11: 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;
}
示例12: getInstance
/**
* Returns a Controller object, always creating it
*
* @param string $type The contlorer type to instantiate
* @param string $prefix Prefix for the controller class name. Optional.
* @param array $config Configuration array for controller. Optional.
*
* @return mixed A model object or false on failure
*
* @since 1.1.0
*/
public static function getInstance($type, $prefix = '', $config = array())
{
// Check for array format.
$filter = JFilterInput::getInstance();
$type = $filter->clean($type, 'cmd');
$prefix = $filter->clean($prefix, 'cmd');
$controllerClass = $prefix . ucfirst($type);
if (!class_exists($controllerClass)) {
if (!isset(self::$paths[$controllerClass])) {
// Get the environment configuration.
$basePath = JArrayHelper::getValue($config, 'base_path', JPATH_COMPONENT);
$nameConfig = empty($type) ? array('name' => 'controller') : array('name' => $type, 'format' => JFactory::getApplication()->input->get('format', '', 'word'));
// Define the controller path.
$paths[] = $basePath . '/controllers';
$paths[] = $basePath;
$path = JPath::find($paths, self::createFileName($nameConfig));
self::$paths[$controllerClass] = $path;
// If the controller file path exists, include it.
if ($path) {
require_once $path;
}
}
if (!class_exists($controllerClass)) {
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $controllerClass), JLog::WARNING, 'kextensions');
return false;
}
}
return new $controllerClass($config);
}
示例13: saveForm
function saveForm()
{
$entry = new stdClass();
$entry->entry_id = hikashop_getCID('entry_id');
$formData = JRequest::getVar('data', array(), '', 'array');
jimport('joomla.filter.filterinput');
$safeHtmlFilter =& JFilterInput::getInstance(null, null, 1, 1);
foreach ($formData['entry'] as $column => $value) {
hikashop_secureField($column);
$entry->{$column} = $safeHtmlFilter->clean($value, 'string');
}
$status = $this->save($entry);
if (JRequest::getVar('tmpl', '') == 'component') {
if ($status) {
$url = hikashop_completeLink('order&task=edit&cid=' . $entry->order_id, false, true);
echo '<html><head><script type="text/javascript">parent.window.location.href=\'' . $url . '\';</script></head><body></body></html>';
exit;
} else {
$app = JFactory::getApplication();
if (version_compare(JVERSION, '1.6', '<')) {
$session =& JFactory::getSession();
$session->set('application.queue', $app->_messageQueue);
}
echo '<html><head><script type="text/javascript">javascript: history.go(-1);</script></head><body></body></html>';
exit;
}
}
return $status;
}
示例14: 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])) {
/** @var JSessionStorage $class */
$class = 'JSessionStorage' . ucfirst($name);
if (!class_exists($class)) {
$path = __DIR__ . '/storage/' . $name . '.php';
if (!file_exists($path)) {
// No attempt to die gracefully here, as it tries to close the non-existing session
jexit('Unable to load session storage class: ' . $name);
}
require_once $path;
// The class should now be loaded
if (!class_exists($class)) {
// No attempt to die gracefully here, as it tries to close the non-existing session
jexit('Unable to load session storage class: ' . $name);
}
}
// Validate the session storage is supported on this platform
if (!$class::isSupported()) {
// No attempt to die gracefully here, as it tries to close the non-existing session
jexit(sprintf('The %s Session Storage is not supported on this platform.', $name));
}
self::$instances[$name] = new $class($options);
}
return self::$instances[$name];
}
示例15: 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));
}
}