forked from aarpon/hrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_management.php
314 lines (264 loc) · 8.6 KB
/
file_management.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?php
// This file is part of the Huygens Remote Manager
// Copyright and license notice: see license.txt
namespace hrm;
require_once dirname(__FILE__) . '/inc/bootstrap.php';
// Settings
global $allowHttpTransfer;
session_start();
if (isset($_GET['home'])) {
header("Location: " . "home.php");
exit();
}
if (!isset($_SESSION['user']) || !$_SESSION['user']->isLoggedIn()) {
$req = $_SERVER['REQUEST_URI'];
$_SESSION['request'] = $req;
header("Location: " . "login.php");
exit();
}
// Keep track of who the referer is: the filemanager (src) will allow returning
// to some selected pages
if (isset($_SERVER['HTTP_REFERER'])) {
if (strpos($_SERVER['HTTP_REFERER'], 'home.php') ||
strpos($_SERVER['HTTP_REFERER'], 'select_parameter_settings.php') ||
strpos($_SERVER['HTTP_REFERER'], 'select_task_settings.php') ||
strpos($_SERVER['HTTP_REFERER'], 'select_analysis_settings.php') ||
strpos($_SERVER['HTTP_REFERER'], 'select_images.php') ||
strpos($_SERVER['HTTP_REFERER'], 'create_job.php')
) {
$_SESSION['filemanager_referer'] = $_SERVER['HTTP_REFERER'];
}
}
if (isset($_SERVER['HTTP_REFERER']) &&
!strstr($_SERVER['HTTP_REFERER'], 'job_queue')
) {
$_SESSION['referer'] = $_SERVER['HTTP_REFERER'];
}
if (isset($_GET['ref'])) {
$_SESSION['referer'] = $_GET['ref'];
} else if (isset($_POST['ref'])) {
$_SESSION['referer'] = $_POST['ref'];
} else {
if (isset($_SERVER['HTTP_REFERER'])) {
$_SESSION['referer'] = $_SERVER['HTTP_REFERER'];
}
}
if (!isset($_SESSION['fileserver'])) {
# session_register("fileserver");
$name = $_SESSION['user']->name();
$_SESSION['fileserver'] = new Fileserver($name);
}
if (isset($_GET['getThumbnail'])) {
if (isset($_GET['dir'])) {
$dir = $_GET['dir'];
} else {
$dir = "dest";
}
$_SESSION['fileserver']->getThumbnail(rawurldecode($_GET['getThumbnail']),
$dir);
exit;
}
if (isset($_GET['getMovie'])) {
if (isset($_GET['dir'])) {
$dir = $_GET['dir'];
} else {
$dir = "dest";
}
$_SESSION['fileserver']->getMovie(rawurldecode($_GET['getMovie']),
$dir);
exit;
}
if (isset($_GET['viewStrip'])) {
if (isset($_GET['dir'])) {
$src = $_GET['dir'];
} else {
$src = "dest";
}
if (isset($_GET['type'])) {
$type = $_GET['type'];
} else {
$type = "stack.comparison";
}
if (isset($_GET['embed'])) {
$embed = true;
} else {
$embed = false;
}
$_SESSION['fileserver']->viewStrip($_GET['viewStrip'],
$type, $src, $embed);
exit;
}
if (isset($_GET['genPreview'])) {
if (isset($_GET['size'])) {
$size = $_GET['size'];
} else {
$size = "preview";
}
if (isset($_GET['src'])) {
$src = $_GET['src'];
} else {
$src = "dest";
}
if (isset($_GET['dest'])) {
$dest = $_GET['dest'];
} else {
$dest = $src;
}
if (isset($_GET['data'])) {
$data = $_GET['data'];
} else {
$data = 0;
}
if (isset($_GET['index'])) {
$index = $_GET['index'];
} else {
$index = 0;
}
$_SESSION['fileserver']->genPreview($_GET['genPreview'],
$src, $dest, $index, $size, $data);
exit;
}
if (isset($_GET['compareResult'])) {
if (isset($_GET['size'])) {
$size = $_GET['size'];
} else {
$size = "400";
}
if (isset($_GET['op'])) {
$op = $_GET['op'];
} else {
$op = "home";
}
if (isset($_GET['mode'])) {
$mode = $_GET['mode'];
} else {
$mode = "MIP";
}
$_SESSION['fileserver']->previewPage(
rawurldecode($_GET['compareResult']), $op, $mode, $size);
exit;
}
# $browse_folder can be 'src' or 'dest'.
$browse_folder = "dest";
if (isset($_GET['folder'])) {
$browse_folder = $_GET['folder'];
}
if ($allowHttpTransfer) {
$message = "";
if (isset($_POST['download'])) {
if (isset($_POST['userfiles']) && is_array($_POST['userfiles'])) {
$message =
$_SESSION['fileserver']->downloadResults($_POST['userfiles']);
exit;
}
} else if (isset($_GET['download'])) {
$downloadArr = array($_GET['download']);
$message = $_SESSION['fileserver']->downloadResults($downloadArr);
exit;
}
}
$operationResult = "";
if (System::isUploadEnabled() == "enabled") {
if (isset($_POST['uploadForm']) && isset($_FILES)) {
$operationResult =
$_SESSION['fileserver']->uploadFiles($_FILES['upfile'],
$browse_folder);
} else if (isset($_GET['upload'])) {
$max = UtilV2::getMaxPostSize() / 1024 / 1024;
$maxPost = "$max MB";
$operationResult = "<b>Nothing uploaded!</b> Probably total post " .
"exceeds maximum allowed size of $maxPost.<br>\n";
}
}
if (isset($_POST['delete'])) {
if (isset($_POST['userfiles']) && is_array($_POST['userfiles'])) {
if ($browse_folder == "dest") {
$message =
$_SESSION['fileserver']->deleteFiles($_POST['userfiles'],
"dest");
} else {
$message =
$_SESSION['fileserver']->deleteFiles($_POST['userfiles'],
"src");
}
}
} else if (isset($_GET['delete'])) {
# This method is only for result files.
$deleteArr = array($_GET['delete']);
$message = $_SESSION['fileserver']->deleteFiles($deleteArr);
exit;
} else if (isset($_POST['update'])) {
if ($browse_folder == "dest") {
$_SESSION['fileserver']->resetDestFiles();
} else {
$_SESSION['fileserver']->resetFiles();
}
} else if (!isset($_POST['update']) && isset($_GET) && isset($_GET['folder'])) {
// Force an update in the file browser
$_POST['update'] = "1";
}
// To (re)generate the thumbnails, don't use template data, as it is not present
// here.
$useTemplateData = 0;
$file_buttons = array();
if ($browse_folder == "dest") {
// Number of displayed files.
$size = 15;
$multiple_files = true;
$page_title = "Results";
$explanation_text = "These are the <b>processed image files</b> " .
"currently in your file area.";
$form_title = "Your result files";
$info = "<h3>Quick help</h3>
<p>Click on a file name to see a preview.</p>
<p><strong>Click on <img src = \"images/eye.png\" /> Detailed View
over the file preview to access previews, reports and
analysis results.</strong></p>";
if ($allowHttpTransfer) {
$info .= "<p>Select the files you want to download (you can <b>SHIFT-</b>
and <b>CTRL-click</b> for multiple selection) and press the
<b>download</b> icon to compress the files into an archive and
start the download process. (Please mind that large files may take
a <b>long time </b>to be packaged before downloading.)</p>
<p> Use the <b>delete</b> icon to delete the selected files
instead.</p>";
$file_buttons[] = "download";
}
$info .= "<p><strong>Move your mouse pointer over the action buttons at " .
"the bottom to redisplay this help.</strong></p>";
} else {
$browse_folder = "src";
$size = 15;
$multiple_files = true;
$page_title = "Raw images";
$explanation_text = "These are the <b>original image files</b> currently " .
"in your file area.";
$form_title = "Your raw files";
$info = "<h3>Quick help</h3>
<p>Click on a file name to see (or create) a preview.</p>
<p>Select the files you want to delete (you can <b>SHIFT-</b> and
<b>CTRL-click</b> for multiple selection) and press the
<b>delete</b> icon to delete them.
</p>";
if (System::isUploadEnabled() == "enabled") {
$validExtensions = str_replace(" ", ", ",
$_SESSION['fileserver']->getValidArchiveTypesAsString());
$info .= "<p>You can also upload files to deconvolve. To upload
multiple files, it may be convenient to pack them first in a single
<b>archive ($validExtensions)</b>, that will be unpacked
automatically after upload.";
$file_buttons[] = "upload";
}
$info .= "<p><strong>Move your mouse pointer over the action buttons at " .
"the bottom to redisplay this help.</strong></p>";
}
$file_buttons[] = "delete";
$file_buttons[] = "update";
$control_buttons = '
<input name="ref" type="hidden" value="' . $_SESSION['referer'] . '" />
<input name="OK" type="hidden" />
';
include("omero_actions.php");
include("./inc/FileBrowser.php");
include("footer.inc.php");
?>