Code Duplication    Length = 3-4 lines in 6 locations

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

@@ 85-88 (lines=4) @@
82
83
        $php_errormsg = '';
84
        $res = @mkdir($backup_dir, $perm_dirs);
85
        if ($res === false) {
86
            //TODO set and handle an error message telling the user to review the permissions on the archive directory
87
            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);
88
        }
89
        // Write the course-object to the file
90
        $fp = @fopen($course_info_file, 'w');
91
        if ($fp === false) {
@@ 91-93 (lines=3) @@
88
        }
89
        // Write the course-object to the file
90
        $fp = @fopen($course_info_file, 'w');
91
        if ($fp === false) {
92
            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);
93
        }
94
95
        $res = @fwrite($fp, base64_encode(serialize($course)));
96
        if ($res === false) {
@@ 96-98 (lines=3) @@
93
        }
94
95
        $res = @fwrite($fp, base64_encode(serialize($course)));
96
        if ($res === false) {
97
            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);
98
        }
99
100
        $res = @fclose($fp);
101
        if ($res === false) {
@@ 101-103 (lines=3) @@
98
        }
99
100
        $res = @fclose($fp);
101
        if ($res === false) {
102
            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);
103
        }
104
105
        // Copy all documents to the temp-dir
106
        if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {

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

@@ 4510-4512 (lines=3) @@
4507
    // Simple delete for a file.
4508
    if (is_file($dirname) || is_link($dirname)) {
4509
        $res = unlink($dirname);
4510
        if ($res === false) {
4511
            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);
4512
        }
4513
        return $res;
4514
    }
4515
@@ 4547-4549 (lines=3) @@
4544
4545
    if ($delete_only_content_in_folder == false) {
4546
        $res = rmdir($dirname);
4547
        if ($res === false) {
4548
            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);
4549
        }
4550
    }
4551
    return $res;
4552
}