If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

[Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

Started by lat9 on 21 Apr 2013, 1:54 PM · Views: 2,200

Results 1 to 8 of 8
21 Apr 2013, 1:54 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

[Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

Zen Cart v1.5.1. My admin is set up to use SSL everywhere, so HTTP_SERVER and HTTPS_SERVER are identical in the admin's /includes/configure.php file. In addition, I'm using the shared SSL provided by my host for this shop.

When I send an order update from admin (Customers->Orders) to a customer who's signed up for HTML emails, the link to the header image is broken. That's because the zen_build_html_email_from_template function is currently setting the BASE_HREF for the email to HTTP_SERVER ... which points to my host's shared SSL server. The change required to correct is shown below.

Here's the code fragment from /includes/functions/functions_email.php (starting at line 454), the change is highlighted in red:

    if (!defined('HTTP_CATALOG_SERVER')) define('HTTP_CATALOG_SERVER', HTTP_SERVER);
    //check for some specifics that need to be included with all messages
    if (!isset($block['EMAIL_STORE_NAME']) || $block['EMAIL_STORE_NAME'] == '')     $block['EMAIL_STORE_NAME']  = STORE_NAME;
    if (!isset($block['EMAIL_STORE_URL']) || $block['EMAIL_STORE_URL'] == '')       $block['EMAIL_STORE_URL']   = '<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>';
    if (!isset($block['EMAIL_STORE_OWNER']) || $block['EMAIL_STORE_OWNER'] == '')   $block['EMAIL_STORE_OWNER'] = STORE_OWNER;
    if (!isset($block['EMAIL_FOOTER_COPYRIGHT']) || $block['EMAIL_FOOTER_COPYRIGHT'] == '') $block['EMAIL_FOOTER_COPYRIGHT'] = EMAIL_FOOTER_COPYRIGHT;
    if (!isset($block['EMAIL_DISCLAIMER']) || $block['EMAIL_DISCLAIMER'] == '')     $block['EMAIL_DISCLAIMER']  = sprintf(EMAIL_DISCLAIMER, '<a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">'. STORE_OWNER_EMAIL_ADDRESS .' </a>');
    if (!isset($block['EMAIL_SPAM_DISCLAIMER']) || $block['EMAIL_SPAM_DISCLAIMER'] == '')   $block['EMAIL_SPAM_DISCLAIMER']  = EMAIL_SPAM_DISCLAIMER;
    if (!isset($block['EMAIL_DATE_SHORT']) || $block['EMAIL_DATE_SHORT'] == '')     $block['EMAIL_DATE_SHORT']  = zen_date_short(date("Y-m-d"));
    if (!isset($block['EMAIL_DATE_LONG']) || $block['EMAIL_DATE_LONG'] == '')       $block['EMAIL_DATE_LONG']   = zen_date_long(date("Y-m-d"));
    if (!isset($block['BASE_HREF']) || $block['BASE_HREF'] == '') $block['BASE_HREF'] = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; /*lat9-c*/
    if (!isset($block['CHARSET']) || $block['CHARSET'] == '') $block['CHARSET'] = CHARSET;
23 Apr 2013, 4:42 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

What happens if in your configure.php you use the settings:

  define('HTTP_SERVER', 'https://www.your_domain.com');
  define('HTTPS_SERVER', 'https://www.your_domain.com');
[B]  define('HTTP_CATALOG_SERVER', 'http://www.your_domain.com');
[/B]  define('HTTPS_CATALOG_SERVER', 'https://www.your_domain.com');

  // secure webserver for admin?  Valid choices are 'true' or 'false' (including quotes).
  define('ENABLE_SSL_ADMIN', 'true');

  // secure webserver for storefront?  Valid choices are 'true' or 'false' (including quotes).
[B]  define('ENABLE_SSL_CATALOG', 'false');
[/B]

we will look into this further ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

23 Apr 2013, 8:44 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

Ajeh, I've already got HTTP_CATALOG_SERVER set like you indicated; changing ENABLE_SSL_CATALOG to false made no difference. I'm hosted by 1and1 (I know ...), so my MY_ADMIN/includes/configure.php file looked like:

  define('HTTP_SERVER', 'https://ssl.perfora.net');
  define('HTTPS_SERVER', 'https://ssl.perfora.net');
  define('HTTP_CATALOG_SERVER', 'http://www.your_domain.com');
  define('HTTPS_CATALOG_SERVER', 'https://ssl.perfora.net/your_domain.com');

  // secure webserver for admin?  Valid choices are 'true' or 'false' (including quotes).
  define('ENABLE_SSL_ADMIN', 'true');

  // secure webserver for storefront?  Valid choices are 'true' or 'false' (including quotes).
  define('ENABLE_SSL_CATALOG', 'true');

I changed that to

  define('HTTP_SERVER', 'https://ssl.perfora.net/your_domain.com');
  define('HTTPS_SERVER', 'https://ssl.perfora.net.your_domain.com');
  define('HTTP_CATALOG_SERVER', 'http://www.your_domain.com');
  define('HTTPS_CATALOG_SERVER', 'https://ssl.perfora.net/your_domain.com');

  // secure webserver for admin?  Valid choices are 'true' or 'false' (including quotes).
  define('ENABLE_SSL_ADMIN', 'true');

  // secure webserver for storefront?  Valid choices are 'true' or 'false' (including quotes).
  define('ENABLE_SSL_CATALOG', 'true');

and the links "unbroke", but the BASE_HREF in the emails is still pointing to https://ssl.perfora.net/your_domain.com instead of http://www.your_domain.com.

23 Apr 2013, 9:31 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

Don't forget to change this one too:

define('ENABLE_SSL_CATALOG', '[B]false[/B]');

but again, we will look into this further ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

23 Apr 2013, 9:44 PM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

Ajeh:

Don't forget to change this one too:

define('ENABLE_SSL_CATALOG', '[B]false[/B]');

> 
> but again, we will look into this further ...
OK, but if my catalog is using SSL why would I set this to false in admin?
24 Apr 2013, 6:35 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

These 1and1 sites using ssl.perfora.net and their odd shared SSL configuration are a real pain!

Be careful with this change because there's not HTTP_CATALOG_SERVER define on the catalog side, and so you might end up causing yourself undefined-constant errors by using this:```
$block['BASE_HREF'] = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;


The URLs on the storefront are built from HTTP_SERVER . DIR_WS_CATALOG or for SSL, from HTTPS_SERVER . DIR_WS_HTTPS_CATALOG.
So on your admin side, your HTTP_CATALOG_SERVER needs to match your catalog HTTP_SERVER and your DIR_WS_CATALOG needs to match catalog's DIR_WS_CATALOG.
Similarly the admin HTTPS_CATALOG_SERVER needs to match catalog HTTPS_SERVER and DIR_WS_HTTPS_CATALOG needs to match DIR_WS_HTTPS_CATALOG


For troubleshooting the cause of the problem, look at the email's raw HTML source to see what base-href and img src are being generated, and backtrack from there. (Evidently you've done this already else you wouldn't have posted the details you have, but I'm mentioning this for the benefit of future readers who don't know how you arrived to the point of posting what you did.)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Apr 2013, 2:19 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

DrByte:

These 1and1 sites using ssl.perfora.net and their odd shared SSL configuration are a real pain!
Agreed!

DrByte:

Be careful with this change because there's not HTTP_CATALOG_SERVER define on the catalog side, and so you might end up causing yourself undefined-constant errors by using this:```
$block['BASE_HREF'] = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;

The base code in /includes/functions/functions_email already has that covered:
if (!defined('HTTP_CATALOG_SERVER')) define('HTTP_CATALOG_SERVER', HTTP_SERVER);
//check for some specifics that need to be included with all messages
if (!isset($block['EMAIL_STORE_NAME']) || $block['EMAIL_STORE_NAME'] == '')     $block['EMAIL_STORE_NAME']  = STORE_NAME;
if (!isset($block['EMAIL_STORE_URL']) || $block['EMAIL_STORE_URL'] == '')       $block['EMAIL_STORE_URL']   = '<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>';
if (!isset($block['EMAIL_STORE_OWNER']) || $block['EMAIL_STORE_OWNER'] == '')   $block['EMAIL_STORE_OWNER'] = STORE_OWNER;
if (!isset($block['EMAIL_FOOTER_COPYRIGHT']) || $block['EMAIL_FOOTER_COPYRIGHT'] == '') $block['EMAIL_FOOTER_COPYRIGHT'] = EMAIL_FOOTER_COPYRIGHT;
if (!isset($block['EMAIL_DISCLAIMER']) || $block['EMAIL_DISCLAIMER'] == '')     $block['EMAIL_DISCLAIMER']  = sprintf(EMAIL_DISCLAIMER, '<a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">'. STORE_OWNER_EMAIL_ADDRESS .' </a>');
if (!isset($block['EMAIL_SPAM_DISCLAIMER']) || $block['EMAIL_SPAM_DISCLAIMER'] == '')   $block['EMAIL_SPAM_DISCLAIMER']  = EMAIL_SPAM_DISCLAIMER;
if (!isset($block['EMAIL_DATE_SHORT']) || $block['EMAIL_DATE_SHORT'] == '')     $block['EMAIL_DATE_SHORT']  = zen_date_short(date("Y-m-d"));
if (!isset($block['EMAIL_DATE_LONG']) || $block['EMAIL_DATE_LONG'] == '')       $block['EMAIL_DATE_LONG']   = zen_date_long(date("Y-m-d"));
if (!isset($block['BASE_HREF']) || $block['BASE_HREF'] == '') $block['BASE_HREF'] = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; /*lat9-c*/
if (!isset($block['CHARSET']) || $block['CHARSET'] == '') $block['CHARSET'] = CHARSET;

> **DrByte:**
>
> The URLs on the storefront are built from HTTP_SERVER . DIR_WS_CATALOG or for SSL, from HTTPS_SERVER . DIR_WS_HTTPS_CATALOG.
> So on your admin side, your HTTP_CATALOG_SERVER needs to match your catalog HTTP_SERVER and your DIR_WS_CATALOG needs to match catalog's DIR_WS_CATALOG.
> Similarly the admin HTTPS_CATALOG_SERVER needs to match catalog HTTPS_SERVER and DIR_WS_HTTPS_CATALOG needs to match DIR_WS_HTTPS_CATALOG
Yep, got that.  The issue, I believe, is that I'm running my admin in full SSL mode (HTTP_SERVER == HTTPS_SERVER), so that the BASE_HREF for emails is always pointing the https site rather than the http site.
28 Jul 2013, 2:18 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: [Done v1.6.0] Incorrect base_href in admin-sent HTML emails in some configurations

lat9:

Zen Cart v1.5.1. My admin is set up to use SSL everywhere, so HTTP_SERVER and HTTPS_SERVER are identical in the admin's /includes/configure.php file. In addition, I'm using the shared SSL provided by my host for this shop.

When I send an order update from admin (Customers->Orders) to a customer who's signed up for HTML emails, the link to the header image is broken. That's because the zen_build_html_email_from_template function is currently setting the BASE_HREF for the email to HTTP_SERVER ... which points to my host's shared SSL server. The change required to correct is shown below.

Here's the code fragment from /includes/functions/functions_email.php (starting at line 454), the change is highlighted in red:

if (!defined('HTTP_CATALOG_SERVER')) define('HTTP_CATALOG_SERVER', HTTP_SERVER);
//check for some specifics that need to be included with all messages
if (!isset($block['EMAIL_STORE_NAME']) || $block['EMAIL_STORE_NAME'] == '')     $block['EMAIL_STORE_NAME']  = STORE_NAME;
if (!isset($block['EMAIL_STORE_URL']) || $block['EMAIL_STORE_URL'] == '')       $block['EMAIL_STORE_URL']   = '<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>';
if (!isset($block['EMAIL_STORE_OWNER']) || $block['EMAIL_STORE_OWNER'] == '')   $block['EMAIL_STORE_OWNER'] = STORE_OWNER;
if (!isset($block['EMAIL_FOOTER_COPYRIGHT']) || $block['EMAIL_FOOTER_COPYRIGHT'] == '') $block['EMAIL_FOOTER_COPYRIGHT'] = EMAIL_FOOTER_COPYRIGHT;
if (!isset($block['EMAIL_DISCLAIMER']) || $block['EMAIL_DISCLAIMER'] == '')     $block['EMAIL_DISCLAIMER']  = sprintf(EMAIL_DISCLAIMER, '<a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">'. STORE_OWNER_EMAIL_ADDRESS .' </a>');
if (!isset($block['EMAIL_SPAM_DISCLAIMER']) || $block['EMAIL_SPAM_DISCLAIMER'] == '')   $block['EMAIL_SPAM_DISCLAIMER']  = EMAIL_SPAM_DISCLAIMER;
if (!isset($block['EMAIL_DATE_SHORT']) || $block['EMAIL_DATE_SHORT'] == '')     $block['EMAIL_DATE_SHORT']  = zen_date_short(date("Y-m-d"));
if (!isset($block['EMAIL_DATE_LONG']) || $block['EMAIL_DATE_LONG'] == '')       $block['EMAIL_DATE_LONG']   = zen_date_long(date("Y-m-d"));
if (!isset($block['BASE_HREF']) || $block['BASE_HREF'] == '') $block['BASE_HREF'] = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; /*lat9-c*/
if (!isset($block['CHARSET']) || $block['CHARSET'] == '') $block['CHARSET'] = CHARSET;
Will incorporate into 1.6.0:
<https://github.com/zencart/zencart/commit/d0d135df0db19d8eeb15203b2b8d8ca916b3e1f9>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.