1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

URL versus Absolute Path

Discussion in 'XenForo Development Discussions' started by LPH, Feb 19, 2015.

  1. LPH

    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?
     
  2. tyteen4a03

    tyteen4a03 Well-Known Member

    You can't include files with anything other than local filesystem URLs.

    What are you trying to do?
     
  3. LPH

    LPH Well-Known Member

    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 :)
     
  4. tyteen4a03

    tyteen4a03 Well-Known Member

    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__ ?
     
  5. LPH

    LPH Well-Known Member

    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 ;)
     
  6. tyteen4a03

    tyteen4a03 Well-Known Member

    They can always install a phpinfo plugin, or even better, you can write a WP plugin they can install that displays the absolute path.
     
  7. LPH

    LPH Well-Known Member

    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 :)
     
  8. LPH

    LPH Well-Known Member

    Guess I was being really silly :p

    It turns out XenForo admin includes phpinfo ...

    /admin.php?tools/phpinfo
     

Share This Page