- sql_dir = data_dir / 'sql'
-
- sql = _get_standard_function_sql(conn, config, sql_dir,
- enable_diff_updates, enable_debug)
- sql += _get_partition_function_sql(conn, sql_dir)
-
- with conn.cursor() as cur:
- cur.execute(sql)
-
- conn.commit()
+ if not basedir.exists():
+ LOG.info('Creating website directory.')
+ basedir.mkdir()
+
+ template = dedent("""\
+ <?php
+
+ @define('CONST_Debug', $_GET['debug'] ?? false);
+ @define('CONST_LibDir', '{0}');
+ @define('CONST_TokenizerDir', '{2}');
+ @define('CONST_NominatimVersion', '{1[0]}.{1[1]}.{1[2]}-{1[3]}');
+
+ """.format(config.lib_dir.php, NOMINATIM_VERSION,
+ config.project_dir / 'tokenizer'))
+
+ for php_name, conf_name, var_type in PHP_CONST_DEFS:
+ if var_type == bool:
+ varout = 'true' if config.get_bool(conf_name) else 'false'
+ elif var_type == int:
+ varout = getattr(config, conf_name)
+ elif not getattr(config, conf_name):
+ varout = 'false'
+ else:
+ varout = "'{}'".format(getattr(config, conf_name).replace("'", "\\'"))
+
+ template += "@define('CONST_{}', {});\n".format(php_name, varout)
+
+ template += "\nrequire_once('{}/website/{{}}');\n".format(config.lib_dir.php)
+
+ search_name_table_exists = bool(conn and conn.table_exists('search_name'))
+
+ for script in WEBSITE_SCRIPTS:
+ if not search_name_table_exists and script == 'search.php':
+ (basedir / script).write_text(template.format('reverse-only-search.php'), 'utf-8')
+ else:
+ (basedir / script).write_text(template.format(script), 'utf-8')