Page 1 of 1

Improve your CONFIG.PHP

Posted: Sat Oct 07, 2006 5:04 pm
by jindravavruska
Hello,

there are several places in config.php where host name of the instance is written. In version 1.0.2, you will typically find it in several config variables at lines 16 (hostname), 40 (root_url), 56 (uploads_url), 118 (image_uploads_url).

Values of these variables are written by the install script as string literals. If you, for whatever reason, need to change the hostname, CMS will not run correctly until you find and change all of the above variable values.

What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.

The story behind this is following:

I installed an instance of CMS-MS on my home pc without too much thinking, leaving "localhost" as the hostname. Later today I tried to access running CMS-MS from my PDA via bluetooth network access, using the BT-NA default IP address 192.168.0.1 as hostname in the URL. The first strange thing was that the CMS home page came as an unformatted, text-only page (in HTML, but without the theme colors and other "bells and whistles"). The second problem was that when I went to admin.php, after filling the login form I never actually reached the site again. It was because the redirect URL supplied by CMS-MS was "http://localhost/admin.php"...

It is interesting that CMS-MS does not use PHP variables (such as _SERVER['HTTP_HOST']) to figure out hostname from request headers or other reliable source, but maybe there is a good reason for that. For me, today, this was a complication :)

Good luck,

Jindra

Re: Improve your CONFIG.PHP

Posted: Thu Nov 09, 2006 12:10 pm
by tsw
jindravavruska wrote:
It is interesting that CMS-MS does not use PHP variables (such as _SERVER['HTTP_HOST']) to figure out hostname from request headers or other reliable source, but maybe there is a good reason for that. For me, today, this was a complication :)
Your suggestion has come up before also. Im not fully avare of all the problems included with this change but do know that $_SERVER['HTTP_HOST'] doesnt work on all situations. Especially IIS has some of these variables set differently compared to apache.

it would be better to add this kind of things as feature requests in the tracker as forum posts tend to get lost and are hard to handle. For example I havent seen this post before you mentioned it in the other thread...

Re: Improve your CONFIG.PHP

Posted: Thu Nov 09, 2006 2:40 pm
by wientanz
Noticed that problem myself and found another thread with exactly the same proposed solution some time ago (think it was half a year ago). So it really seems to be some kind of problem to some people. Especially with people using it simultaneously as intra- and internet portal.

Just my two cents :-)

Re: Improve your CONFIG.PHP

Posted: Thu Nov 09, 2006 8:35 pm
by Pierre M.
jindravavruska wrote: What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.
Well done, nice idea. I'd like it too.
If Jindra posts a wish in the tracker, how can I vote for it ?

PM

Re: Improve your CONFIG.PHP

Posted: Wed Dec 27, 2006 7:45 pm
by Elijah Lofgren
Pierre M. wrote:
jindravavruska wrote: What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.
Well done, nice idea. I'd like it too.
If Jindra posts a wish in the tracker, how can I vote for it ?

PM
Thanks for your suggestion. I've filed it as a FR and assigned it to myself: http://dev.cmsmadesimple.org/tracker/in ... 6&atid=104
Hopefully I'll remember/have time to add this before CMSMS 2.0 is released.

Re: Improve your CONFIG.PHP

Posted: Thu Jul 19, 2007 9:26 pm
by bas_otten
I want to post a slight correction on the first post:

You should leave 'localhost' on line 16: $config['db_hostname'] = 'localhost';

This has to do with the connection between the webserver and the database server, not browser to webserver.

Regards.