Jump to content

[Resolved] Nav bar (categories) ssl problems


foz1234

Recommended Posts

for over 2 weeks now I've been having issues with my nav bar with the categories in.

i have a ssl certificate and we have to use a port in my case :8446

everything was working great then a few weeks ago i started noticing that when you click on the different categories i got ssl error it was putting the https in but not the port :8446 at the end hence giving the certificate error. the strange thing is not all the time. and every other page works correctly its only the nav bar giving me this trouble.

i have tried adding port a redirect on the site from http to https with the port that's made no difference again the error shows itself every now and then.

for weeks been trying different things off and on but its still coming back.

yesterday i removed all the https from the site and was running it http only this morning I've noticed the nav bar adding the https again and its not set to do so,

i must add since having this issue I've upgraded from 6.0.10 to 6.0.11 but made no difference

do you think this is an error with my shop or with the database?

any ideas where the nav bar is in the php? i can have a good friend look at it i am no good with php.

thanks for any help you can provide

 

 

 

 

Link to comment
Share on other sites

The Nav Bar is populated from a cached construction of a category tree. No other set of links do this.

The category tree uses fully-formed URLs determined at the time it is constructed. So, if the store is accessed with https:8443 and that is when the category tree is built, that will be the URL used and that will be the href value shown until the cache gets stale or deleted.

In admin, Maintenance, Rebuild tab, check the Clear Skin Cache and submit. Visit the store front using the desired URL method so that the category tree is rebuilt. Then check the links in the new category tree.

Link to comment
Share on other sites

Many thanks for your reply bsmither

i don't seem to have a clear skin cache tab

i have already ticked clear cache, clear SQL cache, clear language cache & clear image cache and submitted.

i assume in dashboard/settings/SSL the store url would have the port in like this eg http://www.aaabbbxxx.co.uk:8446/shop 

should the cookie domain have the port in as well .aaabbbxxx.co.uk or .aaabbbxxx.co.uk:8446 ?

 

 

Link to comment
Share on other sites

Confusingly, the "Store URL" field on the SSL tab is for the non-SSL variant of the web address. So, this field would have:

http://www.apache_example.com
http://www.tomcat_example.com:8080

I think the cookie does not use a port as part of its host value.

CubeCart detects SSL availability by examining what the web server tells PHP:

isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS'])!== 'off' 
&& ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == true) || $_SERVER['SERVER_PORT'] == 443

In CubeCart admin, PHP Info, scroll to the PHP Variables table and find the value of _SERVER["HTTPS"].

Therefore, I would say it is important that the web server recognizes port 8443 as a legitimate port for https traffic.

Link to comment
Share on other sites

20 hours ago, bsmither said:

Confusingly, the "Store URL" field on the SSL tab is for the non-SSL variant of the web address. So, this field would have:


http://www.apache_example.com
http://www.tomcat_example.com:8080

I think the cookie does not use a port as part of its host value.

CubeCart detects SSL availability by examining what the web server tells PHP:


isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS'])!== 'off' 
&& ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == true) || $_SERVER['SERVER_PORT'] == 443

In CubeCart admin, PHP Info, scroll to the PHP Variables table and find the value of _SERVER["HTTPS"].

Therefore, I would say it is important that the web server recognizes port 8443 as a legitimate port for https traffic.

i do have the store ssl set correctly,

the value of _SERVER["HTTPS"]. just says "ON" in my php variables ?

although the SERVER["SCRIPT_URI"],

 _SERVER["HTTP_HOST"],

_SERVER["SERVER_PORT"],

&  _SERVER "HTTP_REFERER"]  are all showing the port :8446

what php file holds this info? 

isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS'])!== 'off'
&& ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == true) || $_SERVER['SERVER_PORT'] == 443

thanks again

 

 

 

Link to comment
Share on other sites

You will find that PHP statement in the file /ini.inc.php.

A few statements after that, you will find statements that will use _SERVER['HTTP_HOST'] if there is a value for it. You say there is and that it has port 8443.

In my development system, let me configure my web server to accept port 8443 and I will test.

Link to comment
Share on other sites

  • 3 weeks later...

i am still suffering with this problem,

its only the nar bar, its not opening the pages with the port.

