dawber
Posts: 25
|
| Posted: 10/05/2005, 1:28 AM |
|
I have created a CCS "green" site that currently:
a. Runs under https for authentication and so on.
b. Has MySQL running on the same host.
c. The Common.php contains $this->DBHost = "192.168.5.100";
I had to replicate this site on different hardware for "red" and "blue".
The code base is identical for "green", "red" and "blue".
Except that:
On the "green" Common.php contains $this->DBHost = "192.168.5.100";
On the "red" Common.php contains $this->DBHost = "192.168.7.100";
On the "blue" Common.php contains $this->DBHost = "192.168.9.100";
Now every time I need to release an update of my CCS code,
I must manually update the 3 different Common.php files with
the 3 different IP addresses.
When I forget to do this, it causes problems.
I changed the IP addresses to "localhost" but that did not work.
How can I set a universal value of $this->DBHost such that
each CCS site points to its local MySQL?
(So I don't have to manually update the 3 different Common.php files.)
|
 |
 |
Damian Hupfeld
|
| Posted: 10/05/2005, 3:15 AM |
|
Why doesnt "localhost" work?
All of my projects are created using localhost.
Do you get a specific error?
|
|
|
 |
Walter Kempees
|
| Posted: 10/05/2005, 4:28 AM |
|
Apart from the 'localhost' not working which is very strange, is there any
other specific info that differs between red green and blue.
You could then build a sort of identifier script setting the ipnumber for
DBHost depending on that variable.
It would have to be something HTTP specific I think, obtainable through PhP.
One of the GLOBAL variables like
HTTP_HOST
SERVER_NAME
SERVER_ADDR
DOCUMENT_ROOT
Let us know if this helped.
|
|
|
 |
DonB
|
| Posted: 10/05/2005, 7:15 AM |
|
Try going to the 'server' tab of your connection and putting:
$_SERVER['SERVER_ADDR']
into the "Host" property.
Let us know how that behaves. I suspect it will do what you want. This
property is where "DBHost" gets defined.
I think that 'localhost' is rejected just because the site is running on
SSL. Thus the SSL certificate is invalid - because it's tied to a 'real'
URL not 'localhost'.
--
DonB
http://www.gotodon.com/ccbth
|
|
|
 |
lwismanuel
Posts: 39
|
| Posted: 10/07/2005, 3:23 PM |
|
I think it's good prictice to keep setting information away from your codes to avoid future nightmare. The way I do it, I create a xml file and put the settings there:
<?xml version="1.0"?>
<config>
<database>
<host>127.0.0.1</host>
<type>MySQL</type>
<port>3306</port>
<user>db_usr</user>
<pass>IKo6MzCdEH3XPSJ78w5I8vDQdB+71gbp</pass>
<dbname>test_db</dbname>
</database>
</config>
If you are using notepad do not forget to save the file UTF-8 encoding.
Then, go to Project>>Settings>>Connectons and modify your connection
for the DataBase Name enter: $dbconf->dbname
for Host: $dbconf->host
Port: $dbconf->port
Login: $dbconf->user
In the xml file the password is encripted, I have a function that uses mcript to do the job, you choose whatever mechanism you prefer to do that or do not encript the password (it is useless encripting the password if you are not obfuscating your codes) even if somebody get a hold of your xml config file he or she can not do much with it 'cause the password is encripted crypto('d',$dbconf->database->pass,'')
or without encription:
$dbconf->database->pass
If you are using CCS ver. 2.3
go to the Common file and inside the function Initialize() type: $xml = file_get_contents('../path_to_folder/config.xml');that will get the xml file and another thing you may notice is that path is pointing to a folder below the document root making it inaccessible for browsing.
Next we are going to parse and convert the file to native PHP variables
$config = simplexml_load_string($xml);
then copy the database node to a new variable
$dbconf = $config->database;
That's it! this work for me.
Any other setting use in your app could be place in this xml file by adding the appropiate members. Another plus for this approch is that you could create an interface (GUI) to edit the xml file.
|
 |
 |
|