Code Duplication    Length = 8-19 lines in 9 locations

sources/admin.queries.php 1 location

@@ 1594-1612 (lines=19) @@
1591
            }
1592
1593
            // before perform a copy of sk.php file
1594
            if (file_exists($tmp_skfile)) {
1595
                //Do a copy of the existing file
1596
                if (!copy(
1597
                    $tmp_skfile,
1598
                    $tmp_skfile.'.'.date(
1599
                        "Y_m_d",
1600
                        mktime(0, 0, 0, date('m'), date('d'), date('y'))
1601
                    )
1602
                )) {
1603
                    echo '[{"result" : "" , "error" : "Could NOT perform a copy of file: '.$tmp_skfile.'"}]';
1604
                    break;
1605
                } else {
1606
                    fileDelete($tmp_skfile);
1607
                }
1608
            } else {
1609
                // send back an error
1610
                echo '[{"result" : "" , "error" : "Could NOT access file: '.$tmp_skfile.'"}]';
1611
                break;
1612
            }
1613
        }
1614
1615
        // Write back values in sk.php file

install/upgrade_run_final.php 1 location

@@ 207-214 (lines=8) @@
204
* UPDATE CONFIG file
205
*/
206
$tp_config_file = "../includes/config/tp.config.php";
207
if (file_exists($tp_config_file)) {
208
    if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
209
        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.'"}]';
210
        return false;
211
    } else {
212
        unlink($tp_config_file);
213
    }
214
}
215
$file_handler = fopen($tp_config_file, 'w');
216
$config_text = "";
217
$any_settings = false;

install/upgrade_ajax.php 1 location

@@ 812-819 (lines=8) @@
809
                // update CSRFP TOKEN
810
                $csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php";
811
                $csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php";
812
                if (file_exists($csrfp_file) === true) {
813
                    if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
814
                        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.'"}]';
815
                        break;
816
                    } else {
817
                        $events .= "The file $csrfp_file already exist. A copy has been created.<br />";
818
                    }
819
                }
820
                unlink($csrfp_file); // delete existing csrfp.config file
821
                copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
822
                $data = file_get_contents("../includes/libraries/csrfp/libs/csrfp.config.php");

install/upgrade_run_2.1.27.php 1 location

@@ 732-739 (lines=8) @@
729
* Introduce new CONFIG file
730
*/
731
$tp_config_file = "../includes/config/tp.config.php";
732
if (file_exists($tp_config_file)) {
733
    if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
734
        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.'"}]';
735
        return false;
736
    } else {
737
        unlink($tp_config_file);
738
    }
739
}
740
$file_handler = fopen($tp_config_file, 'w');
741
$config_text = "";
742
$any_settings = false;

install/install.queries.php 5 locations

@@ 381-388 (lines=8) @@
378
379
                        // prepare config file
380
                        $tp_config_file = "../includes/config/tp.config.php";
381
                        if (file_exists($tp_config_file)) {
382
                            if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
383
                                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.'"}]';
384
                                break;
385
                            } else {
386
                                unlink($tp_config_file);
387
                            }
388
                        }
389
                        $file_handler = fopen($tp_config_file, 'w');
390
                        $config_text = "<?php
391
global \$SETTINGS;
@@ 1031-1038 (lines=8) @@
1028
                    // 0- check if exists
1029
                    $filename_seckey = $securePath."/teampass-seckey.txt";
1030
1031
                    if (file_exists($filename_seckey)) {
1032
                        if (!copy($filename_seckey, $filename_seckey.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1033
                            echo '[{"error" : "File `$filename_seckey` already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
1034
                            break;
1035
                        } else {
1036
                            unlink($filename);
1037
                        }
1038
                    }
1039
1040
                    // 1- generate saltkey
1041
                    require_once '../includes/libraries/Encryption/Encryption/Crypto.php';
@@ 1063-1070 (lines=8) @@
1060
                    // Now create settings file
1061
                    $filename = "../includes/config/settings.php";
1062
1063
                    if (file_exists($filename)) {
1064
                        if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1065
                            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.'"}]';
1066
                            break;
1067
                        } else {
1068
                            unlink($filename);
1069
                        }
1070
                    }
1071
1072
                    // Encrypt the DB password
1073
                    $encrypted_text = encryptFollowingDefuse(
@@ 1112-1119 (lines=8) @@
1109
                    }
1110
                } elseif ($task === "sk.php") {
1111
//Create sk.php file
1112
                    if (file_exists($skFile)) {
1113
                        if (!copy($skFile, $skFile.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1114
                            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.'"}]';
1115
                            break;
1116
                        } else {
1117
                            unlink($skFile);
1118
                        }
1119
                    }
1120
                    $file_handler = fopen($skFile, 'w');
1121
1122
                    $result = fwrite(
@@ 1166-1173 (lines=8) @@
1163
                    // update CSRFP TOKEN
1164
                    $csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php";
1165
                    $csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php";
1166
                    if (file_exists($csrfp_file)) {
1167
                        if (!copy($csrfp_file, $csrfp_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
1168
                            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.'"}]';
1169
                            break;
1170
                        } else {
1171
                            $events .= "The file $csrfp_file already exist. A copy has been created.<br />";
1172
                        }
1173
                    }
1174
                    unlink($csrfp_file); // delete existing csrfp.config file
1175
                    copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
1176
                    $data = file_get_contents($csrfp_file);