Hiding includes

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

    Hiding includes

    I have this config.php file in a folder "data" in the same directory as public_html
    PHP Code:
    <?php 
    //config.php
    $host "domain.name"//your domain name 
    $port 2082
    $path "/frontend/x2/mail/doaddpop.html"//change x2 to your theme. 
    $cpaneluser "Cpanel Username"
    $cpanelpass "Cpanel Password"
    $authstr "$cpaneluser:$cpanelpass";
    // Server local variables
    $data ="/home/host2xar/data"//include $data."/config.php"; 
    // Defines local variables               
    $server_inc $_SERVER["DOCUMENT_ROOT"]."/inc";  
    $server $_SERVER["DOCUMENT_ROOT"]."/"//include $server."index.php";
    ?>
    Here is my index.php
    PHP Code:
    <?php 
    //index.php 
    include $data."/config.php"
    include 
    $server."setup.php"
    include 
    $data."/header.php"
    include 
    $data."/right.php"
    include 
    $server."content.php"
    include 
    $data."/footer.php"
    ?>
    PHP Code:
    Warningmain(/config.php): failed to open streamNo such file or directory in /home/host2xar/public_html/index.php on line 2 
    Where is my error?
    Newbie here...
  • Buddha
    Senior Member
    • Mar 2004
    • 825

    #2
    In index.php, I don't see where $data is set? I do see it set in config.php but you need to set $data to include() config.php. Set $data inside index.php.

    Also, I'm not sure PHP can access anything outside of document root? You may have to move data directory into public_html? I could be wrong about this on this server. You could set the permission to 600 or something just as restrictive on the data directory?
    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

    Comment

    • Jonathan
      Senior Member
      • Mar 2004
      • 1229

      #3
      I'd say simply use require() as you can
      use more than one, or more than one in a certain way;
      Forget the exact details why its better,
      but was reading in a PHP/mySQL book about it.

      <?php
      require('folder/file.php');
      ?>

      Simple as pie
      "How can someone be so distracted yet so focused?"
      - C

      Comment

      • bd2003
        Junior Member
        • Mar 2004
        • 20

        #4
        yup.. agree with above... looks like you need to do either define $data in your index.php before any of your includes or include your config.php explicitly, ie :
        include "data/config.php";

        make sure you put this include first....

        Comment

        Working...