Skip to content

Commit b10427b

Browse files
author
pedro_morgan
committed
Code tidy and janitor
1 parent 69c8533 commit b10427b

File tree

1 file changed

+62
-19
lines changed

1 file changed

+62
-19
lines changed

interface/lib/config.inc.php

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,86 @@
2727
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30-
Header('Pragma: no-cache');
31-
Header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
32-
Header('Content-Type: text/html');
33-
30+
header('Pragma: no-cache');
31+
header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
32+
header('Content-Type: text/html');
33+
//* TODO: Js caching - pedro
3434

3535
//** Key paramaters
3636
$conf['app_title'] = 'ISPConfig';
3737
$conf['app_version'] = '3.0.0';
3838
$conf['modules_available'] = 'admin,mail,sites,monitor,client,dns';
3939

4040

41-
//** Database Settings
42-
$conf['db_type'] = 'mysql';
43-
$conf['db_host'] = 'localhost';
44-
$conf['db_database'] = 'ispconfig3';
45-
$conf['db_user'] = 'root';
46-
$conf['db_password'] = '';
41+
//** Future Code - pedro comments
42+
/* Database connection
43+
The only time its needed is to connectm otherwise it not needed as
44+
variables aronf the application. Connected and done.
45+
Prefered is an array as $DB in capitals, ie
46+
$DB['host'] = 'type';
47+
$DB['host'] = 'ip';
48+
$DB['user'] = 'me';
49+
$DB['password'] = 'secret';
50+
$DB['database'] = 'persistent_data_stash';
51+
52+
The connection paramaters are all contained within one array structure
53+
With this array structure the connection can be passed around, to functions
54+
However it can also leak. and be destroyed eg
55+
$db->connect($DB);
56+
unset($DB); // only the paranoid survive
57+
58+
Also there is a scenario where we are devloping and using this file
59+
and the database paramaters might leak.
60+
To resolve this there is a file called db_local.php.skel which is not detected
61+
rename this to db_local.php and edit the paramaters
62+
63+
$DB['type'] = 'mysql';
64+
$DB['host'] = 'localhost';
65+
$DB['database'] = 'ispconfig3';
66+
$DB['user'] = 'root';
67+
$DB['password'] = '';
68+
69+
70+
*/
71+
72+
//** Detect for local database setting or set and load default params
73+
if( file_exists('db_local.php') ){
74+
require_once('db_local.php');
75+
$conf['db_type'] = $DB['type'];
76+
$conf['db_host'] = $DB['host'];
77+
$conf['db_database'] = $DB['database'];
78+
$conf['db_user'] = $DB['user'];
79+
$conf['db_password'] = $DB['password'];
80+
}else{
81+
//** Database Settings
82+
$conf['db_type'] = 'mysql';
83+
$conf['db_host'] = 'localhost';
84+
$conf['db_database'] = 'ispconfig3';
85+
$conf['db_user'] = 'root';
86+
$conf['db_password'] = '';
87+
}
4788

4889

4990
//** Path Settings (Do not change!)
50-
$conf["rootpath"] = substr(dirname(__FILE__),0,-4);
51-
$conf["fs_div"] = '/'; // File system divider, \\ on windows and / on linux and unix
52-
$conf["classpath"] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes';
53-
$conf["temppath"] = $conf['rootpath'].$conf['fs_div'].'temp';
91+
$conf['rootpath'] = substr(dirname(__FILE__),0,-4);
92+
$conf['fs_div'] = '/'; // File system divider, \\ on windows and / on linux and unix
93+
$conf['classpath'] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes';
94+
$conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp';
5495

5596

56-
define('DIR_TRENNER',$conf['fs_div']);
57-
define('SERVER_ROOT',$conf['rootpath']);
58-
define('INCLUDE_ROOT',SERVER_ROOT.DIR_TRENNER.'lib');
59-
define('CLASSES_ROOT',INCLUDE_ROOT.DIR_TRENNER.'classes');
97+
define('DIR_TRENNER', $conf['fs_div']);
98+
define('SERVER_ROOT', $conf['rootpath']);
99+
define('INCLUDE_ROOT', SERVER_ROOT.DIR_TRENNER.'lib');
100+
define('CLASSES_ROOT', INCLUDE_ROOT.DIR_TRENNER.'classes');
60101

102+
/* pedro notes ? this stuff is REALLY not necessay */
103+
/*
61104
define('DB_TYPE', $conf['db_type']);
62105
define('DB_HOST', $conf['db_host']);
63106
define('DB_DATABASE',$conf['db_database']);
64107
define('DB_USER', $conf['db_user']);
65108
define('DB_PASSWORD', $conf['db_password']);
66-
109+
*/
67110

68111
//** External programs
69112
//$conf["programs"]["convert"] = "/usr/bin/convert";

0 commit comments

Comments
 (0)