/** * 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; }
/** * 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; }
/** * @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)); } }
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)); }
/** * 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; }
/** * 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)); }
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; }
/** * 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]; }
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); }
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(); }
/** * 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; }
/** * 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); }
/** * 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]; }
/** * 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); }
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; }
public function save(&$configObject, $default = false) { if (empty($this->values)) { $this->load(); } $query = 'REPLACE INTO ' . hikaserial::table('config') . ' (config_namekey,config_value' . ($default ? ',config_default' : '') . ') VALUES '; $params = array(); if (is_object($configObject)) { $configObject = get_object_vars($configObject); } jimport('joomla.filter.filterinput'); $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); foreach ($configObject as $namekey => $value) { if ($namekey == 'default_params' || preg_match('#^(menu_|params_)[0-9]+$#', $namekey)) { $value = base64_encode(serialize($value)); } if (empty($this->values[$namekey])) { $this->values[$namekey] = new stdClass(); } $this->values[$namekey]->config_value = $value; if (!isset($this->values[$namekey]->config_default)) { $this->values[$namekey]->config_default = $this->values[$namekey]->config_value; } $params[] = '(' . $this->db->Quote(strip_tags($namekey)) . ',' . $this->db->Quote($safeHtmlFilter->clean($value, 'string')) . ($default ? ',' . $this->db->Quote($this->values[$namekey]->config_default) : '') . ')'; } $query .= implode(',', $params); $this->db->setQuery($query); return $this->db->query(); }
/** * Query */ function buildQuery() { $app = JFactory::getApplication(); $jemsettings = JemHelper::config(); $filter_order = $app->getUserStateFromRequest('com_jem.userelement.filter_order', 'filter_order', 'u.name', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_jem.userelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_order = JFilterInput::getInstance()->clean($filter_order, 'cmd'); $filter_order_Dir = JFilterInput::getInstance()->clean($filter_order_Dir, 'word'); $search = $app->getUserStateFromRequest('com_jem.userelement.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); // start query $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select(array('u.id', 'u.name', 'u.username', 'u.email')); $query->from('#__users as u'); // where $where = array(); $where[] = 'u.block = 0'; /* * Search name **/ if ($search) { $where[] = ' LOWER(u.name) LIKE \'%' . $search . '%\' '; } $query->where($where); // ordering $orderby = ''; $orderby = $filter_order . ' ' . $filter_order_Dir; $query->order($orderby); return $query; }
/** * 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, 'root' => '[SITEROOT]'); $defConfig = array_merge($defConfig, $parameters); $profile = $filter->clean($defConfig['profile'], 'int'); $root = $filter->clean($defConfig['root'], 'string'); // We need a valid profile ID if ($profile <= 0) { $profile = 1; } // We need a root if (empty($root)) { throw new \RuntimeException('Unknown database root', 500); } // Set the active profile $session = $this->container->session; $session->set('profile', $profile); // Load the configuration Platform::getInstance()->load_configuration($profile); /** @var RegExFileFilters $model */ $model = $this->container->factory->model('RegExFileFilters')->tmpInstance(); return $model->get_regex_filters($root); }
public static function check($domain = '', $secure = true) { $url = $secure ? 'https://' : 'http://'; $url .= 'heatmap.it/api/check/account?u=' . $domain . '&callback=joomla'; if (function_exists('curl_exec')) { // Use cURL $curl_options = array(CURLOPT_AUTOREFERER => true, CURLOPT_FAILONERROR => true, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_MAXREDIRS => 20, CURLOPT_USERAGENT => 'Joomla Plugin Account Checker'); $ch = curl_init($url); foreach ($curl_options as $option => $value) { @curl_setopt($ch, $option, $value); } $data = curl_exec($ch); } elseif (ini_get('allow_url_fopen')) { // Use fopen() wrappers $options = array('http' => array('max_redirects' => 10, 'timeout' => 20, 'user_agent' => 'Joomla Plugin Account Checker')); $context = stream_context_create($options); $data = @file_get_contents($url, false, $context); } elseif ($secure) { //Try calling the non secure url $data = self::check($domain, false); } else { return false; } $data = trim(preg_replace(array('/[\\n\\r]/', '/^joomla/'), array('', ''), $data), '();'); $json = @json_decode($data, true); $json['lastcheck'] = JFactory::getDate(); $json = JFilterInput::getInstance()->clean($json, 'none'); return $json; }
/** * 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, 'uuid' => ''); $defConfig = array_merge($defConfig, $parameters); $profile = $filter->clean($defConfig['profile'], 'int'); $uuid = $filter->clean($defConfig['uuid'], 'string'); // We need a valid profile ID if ($profile <= 0) { $profile = 1; } // We need a uuid if (empty($uuid)) { throw new \RuntimeException('UUID is required', 500); } // Set the active profile $session = $this->container->session; $session->set('profile', $profile); // Load the configuration Platform::getInstance()->load_configuration($profile); /** @var IncludeFolders $model */ $model = $this->container->factory->model('IncludeFolders')->tmpInstance(); return $model->remove($uuid); }
/** * Character Parser Function * * @param object $parser Parser object. * @param object $name The name of the element. * * @return void * * @since 11.1 */ protected function _endElement($parser, $name) { array_pop($this->stack); // @todo remove code: echo 'Closing: '. $name .'<br />'; switch ($name) { case 'UPDATE': $ver = new JVersion(); // Lower case and remove the exclamation mark $product = strtolower(JFilterInput::getInstance()->clean($ver->PRODUCT, 'cmd')); // Check that the product matches and that the version matches (optionally a regexp) if ($product == $this->current_update->targetplatform['NAME'] && preg_match('/' . $this->current_update->targetplatform['VERSION'] . '/', $ver->RELEASE)) { // Target platform isn't a valid field in the update table so unset it to prevent J! from trying to store it unset($this->current_update->targetplatform); if (isset($this->latest)) { if (version_compare($this->current_update->version, $this->latest->version, '>') == 1) { $this->latest = $this->current_update; } } else { $this->latest = $this->current_update; } } break; case 'UPDATES': // :D break; } }
function saveForm() { $limit = new stdClass(); $limit->limit_id = hikashop_getCID('limit_id'); $formData = JRequest::getVar('data', array(), '', 'array'); jimport('joomla.filter.filterinput'); $safeHtmlFilter =& JFilterInput::getInstance(null, null, 1, 1); foreach ($formData['limit'] as $column => $value) { hikashop_secureField($column); if (is_array($value)) { $value = implode(',', $value); } $limit->{$column} = $safeHtmlFilter->clean(strip_tags($value), 'string'); } if (!empty($limit->limit_start)) { $limit->limit_start = hikashop_getTime($limit->limit_start); } if (!empty($limit->limit_end)) { $limit->limit_end = hikashop_getTime($limit->limit_end); } if (empty($limit->limit_id)) { $limit->limit_created = time(); } $limit->limit_modified = time(); $status = $this->save($limit); return $status; }
/** * Send email whith user data from form * * @param array $params An object containing the module parameters * * @access public */ public static function sendMail($params) { $sender = $params->get('sender'); $recipient = $params->get('recipient'); $subject = $params->get('subject'); // Getting the site name $sitename = JFactory::getApplication()->get('sitename'); // Getting user form data------------------------------------------------- $name = JFilterInput::getInstance()->clean(JRequest::getVar('name')); $phone = JFilterInput::getInstance()->clean(JRequest::getVar('phone')); $email = JFilterInput::getInstance()->clean(JRequest::getVar('email')); $message = JFilterInput::getInstance()->clean(JRequest::getVar('message')); // Set the massage body vars $nameLabel = JText::_('MOD_JCALLBACK_FORM_NAME_LABEL_VALUE'); $phoneLabel = JText::_('MOD_JCALLBACK_FORM_PHONE_LABEL_VALUE'); $emailLabel = JText::_('MOD_JCALLBACK_FORM_EMAIL_LABEL_VALUE'); $messageLabel = JText::_('MOD_JCALLBACK_FORM_MESSAGE_LABEL_VALUE'); $emailLabel = $email ? "<b>{$emailLabel}:</b> {$email}" : ""; $messageLabel = $message ? "<b>{$messageLabel}:</b> {$message}" : ""; // Get the JMail ogject $mailer = JFactory::getMailer(); // Set JMail object params------------------------------------------------ $mailer->setSubject($subject); $params->get('useSiteMailfrom') ? $mailer->setSender(JFactory::getConfig()->get('mailfrom')) : $mailer->setSender($sender); $mailer->addRecipient($recipient); // Get the mail message body require JModuleHelper::getLayoutPath('mod_jcallback', 'default_email_message'); $mailer->isHTML(true); $mailer->Encoding = 'base64'; $mailer->setBody($body); $mailer->Send(); // The mail sending errors will be shown in the Joomla Warning Message from JMail object.. }
/** * 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]; }
/** * Method to get a stemmer, creating it if necessary. * * @param string $adapter The type of stemmer to load. * * @return FinderIndexerStemmer A FinderIndexerStemmer instance. * * @since 2.5 * @throws Exception on invalid stemmer. */ public static function getInstance($adapter) { static $instances; // Only create one stemmer for each adapter. if (isset($instances[$adapter])) { return $instances[$adapter]; } // Create an array of instances if necessary. if (!is_array($instances)) { $instances = array(); } // Setup the adapter for the stemmer. $adapter = JFilterInput::getInstance()->clean($adapter, 'cmd'); $path = dirname(__FILE__) . '/stemmer/' . $adapter . '.php'; $class = 'FinderIndexerStemmer' . ucfirst($adapter); // Check if a stemmer exists for the adapter. if (file_exists($path)) { // Instantiate the stemmer. include_once $path; $instances[$adapter] = new $class(); } else { // Throw invalid adapter exception. throw new Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_STEMMER', $adapter)); } return $instances[$adapter]; }
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; }
/** * Method to get a parser, creating it if necessary. * * @param string $format The type of parser to load. * * @return FinderIndexerParser A FinderIndexerParser instance. * * @since 2.5 * @throws Exception on invalid parser. */ public static function getInstance($format) { static $instances; // Only create one parser for each format. if (isset($instances[$format])) { return $instances[$format]; } // Create an array of instances if necessary. if (!is_array($instances)) { $instances = array(); } // Setup the adapter for the parser. $format = JFilterInput::getInstance()->clean($format, 'cmd'); $path = __DIR__ . '/parser/' . $format . '.php'; $class = 'FinderIndexerParser' . ucfirst($format); // Check if a parser exists for the format. if (file_exists($path)) { // Instantiate the parser. include_once $path; $instances[$format] = new $class(); } else { // Throw invalid format exception. throw new Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_PARSER', $format)); } return $instances[$format]; }
/** * 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); }
/** * Returns a session storage handler object, only creating it if it doesn't already exist. * * @param name $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()) { static $instances; if (!isset($instances)) { $instances = array(); } $name = strtolower(JFilterInput::getInstance()->clean($name, 'word')); if (empty($instances[$name])) { $class = 'JSessionStorage' . ucfirst($name); if (!class_exists($class)) { $path = dirname(__FILE__) . '/storage/' . $name . '.php'; if (file_exists($path)) { require_once $path; } else { // No call to JError::raiseError here, as it tries to close the non-existing session jexit('Unable to load session storage class: ' . $name); } } $instances[$name] = new $class($options); } return $instances[$name]; }
/** * 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, 'root' => '[SITEROOT]', 'subdirectory' => ''); $defConfig = array_merge($defConfig, $parameters); $profile = $filter->clean($defConfig['profile'], 'int'); $root = $filter->clean($defConfig['root'], 'string'); $subdirectory = $filter->clean($defConfig['subdirectory'], 'path'); $crumbs = array(); // We need a valid profile ID if ($profile <= 0) { $profile = 1; } // We need a root if (empty($root)) { throw new \RuntimeException('Unknown filesystem root', 500); } // Get the subdirectory and explode it to its parts if (!empty($subdirectory)) { $subdirectory = trim($subdirectory, '/'); } if (!empty($subdirectory)) { $crumbs = explode('/', $subdirectory); } // Set the active profile $session = $this->container->session; $session->set('profile', $profile); // Load the configuration Platform::getInstance()->load_configuration($profile); /** @var FileFilters $model */ $model = $this->container->factory->model('FileFilters')->tmpInstance(); return $model->make_listing($root, $crumbs); }