Code Duplication    Length = 3-4 lines in 6 locations

src/Chamilo/CourseBundle/Component/CourseCopy/CourseArchiver.php 4 locations

@@ 86-89 (lines=4) @@
83
84
        $php_errormsg = '';
85
        $res = @mkdir($backup_dir, $perm_dirs);
86
        if ($res === false) {
87
            //TODO set and handle an error message telling the user to review the permissions on the archive directory
88
            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0);
89
        }
90
        // Write the course-object to the file
91
        $fp = @fopen($course_info_file, 'w');
92
        if ($fp === false) {
@@ 92-94 (lines=3) @@
89
        }
90
        // Write the course-object to the file
91
        $fp = @fopen($course_info_file, 'w');
92
        if ($fp === false) {
93
            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
94
        }
95
96
        $res = @fwrite($fp, base64_encode(serialize($course)));
97
        if ($res === false) {
@@ 97-99 (lines=3) @@
94
        }
95
96
        $res = @fwrite($fp, base64_encode(serialize($course)));
97
        if ($res === false) {
98
            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
99
        }
100
101
        $res = @fclose($fp);
102
        if ($res === false) {
@@ 102-104 (lines=3) @@
99
        }
100
101
        $res = @fclose($fp);
102
        if ($res === false) {
103
            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
104
        }
105
106
        // Copy all documents to the temp-dir
107
        if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {

main/inc/lib/api.lib.php 2 locations

@@ 4626-4628 (lines=3) @@
4623
    // Simple delete for a file.
4624
    if (is_file($dirname) || is_link($dirname)) {
4625
        $res = unlink($dirname);
4626
        if ($res === false) {
4627
            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4628
        }
4629
        return $res;
4630
    }
4631
@@ 4663-4665 (lines=3) @@
4660
4661
    if ($delete_only_content_in_folder == false) {
4662
        $res = rmdir($dirname);
4663
        if ($res === false) {
4664
            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4665
        }
4666
    }
4667
    return $res;
4668
}