i have noticed as soon as i open the admin panel up in a different browser, not clicking on any tabs, the shop nav bar starts working again with the correct port :8446

I've edited the ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == true) || $_SERVER['SERVER_PORT'] == 8446 but still no joy.

Is there anything else i can do/try to fix this issue?

thanks

 

 

Link to comment
Share on other sites

Allow me to mention a possible solution: download the CC6012 package. You do not have to install it.

From this package, look at the contents of the file /classes/seo.class.php, near line 150:

	public function buildURL($type, $item_id = false, $amp = '&', $absolute = true) {
		// Some SEO paths are not stored in the database
		$url = ($absolute) ? $GLOBALS['storeURL'].'/' : $GLOBALS['rootRel'];

		if (!$item_id && in_array($type, $this->_static_sections)) {
			if (($item = $GLOBALS['db']->select('CubeCart_seo_urls', array('path'), array('type' => $type))) !== false) {
				return $url.$item[0]['path'].$this->_extension;
			} else {
				return  $url.$this->setdbPath($type, '', '', false).$this->_extension;
			}
		} elseif (($item = $GLOBALS['db']->select('CubeCart_seo_urls', array('path'), array('type' => $type, 'item_id' => $item_id))) !== false) {
			return $url.$item[0]['path'].$this->_extension;
		} else {
			return  $url.$this->setdbPath($type, $item_id, '', false).$this->_extension;
		}
	}

Compare this with the same function in the seo.class.php in your current installation.

The change in this file that CC6012 has fixed is to, when requested, remove that part of the URL that makes it absolute.

Then, in /classes/gui.class.php, near line 1469:

	private function _makeTree($tree_data) {

		if(!$GLOBALS['smarty']->templateExists('templates/element.navigation_tree.php')) return false;
		
		$out = '';
		if (is_array($tree_data)) {
			foreach ($tree_data as $branch) {
				if (isset($branch['children'])) {
					$branch['children'] = $this->_makeTree($branch['children']);
				}
				$branch['url'] = $GLOBALS['seo']->buildURL('cat', $branch['cat_id'], '&', false);
				$GLOBALS['smarty']->assign('BRANCH', $branch);
				foreach ($GLOBALS['hooks']->load('class.gui.display_navigation.make_tree') as $hook) include $hook;
				$out .= $GLOBALS['smarty']->fetch('templates/element.navigation_tree.php');
			}
		}
		return $out;
	}

Here, we see that the function to build the navigation tree is using that parameter to request the URL be stripped of the absolute part:

buildURL('cat', $branch['cat_id'], '&', false);

I would recommend that you at least edit these two existing files to incorporate this fix.

There may still be some URLs that are absolute. Perhaps the Login and Register URLs?

 

Link to comment
Share on other sites

Just to interject - after you add the files Bsmither has suggested - be sure to check the timestamps on your product listings for the Google Sitemap, if you use it. Mine were wrong, as well as the CubeCart demo store's sitemap.xml.gz. I had to remove these changes from seo.class.php.

Link to comment
Share on other sites

Would it be advisable to update anyway to 6012 if it incorporates the fix?

or would you advise edit the files first?

thanks again for your time guys for helping me with this matter.

just to add my timestamp in sitemap is 2016-06-11T11:47:11+00:00

%Y-%m-%dT%H:%M:%S+00:00 is this correct format?

 

Link to comment
Share on other sites

Upgrading is always a good idea, but maybe it would be better to just add the 6.0.12 edits Bsmither suggested first to see if it fixes your problem. Just be sure to check your timestamp results for products in your sitemap after you make the edits, as there may be a flaw in this code. I've reported an issue with it on GitHub.

Link to comment
Share on other sites

reporting back...

seems upgrading to 6.0.12 has fixed the previous problem with part of the nar bar, but has now created a new issue,

now for some very strange reason i have this problem with the sale items and home tabs in the nav bar not always putting the port in same as previous problem but now on different buttons.

it seems to be when the site has not been used for a while, it like goes stale, but again once i open up the admin.php the tabs in the shop nav bar start working again.

i have edited the ini.ini.php file to add the correct port.

