Why does prepend have to be within the includes directory?

thread: 6 messages  |  last: about 2 years ago  |  started: thursday, january 14, 2010, 12:25 pm pst


#1  |  Patrick Ranger (Montreal, Qc) Canada
Thursday, January 14, 2010, 12:25 PM PST

I have developped a buddy punch application and am offering in in a SaaS mode. On my webserver, I have 15 clients running the same application. Each client has its own directory for its specific business rules and of course its own database. But they all use the same QCodo installation. Its a lot easier to maintain it this way. But it requires that each client has its own configuration file for database credentials, meaning it cannot be in the include directory, which was OK until I updated to version 4. Now these lines in prepend validate that both prepend.inc.php and configuration.inc.php are in the same directory AND validates that prepend is in the includes directory :

if (!file_exists(dirname(__FILE__) . '/configuration.inc.php'))
    exit('error: configuration.inc.php missing from includes/ directory; copy includes/qcodo/_core/configuration.inc.php-dist to the includes/ directory');
require(dirname(__FILE__) . '/configuration.inc.php');
if (realpath(__FILE__) != realpath(__INCLUDES__ . '/prepend.inc.php'))
    exit('error: __DOCROOT__ and/or __INCLUDES__ settings not valid in configuration.inc.php; update includes/configuration.inc.php with the correct settings');

Is there a functional reason for this, or can I just comment the function or find any workaround? Any thought on this is welcome.

Patrick

#2  |  VexedPanda (Calgary, AB) Canada
Thursday, January 14, 2010, 1:27 PM PST

The problem with a shared prepend file is how do you then determine which configuration file should be loaded?

#3  |  VexedPanda (Calgary, AB) Canada
Thursday, January 14, 2010, 1:28 PM PST

Other than that, it's easy to change the other configuration.inc.php constant definitions in order to move every other file out of the vhost-specific folders, and have them shared.

#4  |  Patrick Ranger (Montreal, Qc) Canada
Thursday, January 14, 2010, 1:57 PM PST

Thanks for the reply.

Actually my prepend file wasn't shared, so it “required” a specific configuration file. (EDIT : I have 1 prepend file and 1 configuration file for each client)

I guess I could just remove the database connections from configuration file and store it in a client specific file, and i could then use a shared prepend and configuration file.

But anyways, do you know the reason for validating that the configuration file and prepend are in the includes directory?

#5  |  romcart (Redding, CA) United States of America Qcodo Core Contributor
Thursday, January 14, 2010, 4:14 PM PST

I don't know if this would work in your case, but with some conditional logic in your configuration.inc.php, you can dynamically set the database to be used based on the url. See a discussion of this with example code here

#6  |  Patrick Ranger (Montreal, Qc) Canada
Friday, January 15, 2010, 9:40 AM PST

Thanks for pointing that out romcart. I think choosing the database according to the URL is a good solution, since I would not have to “maintain” so many prepend and configuration files.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.