Code Duplication    Length = 3-4 lines in 6 locations

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

@@ 4526-4528 (lines=3) @@
4523
    // Simple delete for a file.
4524
    if (is_file($dirname) || is_link($dirname)) {
4525
        $res = unlink($dirname);
4526
        if ($res === false) {
4527
            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);
4528
        }
4529
        return $res;
4530
    }
4531
@@ 4563-4565 (lines=3) @@
4560
4561
    if ($delete_only_content_in_folder == false) {
4562
        $res = rmdir($dirname);
4563
        if ($res === false) {
4564
            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);
4565
        }
4566
    }
4567
    return $res;
4568
}

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