public function onAfterRoute() { $application = JFactory::getApplication(); if($application->isSite()) { switch(JRequest::getVar('option', null, 'method', 'cmd')) { case 'com_user': JRequest::setVar('option', 'com_users', 'get'); switch(JRequest::getVar('view', null, 'method', 'cmd')) { case 'login': if(!JFactory::getUser()->guest) { JRequest::setVar('view', 'logout', 'get'); } break; case 'remind': JRequest::setVar('view', 'remind', 'get'); break; case 'register': JRequest::setVar('view', 'user', 'get'); JRequest::setVar('layout', 'register', 'get'); break; case 'user': if(JRequest::getVar('task', null, 'get', 'cmd') == 'edit') { JRequest::setVar('layout', 'form', 'get'); } } switch(JRequest::getVar('task', null, 'method', 'cmd')) { case 'login': JRequest::setVar('view', 'login', 'get'); JRequest::setVar('action', 'login', 'post'); JRequest::setVar('password', JRequest::getVar('passwd', null, 'method', 'none'), 'post'); break; } break; } if(JRequest::getMethod() == 'POST') { $token = JUtility::getToken(); if(JRequest::getVar($token, null, 'post', 'alnum') == 1) { JRequest::setVar('_token', $token, 'post'); } } } }
public static function getInstance($name) { if (isset(self::$instances[$name])) { return self::$instances[$name]; } $plugin = JPluginHelper::getPlugin('api', $name); if (empty($plugin)) { throw new Exception(JText::_('COM_API_PLUGIN_CLASS_NOT_FOUND'), 400); } jimport('joomla.filesystem.file'); $plgfile = JPATH_BASE . self::$plg_path . $name . DS . $name . '.php'; $param_path = JPATH_BASE . self::$plg_path . $name . DS . $name . '.xml'; if (!JFile::exists($plgfile)) { throw new Exception(JText::_('COM_API_FILE_NOT_FOUND'), 400); } include $plgfile; $class = self::$plg_prefix . ucwords($name); if (!class_exists($class)) { throw new Exception(JText::_('COM_API_PLUGIN_CLASS_NOT_FOUND'), 400); } $handler = new $class(); $cparams = JComponentHelper::getParams('com_api'); $params = new JRegistry(); $params->loadString($plugin->params); $cparams->merge($params); $handler->set('params', $cparams); $handler->set('component', JRequest::getCmd('app')); $handler->set('resource', JRequest::getCmd('resource')); $handler->set('format', $handler->negotiateContent(JRequest::getCmd('output', null))); $handler->set('request_method', JRequest::getMethod()); self::$instances[$name] = $handler; return self::$instances[$name]; }
function testGetMethod() { $_SERVER['REQUEST_METHOD'] = 'post'; $this -> assertEquals('POST', JRequest::getMethod()); $_SERVER['REQUEST_METHOD'] = 'get'; $this -> assertEquals('GET', JRequest::getMethod()); }
public static function getInstance($name) { if (isset(self::$instances[$name])) { return self::$instances[$name]; } $plugin = JPluginHelper::getPlugin('api', $name); if (empty($plugin)) { ApiError::raiseError(400, JText::_('COM_API_PLUGIN_CLASS_NOT_FOUND')); } jimport('joomla.filesystem.file'); $plgfile = JPATH_BASE . self::$plg_path . $name . '.php'; $param_path = JPATH_BASE . self::$plg_path . $name . '.xml'; if (!JFile::exists($plgfile)) { ApiError::raiseError(400, JText::_('COM_API_FILE_NOT_FOUND')); } include_once $plgfile; $class = self::$plg_prefix . ucwords($name); if (!class_exists($class)) { ApiError::raiseError(400, JText::_('COM_API_PLUGIN_CLASS_NOT_FOUND')); } $handler = new $class(); $cparams = JComponentHelper::getParams('com_api'); $params = new JParameter($plugin->params, $param_path); $cparams->merge($params); $handler->set('params', $cparams); $handler->set('component', JRequest::getCmd('app')); $handler->set('resource', JRequest::getCmd('resource')); $handler->set('format', JRequest::getCmd('output')); $handler->set('request_method', JRequest::getMethod()); self::$instances[$name] = $handler; return self::$instances[$name]; }
public function display($tpl = null) { $id = JRequest::getInt('id', 0); $badge = DiscussHelper::getTable('Badges'); $badge->load($id); if (!$badge->created) { $date = DiscussHelper::getHelper('Date')->dateWithOffset(DiscussHelper::getDate()->toMySQL()); $badge->created = $date->toMySQL(); } // There could be some errors here. if (JRequest::getMethod() == 'POST') { $badge->bind(JRequest::get('post')); // Description might contain html codes $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $badge->description = $description; } $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $model = $this->getModel('Badges'); $rules = $model->getRules(); $badges = $this->getBadges(); $this->assign('editor', $editor); $this->assign('badges', $badges); $this->assign('rules', $rules); $this->assign('badge', $badge); parent::display($tpl); }
private function doSave() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); if (!JRequest::getMethod() == 'POST') { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_INVALID_REQUEST', 'error')); return false; } // Unset unecessary post data. $post = JRequest::get('POST'); unset($post['task']); unset($post['option']); unset($post['c']); $token = Komento::_('getToken'); unset($post[$token]); // check the target component if (!$post['target_component']) { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_MISSING_TARGET_COMPONENT')); return false; } // rememeber user's choice // $mainframe->setUserState('com_komento.acl.component', $post['target_component']); // Save post data $model = Komento::getModel('Acl', true); if (!$model->save($post)) { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_ERROR', 'error')); return false; } $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_SUCCESS', 'message')); // Clear the component's cache $cache = JFactory::getCache('com_komento'); $cache->clean(); return true; }
function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('trackback'); $mainframe = JFactory::getApplication(); $message = ''; $type = 'message'; if (JRequest::getMethod() != 'POST') { $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_INVALID_REQUEST'), 'error'); $mainframe->close(); } $post = JRequest::get('POST'); $my = JFactory::getUser(); $id = JRequest::getInt('id', 0); JTable::addIncludePath(EBLOG_TABLES); $trackback = EasyBlogHelper::getTable('Trackback', 'Table'); $trackback->load($id); $trackback->bind($post); if (!$trackback->store()) { $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_ERROR'), 'error'); $mainframe->close(); } $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_SUCCESS')); $mainframe->close(); }
/** * Helper method to handle event onAfterInitialise * * @return void */ public static function onAfterInitialise() { $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; if ($isAjax) { return; } // Handle global form post if (JRequest::getMethod() == 'POST') { self::handlePostRequest(); } else { self::handleGetRequest(); } }
private function _store() { $mainframe = JFactory::getApplication(); $message = ''; $type = 'success'; if (JRequest::getMethod() == 'POST') { $model = $this->getModel('Settings'); $postArray = JRequest::get('post'); $saveData = array(); // Unset unecessary data. unset($postArray['controller']); unset($postArray['active']); unset($postArray['child']); unset($postArray['layout']); unset($postArray['task']); unset($postArray['option']); unset($postArray['c']); $token = DiscussHelper::getToken(); unset($postArray[$token]); foreach ($postArray as $index => $value) { // Filter out the dummy checkbox_display_xxx entry if (substr($index, 0, 17) == 'checkbox_display_') { continue; } if ($index == 'integration_google_adsense_code') { $value = str_ireplace(';"', ';', $value); } if ($index != 'task') { } $saveData[$index] = $value; if (is_array($value)) { $saveData[$index] = implode(',', $value); } } // reset the setting 'main_allowdelete' to use from configuration.ini $saveData['main_allowdelete'] = DiscussHelper::getDefaultConfigValue('main_allowdelete', ''); // reset the setting 'layout_featuredpost_style' to always use from configuration.ini $saveData['layout_featuredpost_style'] = DiscussHelper::getDefaultConfigValue('layout_featuredpost_style', '0'); if ($model->save($saveData)) { $message = JText::_('COM_EASYDISCUSS_CONFIGURATION_SAVED'); } else { $message = JText::_('COM_EASYDISCUSS_CONFIGURATION_SAVE_ERROR'); $type = 'error'; } } else { $message = JText::_('COM_EASYDISCUSS_INVALID_FORM_METHOD'); $type = 'error'; } return array('message' => $message, 'type' => $type); }
function _store() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); $message = ''; $type = 'success'; if (JRequest::getMethod() == 'POST') { $cid = JRequest::getVar('cid', null, 'POST'); $acltype = JRequest::getVar('type', '', 'POST'); $name = JRequest::getVar('name', '', 'POST'); if (!is_null($cid) || !empty($acltype)) { $model = $this->getModel('Acl'); $db = DiscussHelper::getDBO(); if ($model->deleteRuleset($cid, $acltype)) { $postArray = JRequest::get('post'); $saveData = array(); // Unset unecessary data. unset($postArray['task']); unset($postArray['option']); unset($postArray['c']); unset($postArray['cid']); unset($postArray['name']); unset($postArray['type']); foreach ($postArray as $index => $value) { if ($index != 'task') { } $saveData[$index] = $value; } if ($model->insertRuleset($cid, $acltype, $saveData)) { $message = JText::_('ACL settings successfully saved.'); } else { $message = JText::_('There was an error while trying to save the ACL settings.'); $type = 'error'; } } else { $message = JText::_('There was an error while trying to update the ACL.'); $type = 'error'; } } else { $message = JText::_('Invalid ID or ACL type, please try again.'); $type = 'error'; } } else { $message = JText::_('Invalid request method. This form needs to be submitted through a "POST" request.'); $type = 'error'; } return array('message' => $message, 'type' => $type); }
function onAfterRoute() { $app = JFactory::getApplication(); // Temporary hack until it is possible to get Joomla to add PUT, DELETE support if ($app->isSite() && in_array(JRequest::getMethod(), array('PUT', 'DELETE'))) { $putdata = $this->getPutParameters(file_get_contents('php://input')); $putdata['format'] = 'raw'; if (isset($putdata['option']) && 'com_api' == $putdata['option']) { $_REQUEST = array_merge($_REQUEST, $putdata); $_POST = array_merge($_POST, $putdata); } } if ('com_api' == JRequest::getVar('option') && $app->isSite()) { JRequest::setVar('format', 'raw'); } }
/** * Method to save the configuration **/ function save() { // Test if this is really a post request $method = JRequest::getMethod(); if ($method == 'GET') { JError::raiseError(500, JText::_('CC ACCESS METHOD NOT ALLOWED')); return; } $mainframe =& JFactory::getApplication(); $model =& $this->getModel('Network'); // Try to save network configurations if ($model->save()) { $message = JText::_('CC NETWORK CONFIGURATION UPDATED'); $mainframe->redirect('index.php?option=com_community&view=network', $message); } else { JError::raiseWarning(100, JText::_('CC UNABLE TO SAVE NETWORK CONFIGURATION INTO DATABASE PLEASE ENSURE THAT THE TABLE JOS_COMMUNITY_CONFIG EXISTS')); } }
/** * Method to save the configuration **/ public function save() { // Test if this is really a post request $method = JRequest::getMethod(); if ($method == 'GET') { JError::raiseError(500, JText::_('COM_COMMUNITY_ACCESS_NOT_ALLOWED')); return; } $mainframe =& JFactory::getApplication(); $model =& $this->getModel('Network'); // Try to save network configurations if ($model->save()) { $message = JText::_('COM_COMMUNITY_NETWORK_CONFIGURATION_UPDATED'); $mainframe->redirect('index.php?option=com_community&view=network', $message); } else { JError::raiseWarning(100, JText::_('COM_COMMUNITY_CONFIGURATION_NETWORK_SAVE_FAIL')); } }
function _store() { $mainframe = JFactory::getApplication(); $message = ''; $type = 'message'; if (JRequest::getMethod() == 'POST') { $model = $this->getModel('Settings'); $post = JRequest::get('post'); $postArray = JRequest::get('post'); $saveData = array(); $layout = $postArray['layout']; $step = $postArray['step']; // Unset unecessary data. unset($postArray['task']); unset($postArray['option']); unset($postArray['layout']); unset($postArray['controller']); unset($postArray['step']); if (!isset($postArray['main_autopost_' . $layout . '_page_id'])) { $postArray['main_autopost_' . $layout . '_page_id'] = ''; } if (empty($postArray)) { // Nothing else to be configured. Assuming that this is the final step. return array('message' => JText::sprintf('COM_EASYDISCUSS_AUTOPOST_LINKED_SUCCESSFULLY', ucfirst($layout)), 'type' => 'completed'); } foreach ($postArray as $index => $value) { $saveData[$index] = $value; } if ($model->save($saveData)) { $message = JText::_('COM_EASYDISCUSS_CONFIGURATION_SAVED'); if ($step == 2 || $step == 'completed') { return array('message' => JText::sprintf('COM_EASYDISCUSS_AUTOPOST_SETTING_SAVED_SUCCESSFULLY', ucfirst($layout)), 'type' => 'completed'); } } else { $message = JText::_('COM_EASYDISCUSS_CONFIGURATION_SAVE_ERROR'); $type = 'error'; } } else { $message = JText::_('COM_EASYDISCUSS_INVALID_FORM_METHOD'); $type = 'error'; } return array('message' => $message, 'type' => $type); }
/** * Unbind the subscriber from the list * * @return void * @since 1.0 */ public function unbind() { if (JRequest::getMethod() == "POST") { try { $sid = JRequest::getInt('subscriber_id', null, 'post'); $lid = JRequest::getInt('list_to_unbind', null, 'post'); $model = JModel::getInstance('Subscriber', 'NewsletterModelEntity'); if (!$model->load($sid)) { throw new Exception(); } if (!$model->unbindFromList($lid)) { throw new Exception(); } $this->setMessage(JText::_("COM_NEWSLETTER_UNBIND_SUCCESS")); } catch (Exception $e) { $this->setMessage(JText::_("COM_NEWSLETTER_UNBIND_FAILED"), 'error'); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($sid, 'subscriber_id'), false)); }
function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('comment'); $mainframe = JFactory::getApplication(); $message = ''; $type = 'message'; if (JRequest::getMethod() == 'POST') { $post = JRequest::get('post'); $user = JFactory::getUser(); $post['created_by'] = $user->id; $commentId = JRequest::getVar('commentid', ''); $comment = EasyBlogHelper::getTable('Comment', 'Table'); if (!empty($commentId)) { $comment->load($commentId); $post['created_by'] = $comment->created_by; } $comment->bind($post); //$comment->comment = EasyBlogStringHelper::url2link( $comment->comment ); if (!$comment->store()) { JError::raiseError(500, $comment->getError()); } else { if ($comment->published && !$comment->sent) { $comment->comment = EasyBlogCommentHelper::parseBBCode($comment->comment); $comment->comment = nl2br($comment->comment); $blog = EasyBlogHelper::getTable('Blog'); $blog->load($comment->post_id); $comment->processEmails(false, $blog); //update the sent flag to sent $comment->updateSent(); } $message = JText::_('COM_EASYBLOG_COMMENTS_SAVED'); } } else { $message = JText::_('Invalid request method. This form needs to be submitted through a "POST" request.'); $type = 'error'; } $mainframe->redirect('index.php?option=com_easyblog&view=comments', $message, $type); }
public function save() { $mainframe = JFactory::getApplication(); $message = ''; $type = 'success'; if (JRequest::getMethod() == 'POST') { $post = JRequest::get('post'); if (empty($post['title'])) { $mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_LABEL'), 'error'); $url = 'index.php?option=com_easydiscuss&view=labels'; $mainframe->redirect(JRoute::_($url, false)); return; } $my = JFactory::getUser(); $post['created_user_id'] = $my->id; $labelId = JRequest::getVar('label_id', ''); $label = DiscussHelper::getTable('Label'); $label->load($labelId); $label->bind($post); $label->title = JString::trim($label->title); if (!$label->store()) { JError::raiseError(500, $label->getError()); } else { $message = JText::_('COM_EASYDISCUSS_LABEL_SAVED'); } } else { $message = JText::_('COM_EASYDISCUSS_INVALID_FORM_METHOD'); $type = 'error'; } DiscussHelper::setMessageQueue($message, $type); $saveNew = JRequest::getBool('savenew', false); $saveNew = JRequest::getCmd('task') == 'savePublishNew'; if ($saveNew) { $mainframe->redirect('index.php?option=com_easydiscuss&view=labels&task=labels.edit'); $mainframe->close(); } $mainframe->redirect('index.php?option=com_easydiscuss&view=labels'); }
function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('tag'); $app = JFactory::getApplication(); $msg = ''; $type = 'message'; $url = 'index.php?option=com_easyblog&view=tags'; // Redirect to new form if necessary $saveNew = JRequest::getInt('savenew', 0); if (JRequest::getMethod() != 'POST') { $message = JText::_('Invalid request method. This form needs to be submitted through a "POST" request.'); $type = 'error'; $app->redirect('index.php?option=com_easyblog&view=tags', $message, $type); } $post = JRequest::get('POST'); $user = JFactory::getUser(); $post['created_by'] = $user->id; $tagId = JRequest::getVar('tagid', ''); $isNew = empty($tagId) ? true : false; $tag = EasyBlogHelper::getTable('tag', 'Table'); $tag->load($tagId); $tag->bind($post); $tag->title = JString::trim($tag->title); $tag->alias = JString::trim($tag->alias); if (!$tag->store()) { $app->redirect('index.php?option=com_easyblog&view=tag', $tag->getError(), 'error'); } $message = JText::_('COM_EASYBLOG_TAGS_TAG_SAVED'); if ($saveNew) { $app->redirect('index.php?option=com_easyblog&view=tag', $message, $type); $app->close(); } $app->redirect('index.php?option=com_easyblog&view=tags', $message, $type); }
public function save() { $mainframe = JFactory::getApplication(); $message = ''; $type = 'success'; $task = $this->getTask(); if (JRequest::getMethod() == 'POST') { $post = JRequest::get('post'); if (empty($post['title'])) { $mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_ROLES'), 'error'); $url = 'index.php?option=com_easydiscuss&view=roles'; $mainframe->redirect(JRoute::_($url, false)); return; } $my = JFactory::getUser(); $post['created_user_id'] = $my->id; $roleId = JRequest::getVar('role_id', ''); $role = DiscussHelper::getTable('Role'); $role->load($roleId); $role->bind($post); $role->title = JString::trim($role->title); if (!$role->store()) { JError::raiseError(500, $role->getError()); } else { $message = JText::_('COM_EASYDISCUSS_ROLE_SAVED'); } } else { $message = JText::_('COM_EASYDISCUSS_INVALID_FORM_METHOD'); $type = 'error'; } DiscussHelper::setMessageQueue($message, $type); if ($task == 'savePublishNew') { $mainframe->redirect('index.php?option=com_easydiscuss&view=roles&task=roles.edit'); $mainframe->close(); } $mainframe->redirect('index.php?option=com_easydiscuss&view=roles'); }
function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('meta'); $mainframe = JFactory::getApplication(); $message = ''; $type = 'message'; $url = JRoute::_('index.php?option=com_easyblog&view=metas', false); if (JRequest::getMethod() == 'POST') { $post = JRequest::get('post'); if (empty($post['id'])) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INVALID_META_TAG_ID'), 'error'); $url = 'index.php?option=com_easyblog&view=metas'; $mainframe->redirect(JRoute::_($url, false)); return; } $meta = EasyBlogHelper::getTable('meta', 'Table'); $user = JFactory::getUser(); $metaId = JRequest::getVar('id', ''); if (!empty($metaId)) { $meta->load($metaId); } $meta->bind($post); $meta->store(); $message = JText::_('COM_EASYBLOG_META_SAVED'); if ($this->getTask() == 'apply') { $url = JRoute::_('index.php?option=com_easyblog&view=meta&id=' . $meta->id, false); } } else { $message = JText::_('Invalid request method. This form needs to be submitted through a "POST" request.'); $type = 'error'; } $mainframe->redirect($url, $message, $type); }
public function parseRule(&$router, &$uri) { $array = array(); $lang_code = JRequest::getString(JApplication::getHash('language'), null, 'cookie'); // No cookie - let's try to detect browser language or use site default if (!$lang_code) { if ($this->params->get('detect_browser', 1)) { $lang_code = JLanguageHelper::detectLanguage(); } else { $lang_code = self::$default_lang; } } if (self::$mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; $app = JFactory::getApplication(); // Redirect only if not in post $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { if ($this->params->get('remove_default_prefix', 0) == 0) { // redirect if sef does not exists if (!isset(self::$sefs[$sef])) { // Use the current language sef or the default one $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } } else { // redirect if sef does not exists and language is not the default one if (!isset(self::$sefs[$sef]) && $lang_code != self::$default_lang) { $sef = self::$default_sef; $uri->setPath($sef . '/' . $path); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } elseif (isset(self::$sefs[$sef]) && self::$default_lang == self::$sefs[$sef]->lang_code && (!$this->params->get('detect_browser', 1) || JLanguageHelper::detectLanguage() == self::$tag || self::$cookie)) { array_shift($parts); $uri->setPath(implode('/', $parts)); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $path = $uri->toString(array('path', 'query', 'fragment')); $app->redirect($uri->base() . 'index.php' . ($path ? '/' . $path : '')); } } } } $lang_code = isset(self::$sefs[$sef]) ? self::$sefs[$sef]->lang_code : ''; if ($lang_code && JLanguage::exists($lang_code)) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } else { $sef = $uri->getVar('lang'); if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setVar('lang', $sef); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); $app->redirect(JURI::base(true) . '/index.php?' . $uri->getQuery()); } } } $array = array('lang' => $sef); return $array; }
/** * Responsible to save an existing or a new group. */ public function save() { JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); if (JString::strtoupper(JRequest::getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=groups', JText::_('COM_COMMUNITY_PERMISSION DENIED'), 'error'); } // Load frontend language file. $lang =& JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT); $group = JTable::getInstance('Group', 'CTable'); $id = JRequest::getInt('groupid'); $group->load($id); $name = JRequest::getVar('name', '', 'POST'); $description = $_POST['description']; $categoryId = JRequest::getVar('categoryid', '', 'POST'); $creator = JRequest::getInt('creator', 0, 'POST'); $website = JRequest::getVar('website', '', 'POST'); $validated = true; $model = CFactory::getModel('Groups'); $isNew = $group->id < 1; $ownerChanged = $group->ownerid != $creator && $group->id >= 1; // @rule: Test for emptyness if (empty($name)) { $validated = false; $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_EMPTY_NAME_ERROR'), 'error'); } // @rule: Test if group exists if ($model->groupExist($name, $group->id)) { $validated = false; $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_NAME_TAKEN_ERROR'), 'error'); } // @rule: Test for emptyness if (empty($description)) { $validated = false; $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_DESCRIPTION_EMPTY_ERROR'), 'error'); } if (empty($categoryId)) { $validated = false; $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_CATEGORY_ERROR'), 'error'); } if ($validated) { // Get the configuration object. $config = CFactory::getConfig(); $group->bindRequestParams(); CFactory::load('helpers', 'owner'); // Bind the post with the table first $group->name = $name; $group->description = $description; $group->categoryid = $categoryId; $group->website = $website; $group->approvals = JRequest::getInt('approvals', '0', 'POST'); $oldOwner = $group->ownerid; $group->ownerid = $creator; if ($isNew) { $group->created = gmdate('Y-m-d H:i:s'); } $group->store(); if ($isNew) { // Since this is storing groups, we also need to store the creator / admin // into the groups members table $member =& JTable::getInstance('GroupMembers', 'CTable'); $member->groupid = $group->id; $member->memberid = $group->ownerid; // Creator should always be 1 as approved as they are the creator. $member->approved = 1; // @todo: Setup required permissions in the future $member->permissions = '1'; $member->store(); } if (!$isNew && $ownerChanged) { $group->updateOwner($oldOwner, $creator); } $message = $isNew ? JText::_('COM_COMMUNITY_GROUPS_CREATED') : JText::_('COM_COMMUNITY_GROUPS_UPDATED'); $mainframe->redirect('index.php?option=com_community&view=groups', $message); } $document = JFactory::getDocument(); $viewName = JRequest::getCmd('view', 'community'); // Get the view type $viewType = $document->getType(); // Get the view $view =& $this->getView($viewName, $viewType); $view->setLayout('edit'); $model =& $this->getModel($viewName); if ($model) { $view->setModel($model, $viewName); } $view->display(); }
/** * Check if is current request method is POST * @return bool */ public function isPost() { if (version_compare(JVERSION, '1.5.0', '<=')) { return 'POST' == JFactory::getApplication()->input->getMethod(false, false); } else { return 'POST' == JRequest::getMethod(); } }
public function parseRule(&$router, &$uri) { $array = array(); $lang_code = JRequest::getString(JUtility::getHash('language'), null, 'cookie'); if (!$lang_code) { $lang_code = JLanguageHelper::detectLanguage(); } if (self::$mode_sef) { $path = $uri->getPath(); $parts = explode('/', $path); $sef = $parts[0]; if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setPath($sef . '/' . $path); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); if ($app->getCfg('sef_rewrite')) { $app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment'))); } else { $app->redirect($uri->base() . 'index.php/' . $uri->toString(array('path', 'query', 'fragment'))); } } } $lang_code = self::$sefs[$sef]->lang_code; if ($lang_code && JLanguage::exists($lang_code)) { array_shift($parts); $uri->setPath(implode('/', $parts)); } } else { $sef = $uri->getVar('lang'); if (!isset(self::$sefs[$sef])) { $sef = isset(self::$lang_codes[$lang_code]) ? self::$lang_codes[$lang_code]->sef : self::$default_sef; $uri->setVar('lang', $sef); $post = JRequest::get('POST'); if (JRequest::getMethod() != "POST" || count($post) == 0) { $app = JFactory::getApplication(); $app->redirect(JURI::base(true) . '/index.php?' . $uri->getQuery()); } } } $array = array('lang' => $sef); return $array; }
/** * check various conditions to decide if we * should redirect from non-sef url to its * sef equivalent */ function shShouldRedirectFromNonSef($shPageInfo) { $sefConfig =& shRouter::shGetConfig(); $shouldRedirect = true; // first condition: component should not be set to "skip" $queryVars = $shPageInfo->URI->getQueryVars(); if (!empty($queryVars['option'])) { $shOption = str_replace('com_', '', $queryVars['option']); if (!empty($shOption) && in_array($shOption, $sefConfig->skip)) { $shouldRedirect = false; } } $method = JRequest::getMethod(); $shouldRedirect = $shouldRedirect && empty($shPageInfo->autoRedirectsDisabled) && $sefConfig->shRedirectNonSefToSef && !empty($shPageInfo->URI->url) && strpos($shPageInfo->URI->url, 'index2.php') === false && strpos($shPageInfo->URI->url, 'tmpl=component') === false && strpos($shPageInfo->URI->url, 'no_html=1') === false && (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') && empty($_POST) && $method != 'POST'; return $shouldRedirect; }
function save() { $mainframe = JFactory::getApplication(); $message = ''; $type = 'message'; $task = $this->getTask(); if (JRequest::getMethod() == 'POST') { $post = JRequest::get('post'); if (empty($post['title'])) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_TAG'), DISCUSS_QUEUE_ERROR); $url = 'index.php?option=com_easydiscuss&view=tags'; $mainframe->redirect(JRoute::_($url, false)); return; } $user = JFactory::getUser(); $post['user_id'] = $user->id; $tagId = JRequest::getVar('tagid', ''); $tag = JTable::getInstance('tags', 'Discuss'); if (!empty($tagId)) { $tag->load($tagId); } else { $tagModel = $this->getModel('Tags'); $result = $tagModel->searchTag($tag->title); if (!empty($result)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_TAG_EXISTS'), DISCUSS_QUEUE_ERROR); $mainframe->redirect('index.php?option=com_easydiscuss&view=tags'); } } $tag->bind($post); $tag->title = JString::trim($tag->title); $tag->alias = JString::trim($tag->alias); if (!$tag->store()) { JError::raiseError(500, $tag->getError()); } else { $message = JText::_('COM_EASYDISCUSS_TAG_SAVED'); } $mergeTo = isset($post['mergeTo']) ? (int) $post['mergeTo'] : 0; $mergeToTag = DiscussHelper::getTable('Tags'); $mergeToTag->load($mergeTo); if ($mergeToTag->id > 0 && $tag->id > 0) { // Move to merge tag id $db = DiscussHelper::getDBO(); // Find posts tagged in both id $query = 'SELECT a.id FROM #__discuss_posts_tags AS a' . ' LEFT JOIN #__discuss_posts_tags AS b ON b.post_id = a.post_id' . ' WHERE a.tag_id = ' . $db->quote($tag->id) . ' AND b.tag_id = ' . $db->quote($mergeToTag->id) . ' GROUP BY a.post_id'; $db->setQuery($query); $excludeIds = $db->loadResultArray(); // Do not update post having both tags, let $table->delete() handle them $query = 'UPDATE `#__discuss_posts_tags`' . ' SET `tag_id` = ' . $db->quote($mergeToTag->id) . ' WHERE `tag_id` = ' . $db->quote($tag->id); if (count($excludeIds) > 0) { JArrayHelper::toInteger($excludeIds); $query .= ' AND `id` NOT IN (' . implode(',', $excludeIds) . ')'; } $db->setQuery($query); $db->query(); $tag->delete(); } } else { $message = JText::_('COM_EASYDISCUSS_INVALID_FORM_METHOD'); $type = 'error'; } DiscussHelper::setMessageQueue($message, $type); if ($task == 'savePublishNew') { $mainframe->redirect('index.php?option=com_easydiscuss&view=tag'); $mainframe->close(); } $mainframe->redirect('index.php?option=com_easydiscuss&view=tags'); }
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Versions: 0.1 -- Initial version written by Omar Shammas (email : omar DOT shammas [a t ] g m ail DOT com) */ // no direct access defined('_JEXEC') or die('Restricted access'); // Include the syndicate functions only once require_once dirname(__FILE__) . DS . 'helper.php'; $msg = null; if (JRequest::getMethod() == 'POST') { $msg = modBigBlueButtonHelper::join($params); } if (!$msg['message'] || $msg['message'] && $msg['message'] != "redirect") { $listOfMeetings = modBigBlueButtonHelper::getForm($params); } require JModuleHelper::getLayoutPath('mod_bigbluebuttonconferencing');
/** * Display and process the multiple profile types. * **/ public function registerProfileType() { $mainframe =& JFactory::getApplication(); $mySess =& JFactory::getSession(); $config = CFactory::getConfig(); if (!$config->get('profile_multiprofile')) { echo JText::_('COM_COMMUNITY_MULTIPROFILE_IS_CURRENTLY_DISABLED'); return; } if (!$mySess->has('JS_REG_TOKEN')) { $mainframe->redirect(CRoute::_('index.php?option=com_community&view=register', false)); return; } $view =& $this->getView('register'); if (JRequest::getMethod() == 'POST') { $type = JRequest::getVar('profileType', 0); // @rule: When multiple profile is enabled, and profile type is not selected, we should trigger an error. if ($config->get('profile_multiprofile') && $type == COMMUNITY_DEFAULT_PROFILE) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_NO_PROFILE_TYPE_SELECTED'), 'error'); } else { $mainframe->redirect(CRoute::_('index.php?option=com_community&view=register&task=registerProfile&profileType=' . $type, false)); } } echo $view->get(__FUNCTION__); }
/** * Check various conditions on a request to * decide whether it is safe to allow a redirection * to another page * Does NOT check configuration settings, only look * at the passed uri and method parameters * * @param JURI object $uri object describing the current request, from which we want to redirect * @param string $method current request method */ protected function _canRedirectFrom($uri, $method = '') { // use framework if no method passed if (empty($method)) { $method = JRequest::getMethod(); } // get the requested url $url = $uri->get('_uri'); // start with hope $canRedirect = !self::$requestParsed; $canRedirect = $canRedirect && !empty($url); $canRedirect = $canRedirect && strpos($url, 'index2.php') === false; $canRedirect = $canRedirect && strpos($url, 'tmpl=component') === false; $canRedirect = $canRedirect && strpos($url, 'no_html=1') === false; $canRedirect = $canRedirect && (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest'); $canRedirect = $canRedirect && empty($_POST); $canRedirect = $canRedirect && $method != 'POST'; return $canRedirect; }
function onAfterRoute() { /** @var JSite $app */ $app = JFactory::getApplication(); if ($app->isAdmin()) { // don't use MobileJoomla in backend return; } $is_joomla15 = $this->isJoomla15(); // don't filter RSS and non-html /** @var JDocument $document */ $document = JFactory::getDocument(); $format = $document->getType(); $doctype = JRequest::getVar('type', false); if ($doctype == 'rss' || $doctype == 'atom' || $format !== 'html' && $format !== 'raw') { //reset mobile content-type header $headers = JResponse::getHeaders(); JResponse::clearHeaders(); foreach ($headers as $header) { if (strtolower($header['name']) != 'content-type') { JResponse::setHeader($header['name'], $header['value']); } } return; } //be last registered onAfterRender event $app->registerEvent('onAfterRender', 'plgSystemMobileBot_onAfterRenderLast'); // Load config $MobileJoomla_Settings =& MobileJoomla::getConfig(); $MobileJoomla_Device =& MobileJoomla::getDevice(); jimport('joomla.environment.browser'); $browser = JBrowser::getInstance(); if (version_compare(JVERSION, '3.0', '<')) { $browser->set('_mobile', $MobileJoomla_Device['markup'] !== false); } else { $refObj = new ReflectionObject($browser); $refProp = $refObj->getProperty('mobile'); $refProp->setAccessible(true); $refProp->setValue($browser, $MobileJoomla_Device['markup'] !== false); } JPluginHelper::importPlugin('mobile'); $app->triggerEvent('onMobileAfterRoute', array(&$MobileJoomla_Settings, &$MobileJoomla_Device)); $this->filterExtensions($MobileJoomla_Settings, $MobileJoomla_Device); // "Vary" header for proxy JResponse::setHeader('Vary', 'User-Agent'); if ($MobileJoomla_Device['markup'] === false) { $pcpage = $MobileJoomla_Settings['pcpage']; if ($pcpage && $pcpage !== 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) { $app->redirect($pcpage); } return; } define('_MJ', 1); /** @var MobileJoomla $MobileJoomla */ $MobileJoomla = MobileJoomla::getInstance(); if (!$is_joomla15 && isset($app->registeredurlparams)) { $registeredurlparams = $app->registeredurlparams; $this->setRequestVar('mjurlkey', null); unset($registeredurlparams->mjurlkey); $app->registeredurlparams = $registeredurlparams; } $app->triggerEvent('onMobile', array(&$MobileJoomla, &$MobileJoomla_Settings, &$MobileJoomla_Device)); $template = $MobileJoomla->getParam('template'); $homepage = $MobileJoomla->getParam('homepage'); $gzip = $MobileJoomla->getParam('gzip'); //Set template if (!empty($template)) { if ($is_joomla15) { $app->setUserState('setTemplate', $template); $app->setTemplate($template); } else { $db = JFactory::getDBO(); $query = "SELECT params FROM #__template_styles WHERE client_id = 0 AND template = " . $db->Quote($template) . " ORDER BY id LIMIT 1"; $db->setQuery($query); $params_data = $db->loadResult(); if (empty($params_data)) { $params_data = '{}'; } if (version_compare(JVERSION, '1.7', '>=')) { $app->setTemplate($template, $params_data); } elseif (version_compare(JVERSION, '1.6', '>=')) { $app->setTemplate($template); $template_obj = $app->getTemplate(true); $template_obj->params->loadJSON($params_data); } } } // JHtml overrides if (version_compare(JVERSION, '3.0', '<')) { jimport('joomla.html.html'); JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/override/html'); if (@is_dir($dir = JPATH_THEMES . '/' . $template . '/override/html')) { JHtml::addIncludePath($dir); } } else { // load email.php only (workaround for new J!3 class loader) if (@is_file($path = JPATH_THEMES . '/' . $template . '/override/html/email.php')) { JLoader::register('JHtmlEmail', $path, true); } else { JLoader::register('JHtmlEmail', JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/override/html/email.php', true); } } $this->setConfig('gzip', $gzip); //Set headers JResponse::clearHeaders(); $document = JFactory::getDocument(); $document->setMimeEncoding($MobileJoomla->getContentType()); $MobileJoomla->setHeader(); // SEO $canonical = MobileJoomla::getCanonicalURI(); if ($canonical) { if ($format == 'html') { $document->addHeadLink($canonical, 'canonical'); } $document->setMetaData('robots', 'noindex, nofollow'); } if (JRequest::getMethod() == 'POST') { return; } /** @var JMenu $menu */ $menu = $app->getMenu(); $router = $app->getRouter(); $Itemid = version_compare(JVERSION, '3.0', '>=') ? $app->input->getInt('Itemid') : JRequest::getInt('Itemid'); $item = $menu->getItem($Itemid); if (is_object($item)) { $current = array_merge($item->query, $_GET, $router->getVars()); } else { $current = array_merge($_GET, $router->getVars()); } if (!isset($current['Itemid'])) { $current['Itemid'] = (string) $Itemid; } unset($current['device']); unset($current['lang']); unset($current['format']); unset($current['no_html']); unset($current['language']); unset($current['tp']); unset($current['template']); unset($current['templateStyle']); unset($current['start']); unset($current['limitstart']); unset($current['limit']); // fix for sh404sef if (isset($current['limitstart']) && $current['limitstart'] == 0) { unset($current['limitstart']); } if (isset($current[session_name()])) { unset($current[session_name()]); } if ($is_joomla15) { $default = $menu->getDefault(); } else { $lang = JFactory::getLanguage(); $default = $menu->getDefault($lang->getTag()); } $home = $default->query; $home['Itemid'] = $default->id; if (substr($homepage, 0, 10) == 'index.php?') { parse_str(substr($homepage, 10), $mj_home); if (isset($mj_home['Itemid'])) { $mj_home_Itemid = (int) $mj_home['Itemid']; if ($is_joomla15) { $menu->setDefault($mj_home_Itemid); } else { $menu->setDefault($mj_home_Itemid, '*'); } } if ($current == $mj_home) { $MobileJoomla->setHome(true); } } if (count($current) == 0 || $current == $home) { $MobileJoomla->setHome(true); if ($homepage) { if (isset($mj_home_Itemid)) { global $Itemid; $Itemid = $mj_home_Itemid; $menu->setActive($Itemid); if (version_compare(JVERSION, '3.2', '>=')) { $menu->authorise($Itemid); } elseif (!$is_joomla15) { $app->authorise($Itemid); } else { $app->authorize($Itemid); } } $_SERVER['REQUEST_URI'] = JUri::base(true) . '/' . $homepage; if (isset($mj_home)) { $_SERVER['QUERY_STRING'] = substr($homepage, 10); foreach ($current as $key => $val) { unset($_REQUEST[$key]); unset($_GET[$key]); } JRequest::set($mj_home, 'get'); } else { $url = 'http'; $url .= isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : ''; $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $uri = new JUri($url); $router = $app->getRouter(); $result = $router->parse($uri); JRequest::set($result, 'get'); } } } }