pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 10/16/2017 : 07:44:45
Hi, a few months ago we created around 20 new information pages such as https://www.cloghog.com/tips/unclog-a-septic-leach-field.php. To keep these similar files organized we placed them in a /tips sub folder instead of the root directory.
This weekend, before migrating the entire site to HTTPS, we noticed our web error log had numerous warnings triggered by these pages.
After the change to HTTPS, we tried changing the headers on these pages to absolute paths like:
<?php session_cache_limiter('none'); session_start(); ob_start(); include "https://www.cloghog.com/vsadmin/db_conn_open.php"; include "https://www.cloghog.com/vsadmin/inc/languagefile.php"; include "https://www.cloghog.com/vsadmin/includes.php"; include "https://www.cloghog.com/vsadmin/inc/incfunctions.php"; ?>
Since updating these paths and switching the site to HTTPS, we now get error log messages like the following:
PHP message: PHP Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/vhosts/cloghog.com/httpdocs/tips/unclog-paper-and-napkins.php on line 5\n
PHP message: PHP Warning: include(https://www.cloghog.com/vsadmin/db_conn_open.php): failed to open stream: no suitable wrapper could be found in /var/www/vhosts/cloghog.com/httpdocs/tips/unclog-paper-and-napkins.php on line 5\n
PHP message: PHP Warning: include(): Failed opening 'https://www.cloghog.com/vsadmin/db_conn_open.php' for inclusion (include_path='.:/opt/plesk/php/5.6/share/pear') in /var/www/vhosts/cloghog.com/httpdocs/tips/unclog-paper-and-napkins.php on line 5\n
Can anyone suggest some steps to help troubleshoot and resolve this? Thanks in advance.
- Paul D.
|
Andy
ECT Moderator
95440 Posts |
Posted - 10/16/2017 : 08:23:14
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 10/16/2017 : 10:41:50
Thanks, Andy.
We deleted those lines as suggested.
- Paul D.
|
ITZAP
Ecommerce Template Guru
Australia
1018 Posts |
Posted - 10/16/2017 : 17:47:18
Hi Andy, If those article pages located in a subfolder had a Dynamic Category Menu, then it does become necessary to load the ECT Database and Content Management System files. So it is an interesting question as to what PHP "include" code will accomplish this, if custom URL webpages are placed in \multiple\subfolders\ for whatever SEO purpose, especially since we cannot use $_SERVER['DOCUMENT_ROOT'] in PHP 7 Could you kindly ask Vince about this please ? Gary 
|
insight
ECT Moderator
USA
4479 Posts |
Posted - 10/16/2017 : 19:35:14
Having allow_url_include disabled isn't stopping you doing anything in your example though, if you want to use $_SERVER['DOCUMENT_ROOT'] in PHP7.x you can and that's fine, it works just as you'd expect. It's just the way that Paul tried to do his includes with full URLs that is bad practice; allowing url_include is just a bad, bad vulnerability and everybody ought to have it turned off (as we do, obviously  ). Peter ServeLink Professional ecommerce web hosting for ASP & PHP https://servelink.comTake a look at our image upload/resize tool for the ASP cart https://servelink.com/clients/cart?gid=7
|
ITZAP
Ecommerce Template Guru
Australia
1018 Posts |
Posted - 10/16/2017 : 20:46:07
Thanks for your reply Peter and I understand what you say. I fess up, it was me who gave Paul the wrong advice about how to go about it.  So now I have been trying PHP code variations to get those ECT system files loaded from subfolders. And this works ...<?php session_cache_limiter('none'); session_start(); ob_start(); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/db_conn_open.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefile.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/includes.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/incfunctions.php') ?>I got that code from this website here. BUT the article does go on to say ... quote: As useful as $_SERVER[‘DOCUMENT_ROOT’] is, it has a drawback. It might not work in some servers.
So if anybody knows a better way, please do add a comment here. Gary 
Edited by - ITZAP on 10/16/2017 20:48:40
|
insight
ECT Moderator
USA
4479 Posts |
Posted - 10/16/2017 : 21:23:36
quote: As useful as $_SERVER[‘DOCUMENT_ROOT’] is, it has a drawback. It might not work in some servers.
I wouldn't start worrying about that until you find a server where it isn't available. Although there is a possibility of it not being available, I reckon you'll find it pretty much always present (unless you're at G*Da**y, in which case just ask yourself, "why?") and it makes sense to me to use elements of the $_SERVER array that's already there, rather than whip up some more complex solution that likely isn't needed. Peter ServeLink Professional ecommerce web hosting for ASP & PHP https://servelink.comTake a look at our image upload/resize tool for the ASP cart https://servelink.com/clients/cart?gid=7
|
dbdave
ECT Moderator
USA
10468 Posts |
Posted - 10/16/2017 : 21:27:06
You can always toss a stripped down copy of the vsadmin folder in the subfolder, but if it's excessive, you can bloat your data I guess and updating is a bit more work. Not a good solution to some I'm sure, but it should work. Personally, I learned some time back, keep it all in the root.  David ECT Power User 
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 10/17/2017 : 05:32:53
Thanks for all of the expert help! The lesson learned definitely seems to be "keep it all in the root".
These ~20 pages in our /tips folder have been critical for bringing traffic, getting top "position 0" on a lot of Google searches.
So if we were to copy those ~20 pages to the root, rename them to append the same new leading text like "tips-..." to keep them organized, and add 301 redirects from the old pages to the new in .htaccess, am I right that we can anticipate a big, bad SEO penalty?
I ask because we'll likely eventually need to run database content on those pages, and it seems smart to fix this once and for all.
- Paul
|
ITZAP
Ecommerce Template Guru
Australia
1018 Posts |
Posted - 10/17/2017 : 05:50:03
Paul, if you just Copy / Paste the PHP code I posted above into the very top of each of those 20 pages in your /tips folder, the ECT system files will load fine and you will not need to change or redirect anything. Gary 
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 01/14/2018 : 09:00:20
Guys, that new code suggested by Gary seems to eliminate most of the errors, but the server log still shows errors like these that involve <languagefile.php> and <languagefile_en.php> :
[Sun Jan 14 08:54:04.274066 2018] [proxy_fcgi:error] [pid 169122] [client xx.xxx.xxx.xxx:59740] AH01071: Got error 'PHP message: PHP Warning: include(./vsadmin/inc/languagefile_en.php): failed to open stream: No such file or directory in /var/www/vhosts/cloghog.com/httpdocs/vsadmin/inc/languagefile.php on line 30\nPHP message: PHP Warning: include(): Failed opening './vsadmin/inc/languagefile_en.php' for inclusion (include_path='.:/opt/plesk/php/7.2/share/pear') in /var/www/vhosts/cloghog.com/httpdocs/vsadmin/inc/languagefile.php on line 30\n', referer: https://www.cloghog.com/tips/unclog-a-roof-vent.php
Can anyone suggest a fix? Note that the new code that produces these errors is:
<?php session_cache_limiter('none'); session_start(); ob_start(); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/db_conn_open.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefile.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/includes.php'); include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/incfunctions.php') ?> <!--Preceding is SPECIAL ECT subfolder includes code-->
Thanks in advance for any further suggestions.
- Paul D.

