dolibarr 21.0.0-beta
connector.php
1<?php
2/*
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * == BEGIN LICENSE ==
8 *
9 * Licensed under the terms of any of the following licenses at your
10 * choice:
11 *
12 * - GNU General Public License Version 2 or later (the "GPL")
13 * https://www.gnu.org/licenses/gpl.html
14 *
15 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
16 * https://www.gnu.org/licenses/lgpl.html
17 *
18 * - Mozilla Public License Version 1.1 or later (the "MPL")
19 * http://www.mozilla.org/MPL/MPL-1.1.html
20 *
21 * == END LICENSE ==
22 *
23 * This is the File Manager Connector for PHP. It returns a XML file used by browser.php
24 */
25
26ob_start();
27
28require 'config.inc.php'; // This include the main.inc.php
29require 'connector.lib.php';
30
31if (!$Config['Enabled']) {
32 SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.inc.php" file');
33}
34
35DoResponse();
36
42function DoResponse()
43{
44 if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) {
45 return;
46 }
47
48 // Get the main request information.
49 $sCommand = GETPOST('Command');
50 $sResourceType = GETPOST('Type');
51 $sCurrentFolder = GetCurrentFolder();
52
53 // Check if it is an allowed command
54 if (!IsAllowedCommand($sCommand)) {
55 SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
56 }
57 // Check if it is an allowed type.
58 if (!IsAllowedType($sResourceType)) {
59 SendError(1, 'Invalid type specified');
60 }
61
62 // File Upload doesn't have to Return XML, so it must be intercepted before anything.
63 if ($sCommand == 'FileUpload') {
64 FileUpload($sResourceType, $sCurrentFolder, $sCommand);
65 // @phan-suppress-next-line PhanPluginUnreachableCode
66 return; // FileUpload exits @phpstan-ignore-line
67 }
68
69 CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
70
71 // Execute the required command.
72 switch ($sCommand) {
73 case 'GetFolders':
74 GetFolders($sResourceType, $sCurrentFolder);
75 break;
76 case 'GetFoldersAndFiles':
77 GetFoldersAndFiles($sResourceType, $sCurrentFolder);
78 break;
79 case 'CreateFolder':
80 CreateFolder($sResourceType, $sCurrentFolder);
81 break;
82 }
83
84 CreateXmlFooter();
85
86 exit;
87}
This class is used to manage file upload using ajax.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.