Skip to content

Commit 8f86e88

Browse files
committed
Remove use of $_SESSION, fix edit svg files.
1 parent 9116f9a commit 8f86e88

24 files changed

+173
-200
lines changed

main/document/create_audio.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
require_once __DIR__.'/../inc/global.inc.php';
17-
$_SESSION['whereami'] = 'document/createaudio';
1817
$this_section = SECTION_COURSES;
1918

2019
$nameTools = get_lang('CreateAudio');

main/document/create_document.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
require_once __DIR__.'/../inc/global.inc.php';
1313

14-
$_SESSION['whereami'] = 'document/create';
1514
$this_section = SECTION_COURSES;
1615
$groupRights = Session::read('group_member_with_upload_rights');
1716
$htmlHeadXtra[] = '

main/document/create_draw.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
require_once __DIR__.'/../inc/global.inc.php';
1616

17-
$_SESSION['whereami'] = 'document/createdraw';
1817
$this_section = SECTION_COURSES;
1918
$groupRights = Session::read('group_member_with_upload_rights');
2019
$nameTools = get_lang('Draw');
@@ -49,9 +48,9 @@
4948
/* Constants and variables */
5049

5150
//path for svg-edit save
52-
$_SESSION['draw_dir'] = Security::remove_XSS($dir);
53-
if ($_SESSION['draw_dir'] == '/') {
54-
$_SESSION['draw_dir'] = '';
51+
Session::write('draw_dir', Security::remove_XSS($dir));
52+
if ($dir == '/') {
53+
Session::write('draw_dir', '');
5554
}
5655

5756
$dir = isset($dir) ? Security::remove_XSS($dir) : (isset($_POST['dir']) ? Security::remove_XSS($_POST['dir']) : '/');

main/document/create_paint.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
use ChamiloSession as Session;
55

66
/**
7-
* This file allows creating audio files from a text.
7+
* This file allows creating audio files from a text.
88
*
9-
* @package chamilo.document
9+
* @package chamilo.document
1010
*
1111
* @author Juan Carlos Raña Trabado
1212
* @since 30/January/2011
1313
* @todo clean all file
1414
*/
1515

1616
require_once __DIR__.'/../inc/global.inc.php';
17-
$_SESSION['whereami'] = 'document/createpaint';
1817
$this_section = SECTION_COURSES;
1918
$nameTools = get_lang('PhotoRetouching');
2019
$groupRights = Session::read('group_member_with_upload_rights');
@@ -43,14 +42,14 @@
4342
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
4443

4544
//path for pixlr save
46-
$_SESSION['paint_dir'] = Security::remove_XSS($dir);
47-
if ($_SESSION['paint_dir'] == '/') {
48-
$_SESSION['paint_dir'] = '';
45+
$paintDir = Security::remove_XSS($dir);
46+
if ($paintDir == '/') {
47+
$paintDir = '';
4948
}
50-
$_SESSION['paint_file'] = get_lang('NewImage');
49+
Session::write('paint_dir', $paintDir);
50+
Session::write('paint_file', get_lang('NewImage'));
5151

5252
// Please, do not modify this dirname formatting
53-
5453
if (strstr($dir, '..')) {
5554
$dir = '/';
5655
}
@@ -116,17 +115,26 @@
116115

117116
// Interbreadcrumb for the current directory root path
118117
if (empty($document_data['parents'])) {
119-
$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
118+
$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
120119
} else {
121120
foreach ($document_data['parents'] as $document_sub_data) {
122-
$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
121+
$interbreadcrumb[] = array(
122+
'url' => $document_sub_data['document_url'],
123+
'name' => $document_sub_data['title']
124+
);
123125
}
124126
}
125127
Display :: display_header($nameTools, 'Doc');
126128

127129
echo '<div class="actions">';
128130
echo '<a href="document.php?id='.$document_id.'">'.
129-
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
131+
Display::return_icon(
132+
'back.png',
133+
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
134+
'',
135+
ICON_SIZE_MEDIUM
136+
).
137+
'</a>';
130138
echo '</div>';
131139

132140
// pixlr
@@ -141,7 +149,7 @@
141149
$loc = $langpixlr; // deprecated ?? TODO:check pixlr read user browser
142150

143151
$exit_path = api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
144-
$_SESSION['exit_pixlr'] = $document_data['path'];
152+
Session::write('exit_pixlr', $document_data['path']);
145153
$referrer = "Chamilo";
146154
$target_path = api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
147155
$target = $target_path;
@@ -164,7 +172,7 @@
164172
} else {
165173
$credentials = "false";
166174
}
167-
$pixlr_url = api_get_protocol().'://pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
175+
$pixlr_url = '//pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
168176
?>
169177
<script>
170178

main/document/document.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@
6464
}
6565

