views:

67

answers:

3

Hi all,

I'm building a CMS on a SaaS principle. I have my webserver (dynamic dedicated) up and running. It's all going like expected, but now I've come across my templating system, and later on simple things such as filehandling. Logically, each client has an own hostingaccount. All the hostingaccounts will be requesting to the masterdatabase, hosted on a large, global account, at the same server.

Some things which need to be handled later on are simple things as filehandling. Typically each client will store his/her own data at his/her own hostingaccount. Only the pagedata, and other data (productcatalogue, surveys, etc etc) will be hosted in the database.

But before I'm able to upload files from the centrally hosted system, I need to figure out how to get to the specified hostingaccount. I've got all the data I need stored in a sessionvariable which is filled when the client selects his/her website to work with (because my system supports mutliple sites).

The urlstructure on my server is like: /home/[unix-user-name]/domains/[domain-name]/public_html/paths/to/the/folders/i/set/up/

The second part in the url is the hostingaccountname, and the fourth part is de domain from the client. Again, I have this info in a session variable, ready for access.

My only problem is, when the client is logged on to the system, a part of the base url is allready filled like this:

/home/ontdek01/domains/ontdek5.nl/public_html/

My question, how can i force PHP to start looking for files from the very root, in this case home.

I hope my question is clear. Thanks in advance for spending time and putting effort in helping me further!

Ben

+1  A: 

I'm not sure if I'm interpreting your question correctly, but have you tried something like:

chdir('/home/');

This sets PHP's working directory to home, so PHP looks for included files relative to that directory.

robbo
Thanks robbo! It did the trick ;)
Ben Fransen
+1  A: 

Adding /home to include_path in php.ini will allow include*() and require*() to root their searches from there.

Ignacio Vazquez-Abrams
Thanks for your answer, i've emailed with my hostingprovider but we came to the conclusion that the provided answer from robbo resulted in a working solution.
Ben Fransen
A: 

you could set up something like:

$subDir = '/path/to/some/subdirectory/';
$includePath = $_SERVER['DOCUMENT_ROOT'] . $subDir;

include $includePath . 'myFile.php';

This allows it to start at the root down ($_SERVER['DOCUMENT_ROOT']) and then drill down further to a subdirectory if required ($subDir).

niggles
Thanks for your answer, but that's not a solution since you're not chaning anything to the document_root, you just add some pathinfo behind it. I was looking for a solution to include from the very root of an absolute path.
Ben Fransen