Code Duplication    Length = 3-4 lines in 6 locations

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

@@ 4552-4554 (lines=3) @@
4549
    // Simple delete for a file.
4550
    if (is_file($dirname) || is_link($dirname)) {
4551
        $res = unlink($dirname);
4552
        if ($res === false) {
4553
            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);
4554
        }
4555
        return $res;
4556
    }
4557
@@ 4589-4591 (lines=3) @@
4586
4587
    if ($delete_only_content_in_folder == false) {
4588
        $res = rmdir($dirname);
4589
        if ($res === false) {
4590
            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);
4591
        }
4592
    }
4593
    return $res;
4594
}

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])) {