Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Cant open boostrap.php error

edited June 2014 in Vanilla 2.0 - 2.8

I have some code that allows people to see if their logged in or not on external pages of my site (Well that's what its supposed to do)
The following code works for my homepage only. I was wondering if anyone could help.

<?php
    /*
    * Include the Garden framework used by Vanilla.
    */
    // Define constants like the way that Vanilla does in its index.php file.
    define('APPLICATION', 'Vanilla');
    define('APPLICATION_VERSION', '2.1');
    define('DS', '/');
    define('PATH_ROOT', './forum'); // Change PATH_ROOT to the path to your forum.
    // Display all PHP errors for development purposes.
    error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);
    ini_set('display_errors', 'on');
    ini_set('track_errors', 1);
    ob_start(); // Buffer the output of the code below.
    require_once(PATH_ROOT . '/bootstrap.php'); // Require the bootstrap for the framework used by Vanilla.
    $Dispatcher = Gdn::Dispatcher(); // Declare an alias for the dispatcher.
    // Set up the dispatcher.
    $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders();
    $Dispatcher->EnabledApplicationFolders($EnabledApplications);
    $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);
    // Mimic the DiscussionsController().
    $Controller = new DiscussionsController();
    Gdn::Controller($Controller);
    Gdn::Request()->WebRoot('');
    ob_end_flush(); // Stop and send the buffer for the code above.
    /*
     /*
    * The above code is to include Garden framework used by Vanilla, so you can use its functions.
    * You can put your code in this file. See the example below.
    * You can also make a separate file with your code and include this file by a require() above all.
    */
    $Session = Gdn::Session(); // Declare an alias for the user session.
    // Check if the user session is valid.
    if($Session->IsValid()) {
   // echo "The user is logged in!"; // The session is valid, so the user is logged in.
    $Username = ($Session->User->Name);
    // display link to user profile
    echo '
               <ul class="nav pull-right">
<li class="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown"><img class="avatar" src="https://minotar.net/helm/'.$Username.'/20.png">   '.$Username.'<b class="caret"></b></a>
<ul class="dropdown-menu pull-right">
<li class=""><a href="/forum/profile/edit"><i class="fa fa-pencil"></i> Edit Profile</a></li>
<li class=""><a href="/forum/entry/signout"><i class="fa fa-sign-out"></i> Sign Out</a></li>
<li class="divider">Other</li>

<li class=""><a href="mailto:info@quollcraft.net"><i class="fa fa-send"></i> Contact Us</a></li>
</ul>
</li>
</ul>
        </div><!--/.nav-collapse -->
      </div>
     ';
    } else {
  //  echo "The user is not logged in."; // The session is invalid, so the user is not logged in.
   // display sign in link to user profile
   echo '
   <ul class="nav pull-right">
<li class="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> Guest <b class="caret"></b></a>
<ul class="dropdown-menu pull-right">
<li class=""><a rel="nofollow" href="/forum/entry/signin"><i class="fa fa-sign-in"></i> Login</a></li>
<li class=""><a rel="nofollow" href="/forum/entry/register"><i class="fa fa-edit"></i> Register</a></li>
<li class="divider">Other</li>

<li class=""><a href="mailto:info@quollcraft.net"><i class="fa fa-send"></i> Contact Us</a></li>
</ul>
</li>
</ul>';


   }
   ?>
</ul>

and it shows this error on pages (eg: www.quollcraft.net/staff) but works on my home page: www.quollcraft.net
Fatal error: require_once(): Failed opening required './forum/bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/quollcr1/public_html/staff/index.php on line 16 <-- Error

Comments

  • Anyone?

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP

    @LaughingQuoll‌

    Bumping a question after two hours could be considered bad form.

    The people replying on here are almost all giving their own time from other non-Vanilla work, so aren't simply sitting around waiting for a question to be asked.

    Patience, my friend.

  • R_JR_J Ex-Fanboy Munich Admin

    @LaughingQuoll said:
    I have some code that allows people to see if their logged in or not on external pages of my site (Well that's what its supposed to do)
    The following code works for my homepage only. I was wondering if anyone could help.

    <?php
        /*
        * Include the Garden framework used by Vanilla.
        */
        // Define constants like the way that Vanilla does in its index.php file.
        define('APPLICATION', 'Vanilla');
        define('APPLICATION_VERSION', '2.1');
        define('DS', '/');
        define('PATH_ROOT', './forum'); // Change PATH_ROOT to the path to your forum.
    

    Fatal error: require_once(): Failed opening required './forum/bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/quollcr1/public_html/staff/index.php on line 16 <-- Error

    I'm no expert, but I'd say it failed opening ./forum/bootstrap.php ;) And the most probable reason for that is, that the specified path is wrong. Maybe you should "Change PATH_ROOT to the path to your forum." Try the absolute path.

  • hgtonighthgtonight ∞ · New Moderator

    Request the MeModule via AJAX. You won't have to worry about keeping this script up to date when things change, the request can be made asynchronously (appearing to be faster), you will get any notification counts too.

    I need to write a tutorial on this.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited June 2014

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Now i get a different error:
    Fatal error: Class 'Gdn' not found in /home/quollcr1/public_html/staff/index.php on line 93
    This is the updated code:
    <?php /* * Include the Garden framework used by Vanilla. */ // Define constants like the way that Vanilla does in its index.php file. define('APPLICATION', 'Vanilla'); define('APPLICATION_VERSION', '2.3a1'); define('DS', ''); define('PATH_ROOT', 'home/quollcr1/public_html/forum'); // Change PATH_ROOT to the path to your forum. // Display all PHP errors for development purposes. error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR); ini_set('display_errors', 'on'); ini_set('track_errors', 1); ob_start(); // Buffer the output of the code below. define('PATH_ROOT', '/forum'); // Change PATH_ROOT to the path to your forum. $Dispatcher = Gdn::Dispatcher(); // Declare an alias for the dispatcher. // Set up the dispatcher. $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders(); $Dispatcher->EnabledApplicationFolders($EnabledApplications); $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications); // Mimic the DiscussionsController(). $Controller = new DiscussionsController(); Gdn::Controller($Controller); Gdn::Request()->WebRoot(''); ob_end_flush(); // Stop and send the buffer for the code above. /* /* * The above code is to include Garden framework used by Vanilla, so you can use its functions. * You can put your code in this file. See the example below. * You can also make a separate file with your code and include this file by a require() above all. */ $Session = Gdn::Session(); // Declare an alias for the user session. // Check if the user session is valid. if($Session->IsValid()) { // echo "The user is logged in!"; // The session is valid, so the user is logged in. $Username = ($Session->User->Name); // display link to user profile echo '

    '; } else { // echo "The user is not logged in."; // The session is invalid, so the user is not logged in. // display sign in link to user profile echo ' '; } ?>
  • Dont worry all fixed. Needed a / before home/quollcr1/

  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.