Jump to content

Recommended Posts

I have a directory in public WWW. The files throughout the directory have many PHP includes amongst themselves. For example, the file "registration.php" begins with require('../parameters.php');

The directory is complex, like this:

/Public WWW directory/
        /My_Directory
            parameters.php
            another_reg.php
                /app
                    files.inc
                     files2.inc
                    /morefiles
                    another.inc
                    another2.inc
                    /css
                mycss.css
                /pages
                config.php
                registration.php
            
My question: I want the entire directory moved out of reach above the public WWW, but I want "registration.php" to go into the public WWW.

How would I do that without breaking all the include paths? (I know the solution is probably a one-liner involving __DIR__  ... but I can't seem to code it so it works).

Thank you!!

 

Link to comment
https://forums.phpfreaks.com/topic/308376-moving-directory-keeping-paths/
Share on other sites

Create an include file just above your WWW directory that will define some very basic things. It will always live just above the WWW directory. Always.

Put in it something like

const INCLUDE_DIR = "some path to find your new include directory";

You can put other commonly-needed things in there too. Or include other files. Whatever.

registration.php will include it with

require_once $_SERVER["DOCUMENT_ROOT"] . "/../the new include file.php";

then it can do things like

require_once INCLUDE_DIR . "/files.inc";

or whatever.

There are better approaches to this problem but they will require more significant changes. For now, this is enough.

"

15 hours ago, requinix said:

There are better approaches to this problem....For now, this is enough.

Thank you, I appreciate that you noticed this was just a temporary thing... so many files, and you're right I just needed a temporary fix. 

I gotta be careful though.... lots of my "temporary fixes" end up being permanent because I get too lazy to clean them all up :-)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.