Using an include in the website Membership Plugin
7 posts by 2 authors in: Forums > CMS Builder
Last Post: July 4, 2020 (RSS)
By gkornbluth - July 1, 2020
Hi All,
I'm trying to set an alternate post login path for mobile devices and inserted this code in the Website Membership Plugin 1.13
$post_login = 'http://pollick.net/OK/index.php' ;
require_once 'http://pollick.net/Mobile_Detect.php';
$detect = new Mobile_Detect;
// Check for mobile environment.
if($detect->isMobile()){
$post_login = 'http://pollick.net/OK/m/welcome.php';
}
$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'] = $post_login ;
Unfortunately require once (and include) seem to throw the following error:
Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php on line 19 Warning: require_once(http://pollick.net/Mobile_Detect.php): failed to open stream: no suitable wrapper could be found in /home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php on line 19 Fatal error: require_once(): Failed opening required 'http://pollick.net/Mobile_Detect.php' (include_path='/home2/ngpymrmy/public_html/pollick/cmsAdmin:/home2/ngpymrmy/public_html/pollick/cmsAdmin/3rdParty:.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php on line 19
Any thoughts to a fix or an alternate approach?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By daniel - July 1, 2020
Hi Jerry,
Is there a specific reason you're using the full URL to the file, or could you try an absolute/relative path? For example, something like this should work in most installations to target a file in the web root:
require_once SCRIPT_DIR . '../Mobile_Detect.php';
(SCRIPT_DIR typically targets the CMSB folder)
Let me know if that does the trick, or if you have any other questions.
Thanks!
Technical Lead
interactivetools.com
By gkornbluth - July 1, 2020
Thanks Daniel,
Just didn't think of it.
Oops...
Seems to be heading in the right direction.
I'll report back tomorrow.
Thanks again,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By gkornbluth - July 2, 2020
Hi Daniel,
When I use the relative url ../Mobile_Detect.php the Website Membership plugin seems happy (the error on the plugins page goes away), but all my mobile pages throw the following error:
Warning: require_once(../Mobile_Detect.php): failed to open stream: No such file or directory in /home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php on line 19 Fatal error: require_once(): Failed opening required '../Mobile_Detect.php' (include_path='/home2/ngpymrmy/public_html/pollick/cmsAdmin:/home2/ngpymrmy/public_html/pollick/cmsAdmin/3rdParty:.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php on line 19
And the error log shows a similar error
#4097 - E_WARNING: require_once(../Mobile_Detect.php): failed to open stream: No such file or directory
/home2/ngpymrmy/public_html/pollick/cmsAdmin/plugins/websiteMembership1.13/websiteMembership.php (line 19)
http://www.pollick.net/OK/m/welcome.php
The original concept was to set up mobile friendly pages and redirect if a mobile device is used. Everything seems to work until I encounter a password protected page. Then things go awry.
Maybe I'm approaching this in the wrong way?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By daniel - July 2, 2020
Hi Jerry,
This error just means that the required file isn't being found, indicating an issue with the relative path specified.
If you just want to use a relative path, it will need to be relative to the current include path - which is generally the file where you're including from. In the membership plugin file, you'll need to traverse up three levels:
require_once '../../../Mobile_Detect.php';
Another option is with the "SCRIPT_DIR" constant I referenced above to use an absolute path. This constant should point at the CMSB directory (e.g. "/home2/ngpymrmy/public_html/pollick/cmsAdmin/") and so you can use this as a consistent reference regardless of the file being used to include, like this:
require_once SCRIPT_DIR . '../Mobile_Detect.php';
Require will interpret "../" in the middle of absolute paths, so "/home2/ngpymrmy/public_html/pollick/cmsAdmin/../Mobile_Detect.php" should resolve to "/home2/ngpymrmy/public_html/pollick/Mobile_Detect.php"
Let me know if this helps resolve the issue; you may need to alter the pathing references to get it to work for your installation.
Thanks,
Technical Lead
interactivetools.com
By gkornbluth - July 2, 2020
Hey Daniel,
Thanks for all the time you spent to answer this as completely as you did (and for your enormous expertise, of course).
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By gkornbluth - July 4, 2020
Hi Daniel,
I couldn't seem to get this to work, (probably my fault) but I did manage to get my original issue solved with careful use of mobile detect redirects on my original desktop site pages.
Sorry for the wheel spin.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php