|
Andy
ECT Moderator
95440 Posts |
Posted - 01/14/2018 : 09:13:35
Can you change this line include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefile.php'); To include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefil_en.php'); And see if that helps. Andy Please feel free to review / rate our software
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 01/14/2018 : 09:20:48
Andy, thanks for this. Changing that line to:
include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefil_en.php');
Produces the following log file error:
[Sun Jan 14 09:18:08.838813 2018] [proxy_fcgi:error] [pid 180415] [client xx.xx.xxx.xxx:56306] AH01071: Got error 'PHP message: PHP Warning: include(/var/www/vhosts/cloghog.com/httpdocs/vsadmin/inc/languagefil_en.php): failed to open stream: No such file or directory in /var/www/vhosts/cloghog.com/httpdocs/tips/unclog-yard-debris-and-dirt.php on line 6\nPHP message: PHP Warning: include(): Failed opening '/var/www/vhosts/cloghog.com/httpdocs/vsadmin/inc/languagefil_en.php' for inclusion (include_path='.:/opt/plesk/php/7.2/share/pear') in /var/www/vhosts/cloghog.com/httpdocs/tips/unclog-yard-debris-and-dirt.php on line 6\n', referer: https://www.cloghog.com/drain-cleaning-tips.php
- Paul D.
|
Andy
ECT Moderator
95440 Posts |
Posted - 01/14/2018 : 09:30:26
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 01/14/2018 : 09:58:05
Andy, thanks for this. That corrected line seems to eliminate the log file error on the page tested.
include ( $_SERVER['DOCUMENT_ROOT'] . '/vsadmin/inc/languagefile_en.php');
- Am I right that it's OK to now apply this change to all ~25 pages in the subfolder?
[In other words, this is the solution and not a temporary diagnostic step, right?]
Again, this is much appreciated.
|
Andy
ECT Moderator
95440 Posts |
Posted - 01/14/2018 : 10:01:58
|
pauld
Ecommerce Template Expert
USA
500 Posts |
Posted - 01/14/2018 : 10:04:16
Thanks so much for this, Andy.
Much appreciated!
|
|
|