dolibarr 21.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 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 // set up a connection or die
111 if (!$conn_id) {
112 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
113 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
114 $conn_id = $resultarray['conn_id'];
115 $ok = $resultarray['ok'];
116 $mesg = $resultarray['mesg'];
117 }
118 if ($conn_id && $ok && !$mesg) {
119 $nbfile = count($_FILES['userfile']['name']);
120 for ($i = 0; $i < $nbfile; $i++) {
121 $newsection = $newsectioniso;
122 $fileupload = dol_sanitizeFileName($_FILES['userfile']['name'][$i]);
123 $fileuploadpath = dol_sanitizePathName($_FILES['userfile']['tmp_name'][$i]);
124 $result = dol_ftp_put($conn_id, $fileupload, $fileuploadpath, $newsection);
125
126 if ($result) {
127 setEventMessages($langs->trans("FileWasUpload", $fileupload), null, 'mesgs');
128 } else {
129 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
130 setEventMessages($langs->trans("FTPFailedToUploadFile", $fileupload), null, 'errors');
131 }
132 }
133 $action = '';
134 } else {
135 dol_print_error(null, $mesg);
136 }
137}
138
139if ($action == 'addfolder' && $user->hasRight('ftp', 'write')) {
140 // set up a connection or die
141 if (!$conn_id) {
142 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
143 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
144 $conn_id = $resultarray['conn_id'];
145 $ok = $resultarray['ok'];
146 $mesg = $resultarray['mesg'];
147 }
148 if ($conn_id && $ok && !$mesg) {
149 $result = dol_ftp_mkdir($conn_id, $newfolder, $newsectioniso);
150
151 if ($result) {
152 setEventMessages($langs->trans("FileWasCreateFolder", $newfolder), null, 'mesgs');
153 } else {
154 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
155 setEventMessages($langs->trans("FTPFailedToCreateFolder", $newfolder), null, 'errors');
156 }
157 $action = '';
158 } else {
159 dol_print_error(null, $mesg);
160 }
161}
162
163// Action ajout d'un rep
164if ($action == 'add' && $user->hasRight('ftp', 'write')) {
165 $ecmdir = new EcmDirectory($db);
166 $ecmdir->ref = GETPOST("ref");
167 $ecmdir->label = GETPOST("label");
168 $ecmdir->description = GETPOST("desc");
169
170 $id = $ecmdir->create($user);
171 if ($id > 0) {
172 header("Location: ".$_SERVER["PHP_SELF"]);
173 exit;
174 } else {
175 setEventMessages($langs->trans("ErrorFailToCreateDir"), null, 'errors');
176 $action = "create";
177 }
178}
179
180// Remove 1 file
181if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes' && $user->hasRight('ftp', 'write')) {
182 // set up a connection or die
183 if (!$conn_id) {
184 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
185 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
186 $conn_id = $resultarray['conn_id'];
187 $ok = $resultarray['ok'];
188 $mesg = $resultarray['mesg'];
189 }
190
191 if ($conn_id && $ok && !$mesg) {
192 $newsection = $section;
193 $result = dol_ftp_delete($conn_id, $file, $newsection);
194
195 if ($result) {
196 setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
197 } else {
198 dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
199 setEventMessages($langs->trans("FTPFailedToRemoveFile", $file), null, 'errors');
200 }
201
202 $action = '';
203 } else {
204 dol_print_error(null, $mesg);
205 }
206}
207
208// Delete several lines at once
209if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete") && $user->hasRight('ftp', 'write')) {
210 // set up a connection or die
211 if (!$conn_id) {
212 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
213 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
214 $conn_id = $resultarray['conn_id'];
215 $ok = $resultarray['ok'];
216 $mesg = $resultarray['mesg'];
217 }
218
219 if ($conn_id && $ok && !$mesg) {
220 foreach (GETPOST('const', 'array') as $const) {
221 if (isset($const["check"])) { // Is checkbox checked
222 $langs->load("other");
223
224 // Remote file
225 $file = $const["file"];
226 $newsection = $const["section"];
227
228 $result = dol_ftp_delete($conn_id, $file, $newsection);
229
230 if ($result) {
231 setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
232 } else {
233 dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR);
234 setEventMessages($langs->trans("FTPFailedToRemoveFile", $file), null, 'errors');
235 }
236
237 //ftp_close($conn_id); Close later
238
239 $action = '';
240 }
241 }
242 } else {
243 dol_print_error(null, $mesg);
244 }
245}
246
247// Remove directory
248if ($action == 'confirm_deletesection' && $confirm == 'yes' && $user->hasRight('ftp', 'write')) {
249 // set up a connection or die
250 if (!$conn_id) {
251 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
252 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
253 $conn_id = $resultarray['conn_id'];
254 $ok = $resultarray['ok'];
255 $mesg = $resultarray['mesg'];
256 }
257
258 if ($conn_id && $ok && !$mesg) {
259 $newsection = $section;
260
261 $result = dol_ftp_rmdir($conn_id, $file, $newsection);
262
263 if ($result) {
264 setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs');
265 } else {
266 setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors');
267 }
268
269 //ftp_close($conn_id); Close later
270
271 $action = '';
272 } else {
273 dol_print_error(null, $mesg);
274 }
275}
276
277// Download directory
278if ($action == 'download' && $user->hasRight('ftp', 'read')) {
279 // set up a connection or die
280 if (!$conn_id) {
281 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
282 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
283 $conn_id = $resultarray['conn_id'];
284 $ok = $resultarray['ok'];
285 $mesg = $resultarray['mesg'];
286 }
287
288 if ($conn_id && $ok && !$mesg) {
289 // Local file
290 $localfile = tempnam($download_dir, 'dol_');
291
292 $newsection = $section;
293
294 $result = dol_ftp_get($conn_id, $localfile, $file, $newsection);
295
296
297 if ($result) {
298 dolChmod($localfile);
299
300 // Define mime type
301 $type = 'application/octet-stream';
302 if (GETPOSTISSET("type")) {
303 $type = GETPOST("type");
304 } else {
305 $type = dol_mimetype($file);
306 }
307
308 // Define attachment (attachment=true to force choice popup 'open'/'save as')
309 $attachment = true;
310
311 //if ($encoding) header('Content-Encoding: '.$encoding);
312 if ($type) {
313 header('Content-Type: '.$type);
314 }
315 if ($attachment) {
316 header('Content-Disposition: attachment; filename="'.$file.'"');
317 } else {
318 header('Content-Disposition: inline; filename="'.$file.'"');
319 }
320
321 // Ajout directives pour resoudre bug IE
322 header('Cache-Control: Public, must-revalidate');
323 header('Pragma: public');
324
325 readfile($localfile);
326
327 exit;
328 } else {
329 setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $file), null, 'errors');
330 }
331 } else {
332 dol_print_error(null, $mesg);
333 }
334
335 //ftp_close($conn_id); Close later
336}
337
338
339/*
340 * View
341 */
342
343llxHeader();
344
345// Add logic to shoow/hide buttons
346if ($conf->use_javascript_ajax) {
347 ?>
348<script type="text/javascript">
349jQuery(document).ready(function() {
350 jQuery("#delconst").hide();
351
352 jQuery(".checkboxfordelete").click(function() {
353 jQuery("#delconst").show();
354 });
355
356 $("#checkall").click(function() {
357 $(".checkboxfordelete").prop('checked', true);
358 jQuery("#delconst").show();
359 });
360 $("#checknone").click(function() {
361 $(".checkboxfordelete").prop('checked', false);
362 jQuery("#delconst").hide();
363 });
364
365});
366
367</script>
368
369 <?php
370}
371
372$form = new Form($db);
373$formfile = new FormFile($db);
374$userstatic = new User($db);
375
376
377// List
378print load_fiche_titre($langs->trans("FTPArea"));
379
380print $langs->trans("FTPAreaDesc")."<br>";
381
382if (!function_exists('ftp_connect')) {
383 print $langs->trans("FTPFeatureNotSupportedByYourPHP");
384} else {
385 if (!empty($ftp_server)) {
386 // Confirm remove file
387 if ($action == 'delete') {
388 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);
389 }
390
391 // Confirmation de la suppression d'une ligne categorie
392 if ($action == 'delete_section') {
393 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);
394 }
395
396 print $langs->trans("Server").': <b>'.$ftp_server.'</b><br>';
397 print $langs->trans("Port").': <b>'.$ftp_port.'</b> '.($ftp_passive ? "(Passive)" : "(Active)").'<br>';
398 print $langs->trans("User").': <b>'.$ftp_user.'</b><br>';
399 print $langs->trans("FTPs (FTP over SSH)").': <b>'.yn(getDolGlobalString('FTP_CONNECT_WITH_SSL')).'</b><br>';
400 print $langs->trans("SFTP (FTP as a subsystem of SSH)").': <b>'.yn(getDolGlobalString('FTP_CONNECT_WITH_SFTP')).'</b><br>';
401 print $langs->trans("Directory").': ';
402 $sectionarray = preg_split('|[\/]|', $section);
403 // For /
404 $newsection = '/';
405 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($newsection ? '&section='.urlencode($newsection) : '').'">';
406 print '/';
407 print '</a> ';
408 // For other directories
409 $i = 0;
410 foreach ($sectionarray as $val) {
411 if (empty($val)) {
412 continue; // Discard first and last entry that should be empty as section start/end with /
413 }
414 if ($i > 0) {
415 print ' / ';
416 $newsection .= '/';
417 }
418 $newsection .= $val;
419 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($newsection ? '&section='.urlencode($newsection) : '').'">';
420 print $val;
421 print '</a>';
422 $i++;
423 }
424 print '<br>';
425 print "<br>\n";
426
427 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
428 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
429 print '<input type="hidden" name="token" value="'.newToken().'">';
430
431
432 // Construit liste des repertoires
433 print '<table width="100%" class="noborder">'."\n";
434
435 print '<tr class="liste_titre">'."\n";
436 print '<td class="liste_titre left">'.$langs->trans("Content").'</td>'."\n";
437 print '<td class="liste_titre center">'.$langs->trans("Size").'</td>'."\n";
438 print '<td class="liste_titre center">'.$langs->trans("Date").'</td>'."\n";
439 print '<td class="liste_titre center">'.$langs->trans("Owner").'</td>'."\n";
440 print '<td class="liste_titre center">'.$langs->trans("Group").'</td>'."\n";
441 print '<td class="liste_titre center">'.$langs->trans("Permissions").'</td>'."\n";
442 print '<td class="liste_titre nowrap right">';
443 if ($conf->use_javascript_ajax) {
444 print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
445 }
446 print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($section ? '&section='.urlencode($section) : '').'">'.img_picto($langs->trans("Refresh"), 'refresh').'</a>&nbsp;';
447 print '</td>'."\n";
448 print '</tr>'."\n";
449
450 // set up a connection or die
451 if (empty($conn_id)) {
452 $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive);
453
454 $conn_id = $resultarray['conn_id'];
455 $ok = $resultarray['ok'];
456 $mesg = $resultarray['mesg'];
457 }
458
459 if ($ok) {
460 //$type = ftp_systype($conn_id);
461
462 $newsection = $section;
463 $newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
464 //$newsection='/home';
465
466 // List content of directory ($newsection = '/', '/home', ...)
467 if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
468 if ($newsection == '/') {
469 //$newsection = '/./';
470 $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
471 }
472
473 //$newsection='/';
474 //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection);
475 //$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./');
476
477 $contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection);
478 $buff = array();
479 foreach ($contents as $i => $key) {
480 $buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key;
481 }
482
483 //$i = 0;
484 //$handle = opendir('ssh2.sftp://'.intval($conn_id).$newsection);
485 //$buff=array();
486 //while (false !== ($file = readdir($handle))) {
487 // if (substr("$file", 0, 1) != "."){
488 // if (is_dir($file)) {
489 // $buff[$i]="d--------- - root root 1234 Aug 01 2000 ".$file;
490 // } else {
491 // $buff[$i]="---------- - root root 1234 Aug 01 2000 ".$file;
492 // }
493 // }
494 // $i++;
495 //}
496 } elseif (!empty($conn_id)) {
497 $buff = ftp_rawlist($conn_id, $newsectioniso);
498 $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist
499 } else {
500 dol_syslog(__FILE__ . ": Unexpected state for ftp connection", LOG_ERR);
501 $buff = array();
502 $contents = array();
503 }
504
505 $nboflines = count($contents);
506 $rawlisthasfailed = false;
507 $i = 0;
508 $nbofentries = 0;
509 while ($i < $nboflines && $i < 1000) {
510 $vals = preg_split('@ +@', mb_convert_encoding($buff[$i], 'UTF-8', 'ISO-8859-1'), 9);
511 //$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
512 $file = $vals[8];
513 if (empty($file)) {
514 $rawlisthasfailed = true;
515 $file = mb_convert_encoding($contents[$i], 'UTF-8', 'ISO-8859-1');
516 }
517
518 if ($file == '.' || ($file == '..' && $section == '/')) {
519 $i++;
520 continue;
521 }
522
523 // Is it a directory ?
524 $is_directory = 0;
525 $is_link = 0;
526 if ($file == '..') {
527 $is_directory = 1;
528 } elseif (!$rawlisthasfailed) {
529 if (preg_match('/^d/', $vals[0])) {
530 $is_directory = 1;
531 }
532 if (preg_match('/^l/', $vals[0])) {
533 $is_link = 1;
534 }
535 } else {
536 // Remote file
537 $filename = $file;
538 //print "section=".$section.' file='.$file.'X';
539 //print preg_match('@[\/]$@','aaa/').'Y';
540 //print preg_match('@[\\\/]$@',"aaa\\").'Y';
541 $remotefile = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').preg_replace('@^[\\\/]@', '', $file);
542 //print 'A'.$remotefile.'A';
543 $newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
544 //print 'Z'.$newremotefileiso.'Z';
545 $is_directory = ftp_isdir($conn_id, $newremotefileiso);
546 }
547
548
549 print '<tr class="oddeven" height="18">';
550 // Name
551 print '<td>';
552 $newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file;
553 $newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa
554 if ($is_directory) {
555 print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
556 }
557 print dol_escape_htmltag($file);
558 if ($is_directory) {
559 print '</a>';
560 }
561 print '</td>';
562 // Size
563 print '<td class="center nowrap">';
564 if (!$is_directory && !$is_link) {
565 print $vals[4];
566 } else {
567 print '&nbsp;';
568 }
569 print '</td>';
570 // Date
571 print '<td class="center nowrap">';
572 print $vals[5].' '.$vals[6].' '.$vals[7];
573 print '</td>';
574 // User
575 print '<td class="center nowrap">';
576 print $vals[2];
577 print '</td>';
578 // Group
579 print '<td class="center nowrap">';
580 print $vals[3];
581 print '</td>';
582 // Permissions
583 print '<td class="center nowrap">';
584 print $vals[0];
585 print '</td>';
586 // Action
587 print '<td class="right nowrap" width="64">';
588 if ($is_directory) {
589 if ($file != '..') {
590 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
591 } else {
592 print '&nbsp;';
593 }
594 } elseif ($is_link) {
595 $newfile = $file;
596 $newfile = preg_replace('/ ->.*/', '', $newfile);
597 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>';
598 } else {
599 print '<a href="'.$_SERVER["PHP_SELF"].'?action=download&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_picto('', 'file').'</a>';
600 print ' &nbsp; ';
601 print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
602 print ' &nbsp; ';
603 print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
604 print '<input type="hidden" name="const['.$i.'][section]" value="'.$section.'">';
605 print '<input type="hidden" name="const['.$i.'][file]" value="'.$file.'">';
606 }
607 print '</td>';
608 print '</tr>'."\n";
609 $i++;
610 $nbofentries++;
611 }
612 }
613
614 print "</table>";
615
616
617 if (!$ok) {
618 print $mesg.'<br>'."\n";
619 setEventMessages($mesg, null, 'errors');
620 }
621
622
623 // Actions
624
625 print '<br>';
626 print '<div id="delconst" class="right">';
627 print '<input type="submit" name="delete" class="button" value="'.$langs->trans("Delete").'">';
628 print '</div>';
629
630 print "</form>";
631
632 if ($user->hasRight('ftp', 'write')) {
633 print load_fiche_titre($langs->trans("AttachANewFile"), '', '');
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="uploadfile">';
639 print '<td><input type="file" class="flat" name="userfile[]" multiple></td>';
640 print '<td></td>';
641 print '<td align="center"><button type="submit" class="butAction" name="uploadfile" value="'.$langs->trans("Save").'">'.$langs->trans("Upload").'</button></td>';
642 print '</form>';
643
644 print '<br><br>';
645
646 print load_fiche_titre($langs->trans("AddFolder"), '', '');
647 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post">';
648 print '<input type="hidden" name="token" value="'.newToken().'">';
649 print '<input type="hidden" name="numero_ftp" value="'.$numero_ftp.'">';
650 print '<input type="hidden" name="section" value="'.$section.'">';
651 print '<input type="hidden" name="action" value="addfolder">';
652 print '<td><input type="text" class="flat" name="newfolder" multiple></td>';
653 print '<td></td>';
654 print '<td align="center"><button type="submit" class="butAction" name="addfolder" value="'.$langs->trans("Save").'">'.$langs->trans("AddFolder").'</button></td>';
655 print '</form>';
656 }
657 } else {
658 $foundsetup = false;
659 $MAXFTP = 20;
660 $i = 1;
661 while ($i <= $MAXFTP) {
662 $paramkey = 'FTP_NAME_'.$i;
663 //print $paramkey;
664 if (getDolGlobalString($paramkey)) {
665 $foundsetup = true;
666 break;
667 }
668 $i++;
669 }
670 if (!$foundsetup) {
671 print $langs->trans("SetupOfFTPClientModuleNotComplete");
672 } else {
673 print $langs->trans("ChooseAFTPEntryIntoMenu");
674 }
675 }
676}
677
678print '<br>';
679
680if (!empty($conn_id)) {
681 $disconnect = dol_ftp_close($conn_id);
682
683 if (!$disconnect) {
684 setEventMessages($langs->trans("ErrorFTPNodisconnect"), null, 'errors');
685 }
686}
687
688// End of page
689llxFooter();
690$db->close();
$id
Definition account.php:48
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:71
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:283
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:166
dol_ftp_rmdir($connect_id, $file, $newsection)
Remove FTP directory.
Definition ftp.lib.php:254
dol_ftp_put($connect_id, $file, $localfile, $newsection)
Upload a FTP file.
Definition ftp.lib.php:226
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:197
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.
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_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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
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.