Code Duplication    Length = 8-19 lines in 5 locations

install/install.queries.php 4 locations

@@ 337-344 (lines=8) @@
334
335
                        // prepare config file
336
                        $tp_config_file = "../includes/config/tp.config.php";
337
                        if (file_exists($tp_config_file)) {
338
                            if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
339
                                echo '[{"error" : "includes/config/tp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
340
                                break;
341
                            } else {
342
                                unlink($tp_config_file);
343
                            }
344
                        }
345
                        $fh = fopen($tp_config_file, 'w');
346
                        $config_text = "<?php
347
global \$SETTINGS;
@@ 987-995 (lines=9) @@
984
                if ($task === "settings.php") {
985
                    $filename = "../includes/config/settings.php";
986
987
                    if (file_exists($filename)) {
988
                        if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
989
                            echo '[{"error" : "Setting.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
990
                            break;
991
                        } else {
992
                            $events .= "The file $filename already exist. A copy has been created.<br />";
993
                            unlink($filename);
994
                        }
995
                    }
996
997
                    // Encrypt the DB password
998
                    require_once "../sources/main.functions.php";
@@ 1035-1042 (lines=8) @@
1032
                    }
1033
                } elseif ($task === "sk.php") {
1034
//Create sk.php file
1035
                    if (file_exists($skFile)) {
1036
                        if (!copy($skFile, $skFile.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1037
                            echo '[{"error" : "sk.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
1038
                            break;
1039
                        } else {
1040
                            unlink($skFile);
1041
                        }
1042
                    }
1043
                    $fh = fopen($skFile, 'w');
1044
1045
                    $result = fwrite(
@@ 1110-1117 (lines=8) @@
1107
                    // update CSRFP TOKEN
1108
                    $csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php";
1109
                    $csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php";
1110
                    if (file_exists($csrfp_file)) {
1111
                        if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1112
                            echo '[{"error" : "csrfp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
1113
                            break;
1114
                        } else {
1115
                            $events .= "The file $csrfp_file already exist. A copy has been created.<br />";
1116
                        }
1117
                    }
1118
                    unlink($csrfp_file); // delete existing csrfp.config file
1119
                    copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
1120
                    $data = file_get_contents($csrfp_file);

sources/admin.queries.php 1 location

@@ 1579-1597 (lines=19) @@
1576
            }
1577
1578
            // before perform a copy of sk.php file
1579
            if (file_exists($tmp_skfile)) {
1580
                //Do a copy of the existing file
1581
                if (!copy(
1582
                    $tmp_skfile,
1583
                    $tmp_skfile.'.'.date(
1584
                        "Y_m_d",
1585
                        mktime(0, 0, 0, date('m'), date('d'), date('y'))
1586
                    )
1587
                )) {
1588
                    echo '[{"result" : "" , "error" : "Could NOT perform a copy of file: '.$tmp_skfile.'"}]';
1589
                    break;
1590
                } else {
1591
                    fileDelete($tmp_skfile);
1592
                }
1593
            } else {
1594
                // send back an error
1595
                echo '[{"result" : "" , "error" : "Could NOT access file: '.$tmp_skfile.'"}]';
1596
                break;
1597
            }
1598
        }
1599
1600
        // Write back values in sk.php file