6666
DocumentManager::removeGeneratedAudioTempFile();
67-
68-
if (isset($_SESSION['temp_realpath_image']) &&
69-
!empty($_SESSION['temp_realpath_image']) &&
70-
file_exists($_SESSION['temp_realpath_image'])
67+
$tempRealPath = Session::read('temp_realpath_image');
68+
if (!empty($tempRealPath) &&
69+
file_exists($tempRealPath)
7170
) {
72-
unlink($_SESSION['temp_realpath_image']);
71+
unlink($tempRealPath);
7372
}
7473
$_user = api_get_user_info();
7574
$courseInfo = api_get_course_info();
@@ -97,9 +96,9 @@
9796
}
9897

9998
// Removing sessions
100-
unset($_SESSION['draw_dir']);
101-
unset($_SESSION['paint_dir']);
102-
unset($_SESSION['temp_audio_nanogong']);
99+
Session::erase('draw_dir');
100+
Session::erase('paint_dir');
101+
Session::erase('temp_audio_nanogong');
103102

104103
$plugin = new AppPlugin();
105104
$pluginList = $plugin->get_installed_plugins();
@@ -870,10 +869,8 @@ function convertModal (id, format) {
870869

871870
/* MAIN SECTION */
872871

873-
// Slideshow inititalisation
874-
$_SESSION['image_files_only'] = '';
872+
Session::write('image_files_only', '');
875873
$image_files_only = '';
876-
877874
if ($is_certificate_mode) {
878875
$interbreadcrumb[] = array(
879876
'url' => '../gradebook/index.php',
@@ -1745,9 +1742,8 @@ function convertModal (id, format) {
17451742
);
17461743
}
17471744
}
1748-
17491745
require 'document_slideshow.inc.php';
1750-
if ($image_present && !isset($_GET['keyword'])) {
1746+
if (!isset($_GET['keyword'])) {
17511747
$actionsLeft .= Display::url(
17521748
Display::return_icon('slideshow.png', get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM),
17531749
api_get_path(WEB_CODE_PATH).'document/slideshow.php?'.api_get_cidreq().'&curdirpath='.$curdirpathurl

main/document/document_slideshow.inc.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
/* For licensing terms, see /license.txt */
3+
4+
use ChamiloSession as Session;
5+
36
/**
47
* This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
58
* files (since these are the files that can be viewed in a browser) and creates
@@ -28,7 +31,7 @@
2831

2932
// Resetting the images of the slideshow = destroying the slideshow
3033
if (isset($_GET['action']) && $_GET['action'] == 'exit_slideshow') {
31-
$_SESSION['image_files_only'] = null;
34+
Session::write('image_files_only', null);
3235
unset($image_files_only);
3336
}
3437

@@ -40,7 +43,6 @@
4043
if (count($array_to_search) > 0) {
4144
while (list($key) = each($array_to_search)) {
4245
$all_files[] = basename($array_to_search[$key]['path']);
43-
//echo basename($array_to_search[$key]['path']).'<br />';
4446
}
4547
}
4648

@@ -67,7 +69,7 @@
6769
}
6870

6971
$image_files_only = sort_files($array_to_search);
70-
$_SESSION['image_files_only'] = $image_files_only;
72+
Session::write('image_files_only', $image_files_only);
7173

7274
function sort_files($table)
7375
{

main/document/edit_document.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
5353
</script>';
5454

55-
$_SESSION['whereami'] = 'document/create';
5655
$this_section = SECTION_COURSES;
5756
$lib_path = api_get_path(LIBRARY_PATH);
5857

main/document/edit_draw.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
require_once __DIR__.'/../inc/global.inc.php';
1616

17-
$_SESSION['whereami'] = 'document/editdraw';
1817
$this_section = SECTION_COURSES;
1918
$groupRights = Session::read('group_member_with_upload_rights');
2019

@@ -27,6 +26,7 @@
2726
true
2827
);
2928

29+
$file_path = '';
3030
if (empty($document_data)) {
3131
api_not_allowed();
3232
} else {
@@ -44,11 +44,11 @@
4444
$group_id = api_get_group_id();
4545

4646
//path for svg-edit save
47-
$_SESSION['draw_dir'] = Security::remove_XSS($dir);
48-
if ($_SESSION['draw_dir'] == '/') {
49-
$_SESSION['draw_dir'] = '';
47+
Session::write('draw_dir', Security::remove_XSS($dir));
48+
if ($dir == '/') {
49+
Session::write('draw_dir', '');
5050
}
51-
$_SESSION['draw_file'] = basename(Security::remove_XSS($file_path));
51+
Session::write('draw_file', basename(Security::remove_XSS($file_path)));
5252
$get_file = Security::remove_XSS($file_path);
5353
$file = basename($get_file);
5454
$temp_file = explode(".", $file);

main/document/edit_paint.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
require_once __DIR__.'/../inc/global.inc.php';
1616

17-
$_SESSION['whereami'] = 'document/editpaint';
1817
$this_section = SECTION_COURSES;
1918
$groupRights = Session::read('group_member_with_upload_rights');
2019

@@ -42,11 +41,11 @@
4241
/* Constants & Variables */
4342
$current_session_id = api_get_session_id();
4443
//path for pixlr save
45-
$_SESSION['paint_dir'] = Security::remove_XSS($dir);
46-
if ($_SESSION['paint_dir'] == '/') {
47-
$_SESSION['paint_dir'] = '';
44+
Session::write('paint_dir', Security::remove_XSS($dir));
45+
if ($dir == '/') {
46+
Session::write('paint_dir', '');
4847
}
49-
$_SESSION['paint_file'] = basename(Security::remove_XSS($file_path));
48+
Session::write('paint_file', basename(Security::remove_XSS($file_path)));
5049
$get_file = Security::remove_XSS($file_path);
5150
$file = basename($get_file);
5251
$temp_file = explode(".", $file);
@@ -141,7 +140,7 @@
141140
$loc = $langpixlr; // deprecated ?? TODO:check pixlr read user browser
142141

143142
$exit_path = api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
144-
$_SESSION['exit_pixlr'] = Security::remove_XSS($parent_id);
143+
Session::write('exit_pixlr', Security::remove_XSS($parent_id));
145144
$referrer = "Chamilo";
146145
$target_path = api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
147146
$target = $target_path;
@@ -202,12 +201,12 @@
202201
$from = $filepath.$file;
203202
$to = api_get_path(SYS_ARCHIVE_PATH).'temp/images/'.$file_crip;
204203
copy($from, $to);
205-
$_SESSION['temp_realpath_image'] = $to;
204+
Session::write('temp_realpath_image', $to);
206205

207206
//load image to url
208207
$to_url = api_get_path(WEB_ARCHIVE_PATH).'temp/images/'.$file_crip;
209208
$image = urlencode($to_url);
210-
$pixlr_url = api_get_protocol().'://pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
209+
$pixlr_url = '//pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
211210

212211
//make frame an send image
213212
?>

main/document/exit_pixlr.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
/* For licensing terms, see /license.txt */
33

4+
use ChamiloSession as Session;
5+
46
/**
57
* This file allows creating new svg and png documents with an online editor.
68
*
@@ -15,21 +17,24 @@
1517
api_block_anonymous_users();
1618

1719
//delete temporal file
18-
unlink($_SESSION['temp_realpath_image']);
20+
$fileToDelete = Session::read('temp_realpath_image');
21+
if (file_exists($fileToDelete)) {
22+
unlink($fileToDelete);
23+
}
1924

2025
//Clean sessions and return to Chamilo file list
21-
unset($_SESSION['paint_dir']);
22-
unset($_SESSION['paint_file']);
23-
unset($_SESSION['whereami']);
24-
unset($_SESSION['temp_realpath_image']);
26+
Session::erase('paint_dir');
27+
Session::erase('paint_file');
28+
Session::erase('temp_realpath_image');
29+
$exit = Session::read('exit_pixlr');
2530

26-
if (!isset($_SESSION['exit_pixlr'])) {
27-
$location = api_get_path(WEB_CODE_PATH).'document/document.php';
31+
if (empty($exit)) {
32+
$location = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq();
2833
echo '<script>window.parent.location.href="'.$location.'"</script>';
2934
api_not_allowed(true);
3035
} else {
3136
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>';
32-
$location = api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']);
37+
$location = api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($exit).'&'.api_get_cidreq();
3338
echo '<script>window.parent.location.href="'.$location.'"</script>';
34-
unset($_SESSION['exit_pixlr']);
39+
Session::erase('exit_pixlr');
3540
}

0 commit comments

Comments
 (0)