@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | */ |
11 | 11 | exit; |
12 | 12 | function encodeRFC5987ValueChars ($str) { |
13 | - // See http://tools.ietf.org/html/rfc5987#section-3.2.1 |
|
14 | - // For better readability within headers, add back the characters escaped by rawurlencode but still allowable |
|
15 | - // Although RFC3986 reserves "!" (%21), RFC5987 does not |
|
16 | - return preg_replace_callback('@%(2[1346B]|5E|60|7C)@', function ($matches) { |
|
17 | - return chr('0x' . $matches[1]); |
|
18 | - }, rawurlencode($str)); |
|
13 | + // See http://tools.ietf.org/html/rfc5987#section-3.2.1 |
|
14 | + // For better readability within headers, add back the characters escaped by rawurlencode but still allowable |
|
15 | + // Although RFC3986 reserves "!" (%21), RFC5987 does not |
|
16 | + return preg_replace_callback('@%(2[1346B]|5E|60|7C)@', function ($matches) { |
|
17 | + return chr('0x' . $matches[1]); |
|
18 | + }, rawurlencode($str)); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | require('allowedMimeTypes.php'); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $mime = !isset($_POST['mime']) || !in_array($_POST['mime'], $allowedMimeTypesBySuffix) ? 'image/svg+xml;charset=UTF-8' : $_POST['mime']; |
24 | 24 | |
25 | 25 | if (!isset($_POST['output_svg']) && !isset($_POST['output_img'])) { |
26 | - die('post fail'); |
|
26 | + die('post fail'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $file = ''; |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | $suffix = '.' . array_search($mime, $allowedMimeTypesBySuffix); |
32 | 32 | |
33 | 33 | if (isset($_POST['filename']) && strlen($_POST['filename']) > 0) { |
34 | - $file = $_POST['filename'] . $suffix; |
|
34 | + $file = $_POST['filename'] . $suffix; |
|
35 | 35 | } else { |
36 | - $file = 'image' . $suffix; |
|
36 | + $file = 'image' . $suffix; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ($suffix == '.svg') { |
40 | - $contents = $_POST['output_svg']; |
|
40 | + $contents = $_POST['output_svg']; |
|
41 | 41 | } else { |
42 | - $contents = $_POST['output_img']; |
|
43 | - $pos = (strpos($contents, 'base64,') + 7); |
|
44 | - $contents = base64_decode(substr($contents, $pos)); |
|
42 | + $contents = $_POST['output_img']; |
|
43 | + $pos = (strpos($contents, 'base64,') + 7); |
|
44 | + $contents = base64_decode(substr($contents, $pos)); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | header("Cache-Control: public"); |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | // See http://tools.ietf.org/html/rfc6266#section-4.1 |
51 | 51 | header("Content-Disposition: attachment; filename*=UTF-8''" . encodeRFC5987ValueChars( |
52 | - // preg_replace('@[\\\\/:*?"<>|]@', '', $file) // If we wanted to strip Windows-disallowed characters server-side (but not a security issue, so we can strip client-side instead) |
|
53 | - $file |
|
52 | + // preg_replace('@[\\\\/:*?"<>|]@', '', $file) // If we wanted to strip Windows-disallowed characters server-side (but not a security issue, so we can strip client-side instead) |
|
53 | + $file |
|
54 | 54 | )); |
55 | 55 | header("Content-Type: " . $mime); |
56 | 56 | header("Content-Transfer-Encoding: binary"); |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | - // You must first create a file "savefile_config.php" in this extensions directory and do whatever |
|
3 | - // checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG |
|
4 | - // files to your server which may cause disk space or possibly security problems |
|
5 | - require('savefile_config.php'); |
|
6 | - if (!isset($_POST['output_svg'])) { |
|
7 | - print "You must supply output_svg"; |
|
8 | - exit; |
|
9 | - } |
|
10 | - $svg = $_POST['output_svg']; |
|
11 | - $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows |
|
2 | + // You must first create a file "savefile_config.php" in this extensions directory and do whatever |
|
3 | + // checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG |
|
4 | + // files to your server which may cause disk space or possibly security problems |
|
5 | + require('savefile_config.php'); |
|
6 | + if (!isset($_POST['output_svg'])) { |
|
7 | + print "You must supply output_svg"; |
|
8 | + exit; |
|
9 | + } |
|
10 | + $svg = $_POST['output_svg']; |
|
11 | + $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows |
|
12 | 12 | |
13 | - $fh = fopen($filename, 'w') or die("Can't open file"); |
|
14 | - fwrite($fh, $svg); |
|
15 | - fclose($fh); |
|
13 | + $fh = fopen($filename, 'w') or die("Can't open file"); |
|
14 | + fwrite($fh, $svg); |
|
15 | + fclose($fh); |
|
16 | 16 | ?> |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
24 | 24 | |
25 | 25 | if (count($array_to_search) > 0) { |
26 | - while (list($key) = each($array_to_search)) { |
|
27 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
28 | - } |
|
26 | + while (list($key) = each($array_to_search)) { |
|
27 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | //get all svg and png files |
32 | 32 | $accepted_extensions = array('.svg', '.png'); |
33 | 33 | |
34 | 34 | if (is_array($all_files) && count($all_files) > 0) { |
35 | - foreach ($all_files as & $file) { |
|
36 | - $slideshow_extension = strrchr($file, '.'); |
|
37 | - $slideshow_extension = strtolower($slideshow_extension); |
|
38 | - if (in_array($slideshow_extension, $accepted_extensions)) { |
|
39 | - $png_svg_files[] =$file; |
|
40 | - } |
|
41 | - } |
|
35 | + foreach ($all_files as & $file) { |
|
36 | + $slideshow_extension = strrchr($file, '.'); |
|
37 | + $slideshow_extension = strtolower($slideshow_extension); |
|
38 | + if (in_array($slideshow_extension, $accepted_extensions)) { |
|
39 | + $png_svg_files[] =$file; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images/gallery/'; |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | <?php |
58 | 58 | echo '<h2>'.get_lang('Course').': '.$course_info['name'].'</h2>'; |
59 | 59 | if (!empty($png_svg_files)) { |
60 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
61 | - echo '<ul>'; |
|
62 | - foreach($png_svg_files as $filename) { |
|
63 | - $image=$disk_path.$filename; |
|
64 | - |
|
65 | - if (strpos($filename, "svg")){ |
|
66 | - $new_sizes['width'] = 60; |
|
67 | - $new_sizes['height'] = 60; |
|
68 | - } |
|
69 | - else { |
|
70 | - $new_sizes = api_resize_image($image, 60, 60); |
|
71 | - } |
|
72 | - |
|
73 | - echo '<li style="display:inline; padding:8px;"><a href="'.$web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
74 | - } |
|
75 | - echo '</ul>'; |
|
60 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
61 | + echo '<ul>'; |
|
62 | + foreach($png_svg_files as $filename) { |
|
63 | + $image=$disk_path.$filename; |
|
64 | + |
|
65 | + if (strpos($filename, "svg")){ |
|
66 | + $new_sizes['width'] = 60; |
|
67 | + $new_sizes['height'] = 60; |
|
68 | + } |
|
69 | + else { |
|
70 | + $new_sizes = api_resize_image($image, 60, 60); |
|
71 | + } |
|
72 | + |
|
73 | + echo '<li style="display:inline; padding:8px;"><a href="'.$web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
74 | + } |
|
75 | + echo '</ul>'; |
|
76 | 76 | } else { |
77 | - Display::display_warning_message(get_lang('NoSVGImagesInImagesGalleryPath')); |
|
77 | + Display::display_warning_message(get_lang('NoSVGImagesInImagesGalleryPath')); |
|
78 | 78 | } |
79 | 79 | ?> |
80 | 80 | </body> |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
35 | 35 | |
36 | 36 | if (count($array_to_search) > 0) { |
37 | - while (list($key) = each($array_to_search)) { |
|
38 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | - } |
|
37 | + while (list($key) = each($array_to_search)) { |
|
38 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //get all svg and png group files |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1 |
71 | 71 | ){ |
72 | 72 | |
73 | - if (!empty($png_svg_files)) { |
|
74 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | - echo '<ul>'; |
|
76 | - foreach($png_svg_files as $filename) { |
|
77 | - $image = $group_disk_path.$filename; |
|
78 | - |
|
79 | - if (strpos($filename, "svg")){ |
|
80 | - $new_sizes['width'] = 60; |
|
81 | - $new_sizes['height'] = 60; |
|
82 | - } else { |
|
83 | - $new_sizes = api_resize_image($image, 60, 60); |
|
84 | - } |
|
73 | + if (!empty($png_svg_files)) { |
|
74 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | + echo '<ul>'; |
|
76 | + foreach($png_svg_files as $filename) { |
|
77 | + $image = $group_disk_path.$filename; |
|
78 | + |
|
79 | + if (strpos($filename, "svg")){ |
|
80 | + $new_sizes['width'] = 60; |
|
81 | + $new_sizes['height'] = 60; |
|
82 | + } else { |
|
83 | + $new_sizes = api_resize_image($image, 60, 60); |
|
84 | + } |
|
85 | 85 | echo '<li style="display:inline; padding:8px;">'; |
86 | 86 | echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">'; |
87 | 87 | echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
88 | - } |
|
89 | - echo '</ul>'; |
|
90 | - } |
|
88 | + } |
|
89 | + echo '</ul>'; |
|
90 | + } |
|
91 | 91 | } else { |
92 | - echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
92 | + echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | </body> |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | $accepted_extensions = array('.svg', '.png'); |
22 | 22 | |
23 | 23 | if (is_array($scan_files) && count($scan_files) > 0) { |
24 | - foreach ($scan_files as & $file) { |
|
25 | - $slideshow_extension = strrchr($file, '.'); |
|
26 | - $slideshow_extension = strtolower($slideshow_extension); |
|
27 | - if (in_array($slideshow_extension, $accepted_extensions)) { |
|
28 | - $png_svg_files[] =$file; |
|
29 | - } |
|
30 | - } |
|
24 | + foreach ($scan_files as & $file) { |
|
25 | + $slideshow_extension = strrchr($file, '.'); |
|
26 | + $slideshow_extension = strtolower($slideshow_extension); |
|
27 | + if (in_array($slideshow_extension, $accepted_extensions)) { |
|
28 | + $png_svg_files[] =$file; |
|
29 | + } |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | $style = '<style>'; |
33 | 33 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | echo '<h2>'.get_lang('SocialNetwork').': '.get_lang('MyFiles').'</h2>'; |
47 | 47 | |
48 | 48 | if (!empty($png_svg_files)) { |
49 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
50 | - echo '<ul>'; |
|
51 | - foreach($png_svg_files as $filename) { |
|
52 | - $image = $user_disk_path.$filename; |
|
53 | - |
|
54 | - if (strpos($filename, "svg")){ |
|
55 | - $new_sizes['width'] = 60; |
|
56 | - $new_sizes['height'] = 60; |
|
57 | - } else { |
|
58 | - $new_sizes = api_resize_image($image, 60, 60); |
|
59 | - } |
|
60 | - |
|
61 | - echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
62 | - } |
|
63 | - echo '</ul>'; |
|
49 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
50 | + echo '<ul>'; |
|
51 | + foreach($png_svg_files as $filename) { |
|
52 | + $image = $user_disk_path.$filename; |
|
53 | + |
|
54 | + if (strpos($filename, "svg")){ |
|
55 | + $new_sizes['width'] = 60; |
|
56 | + $new_sizes['height'] = 60; |
|
57 | + } else { |
|
58 | + $new_sizes = api_resize_image($image, 60, 60); |
|
59 | + } |
|
60 | + |
|
61 | + echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
62 | + } |
|
63 | + echo '</ul>'; |
|
64 | 64 | } else { |
65 | - Display::display_warning_message(get_lang('NoSVGImages')); |
|
65 | + Display::display_warning_message(get_lang('NoSVGImages')); |
|
66 | 66 | } |
67 | 67 | ?> |
68 | 68 | </body> |
@@ -1335,27 +1335,27 @@ |
||
1335 | 1335 | public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
1336 | 1336 | { |
1337 | 1337 | $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
1338 | - $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | - $user_id = intval($user_id); |
|
1338 | + $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | + $user_id = intval($user_id); |
|
1340 | 1340 | |
1341 | - if ($relation_type == 0) { |
|
1342 | - $where_relation_condition = ''; |
|
1343 | - } else { |
|
1344 | - $relation_type = intval($relation_type); |
|
1345 | - $where_relation_condition = "AND gu.relation_type = $relation_type "; |
|
1346 | - } |
|
1341 | + if ($relation_type == 0) { |
|
1342 | + $where_relation_condition = ''; |
|
1343 | + } else { |
|
1344 | + $relation_type = intval($relation_type); |
|
1345 | + $where_relation_condition = "AND gu.relation_type = $relation_type "; |
|
1346 | + } |
|
1347 | 1347 | |
1348 | - $sql = "SELECT count(g.id) as count |
|
1348 | + $sql = "SELECT count(g.id) as count |
|
1349 | 1349 | FROM $tbl_group g |
1350 | 1350 | INNER JOIN $table_group_rel_user gu |
1351 | 1351 | ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition "; |
1352 | 1352 | |
1353 | - $result = Database::query($sql); |
|
1354 | - if (Database::num_rows($result) > 0) { |
|
1355 | - $row = Database::fetch_array($result, 'ASSOC'); |
|
1353 | + $result = Database::query($sql); |
|
1354 | + if (Database::num_rows($result) > 0) { |
|
1355 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
1356 | 1356 | return $row['count']; |
1357 | - } |
|
1358 | - return 0; |
|
1357 | + } |
|
1358 | + return 0; |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | 'changeable', |
20 | 20 | 'filter', |
21 | 21 | 'extra_field_type', |
22 | - /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
22 | + /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
23 | 23 | 'field_loggeable', |
24 | 24 | */ |
25 | 25 | 'created_at' |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * France:Paris;Bretagne;Marseilles;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura; |
524 | 524 | * into |
525 | 525 | * array( |
526 | - * 'France' => |
|
526 | + * 'France' => |
|
527 | 527 | * array('Paris', 'Bregtane', 'Marseilles'), |
528 | 528 | * 'Belgique' => |
529 | 529 | * array('Namur', 'Liège') |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | if ($this->type == 'user') { |
1186 | 1186 | |
1187 | - /* //the magic should be here |
|
1187 | + /* //the magic should be here |
|
1188 | 1188 | $user_tags = UserManager::get_user_tags($user_id, $field_details[0]); |
1189 | 1189 | |
1190 | 1190 | $tag_list = ''; |
@@ -401,19 +401,19 @@ |
||
401 | 401 | |
402 | 402 | public function format_yes_no_optional($value) |
403 | 403 | { |
404 | - $return = ''; |
|
405 | - switch($value) { |
|
406 | - case 0: |
|
407 | - $return = get_lang('No'); |
|
408 | - break; |
|
409 | - case 1: |
|
410 | - $return = get_lang('Yes'); |
|
411 | - break; |
|
412 | - case 2: |
|
413 | - $return = get_lang('Optional'); |
|
414 | - break; |
|
415 | - } |
|
416 | - return $return; |
|
404 | + $return = ''; |
|
405 | + switch($value) { |
|
406 | + case 0: |
|
407 | + $return = get_lang('No'); |
|
408 | + break; |
|
409 | + case 1: |
|
410 | + $return = get_lang('Yes'); |
|
411 | + break; |
|
412 | + case 2: |
|
413 | + $return = get_lang('Optional'); |
|
414 | + break; |
|
415 | + } |
|
416 | + return $return; |
|
417 | 417 | |
418 | 418 | } |
419 | 419 |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | return false; |
721 | 721 | } |
722 | 722 | |
723 | - /** |
|
724 | - * @param int $itemId |
|
725 | - * @param int $fieldId |
|
726 | - * @return array |
|
727 | - */ |
|
723 | + /** |
|
724 | + * @param int $itemId |
|
725 | + * @param int $fieldId |
|
726 | + * @return array |
|
727 | + */ |
|
728 | 728 | public function getAllValuesByItemAndField($itemId, $fieldId) |
729 | 729 | { |
730 | 730 | $fieldId = intval($fieldId); |
@@ -847,7 +847,6 @@ discard block |
||
847 | 847 | /** |
848 | 848 | * Deletes all values from an item |
849 | 849 | * @param int $itemId (session id, course id, etc) |
850 | - |
|
851 | 850 | * @assert (-1,-1) == null |
852 | 851 | */ |
853 | 852 | public function deleteValuesByItem($itemId) |