Exemplo n.º 1
0
 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');
 }
 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);
 }
Exemplo n.º 3
0
 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");
 }
Exemplo n.º 4
0
 protected function _getSearchData()
 {
     // clean html tags
     $filter = new JFilterInput();
     $value = $filter->clean($this->_data->get('value', ''));
     return empty($value) ? null : $value;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 /**
  * 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();
     }
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Exemplo n.º 9
0
 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();
 }
Exemplo n.º 10
0
 /**
  * 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');
     }
 }
Exemplo n.º 11
0
 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 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);
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 /**
  * 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];
 }
Exemplo n.º 15
0
 /**
  * @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));
     }
 }
Exemplo n.º 16
0
 /**
  * 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..
 }
 /**
  * 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;
     }
 }
 /**
  * Here starts the processing
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.0
  */
 public function getStart()
 {
     $jinput = JFactory::getApplication()->input;
     // Load the data
     $this->loadData();
     // Load the helper
     $this->helper = new Com_VirtueMart();
     // Get the logger
     $csvilog = $jinput->get('csvilog', null, null);
     $this->virtuemart_vendor_id = $this->helper->getVendorId();
     // Process data
     foreach ($this->csvi_data as $name => $value) {
         // Check if the field needs extra treatment
         switch ($name) {
             case 'name':
                 $this->{$name} = strtolower(JFilterInput::clean($value, 'alnum'));
                 break;
             default:
                 $this->{$name} = $value;
                 break;
         }
     }
     // Check if we have a field ID
     if (empty($this->virtuemart_userfield_id)) {
         $this->_getFieldId();
     }
     // All is good
     return true;
 }
Exemplo n.º 19
0
 /**
  * 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;
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
 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));
 }
Exemplo n.º 22
0
 /**
  * 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;
 }
Exemplo n.º 23
0
 function search()
 {
     $post['searchword'] = JRequest::getString('searchword', null, 'post');
     $post['ordering'] = JRequest::getWord('ordering', null, 'post');
     $post['searchphrase'] = JRequest::getWord('searchphrase', 'all', 'post');
     $post['limit'] = JRequest::getInt('limit', null, 'post');
     if ($post['limit'] === null) {
         unset($post['limit']);
     }
     $areas = JRequest::getVar('areas', null, 'post', 'array');
     if ($areas) {
         foreach ($areas as $area) {
             $post['areas'][] = JFilterInput::clean($area, 'cmd');
         }
     }
     // set Itemid id for links
     $menu =& JSite::getMenu();
     $items = $menu->getItems('link', 'index.php?option=com_search_lucene&view=search');
     if (isset($items[0])) {
         $post['Itemid'] = $items[0]->id;
     }
     unset($post['task']);
     unset($post['submit']);
     $uri = JURI::getInstance();
     $uri->setQuery($post);
     $uri->setVar('option', 'com_search_lucene');
     $this->setRedirect(JRoute::_('index.php' . $uri->toString(array('query', 'fragment')), false));
 }
Exemplo n.º 24
0
 /**
  * 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;
 }
Exemplo n.º 25
0
 /**
  * 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];
 }
Exemplo n.º 26
0
 /**
  * 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'] = '&nbsp;';
     $json['html'] = $html;
     die(json_encode($json));
 }
Exemplo n.º 27
0
 /**
  * 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];
 }
Exemplo n.º 28
0
 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;
 }
Exemplo n.º 29
0
	/**
	 * 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];
	}
Exemplo n.º 30
0
 /**
  * @return boolean
  */
 function check()
 {
     $this->menutype = JFilterInput::clean($this->menutype, 'menutype');
     if (empty($this->menutype)) {
         $this->setError("Cannot save: Empty menu type");
         return false;
     }
     // correct spurious data
     if (trim($this->title) == '') {
         $this->title = $this->menutype;
     }
     $db =& JFactory::getDBO();
     // check for unique menutype for new menu copy
     $query = 'SELECT menutype' . ' FROM #__menu_types';
     if ($this->id) {
         $query .= ' WHERE id != ' . (int) $this->id;
     }
     $db->setQuery($query);
     $menus = $db->loadResultArray();
     foreach ($menus as $menutype) {
         if ($menutype == $this->menutype) {
             $this->setError("Cannot save: Duplicate menu type '{$this->menutype}'");
             return false;
         }
     }
     return true;
 }