dolibarr 23.0.3
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-2025 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 // Confirmation de la suppression d'une ligne categorie
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')) {
470 if ($newsection == '/') {
471 //$newsection = '/./';
472 $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
473 }
474
475 //$newsection='/';
476 //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection);
477 //$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./');
478
479 $contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection);
480 $buff = array();
481 foreach ($contents as $i => $key) {
482 $buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key;
483 }
484
485 //$i = 0;
486 //$handle = opendir('ssh2.sftp://'.intval($conn_id).$newsection);
487 //$buff=array();
488 //while (false !== ($file = readdir($handle))) {
489 // if (substr("$file", 0, 1) != "."){
490 // if (is_dir($file)) {
491 // $buff[$i]="d--------- - root root 1234 Aug 01 2000 ".$file;
492 // } else {
493 // $buff[$i]="---------- - root root 1234 Aug 01 2000 ".$file;
494 // }
495 // }
496 // $i++;
497 //}
498 } elseif (!empty($conn_id)) {
499 $buff = ftp_rawlist($conn_id, $newsectioniso);
500 $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist
501 } else {
502 dol_syslog(__FILE__ . ": Unexpected state for ftp connection", LOG_ERR);
503 $buff = array();
504 $contents = array();
505 }
506
507 $nboflines = count($contents);
508 $rawlisthasfailed = false;
509 $i = 0;
510 $nbofentries = 0;
511 while ($i < $nboflines && $i < 1000) {
512 $vals = preg_split('@ +@', mb_convert_encoding($buff[$i], 'UTF-8', 'ISO-8859-1'), 9);
513 //$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
514 $file = $vals[8];
515 if (empty($file)) {
516 $rawlisthasfailed = true;
517 $file = mb_convert_encoding($contents[$i], 'UTF-8', 'ISO-8859-1');
518 }
519
520 if ($file == '.' || ($file == '..' && $section == '/')) {
521 $i++;
522 continue;
523 }
524
525 // Is it a directory ?
526 $is_directory = 0;
527 $is_link = 0;
528 if ($file == '..') {
529 $is_directory = 1;
530 } elseif (!$rawlisthasfailed) {
531 if (preg_match('/^d/', $vals[0])) {
532 $is_directory = 1;
533 }
534 if (preg_match('/^l/', $vals[0])) {
535 $is_link = 1;
536 }
537 } else {
538 // Remote file
539 $filename = $file;
540 //print "section=".$section.' file='.$file.'X';
541 //print preg_match('@[\/]$@','aaa/').'Y';
542 //print preg_match('@[\\\/]$@',"aaa\\").'Y';
543 $remotefile = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').preg_replace('@^[\\\/]@', '', $file);
544 //print 'A'.$remotefile.'A';
545 $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
546 //print 'Z'.$newremotefileiso.'Z';
547 $is_directory = ftp_isdir($conn_id, $newremotefileiso);
548 }
549
550
551 print '<tr class="oddeven" height="18">';
552 // Name
553 print '<td>';
554 $newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file;
555 $newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa
556 if ($is_directory) {
557 print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
558 }
559 print dol_escape_htmltag($file);
560 if ($is_directory) {
561 print '</a>';
562 }
563 print '</td>';
564 // Size
565 print '<td class="center nowrap">';
566 if (!$is_directory && !$is_link) {
567 print $vals[4];
568 } else {
569 print '&nbsp;';
570 }
571 print '</td>';
572 // Date
573 print '<td class="center nowrap">';
574 print $vals[5].' '.$vals[6].' '.$vals[7];
575 print '</td>';
576 // User
577 print '<td class="center nowrap">';
578 print $vals[2];
579 print '</td>';
580 // Group
581 print '<td class="center nowrap">';
582 print $vals[3];
583 print '</td>';
584 // Permissions
585 print '<td class="center nowrap">';
586 print $vals[0];
587 print '</td>';
588 // Action
589 print '<td class="right nowrap" width="64">';
590 if ($is_directory) {
591 if ($file != '..') {
592 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
593 } else {
594 print '&nbsp;';
595 }
596 } elseif ($is_link) {
597 $newfile = $file;
598 $newfile = preg_replace('/ ->.*/', '', $newfile);
599 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>';
600 } else {
601 print '<a href="'.$_SERVER["PHP_SELF"].'?action=download&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_picto('', 'file').'</a>';
602 print ' &nbsp; ';
603 print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
604 print ' &nbsp; ';
605 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
606 print '<input type="hidden" name="const['.$i.'][section]" value="'.$section.'">';
607 print '<input type="hidden" name="const['.$i.'][file]" value="'.$file.'">';
608 }
609 print '</td>';
610 print '</tr>'."\n";
611 $i++;
612 $nbofentries++;
613 }
614 }
615
616 print "</table>";
617
618
619 if (!$ok) {
620 print $mesg.'<br>'."\n";
621 setEventMessages($mesg, null, 'errors');
622 }
623
624
625 // Actions
626
627 print '<br>';
628 print '<div id="delconst" class="right">';
629 print '<input type="submit" name="delete" class="button" value="'.$langs->trans("Delete").'">';
630 print '</div>';
631
632 print "</form>";
633
634 if ($user->hasRight('ftp', 'write')) {
635 print load_fiche_titre($langs->trans("AttachANewFile"), '', '');
636 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post">';
637 print '<input type="hidden" name="token" value="'.newToken().'">';
638 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
639 print '<input type="hidden" name="section" value="'.$section.'">';
640 print '<input type="hidden" name="action" value="uploadfile">';
641 print '<td><input type="file" class="flat" name="userfile[]" multiple></td>';
642 print '<td></td>';
643 print '<td align="center"><button type="submit" class="butAction" name="uploadfile" value="'.$langs->trans("Save").'">'.$langs->trans("Upload").'</button></td>';
644 print '</form>';
645
646 print '<br><br>';
647
648 print load_fiche_titre($langs->trans("AddFolder"), '', '');
649 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post">';
650 print '<input type="hidden" name="token" value="'.newToken().'">';
651 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
652 print '<input type="hidden" name="section" value="'.$section.'">';
653 print '<input type="hidden" name="action" value="addfolder">';
654 print '<td><input type="text" class="flat" name="newfolder" multiple></td>';
655 print '<td></td>';
656 print '<td align="center"><button type="submit" class="butAction" name="addfolder" value="'.$langs->trans("Save").'">'.$langs->trans("AddFolder").'</button></td>';
657 print '</form>';
658 }
659 } else {
660 $foundsetup = false;
661 $MAXFTP = 20;
662 $i = 1;
663 while ($i <= $MAXFTP) {
664 $paramkey = 'FTP_NAME_'.$i;
665 //print $paramkey;
666 if (getDolGlobalString($paramkey)) {
667 $foundsetup = true;
668 break;
669 }
670 $i++;
671 }
672 if (!$foundsetup) {
673 print $langs->trans("SetupOfFTPClientModuleNotComplete");
674 } else {
675 print $langs->trans("ChooseAFTPEntryIntoMenu");
676 }
677 }
678}
679
680print '<br>';
681
682if (!empty($conn_id)) {
683 $disconnect = dol_ftp_close($conn_id);
684
685 if (!$disconnect) {
686 setEventMessages($langs->trans("ErrorFTPNodisconnect"), null, 'errors');
687 }
688}
689
690// End of page
691llxFooter();
692$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.
dol_ftp_mkdir($connect_id, $newdir, $newsection)
Remove FTP directory.
Definition ftp.lib.php:269
ftp_isdir($connect_id, $dir)
Tell if an entry is a FTP directory.
Definition ftp.lib.php:129
dol_ftp_close($connect_id)
Tell if an entry is a FTP directory.
Definition ftp.lib.php:145
dol_ftp_delete($connect_id, $file, $newsection)
Delete a FTP file.
Definition ftp.lib.php:164
dol_ftp_rmdir($connect_id, $file, $newsection)
Remove FTP directory.
Definition ftp.lib.php:243
dol_ftp_put($connect_id, $file, $localfile, $newsection)
Upload a FTP file.
Definition ftp.lib.php:218
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:192
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.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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:125
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.