Page 1 of 1

CGSmartImage with https source

Posted: Thu Jan 05, 2017 10:29 am
by rotezecke
I also experience periodic failures that can be 'fixed' by clearing cache but re-appear in a few days. One of the problems is that CGSmartImage does not embed images anymore, but prints the image tag - which still works but results in insecure content warnings on secure pages. I thought I can work around that problem by using an absolute instead of a relative path:

Code: Select all

 {* top of base template *}
{$ssl_url = {ssl_url} scope=global}
...
{* somewhere in body tag*}
{$ssl_url} {* just to see if variable is in scope - and it is *}

{* forcing noembed for testing *}
{CGSmartImage src1=$ssl_url src2="uploads/images/logos/xxx_text_logo_grey500px_tiny.png" noembed=1 notag=1 assign=textlogosrc}

{cms_selflink  page="home" id="textLogo" imageonly=1 text="$sitename" alt="xxx Text Logo" image="{$textlogosrc}"}
I also tested src1 with hard coded https URL as well as just a single src tag, but the result is always the same, the assigned textlogosrc is "http://xxx..."

of course it would be better to find out why the page breaks in the first place, but I've been watching the error logs for months now, and cannot see a pattern. There are other errors as well, but I manged to work around those by modifying my templates.



----------------------------------------------

Cms Version: 2.1.5

Installed Modules:

CGBlog: 1.14.1
CGExtensions: 1.53.13
CGFeedback: 1.8
CGSimpleSmarty: 2.1.4
CGSmartImage: 1.21.5
CMSContentManager: 1.1.1
CMSMailer: 6.2.14
Captcha: 0.5.3
DesignManager: 1.1.1
FileManager: 1.5.2
FormBuilder: 0.8.1.4
JQueryTools: 1.3.9
ModuleManager: 2.0.4
Navigator: 1.0.3
News: 2.50.5
Search: 1.50.2


Config Information:

php_memory_limit:
max_upload_size: 16000000
url_rewriting: mod_rewrite
page_extension: .html
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: Australia/Brisbane
permissive_smarty: false


Php Information:

phpversion: 7.0.13
md5_function: On (True)
json_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_ALL: 32759
E_STRICT: 2048
E_DEPRECATED: 8192
test_file_timedifference: No time difference found
test_db_timedifference: No time difference found
create_dir_and_file: 1
memory_limit: 256M
max_execution_time: 30
register_globals: Off (False)
output_buffering: 4096
disable_functions:
open_basedir:
test_remote_url: Success
file_uploads: On (True)
post_max_size: 16M
upload_max_filesize: 16M
session_save_path: /tmp (0700)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)
check_ini_set: On (True)
curl: On


Performance Information:

allow_browser_cache: Off (False)
browser_cache_expiry: 0
php_opcache: Off (False)
smarty_cache: Off (False)
smarty_compilecheck: Off (False)
smarty_cache_udt: Off (False)
auto_clear_cache_age: On (True)

Server Information:

Server Software: Apache
Server Api: cgi-fcgi
Server Os: Linux 2.6.32-673.8.1.lve1.4.3.el6.x86_64 On x86_64
Server Db Type: MySQL (mysqli)
Server Db Version: 10.0.25
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable


Permission Information:

tmp: /home/xxx/public_html/tmp (0755)
tmp_cache: /home/xxx/public_html/tmp/cache (0755)
templates_c: /home/xxx/public_html/tmp/templates_c (0755)
modules: /home/xxx/public_html/modules (0755)
uploads: /home/xxx/public_html/uploads (0755)
File Creation Mask (umask): /home/rxxx/public_html/tmp/cache (0755)
config_file: 0444

----------------------------------------------

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 2:51 pm
by velden
Try (untested) to get rid of the mixed content warning as a work-around:

Code: Select all

{$textlogosrc|regex_replace:'/^https?:/':''}

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 4:27 pm
by calguy1000
So I am thinking that your root url is in http but 'some' content pages are in https?

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 4:55 pm
by rotezecke
:) Thanks
that's a workaround for the workaround.

Code: Select all

{$textlogosrc = $textlogosrc|replace:{root_url}:{$ssl_url}}
does the trick. (couldnt get regex to work)
I since realised that CGSmartImage converts every absolute path into the root url

Code: Select all

$dest_url = $config['root_url'].$_src;
(from cgsi_utils class).
Sigh.

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 5:13 pm
by rotezecke
@calguy
yes, root_url is http and some of my pages are not. this has worked fine for years. i use relative paths for all my src paths for CGSI, but as stated, this now periodically breaks (I think since 2.x upgrade), and then CGSI prints normal image tags, instead of embedding. As far as CMSMS is concerned, the page request is NOT https (as my secure pages are initiated via different CMS - i use CMSMS Shop Skin Maker plugin) hence CGSI probably actually behaves correctly in its fall back. However, in the example above, I tried to force a https URL on a plain CMSMS page, and that failed, too.
Is there a way to force CGSI to output an absolute https URL?

here's the site, but its currently working fine: "https://secure.rpc.com.au/catalog/login.php"

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 6:18 pm
by calguy1000
I think the best solution to this would probably be to use a protocol relative URL as your root url.

i.e.: $config['root_url'] = '//www.mysite.com/';

Re: CGSmartImage with https source

Posted: Thu Jan 05, 2017 7:57 pm
by rotezecke
unfortunately, my root_url domain and ssl_url domain are not the same:
"http://www.site.com" and
"https://secure.site.com"
which I cannot change for a few years (it is on the todo list though). It's not a huge drama as I usually clear cache a couple of times a week.