Changing working directory

Ok this might be weird but i’ll explain this as easily as I can.

I’m starting a free-forum hosting service which eventually will provide multiple different forum systems (phpbb, smf etc) and I have the following setup:

domain.com points to main site with signup etc.

Upon registration, users will get a subdomain.domain.com

All sub-domains are CName’d to point to a sub-domain I have called s1.domain.com which on my apache settings points to domain.com/forums/

In this forums folder I plan to have a config file which will work out which forum system that particular sub-domain should be using, and as such change said working directory to match the forum type.

To start with I’m using phpbb so the phpbb files are located in domain.com/forums/phpbb so say I have

phpbb.domain.com points to domain.com/forums which the file would determine from my database it needs to show the phpbb files.

I guess the question is, without redirecting, how would I set it to show the phpbb files since include would make things messy code-wise. I’m guessing this would be a change working directory within the file somehow.

Any ideas?

I’m not sure how exactly the project is laid out obviously, but surely you could make use of a .htaccess file? Not really done anything along these lines before, something like the below might be worth looking into.

[code]RewriteCond %{HTTP_HOST} !^phpbb.domain.com$ [NC]
RewriteRule .* /forums/phpbb/index.php [QSA]

RewriteCond %{HTTP_HOST} !^other.domain.com$ [NC]
RewriteRule .* /forums/other/index.php [QSA][/code]

phpbb.domain.com was an example. users will actually have their own sub-domain which will be stored in a database. The database will then return what type of forum it should load.

Example:
user1.domain.com | phpbb
user2.domain.com | smf
user3.domain.com | ipb

each would have to load a different folder

Edit: obviously I want to do this way as all i’d have to do is change the database used, rather than make a new directory for every user and copy files over which takes more disk space.

Than you would have to look at forum software that supports multi-domains. because the db settings would be in a configuration file amongst other things (Uploads, avatars, mods).

I’ve already worked that out. That isn’t my problem. The only problem I am having is the one I stated which is for multiple forum systems as the server has to work out which forum system to load.

Add user4.domain.com to my table with the type phpbb. Now there’s 2 phpbb’s. I need the server to work out that it has to load phpbb and not say SMF or IPB but if it loads user2 it needs to load SMF. The multi-domain I already know howto do.

Doing some research and want to know what all the other experienced people think of me using chdir()

[php]

<?php /* INSERT CODE TO GET SUB-DOMAIN HERE */ /* CHECK MYSQL DATABASE AND RETURN FORUM TYPE */ If ($ForumType == "phpbb") { chdir('phpbb'); } elseif ($ForumType == "smf") { chdir('smf'); } ?>

[/php]

I prob need more stuff after this but this would be a start if it’s the correct function.

Sponsor our Newsletter | Privacy Policy | Terms of Service