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