Code Duplication    Length = 19-19 lines in 2 locations

install/cli-install.php 1 location

@@ 1205-1223 (lines=19) @@
1202
            // add template assignments
1203
            $assignments = explode(',', $assignments);
1204
1205
            if (count($assignments) > 0) {
1206
1207
                // remove existing tv -> template assignments
1208
                $ds = mysqli_query($sqlParser->conn,
1209
                    "SELECT id FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name' AND description='$desc';");
1210
                $row = mysqli_fetch_assoc($ds);
1211
                $id = $row["id"];
1212
                mysqli_query($sqlParser->conn,
1213
                    'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
1214
1215
                // add tv -> template assignments
1216
                foreach ($assignments as $assignment) {
1217
                    $template = mysqli_real_escape_string($conn, $assignment);
1218
                    $ts = mysqli_query($sqlParser->conn,
1219
                        "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$template';");
1220
                    if ($ds && $ts) {
1221
                        $tRow = mysqli_fetch_assoc($ts);
1222
                        $templateId = $tRow['id'];
1223
                        mysqli_query($sqlParser->conn,
1224
                            "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1225
                    }
1226
                }

install/src/controllers/install.php 1 location

@@ 393-411 (lines=19) @@
390
            // add template assignments
391
            $assignments = explode(',', $assignments);
392
393
            if (count($assignments) > 0) {
394
395
                // remove existing tv -> template assignments
396
                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
397
                $row = mysqli_fetch_assoc($ds);
398
                $id = $row["id"];
399
                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
400
401
                // add tv -> template assignments
402
                foreach ($assignments as $assignment) {
403
                    $template = mysqli_real_escape_string($conn, $assignment);
404
                    $ts = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$template';");
405
                    if ($ds && $ts) {
406
                        $tRow = mysqli_fetch_assoc($ts);
407
                        $templateId = $tRow['id'];
408
                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
409
                    }
410
                }
411
            }
412
        }
413
    }
414
}