Use base_config template and merge in the config file, instead of manually substituting default value when they are missing
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
[main]
|
[main]
|
||||||
debug = on ; The output in the browser window for more information
|
debug = on ; The output in the browser window for more information
|
||||||
|
|
||||||
tftproot = /tftpboot
|
tftproot = /tftpboot
|
||||||
|
;default_language = English_United_States
|
||||||
|
|
||||||
;firmware = firmware
|
;firmware = firmware
|
||||||
;settings = settings
|
;settings = settings
|
||||||
@@ -10,4 +10,3 @@ tftproot = /tftpboot
|
|||||||
;locales = locales
|
;locales = locales
|
||||||
;countries = locales/countries
|
;countries = locales/countries
|
||||||
;languages = locales/languages
|
;languages = locales/languages
|
||||||
;default_language = English_United_States
|
|
||||||
|
@@ -3,35 +3,34 @@
|
|||||||
// Written by Alex / github.com/PhantomVI
|
// Written by Alex / github.com/PhantomVI
|
||||||
//
|
//
|
||||||
|
|
||||||
//Setup should be moved to ini/json file
|
$base_path = realpath($_SERVER['DOCUMENT_ROOT']);
|
||||||
// -- tftpboot path
|
$base_config = Array(
|
||||||
|
'debug' => 1,
|
||||||
|
'tftproot' => $base_path,
|
||||||
|
'default_language' => 'English_United_States',
|
||||||
|
'firmware' => 'firmware', 'settings' => 'settings', 'wallpapers' => 'wallpapers', 'ringtones' => 'ringtones',
|
||||||
|
'locales' => 'locales', 'countries' => 'countries', 'languages' => 'languages'
|
||||||
|
);
|
||||||
|
|
||||||
|
# Merge config
|
||||||
$ini_array = parse_ini_file('index.cnf');
|
$ini_array = parse_ini_file('index.cnf');
|
||||||
if (!empty($ini_array)) {
|
if (!empty($ini_array)) {
|
||||||
foreach ($ini_array as $key => $value) {
|
$config = array_merge($base_config, $ini_array);
|
||||||
$config[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($config['firmware'])) { $config['firmware'] = 'firmware';}
|
#$config['tftproot'] = (!empty($config['tftproot'])) ? $config['tftproot'] : '/tftpboot';
|
||||||
if (empty($config['settings'])) {$config['settings'] = 'settings';}
|
|
||||||
if (empty($config['wallpapers'])) {$config['wallpapers'] = 'wallpapers';}
|
|
||||||
if (empty($config['ringtones'])) {$config['ringtones'] = 'ringtones';}
|
|
||||||
if (empty($config['locales'])) {$config['locales'] = 'locales';}
|
|
||||||
if (empty($config['countries'])) {$config['countries'] = 'countries';}
|
|
||||||
if (empty($config['languages'])) {$config['languages'] = 'languages';}
|
|
||||||
if (empty($config['default_language'])) {$config['default_language'] = $config['languages']. 'English_United_States';}
|
|
||||||
|
|
||||||
$config['tftproot'] = (!empty($config['tftproot'])) ? $config['tftproot'] : '/tftpboot';
|
# Fixup debug
|
||||||
$print_debug = (!empty($config['debug'])) ? $config['debug'] : 'off';
|
$print_debug = (!empty($config['debug'])) ? $config['debug'] : 'off';
|
||||||
$print_debug = ($print_debug == 1) ? 'on' : $print_debug;
|
$print_debug = ($print_debug == 1) ? 'on' : $print_debug;
|
||||||
|
|
||||||
|
# Parse request
|
||||||
$request = $_REQUEST;
|
$request = $_REQUEST;
|
||||||
$req_file = !empty($request['id']) ? $request['id'] : '';
|
$req_file = !empty($request['id']) ? $request['id'] : '';
|
||||||
|
|
||||||
// -- TFTPD - structure
|
# directory content extensions map
|
||||||
//$fw_suffix = array('bin', 'loads', 'sbn', 'sb2', 'sbin', 'zz', 'zup');
|
|
||||||
$fw_suffix = array('.bin', '.loads', '.sbn', '.sb2', '.sbin', '.zz', '.zup');
|
$fw_suffix = array('.bin', '.loads', '.sbn', '.sb2', '.sbin', '.zz', '.zup');
|
||||||
|
|
||||||
//$settings_suffix = array('cnf.xml');
|
//$settings_suffix = array('cnf.xml');
|
||||||
|
|
||||||
$ringtones_list = array('distinctive.xml', 'ringlist.xml');
|
$ringtones_list = array('distinctive.xml', 'ringlist.xml');
|
||||||
@@ -39,6 +38,7 @@ $ringtones_list = array('distinctive.xml', 'ringlist.xml');
|
|||||||
$locale_list = array('-dictionary.', 'dictionary-ext.', '-dictionary.utf-8.', '-kate.xml', '-font.xml', '-font.dat','-tones.xml',
|
$locale_list = array('-dictionary.', 'dictionary-ext.', '-dictionary.utf-8.', '-kate.xml', '-font.xml', '-font.dat','-tones.xml',
|
||||||
'be-sccp.jar', 'tc-sccp.jar', 'td-sccp.jar', 'ipc-sccp.jar', 'mk-sccp.jar', '_locale.loads', 'i-button-help.xml');
|
'be-sccp.jar', 'tc-sccp.jar', 'td-sccp.jar', 'ipc-sccp.jar', 'mk-sccp.jar', '_locale.loads', 'i-button-help.xml');
|
||||||
|
|
||||||
|
# Show debug output
|
||||||
if ($print_debug == 'on') {
|
if ($print_debug == 'on') {
|
||||||
print_r("<br> Config:<pre>");
|
print_r("<br> Config:<pre>");
|
||||||
print_r($config);
|
print_r($config);
|
||||||
@@ -48,6 +48,7 @@ if ($print_debug == 'on') {
|
|||||||
print("</pre>");
|
print("</pre>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Start parsing the request
|
||||||
$req_file_full_path = '' ;
|
$req_file_full_path = '' ;
|
||||||
|
|
||||||
if (!empty($req_file)) {
|
if (!empty($req_file)) {
|
||||||
|
Reference in New Issue
Block a user