URL versus Absolute Path

LPH

Well-known member
I'm trying to figure out how to call a site URL rather absolute path to initialize XenForo.

This is the what I have written.

PHP:
        if ( $xenword_options['use_url'] == true ) {

            $protocol = is_ssl() ? 'https://' : 'http://';
            $host = $xenword_options['use_host'];
            $path = $xenword_options['use_path'];

            $fileDir = $protocol . $host . $path;

        } else {

            $fileDir = $xenword_options['absolute_path'];
        }

        if ( !class_exists( 'XenForo_Autoloader' ) ) {

            require( $fileDir . "/library/XenForo/Autoloader.php");
           // The rest of the initialize XenForo code from index.php

When use_url is false and the xenword_option loaded is absolute path then everything is fine. The problem is in the use_url true part of the code.

I'm getting the error:

Code:
Fatal error: require(): Failed opening required 'http://www.lph.dev/community/library/XenForo/Autoloader.php' (include_path='.:/Applications/MAMP/bin/php/php5.6.1/lib/php') in /Applications/MAMP/htdocs/wp-content/plugins/xenword-2.5.0.01/includes/class-xenword.php on line [I]95[/I]

Line 95 is the require Autoloader.php.

The path http://www.lph.dev/community/library/XenForo/Autoloader.php is correct ... but it isn't opening.

Is there a reason that this code fails that I'm overlooking?
 
You can't include files with anything other than local filesystem URLs.

What are you trying to do?

I was trying to see if it was possible to initialize XF via URL rather than absolute path. So if someone knew their board URL then they can put it in the option rather than the absolute path to the XF files :)
 
I was trying to see if it was possible to initialize XF via URL rather than absolute path. So if someone knew their board URL then they can put it in the option rather than the absolute path to the XF files :)
No; the absolute part is absolutely necessary (pun not intended), because it is impossible to grasp the file path just by inspecting the URL (as the web server's htdocs can be somewhere else).

Can't you use __DIR__ ?
 
No; the absolute part is absolutely necessary (pun not intended), because it is impossible to grasp the file path just by inspecting the URL (as the web server's htdocs can be somewhere else).

Can't you use __DIR__ ?

Yeah it was a stupid idea but I'm trying to get past all the new WP people who don't know how to get their absolute path. So I have to explain how to create a phpinfo(), upload it, then I end up reading it for them and give them the path....

__DIR__ wouldn't do anything in the plugin because people put XenForo and WordPress in many different directories.

I'll keep the absolute path for now because it is better than when it was relative path ;)
 
Yeah it was a stupid idea but I'm trying to get past all the new WP people who don't know how to get their absolute path. So I have to explain how to create a phpinfo(), upload it, then I end up reading it for them and give them the path....

__DIR__ wouldn't do anything in the plugin because people put XenForo and WordPress in many different directories.

I'll keep the absolute path for now because it is better than when it was relative path ;)
They can always install a phpinfo plugin, or even better, you can write a WP plugin they can install that displays the absolute path.
 
They can always install a phpinfo plugin, or even better, you can write a WP plugin they can install that displays the absolute path.

Yeah - you are right but I'm struggling with some of the features in the redux framework. I can include html, txt, and css files easily into the options page (their init file) but can't seem to get a PHP script added. They have an extensions feature which is cryptic. I'll keep trying :)
 
Guess I was being really silly :p

It turns out XenForo admin includes phpinfo ...

/admin.php?tools/phpinfo
 
Top Bottom