Post by straightlight » Sun Jul 10, 2016 8:35 pm

I have developed an alternate solution for SSL versus non-SSL site redirection issues by using the $this->config->get('config_url') versus the $this->config->get('config_ssl') objects which the $this->response->redirect method from this object does not seem to be conformed with.

It would be great if people could test the new methodology and report the results on their end. On my end, I do not seem to have any issues using the URLs, so far.

In system/library/url.php file, replace the entire: url method code block with this:

Code: Select all

public function link($route, $args = '', $secure = false) {
                static $url = '';

		if ($this->ssl && $secure && preg_match_all('#\b(https?)://([^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s])|/))#', HTTPS_SERVER, $url_match) && isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
			if (strlen(trim(html_entity_decode($url_match[1][0], ENT_QUOTES, 'UTF-8'))) == 4) {
				// Force SSL protocol to match the PCI-Compliance policy.
				$url_match[1][0] = 'https';
			}
			
			$url = html_entity_decode($url_match[1][0] . '://' . $url_match[2][0], ENT_QUOTES, 'UTF-8') . 'index.php?route=' . $route;
			
		} elseif ((!$this->ssl || !$secure) && preg_match_all('#\b(https?)://([^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s])|/))#', HTTP_SERVER, $url_match)) {
			if (strlen(trim(html_entity_decode($url_match[1][0], ENT_QUOTES, 'UTF-8'))) != 4) {
				$url_match[1][0] = 'http';
			}
			
			$url = html_entity_decode($url_match[1][0] . '://' . $url_match[2][0], ENT_QUOTES, 'UTF-8') . 'index.php?route=' . $route;
		}
		
		if ($args) {
			if (is_array($args)) {
				$url .= '&' . http_build_query($args);
			} else {
				$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
			}
		}

		foreach ($this->rewrite as $rewrite) {
			$url = $rewrite->rewrite($url);
		}

		return $url;
	}
Also ensure to follow this step: http://forum.opencart.com/viewtopic.php ... 40#p628048
Last edited by straightlight on Sun Jul 10, 2016 10:03 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 8:45 pm

Edited a slight change above.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:03 pm

In admin/controller/sale/order.php file,

find all instances of:

Code: Select all

$data['store_url'] = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG;
replace each with:

Code: Select all

$data['store_url'] = isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1')) ? HTTPS_CATALOG : HTTP_CATALOG;

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:05 pm

In admin/controller/common/filemanager.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:06 pm

In admin/controller/setting/setting.php file,

find all instances of:

Code: Select all

if ($this->request->server['HTTPS']) {
replace each with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
Last edited by straightlight on Sun Jul 10, 2016 9:11 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:07 pm

In admin/model/tool/image.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:10 pm

In catalog/controller/common/currency.php file,

find:

Code: Select all

$data['action'] = $this->url->link('common/currency/currency', '', $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$data['action'] = $this->url->link('common/currency/currency', '', true);
			
		} else {
			$data['action'] = $this->url->link('common/currency/currency');
		}
Then, find:

Code: Select all

$data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
				$data['redirect'] = $this->url->link($route, $url, true);
				
			} else {
				$data['redirect'] = $this->url->link($route, $url, false);
			}
Last edited by straightlight on Sun Jul 10, 2016 9:32 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:14 pm

In catalog/controller/common/language.php file,

find:

Code: Select all

$data['action'] = $this->url->link('common/language/language', '', $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$data['action'] = $this->url->link('common/language/language', '', true);
			
		} else {
			$data['action'] = $this->url->link('common/language/language');
		}
Then, find:

Code: Select all

$data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
				$data['redirect'] = $this->url->link($route, $url, true);
				
			} else {
				$data['redirect'] = $this->url->link($route, $url, false);
			}
Last edited by straightlight on Sun Jul 10, 2016 9:32 pm, edited 1 time in total.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:19 pm

In catalog/controller/error/not_found.php file,

find:

Code: Select all

'href' => $this->url->link($route, $url, $this->request->server['HTTPS'])
replace with:

Code: Select all

'href' => $this->url->link($route, $url, isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1')) ? true : false)

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:20 pm

In catalog/controller/module/amazon_login.php file,

find:

Code: Select all

if ($this->config->get('amazon_login_pay_status') && $this->config->get('amazon_login_status') && !$this->customer->isLogged() && !empty($this->request->server['HTTPS'])) {
replace with:

Code: Select all

if ($this->config->get('amazon_login_pay_status') && $this->config->get('amazon_login_status') && !$this->customer->isLogged() && isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:22 pm

In catalog/controller/module/google_hangouts.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:24 pm

In catalog/controller/payment/paypoint.php file,

find:

Code: Select all

if (!$this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:25 pm

In catalog/controller/startup/startup.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:27 pm

In catalog/model/tool/image.php file,

find:

Code: Select all

if ($this->request->server['HTTPS']) {
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sun Jul 10, 2016 9:29 pm

In catalog/controller/common/column_left.php file,

find:

Code: Select all

$data['action'] = $this->url->link('common/column_left/language', '', $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$data['action'] = $this->url->link('common/column_left/language', '', true);
			
		} else {
			$data['action'] = $this->url->link('common/column_left/language');
		}
Then, find:

Code: Select all

$data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']);
replace with:

Code: Select all

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
				$data['redirect'] = $this->url->link($route, $url, true);
				
			} else {
				$data['redirect'] = $this->url->link($route, $url, false);
			}

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 9 guests