Page 1 of 1
Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 8:35 pm
by straightlight
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
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 8:45 pm
by straightlight
Edited a slight change above.
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:03 pm
by straightlight
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;
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:05 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:06 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:07 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:10 pm
by straightlight
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);
}
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:14 pm
by straightlight
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);
}
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:19 pm
by straightlight
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)
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:20 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:22 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:24 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:25 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:27 pm
by straightlight
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'))) {
Re: Opencart v2.2.0.0 - site redirection issues
Posted: Sun Jul 10, 2016 9:29 pm
by straightlight
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);
}