/** * Method to set SSL if needed * * @access private * * @param null * * @return null */ private function redirectSSL() { // Get system variables $uri = JURI::getInstance(); $enforce_ssl = $this->loadConfig('enforce_ssl'); $from_http_to_https = $this->getParam('enable_ssl_redirect', 1); $from_https_to_http = $this->getParam('enable_nonssl_redirect', 1); $post = $this->input->post->getArray(); // Match situation where we don't want to redirect if (!empty($post)) { return false; } else { if (in_array($this->input->getCmd('view'), array('ajax', 'jsonrpc'))) { return false; } else { if (in_array($this->input->getCmd('task'), array('ajax', 'json'))) { return false; } else { if (in_array($this->input->getCmd('controller'), array('ajax', 'jsonrpc'))) { return false; } } } } // Check the Menu-Item settings $menu = $this->app->getMenu(); $active = $menu->getActive(); if (!empty($active)) { $secureMenuItem = $active->params->get('secure', 0) == 1 ? true : false; } else { $secureMenuItem = false; } // Check if SSL should be forced if ($uri->isSSL() == false && $this->getParam('enable_ssl_redirect', 1) == 1) { // Determine whether to do a redirect $redirect = false; // Do not redirect if SSL is disabled if ($enforce_ssl == 0) { $redirect = false; // Set the redirect for the entire Joomla! site } else { if ($enforce_ssl == 1) { $redirect = true; // Set the redirect for MageBridge only } else { if ($enforce_ssl == 2) { // MageBridge links if ($this->input->getCmd('option') == 'com_magebridge') { // Prevent redirection when doing Single Sign On if ($this->input->getCmd('task') != 'login') { $redirect = true; } } else { if ($secureMenuItem == 1) { $redirect = true; } } } else { if ($enforce_ssl == 3) { if ($this->input->getCmd('option') == 'com_magebridge') { $redirect = MageBridgeUrlHelper::isSSLPage() ? true : false; } else { if ($secureMenuItem == 1) { $redirect = true; } } } } } } // Redirect to SSL if ($redirect == true) { $uri->setScheme('https'); $this->app->redirect($uri->toString()); $this->app->close(); } // Check if non-SSL should be forced } else { if ($uri->isSSL() == true && $this->getParam('enable_nonssl_redirect', 1) == 1) { // Determine whether to do a redirect $redirect = false; $components = array('com_magebridge', 'com_scriptmerge'); // Set the redirect if SSL is disabled if ($enforce_ssl == 0) { $redirect = true; // Do not redirect if SSL is set for the entire site } else { if ($enforce_ssl == 1) { $redirect = false; // Do redirect if SSL is set for the shop only } else { if ($enforce_ssl == 2) { if (!in_array($this->input->getCmd('option'), $components)) { $redirect = true; if ($secureMenuItem == 1) { $redirect = false; } } // Set the redirect if SSL is only enabled for MageBridge } else { if ($enforce_ssl == 3) { if ($this->input->getCmd('option') == 'com_magebridge') { $redirect = MageBridgeUrlHelper::isSSLPage() ? false : true; } else { $redirect = true; if ($secureMenuItem == 1) { $redirect = false; } } } } } } if ($redirect == true) { $uri->setScheme('http'); $this->app->redirect($uri->toString()); $this->app->close(); } } } }
/** * Method to set SSL if needed * * @access private * @param null * @return null */ private function redirectSSL() { // Get system variables $application = JFactory::getApplication(); $uri = JFactory::getURI(); $enforce_ssl = $this->loadConfig('enforce_ssl'); $from_http_to_https = $this->getParam('enable_ssl_redirect', 1); $from_https_to_http = $this->getParam('enable_nonssl_redirect', 1); $post = JRequest::get('post'); // Match situation where we don't want to redirect if (!empty($post)) { return false; } else { if (in_array(JRequest::getCmd('view'), array('ajax', 'jsonrpc'))) { return false; } else { if (in_array(JRequest::getCmd('controller'), array('ajax', 'jsonrpc'))) { return false; } } } // Check if SSL should be forced if ($uri->isSSL() == false && $this->getParam('enable_ssl_redirect', 1) == 1) { // Determine whether to do a redirect $redirect = false; // Do not redirect if SSL is disabled if ($enforce_ssl == 0) { $redirect = false; // Set the redirect for the entire Joomla! site } else { if ($enforce_ssl == 1) { $redirect = true; // Set the redirect for MageBridge only } else { if ($enforce_ssl == 2 && JRequest::getCmd('option') == 'com_magebridge') { // Prevent redirection when doing Single Sign On if (JRequest::getCmd('task') != 'login') { $redirect = true; } // Set the redirect for specific MageBridge pages which should be served through SSL } else { if ($enforce_ssl == 3 && JRequest::getCmd('option') == 'com_magebridge') { $redirect = MageBridgeUrlHelper::isSSLPage() ? true : false; } } } } // Redirect to SSL if ($redirect == true) { $uri->setScheme('https'); $application->redirect($uri->toString()); $application->close(); } // Check if non-SSL should be forced } else { if ($uri->isSSL() == true && $this->getParam('enable_nonssl_redirect', 1) == 1) { // Determine whether to do a redirect $redirect = false; $components = array('com_magebridge', 'com_scriptmerge'); // Set the redirect if SSL is disabled if ($enforce_ssl == 0) { $redirect = true; // Do not redirect if SSL is set for the entire site } else { if ($enforce_ssl == 1) { $redirect = false; // Do redirect if SSL is set for the shop only } else { if ($enforce_ssl == 2 && !in_array(JRequest::getCmd('option'), $components)) { $redirect = true; // Set the redirect if SSL is only enabled for MageBridge } else { if ($enforce_ssl == 3 && JRequest::getCmd('option') == 'com_magebridge') { $redirect = MageBridgeUrlHelper::isSSLPage() ? false : true; } } } } if ($redirect == true) { $uri->setScheme('http'); $application->redirect($uri->toString()); $application->close(); } } } }