dolibarr 21.0.0-alpha
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2008-2009 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/ftp.lib.php';
32
33// Load translation files required by the page
34$langs->loadLangs(array('companies', 'other'));
35
36// Get parameters
37$action = GETPOST('action', 'aZ09');
38$section = GETPOST('section');
39$newfolder = GETPOST('newfolder');
40if (!$section) {
41 $section = '/';
42}
43$numero_ftp = GETPOST("numero_ftp");
44/* if (! $numero_ftp) $numero_ftp=1; */
45$file = GETPOST("file");
46$confirm = GETPOST('confirm');
47
48$upload_dir = $conf->ftp->dir_temp;
49$download_dir = $conf->ftp->dir_temp;
50
51$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
52$sortfield = GETPOST('sortfield', 'aZ09comma');
53$sortorder = GETPOST('sortorder', 'aZ09comma');
54$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
55if (empty($page) || $page == -1) {
56 $page = 0;
57} // If $page is not defined, or '' or -1
58$offset = $limit * $page;
59$pageprev = $page - 1;
60$pagenext = $page + 1;
61if (!$sortorder) {
62 $sortorder = "ASC";
63}
64if (!$sortfield) {
65 $sortfield = "label";
66}
67
68$s_ftp_name = 'FTP_NAME_'.$numero_ftp;
69$s_ftp_server = 'FTP_SERVER_'.$numero_ftp;
70$s_ftp_port = 'FTP_PORT_'.$numero_ftp;
71$s_ftp_user = 'FTP_USER_'.$numero_ftp;
72$s_ftp_password = 'FTP_PASSWORD_'.$numero_ftp;
73$s_ftp_passive = 'FTP_PASSIVE_'.$numero_ftp;
74$ftp_name = getDolGlobalString($s_ftp_name);
75$ftp_server = getDolGlobalString($s_ftp_server);
76$ftp_port = getDolGlobalString($s_ftp_port);
77if (empty($ftp_port)) {
78 $ftp_port = 21;
79}
80$ftp_user = getDolGlobalString($s_ftp_user);
81$ftp_password = getDolGlobalString($s_ftp_password);
82$ftp_passive = getDolGlobalInt($s_ftp_passive);
83
84// For result on connection
85$ok = 0;
86$conn_id = null; // FTP connection ID
87$mesg = '';
88
89// Security check
90if ($user->socid) {
91 $socid = $user->socid;
92}
93$result = restrictedArea($user, 'ftp', '');
94
95
96/*
97 * ACTIONS
98 */
99
100if ($action == 'uploadfile' && $user->hasRight('ftp', 'write')) {
101 // set up a connection or die
102 if (!$conn_id) {
103 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
104 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
105 $conn_id = $resultarray['conn_id'];
106 $ok = $resultarray['ok'];
107 $mesg = $resultarray['mesg'];
108 }
109 if ($conn_id && $ok && !$mesg) {
110 $nbfile = count($_FILES['userfile']['name']);
111 for ($i = 0; $i < $nbfile; $i++) {
112 $newsection = $newsectioniso;
113 $fileupload = dol_sanitizeFileName($_FILES['userfile']['name'][$i]);
114 $fileuploadpath = dol_sanitizePathName($_FILES['userfile']['tmp_name'][$i]);
115 $result = dol_ftp_put($conn_id, $fileupload, $fileuploadpath, $newsection);
116
117 if ($result) {
118 setEventMessages($langs->trans("FileWasUpload", $fileupload), null, 'mesgs');
119 } else {
120 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
121 setEventMessages($langs->trans("FTPFailedToUploadFile", $fileupload), null, 'errors');
122 }
123 }
124 $action = '';
125 } else {
126 dol_print_error(null, $mesg);
127 }
128}
129
130if ($action == 'addfolder' && $user->hasRight('ftp', 'write')) {
131 // set up a connection or die
132 if (!$conn_id) {
133 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
134 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
135 $conn_id = $resultarray['conn_id'];
136 $ok = $resultarray['ok'];
137 $mesg = $resultarray['mesg'];
138 }
139 if ($conn_id && $ok && !$mesg) {
140 $result = dol_ftp_mkdir($conn_id, $newfolder, $newsectioniso);
141
142 if ($result) {
143 setEventMessages($langs->trans("FileWasCreateFolder", $newfolder), null, 'mesgs');
144 } else {
145 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
146 setEventMessages($langs->trans("FTPFailedToCreateFolder", $newfolder), null, 'errors');
147 }
148 $action = '';
149 } else {
150 dol_print_error(null, $mesg);
151 }
152}
153
154// Action ajout d'un rep
155if ($action == 'add' && $user->hasRight('ftp', 'write')) {
156 $ecmdir = new EcmDirectory($db);
157 $ecmdir->ref = GETPOST("ref");
158 $ecmdir->label = GETPOST("label");
159 $ecmdir->description = GETPOST("desc");
160
161 $id = $ecmdir->create($user);
162 if ($id > 0) {
163 header("Location: ".$_SERVER["PHP_SELF"]);
164 exit;
165 } else {
166 setEventMessages($langs->trans("ErrorFailToCreateDir"), null, 'errors');
167 $action = "create";
168 }
169}
170
171// Remove 1 file
172if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes' && $user->hasRight('ftp', 'write')) {
173 // set up a connection or die
174 if (!$conn_id) {
175 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
176 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
177 $conn_id = $resultarray['conn_id'];
178 $ok = $resultarray['ok'];
179 $mesg = $resultarray['mesg'];
180 }
181
182 if ($conn_id && $ok && !$mesg) {
183 $newsection = $section;
184 $result = dol_ftp_delete($conn_id, $file, $newsection);
185
186 if ($result) {
187 setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
188 } else {
189 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
190 setEventMessages($langs->trans("FTPFailedToRemoveFile", $file), null, 'errors');
191 }
192
193 $action = '';
194 } else {
195 dol_print_error(null, $mesg);
196 }
197}
198
199// Delete several lines at once
200if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete") && $user->hasRight('ftp', 'write')) {
201 // set up a connection or die
202 if (!$conn_id) {
203 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
204 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
205 $conn_id = $resultarray['conn_id'];
206 $ok = $resultarray['ok'];
207 $mesg = $resultarray['mesg'];
208 }
209
210 if ($conn_id && $ok && !$mesg) {
211 foreach (GETPOST('const', 'array') as $const) {
212 if (isset($const["check"])) { // Is checkbox checked
213 $langs->load("other");
214
215 // Remote file
216 $file = $const["file"];
217 $newsection = $const["section"];
218
219 $result = dol_ftp_delete($conn_id, $file, $newsection);
220
221 if ($result) {
222 setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
223 } else {
224 dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR);
225 setEventMessages($langs->trans("FTPFailedToRemoveFile", $file), null, 'errors');
226 }
227
228 //ftp_close($conn_id); Close later
229
230 $action = '';
231 }
232 }
233 } else {
234 dol_print_error(null, $mesg);
235 }
236}
237
238// Remove directory
239if ($action == 'confirm_deletesection' && $confirm == 'yes' && $user->hasRight('ftp', 'write')) {
240 // set up a connection or die
241 if (!$conn_id) {
242 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
243 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
244 $conn_id = $resultarray['conn_id'];
245 $ok = $resultarray['ok'];
246 $mesg = $resultarray['mesg'];
247 }
248
249 if ($conn_id && $ok && !$mesg) {
250 $newsection = $section;
251
252 $result = dol_ftp_rmdir($conn_id, $file, $newsection);
253
254 if ($result) {
255 setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs');
256 } else {
257 setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors');
258 }
259
260 //ftp_close($conn_id); Close later
261
262 $action = '';
263 } else {
264 dol_print_error(null, $mesg);
265 }
266}
267
268// Download directory
269if ($action == 'download' && $user->hasRight('ftp', 'read')) {
270 // set up a connection or die
271 if (!$conn_id) {
272 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
273 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
274 $conn_id = $resultarray['conn_id'];
275 $ok = $resultarray['ok'];
276 $mesg = $resultarray['mesg'];
277 }
278
279 if ($conn_id && $ok && !$mesg) {
280 // Local file
281 $localfile = tempnam($download_dir, 'dol_');
282
283 $newsection = $section;
284
285 $result = dol_ftp_get($conn_id, $localfile, $file, $newsection);
286
287
288 if ($result) {
289 dolChmod($localfile);
290
291 // Define mime type
292 $type = 'application/octet-stream';
293 if (GETPOSTISSET("type")) {
294 $type = GETPOST("type");
295 } else {
296 $type = dol_mimetype($file);
297 }
298
299 // Define attachment (attachment=true to force choice popup 'open'/'save as')
300 $attachment = true;
301
302 //if ($encoding) header('Content-Encoding: '.$encoding);
303 if ($type) {
304 header('Content-Type: '.$type);
305 }
306 if ($attachment) {
307 header('Content-Disposition: attachment; filename="'.$file.'"');
308 } else {
309 header('Content-Disposition: inline; filename="'.$file.'"');
310 }
311
312 // Ajout directives pour resoudre bug IE
313 header('Cache-Control: Public, must-revalidate');
314 header('Pragma: public');
315
316 readfile($localfile);
317
318 exit;
319 } else {
320 setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $file), null, 'errors');
321 }
322 } else {
323 dol_print_error(null, $mesg);
324 }
325
326 //ftp_close($conn_id); Close later
327}
328
329
330/*
331 * View
332 */
333
334llxHeader();
335
336// Add logic to shoow/hide buttons
337if ($conf->use_javascript_ajax) {
338 ?>
339<script type="text/javascript">
340jQuery(document).ready(function() {
341 jQuery("#delconst").hide();
342
343 jQuery(".checkboxfordelete").click(function() {
344 jQuery("#delconst").show();
345 });
346
347 $("#checkall").click(function() {
348 $(".checkboxfordelete").prop('checked', true);
349 jQuery("#delconst").show();
350 });
351 $("#checknone").click(function() {
352 $(".checkboxfordelete").prop('checked', false);
353 jQuery("#delconst").hide();
354 });
355
356});
357
358</script>
359
360 <?php
361}
362
363$form = new Form($db);
364$formfile = new FormFile($db);
365$userstatic = new User($db);
366
367
368// List
369print load_fiche_titre($langs->trans("FTPArea"));
370
371print $langs->trans("FTPAreaDesc")."<br>";
372
373if (!function_exists('ftp_connect')) {
374 print $langs->trans("FTPFeatureNotSupportedByYourPHP");
375} else {
376 if (!empty($ftp_server)) {
377 // Confirm remove file
378 if ($action == 'delete') {
379 print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', GETPOST('file')), 'confirm_deletefile', '', '', 1);
380 }
381
382 // Confirmation de la suppression d'une ligne categorie
383 if ($action == 'delete_section') {
384 print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', GETPOST('file')), 'confirm_deletesection', '', '', 1);
385 }
386
387 print $langs->trans("Server").': <b>'.$ftp_server.'</b><br>';
388 print $langs->trans("Port").': <b>'.$ftp_port.'</b> '.($ftp_passive ? "(Passive)" : "(Active)").'<br>';
389 print $langs->trans("User").': <b>'.$ftp_user.'</b><br>';
390 print $langs->trans("FTPs (FTP over SSH)").': <b>'.yn(getDolGlobalString('FTP_CONNECT_WITH_SSL')).'</b><br>';
391 print $langs->trans("SFTP (FTP as a subsystem of SSH)").': <b>'.yn(getDolGlobalString('FTP_CONNECT_WITH_SFTP')).'</b><br>';
392 print $langs->trans("Directory").': ';
393 $sectionarray = preg_split('|[\/]|', $section);
394 // For /
395 $newsection = '/';
396 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($newsection ? '&section='.urlencode($newsection) : '').'">';
397 print '/';
398 print '</a> ';
399 // For other directories
400 $i = 0;
401 foreach ($sectionarray as $val) {
402 if (empty($val)) {
403 continue; // Discard first and last entry that should be empty as section start/end with /
404 }
405 if ($i > 0) {
406 print ' / ';
407 $newsection .= '/';
408 }
409 $newsection .= $val;
410 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($newsection ? '&section='.urlencode($newsection) : '').'">';
411 print $val;
412 print '</a>';
413 $i++;
414 }
415 print '<br>';
416 print "<br>\n";
417
418 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
419 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
420 print '<input type="hidden" name="token" value="'.newToken().'">';
421
422
423 // Construit liste des repertoires
424 print '<table width="100%" class="noborder">'."\n";
425
426 print '<tr class="liste_titre">'."\n";
427 print '<td class="liste_titre left">'.$langs->trans("Content").'</td>'."\n";
428 print '<td class="liste_titre center">'.$langs->trans("Size").'</td>'."\n";
429 print '<td class="liste_titre center">'.$langs->trans("Date").'</td>'."\n";
430 print '<td class="liste_titre center">'.$langs->trans("Owner").'</td>'."\n";
431 print '<td class="liste_titre center">'.$langs->trans("Group").'</td>'."\n";
432 print '<td class="liste_titre center">'.$langs->trans("Permissions").'</td>'."\n";
433 print '<td class="liste_titre nowrap right">';
434 if ($conf->use_javascript_ajax) {
435 print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
436 }
437 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($section ? '&section='.urlencode($section) : '').'">'.img_picto($langs->trans("Refresh"), 'refresh').'</a>&nbsp;';
438 print '</td>'."\n";
439 print '</tr>'."\n";
440
441 // set up a connection or die
442 if (empty($conn_id)) {
443 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive);
444
445 $conn_id = $resultarray['conn_id'];
446 $ok = $resultarray['ok'];
447 $mesg = $resultarray['mesg'];
448 }
449
450 if ($ok) {
451 //$type = ftp_systype($conn_id);
452
453 $newsection = $section;
454 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
455 //$newsection='/home';
456
457 // List content of directory ($newsection = '/', '/home', ...)
458 if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
459 if ($newsection == '/') {
460 //$newsection = '/./';
461 $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
462 }
463
464 //$newsection='/';
465 //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection);
466 //$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./');
467
468 $contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection);
469 $buff = array();
470 foreach ($contents as $i => $key) {
471 $buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key;
472 }
473
474 //$i = 0;
475 //$handle = opendir('ssh2.sftp://'.intval($conn_id).$newsection);
476 //$buff=array();
477 //while (false !== ($file = readdir($handle))) {
478 // if (substr("$file", 0, 1) != "."){
479 // if (is_dir($file)) {
480 // $buff[$i]="d--------- - root root 1234 Aug 01 2000 ".$file;
481 // } else {
482 // $buff[$i]="---------- - root root 1234 Aug 01 2000 ".$file;
483 // }
484 // }
485 // $i++;
486 //}
487 } else {
488 $buff = ftp_rawlist($conn_id, $newsectioniso);
489 $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist
490 }
491
492 $nboflines = count($contents);
493 $rawlisthasfailed = false;
494 $i = 0;
495 $nbofentries = 0;
496 while ($i < $nboflines && $i < 1000) {
497 $vals = preg_split('@ +@', mb_convert_encoding($buff[$i], 'UTF-8', 'ISO-8859-1'), 9);
498 //$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
499 $file = $vals[8];
500 if (empty($file)) {
501 $rawlisthasfailed = true;
502 $file = mb_convert_encoding($contents[$i], 'UTF-8', 'ISO-8859-1');
503 }
504
505 if ($file == '.' || ($file == '..' && $section == '/')) {
506 $i++;
507 continue;
508 }
509
510 // Is it a directory ?
511 $is_directory = 0;
512 $is_link = 0;
513 if ($file == '..') {
514 $is_directory = 1;
515 } elseif (!$rawlisthasfailed) {
516 if (preg_match('/^d/', $vals[0])) {
517 $is_directory = 1;
518 }
519 if (preg_match('/^l/', $vals[0])) {
520 $is_link = 1;
521 }
522 } else {
523 // Remote file
524 $filename = $file;
525 //print "section=".$section.' file='.$file.'X';
526 //print preg_match('@[\/]$@','aaa/').'Y';
527 //print preg_match('@[\\\/]$@',"aaa\\").'Y';
528 $remotefile = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').preg_replace('@^[\\\/]@', '', $file);
529 //print 'A'.$remotefile.'A';
530 $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
531 //print 'Z'.$newremotefileiso.'Z';
532 $is_directory = ftp_isdir($conn_id, $newremotefileiso);
533 }
534
535
536 print '<tr class="oddeven" height="18">';
537 // Name
538 print '<td>';
539 $newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file;
540 $newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa
541 if ($is_directory) {
542 print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
543 }
544 print dol_escape_htmltag($file);
545 if ($is_directory) {
546 print '</a>';
547 }
548 print '</td>';
549 // Size
550 print '<td class="center nowrap">';
551 if (!$is_directory && !$is_link) {
552 print $vals[4];
553 } else {
554 print '&nbsp;';
555 }
556 print '</td>';
557 // Date
558 print '<td class="center nowrap">';
559 print $vals[5].' '.$vals[6].' '.$vals[7];
560 print '</td>';
561 // User
562 print '<td class="center nowrap">';
563 print $vals[2];
564 print '</td>';
565 // Group
566 print '<td class="center nowrap">';
567 print $vals[3];
568 print '</td>';
569 // Permissions
570 print '<td class="center nowrap">';
571 print $vals[0];
572 print '</td>';
573 // Action
574 print '<td class="right nowrap" width="64">';
575 if ($is_directory) {
576 if ($file != '..') {
577 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
578 } else {
579 print '&nbsp;';
580 }
581 } elseif ($is_link) {
582 $newfile = $file;
583 $newfile = preg_replace('/ ->.*/', '', $newfile);
584 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>';
585 } else {
586 print '<a href="'.$_SERVER["PHP_SELF"].'?action=download&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_picto('', 'file').'</a>';
587 print ' &nbsp; ';
588 print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
589 print ' &nbsp; ';
590 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
591 print '<input type="hidden" name="const['.$i.'][section]" value="'.$section.'">';
592 print '<input type="hidden" name="const['.$i.'][file]" value="'.$file.'">';
593 }
594 print '</td>';
595 print '</tr>'."\n";
596 $i++;
597 $nbofentries++;
598 }
599 }
600
601 print "</table>";
602
603
604 if (!$ok) {
605 print $mesg.'<br>'."\n";
606 setEventMessages($mesg, null, 'errors');
607 }
608
609
610 // Actions
611
612 print '<br>';
613 print '<div id="delconst" class="right">';
614 print '<input type="submit" name="delete" class="button" value="'.$langs->trans("Delete").'">';
615 print '</div>';
616
617 print "</form>";
618
619 if ($user->hasRight('ftp', 'write')) {
620 print load_fiche_titre($langs->trans("AttachANewFile"), '', '');
621 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post">';
622 print '<input type="hidden" name="token" value="'.newToken().'">';
623 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
624 print '<input type="hidden" name="section" value="'.$section.'">';
625 print '<input type="hidden" name="action" value="uploadfile">';
626 print '<td><input type="file" class="flat" name="userfile[]" multiple></td>';
627 print '<td></td>';
628 print '<td align="center"><button type="submit" class="butAction" name="uploadfile" value="'.$langs->trans("Save").'">'.$langs->trans("Upload").'</button></td>';
629 print '</form>';
630
631 print '<br><br>';
632
633 print load_fiche_titre($langs->trans("AddFolder"), '', '');
634 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post">';
635 print '<input type="hidden" name="token" value="'.newToken().'">';
636 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
637 print '<input type="hidden" name="section" value="'.$section.'">';
638 print '<input type="hidden" name="action" value="addfolder">';
639 print '<td><input type="text" class="flat" name="newfolder" multiple></td>';
640 print '<td></td>';
641 print '<td align="center"><button type="submit" class="butAction" name="addfolder" value="'.$langs->trans("Save").'">'.$langs->trans("AddFolder").'</button></td>';
642 print '</form>';
643 }
644 } else {
645 $foundsetup = false;
646 $MAXFTP = 20;
647 $i = 1;
648 while ($i <= $MAXFTP) {
649 $paramkey = 'FTP_NAME_'.$i;
650 //print $paramkey;
651 if (getDolGlobalString($paramkey)) {
652 $foundsetup = true;
653 break;
654 }
655 $i++;
656 }
657 if (!$foundsetup) {
658 print $langs->trans("SetupOfFTPClientModuleNotComplete");
659 } else {
660 print $langs->trans("ChooseAFTPEntryIntoMenu");
661 }
662 }
663}
664
665print '<br>';
666
667if (!empty($conn_id)) {
668 $disconnect = dol_ftp_close($conn_id);
669
670 if (!$disconnect) {
671 setEventMessages($langs->trans("ErrorFTPNodisconnect"), null, 'errors');
672 }
673}
674
675// End of page
676llxFooter();
677$db->close();
$id
Definition account.php:39
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage ECM directories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_ftp_mkdir($connect_id, $newdir, $newsection)
Remove FTP directory.
Definition ftp.lib.php:282
ftp_isdir($connect_id, $dir)
Tell if an entry is a FTP directory.
Definition ftp.lib.php:128
dol_ftp_close($connect_id)
Tell if an entry is a FTP directory.
Definition ftp.lib.php:144
dol_ftp_delete($connect_id, $file, $newsection)
Delete a FTP file.
Definition ftp.lib.php:165
dol_ftp_rmdir($connect_id, $file, $newsection)
Remove FTP directory.
Definition ftp.lib.php:253
dol_ftp_put($connect_id, $file, $localfile, $newsection)
Upload a FTP file.
Definition ftp.lib.php:225
dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive=0)
Connect to FTP server.
Definition ftp.lib.php:39
dol_ftp_get($connect_id, $localfile, $file, $newsection)
Download a FTP file.
Definition ftp.lib.php:196
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.