Announcement

Collapse
No announcement yet.

How to include vB3 into a file outside of vB3 folder?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to include vB3 into a file outside of vB3 folder?

    How can I include vBulletin 3's functions, variables, etc. into a file outside of vB3?

    In vB 2, I used to be able to just add require("./forum/global.php"); then that would work, but now, it's a totally different story. If I try including the global.php, then the other relative paths will have problems, such as the require_once('./includes/init.php'); in global.php or the require_once('./includes/config.php'); in includes/init.php

    Any ideas?
    Thanks in advance!

  • #2
    you'l need to use chdir to change the directory to the forums directory then
    require_once('./global.php');

    then chdir back to the one before if need be.
    Scott MacVicar

    My Blog | Twitter

    Comment


    • #3
      Ah yes, thanks Scott.

      Comment


      • #4
        Gary,

        Can you give me an example of how you do this? I have been trying to accomplish something like this aswell but am nowhere near as smart ;-)
        sigpic

        Comment


        • #5
          Originally posted by trackpads
          Gary,

          Can you give me an example of how you do this? I have been trying to accomplish something like this aswell but am nowhere near as smart ;-)
          PHP Code:
          <?php
          chdir
          ('./forums');
          require_once(
          './global.php');
          chdir('./../');
          ?>

          Comment


          • #6
            forgive me if its obvious, but what kind of things can you do by accessing the vbulletin functions from external pages? I'm pretty interested in what that can do incase it would be off use for my site.

            Comment


            • #7
              Originally posted by scri
              forgive me if its obvious, but what kind of things can you do by accessing the vbulletin functions from external pages? I'm pretty interested in what that can do incase it would be off use for my site.
              There's many things, mainly for convenience, maybe they'd want to easily connect to the database, or use vBulletin's functions, etc. many options . Sometimes it's to display statistics like # of members .

              Comment


              • #8
                Originally posted by squall14716
                PHP Code:
                <?php
                chdir
                ('./forums');
                require_once(
                './global.php');
                chdir('./../');
                ?>
                actually thats all right except last part

                <?php
                chdir("./location');
                require_once("./global.php");
                chdir("../");
                ?>

                using ./../ is redundant only ../ is needed.

                Comment


                • #9
                  Originally posted by Trigunflame
                  actually thats all right except last part

                  <?php
                  chdir("./location');
                  require_once("./global.php");
                  chdir("../");
                  ?>

                  using ./../ is redundant only ../ is needed.
                  I use it for requiring people to be logged in/registered before viewing other pages of my site. for example I have a fact sheets database (really a modded phpbb) and I used this code similar to make folks log into VB first-

                  http://www.trackpads.com/factsheets

                  You have to admit there is something funny about requiring a VB registration to see a phpBB
                  sigpic

                  Comment


                  • #10
                    Originally posted by Trigunflame
                    actually thats all right except last part

                    <?php
                    chdir("./location');
                    require_once("./global.php");
                    chdir("../");
                    ?>

                    using ./../ is redundant only ../ is needed.
                    Or you can use just
                    PHP Code:
                    chdir(".."); 

                    Comment


                    • #11
                      true..but i prefer trailing slash

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X