dolibarr 23.0.3
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
32require 'connector.lib.php';
33
34if (!$Config['Enabled']) {
35 SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.inc.php" file');
36}
37
38DoResponse();
39
45function DoResponse()
46{
47 if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) {
48 return;
49 }
50
51 // Get the main request information.
52 $sCommand = GETPOST('Command');
53 $sResourceType = GETPOST('Type');
54 $sCurrentFolder = GetCurrentFolder();
55
56 // Check if it is an allowed command
57 if (!IsAllowedCommand($sCommand)) {
58 SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
59 }
60 // Check if it is an allowed type.
61 if (!IsAllowedType($sResourceType)) {
62 SendError(1, 'Invalid type specified');
63 }
64
65 // File Upload doesn't have to Return XML, so it must be intercepted before anything.
66 if ($sCommand == 'FileUpload') {
67 FileUpload($sResourceType, $sCurrentFolder, $sCommand);
68 // @phan-suppress-next-line PhanPluginUnreachableCode
69 return; // FileUpload exits @phpstan-ignore-line
70 }
71
72 CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
73
74 // Execute the required command.
75 switch ($sCommand) {
76 case 'GetFolders':
77 GetFolders($sResourceType, $sCurrentFolder);
78 break;
79 case 'GetFoldersAndFiles':
80 GetFoldersAndFiles($sResourceType, $sCurrentFolder);
81 break;
82 case 'CreateFolder':
83 CreateFolder($sResourceType, $sCurrentFolder);
84 break;
85 }
86
87 CreateXmlFooter();
88
89 exit;
90}
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.