Code Duplication    Length = 3-4 lines in 6 locations

main/coursecopy/classes/CourseArchiver.class.php 4 locations

@@ 57-60 (lines=4) @@
54
        $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip';
55
        $php_errormsg = '';
56
        $res = @mkdir($backup_dir, $perm_dirs);
57
        if ($res === false) {
58
            //TODO set and handle an error message telling the user to review the permissions on the archive directory
59
            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);
60
        }
61
        // Write the course-object to the file
62
        $fp = @fopen($course_info_file, 'w');
63
        if ($fp === false) {
@@ 63-65 (lines=3) @@
60
        }
61
        // Write the course-object to the file
62
        $fp = @fopen($course_info_file, 'w');
63
        if ($fp === false) {
64
            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);
65
        }
66
67
        $res = @fwrite($fp, base64_encode(serialize($course)));
68
        if ($res === false) {
@@ 68-70 (lines=3) @@
65
        }
66
67
        $res = @fwrite($fp, base64_encode(serialize($course)));
68
        if ($res === false) {
69
            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);
70
        }
71
72
        $res = @fclose($fp);
73
        if ($res === false) {
@@ 73-75 (lines=3) @@
70
        }
71
72
        $res = @fclose($fp);
73
        if ($res === false) {
74
            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);
75
        }
76
77
        // Copy all documents to the temp-dir
78
        if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {

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

@@ 4726-4728 (lines=3) @@
4723
    // Simple delete for a file.
4724
    if (is_file($dirname) || is_link($dirname)) {
4725
        $res = unlink($dirname);
4726
        if ($res === false) {
4727
            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);
4728
        }
4729
        return $res;
4730
    }
4731
@@ 4763-4765 (lines=3) @@
4760
4761
    if ($delete_only_content_in_folder == false) {
4762
        $res = rmdir($dirname);
4763
        if ($res === false) {
4764
            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);
4765
        }
4766
    }
4767
    return $res;
4768
}