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

@@ 4481-4483 (lines=3) @@
4478
    // Simple delete for a file.
4479
    if (is_file($dirname) || is_link($dirname)) {
4480
        $res = unlink($dirname);
4481
        if ($res === false) {
4482
            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);
4483
        }
4484
        return $res;
4485
    }
4486
@@ 4518-4520 (lines=3) @@
4515
4516
    if ($delete_only_content_in_folder == false) {
4517
        $res = rmdir($dirname);
4518
        if ($res === false) {
4519
            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);
4520
        }
4521
    }
4522
    return $res;
4523
}