Code Duplication    Length = 18-24 lines in 2 locations

install/cli-install.php 1 location

@@ 930-947 (lines=18) @@
927
}
928
929
// generate new site_id and set manager theme to default
930
if ($installMode == 0) {
931
    $siteid = uniqid('');
932
    mysqli_query($sqlParser->conn,
933
        "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
934
} else {
935
    // update site_id if missing
936
    $ds = mysqli_query($sqlParser->conn,
937
        "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
938
    if ($ds) {
939
        $r = mysqli_fetch_assoc($ds);
940
        $siteid = $r['setting_value'];
941
        if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
942
            $siteid = uniqid('');
943
            mysqli_query($sqlParser->conn,
944
                "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
945
        }
946
    }
947
}
948
949
// Reset database for installation of demo-site
950
if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) {

install/src/controllers/install.php 1 location

@@ 209-232 (lines=24) @@
206
207
    if ($installLevel === 4) {
208
        // generate new site_id and set manager theme to default
209
        if ($installMode == 0) {
210
            $siteid = uniqid('');
211
            mysqli_query(
212
                    $sqlParser->conn,
213
                "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"
214
            );
215
        } else {
216
            // update site_id if missing
217
            $ds = mysqli_query(
218
                    $sqlParser->conn,
219
                "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"
220
            );
221
            if ($ds) {
222
                $r = mysqli_fetch_assoc($ds);
223
                $siteid = $r['setting_value'];
224
                if ($siteid == '' || $siteid === 'MzGeQ2faT4Dw06+U49x3') {
225
                    $siteid = uniqid('');
226
                    mysqli_query(
227
                            $sqlParser->conn,
228
                        "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"
229
                    );
230
                }
231
            }
232
        }
233
234
        // Reset database for installation of demo-site
235
        if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) {