@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function courses_list($security_key, $visibilities = 'public') { |
24 | 24 | |
25 | - global $_configuration; |
|
25 | + global $_configuration; |
|
26 | 26 | |
27 | - // Check if this script is launch by server and if security key is ok. |
|
28 | - if ($security_key != $_configuration['security_key']) { |
|
29 | - return array('error_msg' => 'Security check failed'); |
|
30 | - } |
|
27 | + // Check if this script is launch by server and if security key is ok. |
|
28 | + if ($security_key != $_configuration['security_key']) { |
|
29 | + return array('error_msg' => 'Security check failed'); |
|
30 | + } |
|
31 | 31 | |
32 | - $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); |
|
32 | + $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); |
|
33 | 33 | |
34 | - $courses_list = array(); |
|
34 | + $courses_list = array(); |
|
35 | 35 | |
36 | - if (!is_array($visibilities)) { |
|
37 | - $tmp = $visibilities; |
|
38 | - $visibilities = array($tmp); |
|
39 | - } |
|
40 | - foreach ($visibilities as $visibility) { |
|
41 | - if (!in_array($visibility, array_keys($vis))) { |
|
42 | - return array('error_msg' => 'Security check failed'); |
|
43 | - } |
|
44 | - $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); |
|
45 | - foreach ($courses_list_tmp as $index => $course) { |
|
46 | - $course_info = CourseManager::get_course_information($course['code']); |
|
47 | - $courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); |
|
48 | - } |
|
49 | - } |
|
50 | - return $courses_list; |
|
36 | + if (!is_array($visibilities)) { |
|
37 | + $tmp = $visibilities; |
|
38 | + $visibilities = array($tmp); |
|
39 | + } |
|
40 | + foreach ($visibilities as $visibility) { |
|
41 | + if (!in_array($visibility, array_keys($vis))) { |
|
42 | + return array('error_msg' => 'Security check failed'); |
|
43 | + } |
|
44 | + $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); |
|
45 | + foreach ($courses_list_tmp as $index => $course) { |
|
46 | + $course_info = CourseManager::get_course_information($course['code']); |
|
47 | + $courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); |
|
48 | + } |
|
49 | + } |
|
50 | + return $courses_list; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | header('Content-Type: text/xml; charset=utf-8'); |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | echo '<courseslist>'; |
56 | 56 | |
57 | 57 | if (empty($_POST['security-key']) || empty($_POST['visibility'])) { |
58 | - echo '<errormsg>Invalid parameters, this script expects a security-key and a visibility parameters</errormsg>'; |
|
58 | + echo '<errormsg>Invalid parameters, this script expects a security-key and a visibility parameters</errormsg>'; |
|
59 | 59 | } else { |
60 | - $courses_list = courses_list($_POST['security-key'], $_POST['visibility']); |
|
61 | - foreach ($courses_list as $code => $cd) { |
|
62 | - echo '<course>'; |
|
63 | - echo '<code>' , $code , '</code>'; |
|
64 | - echo '<title>' , $cd['title'] , '</title>'; |
|
65 | - echo '<url>' , $cd['url'] , '</url>'; |
|
66 | - echo '<teacher>' , $cd['teacher'] , '</teacher>'; |
|
67 | - echo '<language>' , $cd['language'] , '</language>'; |
|
68 | - echo '</course>'; |
|
69 | - } |
|
60 | + $courses_list = courses_list($_POST['security-key'], $_POST['visibility']); |
|
61 | + foreach ($courses_list as $code => $cd) { |
|
62 | + echo '<course>'; |
|
63 | + echo '<code>' , $code , '</code>'; |
|
64 | + echo '<title>' , $cd['title'] , '</title>'; |
|
65 | + echo '<url>' , $cd['url'] , '</url>'; |
|
66 | + echo '<teacher>' , $cd['teacher'] , '</teacher>'; |
|
67 | + echo '<language>' , $cd['language'] , '</language>'; |
|
68 | + echo '</course>'; |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | echo '</courseslist>'; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $result = $objExercise->read($exercise_id); |
18 | 18 | |
19 | 19 | if (!$result) { |
20 | - api_not_allowed(true); |
|
20 | + api_not_allowed(true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $interbreadcrumb[] = array( |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | api_block_anonymous_users(); |
18 | 18 | |
19 | 19 | if ($_user['user_id']!= api_get_user_id() || api_get_user_id()==0 || $_user['user_id']==0) { |
20 | - api_not_allowed(); |
|
21 | - die(); |
|
20 | + api_not_allowed(); |
|
21 | + die(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if(!isset($_GET['title']) || !isset($_GET['type']) || !isset($_GET['image'])) { |
25 | - api_not_allowed(); |
|
26 | - die(); |
|
25 | + api_not_allowed(); |
|
26 | + die(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | if(!isset($_SESSION['paint_dir']) || !isset($_SESSION['whereami']) ){ |
30 | - api_not_allowed(); |
|
31 | - die(); |
|
30 | + api_not_allowed(); |
|
31 | + die(); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | //pixlr return |
@@ -72,22 +72,22 @@ discard block |
||
72 | 72 | $filename = disable_dangerous_file($filename); |
73 | 73 | |
74 | 74 | if (strlen(trim($filename))==0) { |
75 | - echo "The title is empty";//if title is empty, headers Content-Type = application/octet-stream, then not create a new title here please |
|
76 | - exit; |
|
75 | + echo "The title is empty";//if title is empty, headers Content-Type = application/octet-stream, then not create a new title here please |
|
76 | + exit; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | //check file_get_contents |
80 | 80 | if ($contents === false) { |
81 | - echo "I cannot read: ".$urlcontents; |
|
81 | + echo "I cannot read: ".$urlcontents; |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Extension security |
86 | 86 | if($extension!= 'jpg' && $extension!= 'png' && $extension!= 'pxd'){ |
87 | - die(); |
|
87 | + die(); |
|
88 | 88 | } |
89 | 89 | if($extension=='pxd') { |
90 | - echo "pxd file type does not supported";// not secure because check security headers and finfo() return Content-Type = application/octet-stream |
|
90 | + echo "pxd file type does not supported";// not secure because check security headers and finfo() return Content-Type = application/octet-stream |
|
91 | 91 | exit; |
92 | 92 | } |
93 | 93 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | $headers = get_headers($urlcontents, 1); |
96 | 96 | $content_type = explode("/", $headers['Content-Type']); |
97 | 97 | if ($content_type[0] != "image") { |
98 | - echo "Invalid file type"; |
|
99 | - exit; |
|
98 | + echo "Invalid file type"; |
|
99 | + exit; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | //Verify that the file is an image. Fileinfo method |
@@ -114,49 +114,49 @@ discard block |
||
114 | 114 | $title = $title.'.'.$extension; |
115 | 115 | |
116 | 116 | if($currentTool=='document/createpaint'){ |
117 | - //check save as and prevent rewrite an older file with same name |
|
118 | - if (0 != $groupId){ |
|
117 | + //check save as and prevent rewrite an older file with same name |
|
118 | + if (0 != $groupId){ |
|
119 | 119 | $group_properties = GroupManager :: get_group_properties($groupId); |
120 | 120 | $groupPath = $group_properties['directory']; |
121 | - } else { |
|
122 | - $groupPath =''; |
|
123 | - } |
|
124 | - |
|
125 | - if (file_exists($saveDir.'/'.$filename.'.'.$extension)){ |
|
126 | - $i = 1; |
|
127 | - while (file_exists($saveDir.'/'.$filename.'_'.$i.'.'.$extension)) $i++; |
|
128 | - $paintFileName = $filename . '_' . $i . '.'.$extension; |
|
129 | - $title = $filename . '_' . $i . '.'.$extension; |
|
130 | - } |
|
131 | - |
|
132 | - // |
|
133 | - $documentPath = $saveDir.'/'.$paintFileName; |
|
134 | - //add new document to disk |
|
135 | - file_put_contents( $documentPath, $contents ); |
|
136 | - //add document to database |
|
137 | - $doc_id = add_document($_course, $relativeUrlPath.'/'.$paintFileName, 'file', filesize($documentPath), $title); |
|
138 | - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
121 | + } else { |
|
122 | + $groupPath =''; |
|
123 | + } |
|
124 | + |
|
125 | + if (file_exists($saveDir.'/'.$filename.'.'.$extension)){ |
|
126 | + $i = 1; |
|
127 | + while (file_exists($saveDir.'/'.$filename.'_'.$i.'.'.$extension)) $i++; |
|
128 | + $paintFileName = $filename . '_' . $i . '.'.$extension; |
|
129 | + $title = $filename . '_' . $i . '.'.$extension; |
|
130 | + } |
|
131 | + |
|
132 | + // |
|
133 | + $documentPath = $saveDir.'/'.$paintFileName; |
|
134 | + //add new document to disk |
|
135 | + file_put_contents( $documentPath, $contents ); |
|
136 | + //add document to database |
|
137 | + $doc_id = add_document($_course, $relativeUrlPath.'/'.$paintFileName, 'file', filesize($documentPath), $title); |
|
138 | + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
139 | 139 | |
140 | 140 | }elseif($currentTool=='document/editpaint'){ |
141 | 141 | |
142 | - $documentPath = $saveDir.'/'.$paintFileName; |
|
143 | - //add new document to disk |
|
144 | - file_put_contents( $documentPath, $contents ); |
|
145 | - |
|
146 | - //check path |
|
147 | - if(!isset($_SESSION['paint_file'])){ |
|
148 | - api_not_allowed(); |
|
149 | - die(); |
|
150 | - } |
|
151 | - if($_SESSION['paint_file']==$paintFileName){ |
|
152 | - $document_id = DocumentManager::get_document_id($_course, $relativeUrlPath.'/'.$paintFileName); |
|
153 | - update_existing_document($_course, $document_id, filesize($documentPath), null); |
|
154 | - api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
155 | - }else{ |
|
156 | - //add a new document |
|
157 | - $doc_id = add_document($_course, $relativeUrlPath.'/'.$paintFileName, 'file', filesize($documentPath), $title); |
|
158 | - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
159 | - } |
|
142 | + $documentPath = $saveDir.'/'.$paintFileName; |
|
143 | + //add new document to disk |
|
144 | + file_put_contents( $documentPath, $contents ); |
|
145 | + |
|
146 | + //check path |
|
147 | + if(!isset($_SESSION['paint_file'])){ |
|
148 | + api_not_allowed(); |
|
149 | + die(); |
|
150 | + } |
|
151 | + if($_SESSION['paint_file']==$paintFileName){ |
|
152 | + $document_id = DocumentManager::get_document_id($_course, $relativeUrlPath.'/'.$paintFileName); |
|
153 | + update_existing_document($_course, $document_id, filesize($documentPath), null); |
|
154 | + api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
155 | + }else{ |
|
156 | + //add a new document |
|
157 | + $doc_id = add_document($_course, $relativeUrlPath.'/'.$paintFileName, 'file', filesize($documentPath), $title); |
|
158 | + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
159 | + } |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | unset($_SESSION['temp_realpath_image']); |
172 | 172 | |
173 | 173 | if (!isset($_SESSION['exit_pixlr'])) { |
174 | - $location=api_get_path(WEB_CODE_PATH).'document/document.php'; |
|
175 | - echo '<script>window.parent.location.href="'.$location.'"</script>'; |
|
176 | - api_not_allowed(true); |
|
174 | + $location=api_get_path(WEB_CODE_PATH).'document/document.php'; |
|
175 | + echo '<script>window.parent.location.href="'.$location.'"</script>'; |
|
176 | + api_not_allowed(true); |
|
177 | 177 | } else { |
178 | - echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>'; |
|
179 | - $location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']); |
|
180 | - echo '<script>window.parent.location.href="'.$location.'"</script>'; |
|
181 | - unset($_SESSION['exit_pixlr']); |
|
178 | + echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>'; |
|
179 | + $location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']); |
|
180 | + echo '<script>window.parent.location.href="'.$location.'"</script>'; |
|
181 | + unset($_SESSION['exit_pixlr']); |
|
182 | 182 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | if ($quota_bytes != 0) { |
88 | - $quota_percentage = round($quota_bytes/$total_quota_bytes, 2)*100; |
|
88 | + $quota_percentage = round($quota_bytes/$total_quota_bytes, 2)*100; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $session[] = array(addslashes(get_lang('Teacher').': '.$user_name).' ('.format_file_size($quota_bytes).')', $quota_percentage); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | $session[] = array(addslashes(sprintf(get_lang('TeacherXInSession'),$user_name)), $quota_percentage); |
105 | 105 | |
106 | - } |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $quota_percentage = round(($total_quota_bytes - $used_quota_bytes)/$total_quota_bytes, 2)*100; |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $result = $objExercise->read($exercise_id); |
18 | 18 | |
19 | 19 | if (!$result) { |
20 | - api_not_allowed(true); |
|
20 | + api_not_allowed(true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $interbreadcrumb[] = array( |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | //user has submitted a file |
50 | 50 | if (isset($_FILES['user_upload'])) { |
51 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
52 | - if ($upload_ok) { |
|
53 | - //file got on the server without problems, now process it |
|
51 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
52 | + if ($upload_ok) { |
|
53 | + //file got on the server without problems, now process it |
|
54 | 54 | $new_path = handle_uploaded_document( |
55 | 55 | $_course, |
56 | 56 | $_FILES['user_upload'], |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | $_POST['unzip'], |
63 | 63 | $_POST['if_exists'] |
64 | 64 | ); |
65 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
66 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
65 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
66 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
67 | 67 | |
68 | - if ($new_path && ($new_comment || $new_title)) |
|
69 | - if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
70 | - $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
71 | - $ct = ''; |
|
72 | - if ($new_comment) $ct .= ", comment='$new_comment'"; |
|
73 | - if ($new_title) $ct .= ", title='$new_title'"; |
|
74 | - Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
75 | - } |
|
68 | + if ($new_path && ($new_comment || $new_title)) |
|
69 | + if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
70 | + $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
71 | + $ct = ''; |
|
72 | + if ($new_comment) $ct .= ", comment='$new_comment'"; |
|
73 | + if ($new_title) $ct .= ", title='$new_title'"; |
|
74 | + Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
75 | + } |
|
76 | 76 | //check for missing images in html files |
77 | 77 | $missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path); |
78 | 78 | if ($missing_files) { |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | } |
129 | 129 | //they want to create a directory |
130 | 130 | if (isset($_POST['create_dir']) && $_POST['dirname']!='') { |
131 | - $added_slash = ($path=='/')?'':'/'; |
|
132 | - $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
131 | + $added_slash = ($path=='/')?'':'/'; |
|
132 | + $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
133 | 133 | $created_dir = create_unexisting_directory( |
134 | 134 | $_course, |
135 | 135 | $_user['user_id'], |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | if (isset($_GET['createdir'])) { |
152 | - //create the form that asks for the directory name |
|
153 | - $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
154 | - $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
155 | - $new_folder_text .= get_lang('NewDir') .' '; |
|
156 | - $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
157 | - $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
158 | - $new_folder_text .= '</form>'; |
|
159 | - //show the form |
|
160 | - Display::display_normal_message($new_folder_text); |
|
152 | + //create the form that asks for the directory name |
|
153 | + $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
154 | + $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
155 | + $new_folder_text .= get_lang('NewDir') .' '; |
|
156 | + $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
157 | + $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
158 | + $new_folder_text .= '</form>'; |
|
159 | + //show the form |
|
160 | + Display::display_normal_message($new_folder_text); |
|
161 | 161 | } else { //give them a link to create a directory |
162 | 162 | ?> |
163 | 163 | <p> |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $result = $objExercise->read($exercise_id); |
18 | 18 | |
19 | 19 | if (!$result) { |
20 | - api_not_allowed(true); |
|
20 | + api_not_allowed(true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $interbreadcrumb[] = array( |
@@ -261,7 +261,7 @@ |
||
261 | 261 | ?> |
262 | 262 | <option value="<?php echo $enreg['user_id']; ?>"><?php echo $enreg['username'].' - '.api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></option> |
263 | 263 | <?php |
264 | - } |
|
264 | + } |
|
265 | 265 | unset($nosessionUsersList); |
266 | 266 | ?> |
267 | 267 | </select> |
@@ -60,9 +60,9 @@ |
||
60 | 60 | |
61 | 61 | <?php |
62 | 62 | if (isset($action) && ($action=="synchro")) { |
63 | - $included=true; |
|
64 | - require('ldap_synchro.php'); |
|
65 | - Display :: display_normal_message($message,false); |
|
63 | + $included=true; |
|
64 | + require('ldap_synchro.php'); |
|
65 | + Display :: display_normal_message($message,false); |
|
66 | 66 | } |
67 | 67 | Display::display_footer(); |
68 | 68 | ?> |