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