if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])!== 'off' && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == true) || $_SERVER['SERVER_PORT'] == 8446) {

sorry to report back again with a problem, any ideas?

 

Link to comment
Share on other sites

There is a function in the file seo.class.php called buildURL(). This function was changed in CC6012 to allow for the capability of creating an absolute URL or a relative URL.

This was implemented so that the NAV bar ("Shop by Category") could have relative URLs. This then frees the browser to use whatever protocol (http vs https), domain name, and port that the page originally arrived under. The code that builds the Navigation Tree part (not including Home, Gift Certificates, nor Sale Items) makes use of this new capability to create relative URLs.

However, in the file gui.class.php, the function _displayNavigation(), which calls the code to build the Navigation Tree, does not, of itself, use this new capability to also create relative URLs. The URLs for Gift Certificates and Sale Items are still built and cached as absolute URLs.

Thus, when a page is requested using a protocol, domain, port different than what was cached, problems occur. Again, the change in CC6012 fixed most, but not all of this issue.

In the file gui.class.php, near line 1006:

Find:

			$url = array (
				'saleitems' => $GLOBALS['seo']->buildURL('saleitems'),
				'certificates' => $GLOBALS['seo']->buildURL('certificates')
			);

Change to:

			$url = array (
				'saleitems' => $GLOBALS['seo']->buildURL('saleitems',false,'&',false),
				'certificates' => $GLOBALS['seo']->buildURL('certificates',false,'&',false)
			);

So why does it sometimes seem to work itself out? Every time an admin makes a page request from the admin side of the store, CubeCart will dutifully clear out all files from the /cache/ folder (but not the /cache/skin/ folder). This is where the NAV Bar is cached. That means, the first page request of the storefront will recreate and cache the NAV Bar (respective to those items still using absolute URLs) using whatever protocol, domain, port was used for that request.

We still need to find a solution for the Homepage link in the NAV Bar.

Link to comment
Share on other sites

While the above is important, the code change only affects the template variable "URL", but not in this Foundation template that constructs the NAV Bar. ($URL is used in other Foundation templates in a discreet manner.)

We actually need to change the template and incorporate the "URL" variable. In the Foundation template box.navigation.php:

Find:
        {if $CTRL_CERTIFICATES && !$CATALOGUE_MODE}
        <li><a href="{$STORE_URL}/gift-certificates.html" title="{$LANG.navigation.giftcerts}">{$LANG.navigation.giftcerts}</a></li>
        {/if}
        {if $CTRL_SALE}
        <li><a href="{$STORE_URL}/sale-items.html" title="{$LANG.navigation.saleitems}">{$LANG.navigation.saleitems}</a></li>
        {/if}

Replace that with:
        {if $CTRL_CERTIFICATES && !$CATALOGUE_MODE}
        <li><a href="{$URL.certificates}" title="{$LANG.navigation.giftcerts}">{$LANG.navigation.giftcerts}</a></li>
        {/if}
        {if $CTRL_SALE}
        <li><a href="{$URL.saleitems}" title="{$LANG.navigation.saleitems}">{$LANG.navigation.saleitems}</a></li>
        {/if}

 

Link to comment
Share on other sites

thank you again bsmither, i have applied both amendments this morning all working great currently, will report back within the next couple of days any finds or fingers cross report the fix has worked 100%

again thank you for your time and effort in trying to resolving this issue.

regards

Link to comment
Share on other sites

In the template box.navigation.php:

Find:
<li class="show-for-medium-up"><a href="{$STORE_URL}" title="{$LANG.common.home}"><i class="fa fa-home"></i></a></li>

Change to:
<li class="show-for-medium-up"><a href="{$ROOT_PATH}" title="{$LANG.common.home}"><i class="fa fa-home"></i></a></li>

Reminding you that this template is used to create a finalized HTML snippet and is cached. Every time an Administrator requests a page from admin, the cache where this snippet lives is cleared out.

However, there is a compiled version of this template in the /cache/skin/ folder, and the template rendering engine will use it, if present, to make the finalized snippet. The admin-caused clearing of /cache/ does not affect /cache/skin/. So, be sure to manually clear the cache after making this edit.

 

Edited by bsmither
Clarifying what does and should get cleared and when.
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...