- $rOutputFile = fopen(CONST_InstallPath.'/settings/settings-frontend.php', 'w');
-
- fwrite($rOutputFile, "<?php
-@define('CONST_BasePath', '".CONST_BasePath."');
-if (file_exists(getenv('NOMINATIM_SETTINGS'))) require_once(getenv('NOMINATIM_SETTINGS'));
-
-@define('CONST_Database_DSN', '".CONST_Database_DSN."'); // or add ;host=...;port=...;user=...;password=...
-@define('CONST_Default_Language', ".(CONST_Default_Language ? ("'".CONST_Default_Language."'") : 'false').");
-@define('CONST_Default_Lat', ".CONST_Default_Lat.");
-@define('CONST_Default_Lon', ".CONST_Default_Lon.");
-@define('CONST_Default_Zoom', ".CONST_Default_Zoom.");
-@define('CONST_Map_Tile_URL', '".CONST_Map_Tile_URL."');
-@define('CONST_Map_Tile_Attribution', '".CONST_Map_Tile_Attribution."'); // Set if tile source isn't osm.org
-@define('CONST_Log_DB', ".(CONST_Log_DB ? 'true' : 'false').");
-@define('CONST_Log_File', ".(CONST_Log_File ? ("'".CONST_Log_File."'") : 'false').");
-@define('CONST_Max_Word_Frequency', '".CONST_Max_Word_Frequency."');
-@define('CONST_NoAccessControl', ".CONST_NoAccessControl.");
-@define('CONST_Places_Max_ID_count', ".CONST_Places_Max_ID_count.");
-@define('CONST_PolygonOutput_MaximumTypes', ".CONST_PolygonOutput_MaximumTypes.");
-@define('CONST_Search_AreaPolygons', ".CONST_Search_AreaPolygons.");
-@define('CONST_Search_BatchMode', ".(CONST_Search_BatchMode ? 'true' : 'false').");
-@define('CONST_Search_NameOnlySearchFrequencyThreshold', ".CONST_Search_NameOnlySearchFrequencyThreshold.");
-@define('CONST_Search_ReversePlanForAll', ".CONST_Search_ReversePlanForAll.");
-@define('CONST_Term_Normalization_Rules', \"".CONST_Term_Normalization_Rules."\");
-@define('CONST_Use_Aux_Location_data', ".(CONST_Use_Aux_Location_data ? 'true' : 'false').");
-@define('CONST_Use_US_Tiger_Data', ".(CONST_Use_US_Tiger_Data ? 'true' : 'false').");
-@define('CONST_Website_BaseURL', '".CONST_Website_BaseURL."');
-");
- info(CONST_InstallPath.'/settings/settings-frontend.php has been set up successfully');
+ if (!is_dir(CONST_InstallDir.'/website')) {
+ info('Creating directory for website scripts at: '.CONST_InstallDir.'/website');
+ mkdir(CONST_InstallDir.'/website');
+ }
+
+ $aScripts = array(
+ 'deletable.php',
+ 'details.php',
+ 'lookup.php',
+ 'polygons.php',
+ 'reverse.php',
+ 'search.php',
+ 'status.php'
+ );
+
+ foreach ($aScripts as $sScript) {
+ $rFile = fopen(CONST_InstallDir.'/website/'.$sScript, 'w');
+
+ fwrite($rFile, "<?php\n\n");
+ fwrite($rFile, '@define(\'CONST_Debug\', $_GET[\'debug\'] ?? false);'."\n\n");
+
+ fwriteConstDef($rFile, 'LibDir', CONST_LibDir);
+ fwriteConstDef($rFile, 'DataDir', CONST_DataDir);
+ fwriteConstDef($rFile, 'InstallDir', CONST_InstallDir);
+ fwriteConstDef($rFile, 'Database_DSN', getSetting('DATABASE_DSN'));
+ fwriteConstDef($rFile, 'Default_Language', getSetting('DEFAULT_LANGUAGE'));
+ fwriteConstDef($rFile, 'Log_DB', getSettingBool('LOG_DB'));
+ fwriteConstDef($rFile, 'Log_File', getSetting('LOG_FILE'));
+ fwriteConstDef($rFile, 'Max_Word_Frequency', (int)getSetting('MAX_WORD_FREQUENCY'));
+ fwriteConstDef($rFile, 'NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
+ fwriteConstDef($rFile, 'Places_Max_ID_count', (int)getSetting('LOOKUP_MAX_COUNT'));
+ fwriteConstDef($rFile, 'PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
+ fwriteConstDef($rFile, 'Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
+ fwriteConstDef($rFile, 'Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
+ fwriteConstDef($rFile, 'Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
+ fwriteConstDef($rFile, 'Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
+ fwriteConstDef($rFile, 'Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
+ fwriteConstDef($rFile, 'MapIcon_URL', getSetting('MAPICON_URL'));
+
+ // XXX scripts should go into the library.
+ fwrite($rFile, 'require_once(\''.CONST_DataDir.'/website/'.$sScript."');\n");
+ fclose($rFile);
+
+ chmod(CONST_InstallDir.'/website/'.$sScript, 0755);
+ }