Production - Create a Simple Config File

Hi,

I am very excited to use Scriptcase and just finished my first application for production use. I deployed the project and noticed that
in order to configure the connections the system requires me to go to the /_lib/ area and configure the settings. And I also have to
make sure the directory /_lib/ is writable.

I feel that it would be lot easier for my users if they actually could simply edit a config.php file and enter the database information
there.

I am trying to avoid a situation where the user has to visit /_lib/ directory.

Is that possible? I tried dissecting /_lib/conf/prod.config.php but the contents look encrypted.

I think that you need to contact SC for this. I don’t know about documentation regarding this. Besides the database connection other things are configured in your admin area too like up/downloads etc.

After fiddling around with Scrtipcase, I think it is actually better to use Scriptcase to generate the config file. And since the config files are encrypted the credentials are safe. However, I wanted to avoid a situation where my front-end application needed to have the config file stored in another file/location. To avoid that, I figured out a solution that reads the scriptcase config file and actually decodes the data. So, you can use the same credentials to connect to the database and do things for your custom/non scriptcase application. Here is the code:


require("/scriptcase_app_name/_lib/prod/lib/php/nm_ini_lib.php");
require("/scriptcase_app_name/_lib/prod/lib/php/nm_serialize.php");

$connection_name = ""; // e.g. conn_mysql

$application_config = nm_unserialize_ini("./scriptcase_app_name/_lib/conf/prod.config.php");

$db_host = decode_string($application_config['PROFILE'][$connection_name]['VAL_HOST']);
$db_user = decode_string($application_config['PROFILE'][$connection_name]['VAL_USER']);
$db_pass = decode_string($application_config['PROFILE'][$connection_name]['VAL_PASS']);
$db_name = decode_string($application_config['PROFILE'][$connection_name]['VAL_BASE']);

I hope this will come handy for some.

1 Like

I went ahead and customized the setup area, so there is no mention of scriptcase and it looks as if its part of the actual site, as an alternative solution was simple to replace the images used.

Thanks for that, very helpful. I was moving an old v6 application to a new server and the prod ini manager wasn’t working on the new server.

I used the following to encode the new username, password and database name.


require("/var/www/charter/_lib/prod/lib/php/nm_ini_lib.php");
require("/var/www/charter/_lib/prod/lib/php/nm_serialize.php");
echo encode_string_utf8("new_database");