/** * Example before save content method * * Method is called right before content is saved into the database. * Article object is passed by reference, so any changes will be saved! * NOTE: Returning false will abort the save with an error. *You can set the error by calling $article->setError($message) * * @param string The context of the content passed to the plugin. * @param object A JTableContent object * @param bool If the content is just about to be created * @return bool If false, abort the save * @since 1.6 */ public function onContentBeforeSave($context, $article, $isNew) { //error_log("plgContentArticlesubmit::onContentBeforeSave") ; $app = JFactory::getApplication(); // run this plugin only for com_content $parts = explode(".", $context); if ($parts[0] != 'com_content') { return true; } // dont do anything is it is not frontend if (!$app->isSite()) { return true; } $jinput = $app->input; $formData = new JInput($jinput->get('jform', '', 'array')); //error_log("jinput == " . print_r($jinput,true)); $introtext = $formData->get('article_introtext', '', 'html'); //error_log("introtext == " . $introtext); $fulltext = $formData->get('article_fulltext', '', 'raw'); //error_log("fulltext == " . $fulltext); $article->introtext = $introtext; $article->fulltext = $fulltext; $savedImage = $this->saveImage($article); if ($savedImage) { $images = array(); $images['image_fulltext'] = $savedImage; $images['image_intro'] = $savedImage; $article->images = json_encode($images); return true; } else { $article->setError("Could not process the uploaded image. Please try again with a different (smaller) image."); return false; } return true; }
function validate() { $return = array('error' => 0, 'msg' => array()); $input = new JInput(); $ajax = $input->getInt('ajax', 0); $email = $input->getString('email', ''); $name = $input->getString('name', ''); $username = $input->getString('username', ''); if ($email && !$this->validateEmail($email)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIDATE_MAIL'); } if ($email && !$this->checkUniqueEmail($email)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_NOT_UNIQUE_MAIL'); } if ($name && !$this->validateName($name)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIATE_NAME'); } if ($username && !$this->validateUserName($username)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIATE_USERNAME'); } if ($ajax) { echo json_encode($return); die; } return $return; }
/** * This method checks if a value for remote user is present inside * the $_SERVER array. If so then replace any domain related stuff * to get the username and return it. * * @return mixed Username of detected user or False. * * @since 1.0 */ public function detectRemoteUser() { /* * When legacy flag is true, it ensures compatibility with JSSOMySite 1.x by * only returning a string username or false can be returned. This also means * keeping compatibility with Joomla 1.6. * When it is set to False, it can return an array and compatible with Joomla 2.5. */ $legacy = $this->params->get('use_legacy', false); // Get the array key of $_SERVER where the user can be located $serverKey = strtoupper($this->params->get('userkey', 'REMOTE_USER')); // Get the $_SERVER key and ensure its lowercase and doesn't filter if ($legacy) { // Get the $_SERVER value which should contain the SSO username $remoteUser = JRequest::getVar($serverKey, null, 'server', 'string', JREQUEST_ALLOWRAW); } else { // Get the $_SERVER value which should contain the SSO username $input = new JInput($_SERVER); $remoteUser = $input->get($serverKey, null, 'USERNAME'); unset($input); } // Ensures the returned user is lowercased $remoteUser = strtolower($remoteUser); // Get a username replacement parameter in lowercase and split by semi-colons $replace_set = explode(';', strtolower($this->params->get('username_replacement', ''))); foreach ($replace_set as $replacement) { $remoteUser = str_replace(trim($replacement), '', $remoteUser); } // Returns the username return $remoteUser; }
function build() { $jinput = new JInput(); //Initialize default form $keys = array('option' => $this->getExtension(), 'view' => $this->getView(), 'layout' => $jinput->get('layout', null, 'CMD'), 'task' => ""); //For item layout if (isset($this->dataObject)) { $keys['id'] = isset($this->dataObject->id) ? $this->dataObject->id : 0; //Deprecated $keys['cid[]'] = isset($this->dataObject->id) ? $this->dataObject->id : 0; } //Specifics values or overrides if (isset($this->values)) { foreach ($this->values as $key => $value) { $keys[$key] = $value; } } //Reproduce current query in the form $followers = array('lang', 'Itemid', 'tmpl'); //Cmd types only for the moment foreach ($followers as $follower) { $val = $jinput->get($follower, null, 'CMD'); if ($val) { $keys[$follower] = $val; } } $html = ""; foreach ($keys as $key => $value) { $html .= JDom::_('html.form.input.hidden', array('dataKey' => $key, 'dataValue' => $value)); } //Token $html .= JHTML::_('form.token'); return $html; }
public function onAfterInitialise() { // Make sure this is the back-end $app = JFactory::getApplication(); if (!in_array($app->getName(), array('administrator', 'admin'))) { return; } if (version_compare(JVERSION, '2.5.0', 'lt')) { $this->autoDisable(); return; } // Get the input variables $ji = new JInput(); $component = $ji->getCmd('option', ''); $task = $ji->getCmd('task', ''); $view = $ji->getCmd('view', ''); $backedup = $ji->getInt('is_backed_up', 0); // Perform a redirection on Joomla! Update download or install task, unless we have already backed up the site if ($component == 'com_joomlaupdate' && $task == 'update.install' && !$backedup) { // Get the backup profile ID $profileId = (int) $this->params->get('profileid', 1); if ($profileId <= 0) { $profileId = 1; } // Get the return URL $return_url = JUri::base() . 'index.php?option=com_joomlaupdate&task=update.install&is_backed_up=1'; // Get the redirect URL $token = JFactory::getSession()->getToken(); $redirect_url = JUri::base() . 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($return_url) . '&profileid=' . $profileId . "&{$token}=1"; // Perform the redirection $app = JFactory::getApplication(); $app->redirect($redirect_url); } }
/** * upload * * @param \JInput $input */ public static function upload(\JInput $input) { try { $editorPlugin = \JPluginHelper::getPlugin('editors', 'akmarkdown'); if (!$editorPlugin) { throw new \Exception('Editor Akmarkdown not exists'); } $params = new Registry($editorPlugin->params); $files = $input->files; $field = $input->get('field', 'file'); $type = $input->get('type', 'post'); $allows = $params->get('Upload_AllowExtension', ''); $allows = array_map('strtolower', array_map('trim', explode(',', $allows))); $file = $files->getVar($field); $src = $file['tmp_name']; $name = $file['name']; $tmp = new \SplFileInfo(JPATH_ROOT . '/tmp/ak-upload/' . $name); if (empty($file['tmp_name'])) { throw new \Exception('File not upload'); } $ext = pathinfo($name, PATHINFO_EXTENSION); if (!in_array($ext, $allows)) { throw new \Exception('File extension now allowed.'); } // Move file to tmp if (!is_dir($tmp->getPath())) { \JFolder::create($tmp->getPath()); } if (is_file($tmp->getPathname())) { \JFile::delete($tmp->getPathname()); } \JFile::upload($src, $tmp->getPathname()); $src = $tmp; $dest = static::getDest($name, $params->get('Upload_S3_Subfolder', 'ak-upload')); $s3 = new \S3($params->get('Upload_S3_Key'), $params->get('Upload_S3_SecretKey')); $bucket = $params->get('Upload_S3_Bucket'); $result = $s3::putObject(\S3::inputFile($src->getPathname(), false), $bucket, $dest, \S3::ACL_PUBLIC_READ); if (is_file($tmp->getPathname())) { \JFile::delete($tmp->getPathname()); } if (!$result) { throw new \Exception('Upload fail.'); } } catch (\Exception $e) { $response = new Response(); $response->setBody(json_encode(['error' => $e->getMessage()])); $response->setMimeType('text/json'); $response->respond(); exit; } $return = new \JRegistry(); $return['filename'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest; $return['file'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest; $response = new Response(); $response->setBody((string) $return); $response->setMimeType('text/json'); $response->respond(); }
/** * Test the JInput::get method using a nested data set. */ public function testGetArrayNested() { $filterMock = new JFilterInputMockTracker(); $input = new JInput(array('var2' => 34, 'var3' => array('var2' => 'test'), 'var4' => array('var1' => array('var2' => 'test'))), array('filter' => $filterMock)); $this->assertThat($input->getArray(array('var2' => 'filter2', 'var3' => array('var2' => 'filter3'))), $this->equalTo(array('var2' => 34, 'var3' => array('var2' => 'test'))), 'Line: ' . __LINE__ . '.'); $this->assertThat($input->getArray(array('var4' => array('var1' => array('var2' => 'filter1')))), $this->equalTo(array('var4' => array('var1' => array('var2' => 'test')))), 'Line: ' . __LINE__ . '.'); $this->assertThat($filterMock->calls['clean'][0], $this->equalTo(array(34, 'filter2')), 'Line: ' . __LINE__ . '.'); $this->assertThat($filterMock->calls['clean'][1], $this->equalTo(array(array('var2' => 'test'), 'array')), 'Line: ' . __LINE__ . '.'); }
/** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // TemplateckHelper::addSubmenu(JRequest::getCmd('view', 'templates')); $input = new JInput(); $view = $input->get('view', 'Modulesmanagerck'); $input->set('view', $view); parent::display(); return $this; }
/** * Gets the IP address of the client machine, translates it to a compatiable * eDirectory netadress and queries it against the LDAP server using a filter. * * @return mixed Username of detected user or False. * * @since 1.0 */ public function detectRemoteUser() { // Import languages for frontend errors $this->loadLanguage(); /* * When legacy flag is true, it ensures compatibility with JSSOMySite 1.x by * only returning a string username or false can be returned. This also means * keeping compatibility with Joomla 1.6. * When it is set to False, it can return an array and compatible with Joomla 2.5. */ $legacy = $this->params->get('use_legacy', false); if ($legacy) { // Use legacy way of getting paramters $authParams = new JRegistry(); $authName = $this->params->get('auth_plugin', 'jmapmyldap'); $authPlugin = JPluginHelper::getPlugin('authentication', $authName); $authParams->loadString($authPlugin->params); $ldapUid = $authParams->get('ldap_uid', 'uid'); // Attempt to load up a LDAP instance using the legacy method jimport('shmanic.jldap2'); $ldap = new JLDAP2($authParams); // Lets try to bind using proxy user if (!$ldap->connect() || !$ldap->bind($ldap->connect_username, $ldap->connect_password)) { JError::raiseWarning('SOME_ERROR_CODE', JText::_('PLG_EDIR_ERROR_LDAP_BIND')); return; } // Get IP of client machine $myip = JRequest::getVar('REMOTE_ADDR', 0, 'server'); // Convert this to some net address thing that edir likes $na = JLDAPHelper::ipToNetAddress($myip); // Find the network address and return the uid for it $filter = "(networkAddress={$na})"; $dn = $authParams->get('base_dn'); // Do the LDAP filter search now $result = new JLDAPResult($ldap->search($dn, $filter, array($ldapUid))); $ldap->close(); } else { try { // We will only check the first LDAP config $ldap = SHLdap::getInstance(); $ldap->proxyBind(); $ldapUid = $ldap->getUid; // Get the IP address of this client and convert to netaddress for LDAP searching $input = new JInput($_SERVER); $myIp = $input->get('REMOTE_ADDR', false, 'string'); $na = SHLdapHelper::ipToNetAddress($myIp); $result = $ldap->search(null, "(networkAddress={$na})", array($ldapUid)); } catch (Exception $e) { SHLog::add($e, 16010, JLog::ERROR, 'sso'); return; } } if ($value = $result->getValue(0, $ldapuid, 0)) { // Username was found logged in on this client machine return $value; } }
/** * @param array $data * @return Renderer */ public function createView(array $data = array()) { $renderer = new Renderer($data); $name = $this->getName(); // Add the default view path $renderer->addIncludePath(COMPONENT_ROOT . '/src/views/' . $this->getName()); $template = $this->app->getTemplate(); $option = $this->input->get('option'); // Prepend the template path $renderer->addIncludePath(JPATH_ROOT . '/templates/' . $template . '/html/' . $option . '/' . $this->getName(), true); return $renderer; }
/** * Starts the session * * @return boolean True if started * * @since 3.5 * @throws RuntimeException If something goes wrong starting the session. */ public function start() { $session_name = $this->getName(); // Get the JInputCookie object $cookie = $this->input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->input->get($session_name, false, 'string'); if ($session_clean) { $this->setId($session_clean); $cookie->set($session_name, '', time() - 3600); } } return parent::start(); }
public function confirmDelivered($post) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $delivered = array(); if (!empty($post['delivered'])) { $delivered = $post['delivered']; } foreach ($delivered as $d) { $query->clear(); $query->update('#__hp_order_items')->set('delivered = 1')->where('id = ' . $d)->where('business_id = ' . JFactory::getUser()->id); $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { die($db->getErrorMsg()); } } // Upload file $jFileInput = new JInput($_FILES); $file = $jFileInput->get('jform', array(), 'array'); $filepath = JPATH_ROOT . DS . 'upload' . DS . 'orders' . DS . $post['order_id'] . DS; @mkdir($filepath, 0777, true); $uploadResult = false; if (!empty($file['name']['file_upload'])) { $uploadResult = JFile::upload($file['tmp_name']['file_upload'], $filepath . $file['name']['file_upload']); } if ($uploadResult) { // Update to files $fileName = $file['name']['file_upload']; $query->clear()->insert('#__files')->columns('item_id, item_type, file_upload, description, created')->values($post['order_id'] . ', "order", ' . $db->quote($fileName) . ', ' . $db->quote($post['description']) . ', ' . $db->quote(date('Y-m-d H:i:s'))); $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { die($db->getErrorMsg()); } } // Update note $note = trim($post['business_note']); if (!empty($note)) { $query->clear()->insert('#__hp_order_notes')->columns('order_id, business_id, note, created')->values($post['order_id'] . ',' . JFactory::getUser()->id . ',' . $db->quote($note) . ',' . $db->quote(date('Y-m-d H:i:s'))); $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { die($db->getErrorMsg()); } } return true; }
/** * Build route. * * @param string $name Route resource name. * @param array &$queries Http queries. * * @return array */ public function build($name, &$queries) { if (empty($this->resources[$name])) { return array(); } if (is_callable($this->buildHandler[$name])) { call_user_func_array($this->buildHandler[$name], array($queries)); } $replace = array(); $pattern = $this->resources[$name]; foreach ($this->maps[$name]['vars'] as $key) { $var = isset($queries[$key]) ? $queries[$key] : $this->input->get($key, 'null'); if (is_array($var) || is_object($var)) { $var = implode('/', (array) $var); $key2 = '*' . $key; $replace[$key2] = $var; } else { $key2 = ':' . $key; $replace[$key2] = $var; } if (strpos($pattern, $key2) !== false) { unset($queries[$key]); } } $pattern = strtr($pattern, $replace); return explode('/', $pattern); }
/** * Start a session. * * Creates a session (or resumes the current one based on the state of the session) * * @return boolean true on success * * @since 11.1 */ protected function _start() { // Start session if not started if ($this->_state === 'restart') { session_regenerate_id(true); } else { $session_name = session_name(); // Get the JInputCookie object $cookie = $this->_input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->_input->get($session_name, false, 'string'); if ($session_clean) { session_id($session_clean); $cookie->set($session_name, '', time() - 3600); } } } /** * Write and Close handlers are called after destructing objects since PHP 5.0.5. * Thus destructors can use sessions but session handler can't use objects. * So we are moving session closure before destructing objects. * * Replace with session_register_shutdown() when dropping compatibility with PHP 5.3 */ register_shutdown_function('session_write_close'); session_cache_limiter('none'); session_start(); return true; }
protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $input = new JInput(); // Adjust the context to support modal layouts. if ($layout = $input->getString('layout', 'default')) { $this->context .= '.' . $layout; } $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $provider = $this->getUserStateFromRequest($this->context . '.filter.provider', 'filter_provider', 0, 'string'); $this->setState('filter.provider', $provider); // List state information. parent::populateState('su.id', 'desc'); }
/** * getContext * * @return string */ public function getContext() { $option = $this->input->get('option'); $view = $this->input->get('view'); $context = "{$option}.{$view}"; return $context; }
/** * Init this component. * * @return void */ public function init() { $dispatcher = $this->container->get('event.dispatcher'); // Event $dispatcher->trigger('onComponentBeforeInit', array($this->name, $this, $this->input)); // We build component path constant, helpe us get path easily. $this->path['self'] = JPATH_BASE . '/components/' . strtolower($this->option); $this->path['site'] = JPATH_ROOT . '/components/' . strtolower($this->option); $this->path['administrator'] = JPATH_ROOT . '/administrator/components/' . strtolower($this->option); define(strtoupper($this->name) . '_SELF', $this->path['self']); define(strtoupper($this->name) . '_SITE', $this->path['site']); define(strtoupper($this->name) . '_ADMIN', $this->path['administrator']); // Register some useful object for this component. $this->container->registerServiceProvider(new ComponentProvider($this->name, $this)); $task = $this->input->getWord('task'); $controller = $this->input->getWord('controller'); // Prepare default controller if (!$task && !$controller) { // If we got view, set it to display controller. $view = $this->input->get('view'); $task = $view ? $view . '.display' : $this->defaultController; $this->input->set('task', $task); $this->input->set('controller', $task); } // Register form and fields \JForm::addFieldPath(WINDWALKER_SOURCE . '/Form/Fields'); \JForm::addFormPath(WINDWALKER_SOURCE . '/Form/Forms'); $this->registerEventListener(); // Register elFinder controllers // @TODO: Should use event listener $this->registerTask('finder.elfinder.display', '\\Windwalker\\Elfinder\\Controller\\DisplayController'); $this->registerTask('finder.elfinder.connect', '\\Windwalker\\Elfinder\\Controller\\ConnectController'); // Event $dispatcher->trigger('onComponentAfterInit', array($this->name, $this, $this->input)); }
public function getOrderId() { $user = JFactory::getUser(); $user_id = $user->id; $jinput = new JInput(); $post = $jinput->get('jform', '', 'array'); $order_sum = $post['order_sum']; $row = array(); $row['user_id'] = $user_id; $row['sum'] = $order_sum; $payments =& JTable::getInstance('payments', 'VideoTranslationTable'); if (!$payments->bind($row)) { return JError::raiseWarning(500, $row->getError()); } if (!$payments->store()) { JError::raiseError(500, $row->getError()); } return $payments->id; }
/** * Test the JInput::serialize method. * * @return void * * @since 12.1 */ public function testSerialize() { // Load the inputs so that the static $loaded is set to true. TestReflection::invoke($this->class, 'loadAllInputs'); // Adjust the values so they are easier to handle. TestReflection::setValue($this->class, 'inputs', array('server' => 'remove', 'env' => 'remove', 'request' => 'keep')); TestReflection::setValue($this->class, 'options', 'options'); TestReflection::setValue($this->class, 'data', 'data'); $this->assertThat($this->class->serialize(), $this->equalTo('a:3:{i:0;s:7:"options";i:1;s:4:"data";i:2;a:1:{s:7:"request";s:4:"keep";}}')); }
/** * Method to get the data that should be injected in the form. * * @return array The default data is an empty array. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered login form data. $app = JFactory::getApplication(); $input = new JInput(); $data = $app->getUserState('slogin.login.form.data', array()); // check for return URL from the request first if ($return = $input->Get('return', '', 'BASE64')) { $data['return'] = base64_decode($return); if (!JURI::isInternal($data['return'])) { $data['return'] = ''; } } // Set the return URL if empty. if (!isset($data['return']) || empty($data['return'])) { $data['return'] = 'index.php?option=com_users&view=profile'; } $app->setUserState('users.login.form.data', $data); return $data; }
/** * Gets a value from the input data. * * @param string $name Name of the value to get. * @param mixed $default Default value to return if variable does not exist. * @param string $filter Filter to apply to the value. * * @return mixed The filtered input value. * * @since 11.1 */ public function get($name, $default = null, $filter = 'cmd') { // No filtering in RAW format if (strtoupper($filter) == 'RAW') { if (isset($this->data[$name])) { return $this->data[$name]; } return $default; } return parent::get($name, $default, $filter); }
/** * Display the view */ public function display($tpl = null) { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $app = JFactory::getApplication(); $input = new JInput(); // load the module params $controller = new MaximenuckController(); $this->params_string = $controller->load_param($input->get('id', 0, 'int'), '', false, true, true); $this->params = new JRegistry($this->params_string); $this->imagespath = JUri::root(true) . '/administrator/components/com_maximenuck'; $this->colorpicker_class = 'color {required:false,pickerPosition:\'top\',pickerBorder:2,pickerInset:3,hash:true}'; // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); die; }
protected function getLabel() { $input = new JInput(); $imgpath = JUri::root(true) . '/modules/mod_maximenuck/elements/images/'; // check if the maximenu params component is installed $com_params_text = ''; if (file_exists(JPATH_ROOT . '/administrator/components/com_maximenuck/maximenuck.php')) { $com_params_text = '<img src="' . $imgpath . 'accept.png" />' . JText::_('MOD_MAXIMENUCK_COMPONENT_PARAMS_INSTALLED'); $button = '<input name="' . $this->name . '_button" id="' . $this->name . '_button" class="ckpopupwizardmanager_button" style="background-image:url(' . $imgpath . 'pencil.png);width:100%;" type="button" value="' . JText::_('MAXIMENUCK_STYLES_WIZARD') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 800, y: 500}, url:\'' . JUri::root(true) . '/administrator/index.php?option=com_maximenuck&view=modules&view=styles&&layout=modal&id=' . $input->get('id', 0, 'int') . '\'})"/>'; } else { $com_params_text = '<img src="' . $imgpath . 'cross.png" />' . JText::_('MOD_MAXIMENUCK_COMPONENT_PARAMS_NOT_INSTALLED'); $button = ''; } $html = ''; // css styles already loaded into the ckmaximenuchecking field $html .= $com_params_text ? '<div class="maximenuckchecking">' . $com_params_text . '</div>' : ''; $html .= '<div class="clr"></div>'; $html .= $button; return $html; }
/** * Start a session. * * Creates a session (or resumes the current one based on the state of the session) * * @return boolean true on success * * @since 11.1 */ protected function _start() { // Start session if not started if ($this->_state === 'restart') { session_regenerate_id(true); } else { $session_name = session_name(); // Get the JInputCookie object $cookie = $this->_input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->_input->get($session_name, false, 'string'); if ($session_clean) { session_id($session_clean); $cookie->set($session_name, '', time() - 3600); } } } /** * Write and Close handlers are called after destructing objects since PHP 5.0.5. * Thus destructors can use sessions but session handler can't use objects. * So we are moving session closure before destructing objects. */ register_shutdown_function(array($this, 'close')); session_cache_limiter('none'); session_start(); // Ok let's unserialize the whole thing // Try loading data from the session if (isset($_SESSION['joomla']) && !empty($_SESSION['joomla'])) { $data = $_SESSION['joomla']; $data = base64_decode($data); $this->data = unserialize($data); } // Temporary, PARTIAL, data migration of existing session data to avoid logout on update from J < 3.4.7 if (isset($_SESSION['__default']) && !empty($_SESSION['__default'])) { $migratableKeys = array("user", "session.token", "session.counter", "session.timer.start", "session.timer.last", "session.timer.now"); foreach ($migratableKeys as $migratableKey) { if (!empty($_SESSION['__default'][$migratableKey])) { // Don't overwrite existing session data if (!is_null($this->data->get('__default.' . $migratableKey, null))) { continue; } $this->data->set('__default.' . $migratableKey, $_SESSION['__default'][$migratableKey]); unset($_SESSION['__default'][$migratableKey]); } } /** * Finally, empty the __default key since we no longer need it. Don't unset it completely, we need this * for the administrator/components/com_admin/script.php to detect upgraded sessions and perform a full * session cleanup. */ $_SESSION['__default'] = array(); } return true; }
/** * @param $name * @param null $default * @param string $hash * @param string $type * * @return mixed */ protected function getVar($name, $default = null, $hash = 'request', $type = 'none') { // If we are not in embedded mode, get variable from request if (!$this->embedded) { if ($hash == 'request') { return $this->input->get($name, $default, $type); } else { return $this->input->{$hash}->get($name, $default, $type); } } return $this->filter->clean($this->params->get($name, $default), $type); }
public function onAfterInitialise() { // Make sure this is the back-end $app = JFactory::getApplication(); if (!in_array($app->getName(), array('administrator', 'admin'))) { return; } // Get the input variables $ji = new JInput(); $component = $ji->getCmd('option', ''); $task = $ji->getCmd('task', ''); $view = $ji->getCmd('view', ''); $backedup = $ji->getInt('is_backed_up', 0); // Perform a redirection on Joomla! Update download or install task, unless we have already backed up the site if ($component == 'com_joomlaupdate' && $task == 'update.install' && !$backedup) { $return_url = JURI::base() . 'index.php?option=com_joomlaupdate&task=update.install&is_backed_up=1'; $redirect_url = JURI::base() . 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($return_url); $app = JFactory::getApplication(); $app->redirect($redirect_url); } }
/** * Start a session. * * Creates a session (or resumes the current one based on the state of the session) * * @return boolean true on success * * @since 11.1 */ protected function _start() { // Start session if not started if ($this->_state === 'restart') { session_regenerate_id(true); } else { $session_name = session_name(); // Get the JInputCookie object $cookie = $this->_input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->_input->get($session_name, false, 'string'); if ($session_clean) { session_id($session_clean); $cookie->set($session_name, '', time() - 3600); } } } /** * Write and Close handlers are called after destructing objects since PHP 5.0.5. * Thus destructors can use sessions but session handler can't use objects. * So we are moving session closure before destructing objects. * * Replace with session_register_shutdown() when dropping compatibility with PHP 5.3 */ register_shutdown_function(array($this, 'close')); session_cache_limiter('none'); session_start(); // Ok let's unserialize the whole thing $this->data = new \Joomla\Registry\Registry(); // Try loading data from the session if (isset($_SESSION['joomla']) && !empty($_SESSION['joomla'])) { $data = $_SESSION['joomla']; $data = base64_decode($data); $this->data = unserialize($data); } // Migrate existing session data to avoid logout on update from J < 3.4.7 if (isset($_SESSION['__default'])) { $migratableKeys = array("user", "session.token", "session.counter", "session.timer.start", "session.timer.last", "session.timer.now"); foreach ($migratableKeys as $migratableKey) { if (!empty($_SESSION['__default'][$migratableKey])) { // Don't overwrite existing session data if (!is_null($this->data->get('__default.' . $migratableKey, null))) { continue; } $this->data->set('__default.' . $migratableKey, $_SESSION['__default'][$migratableKey]); unset($_SESSION['__default'][$migratableKey]); } } } return true; }
/** * Public constructor. Overriden to allow specifying the global input array * to use as a string and instantiate from an objetc holding variables. * * @param array|string|object|null $source Source data; set null to use $_REQUEST * @param array $options Filter options */ public function __construct($source = null, array $options = array()) { $hash = null; if (is_string($source)) { $hash = strtoupper($source); switch ($hash) { case 'GET': $source = $_GET; break; case 'POST': $source = $_POST; break; case 'FILES': $source = $_FILES; break; case 'COOKIE': $source = $_COOKIE; break; case 'ENV': $source = $_ENV; break; case 'SERVER': $source = $_SERVER; break; default: $source = $_REQUEST; $hash = 'REQUEST'; break; } } elseif (is_object($source)) { try { $source = (array) $source; } catch (Exception $exc) { $source = null; } } elseif (is_array($source)) { // Nothing, it's already an array } else { // Any other case $source = $_REQUEST; $hash = 'REQUEST'; } // Magic quotes GPC handling (something JInput simply can't handle at all) if ($hash == 'REQUEST' && get_magic_quotes_gpc() && class_exists('JRequest', true)) { $source = JRequest::get('REQUEST', 2); } parent::__construct($source, $options); }
/** * Render action template * * @param string $tmpl Template file name to render * @return void */ public function render($tmpl, $data = array()) { $widgetName = $this->request->getCmd('widget'); $tmplFile = JSN_PATH_TPLFRAMEWORK_LIBRARIES . '/widget/tmpl/' . $widgetName . '/' . $tmpl . '.php'; if (!is_file($tmplFile) || !is_readable($tmplFile)) { throw new Exception('Template file not found: ' . $tmplFile); } // Extract data to seperated variables extract($data); // Start output buffer ob_start(); // Load template file include $tmplFile; // Send rendered content to client $this->responseContent = ob_get_clean(); }
/** * parseTask * * @param string $controller * @param \JInput $input * * @return void */ public static function parseUserTask($controller, $input) { $task = $input->get('task'); if (is_numeric($task)) { $id = $task; $input->set('id', $id); $input->set('task', null); } else { $input->set('task', 'user.' . $input->get('task')); } }