dolibarr 19.0.4
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 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 * - GNU General Public License Version 2 or later (the "GPL")
12 * https://www.gnu.org/licenses/gpl.html
13 *
14 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 * https://www.gnu.org/licenses/lgpl.html
16 *
17 * - Mozilla Public License Version 1.1 or later (the "MPL")
18 * http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * This is the File Manager Connector for PHP. It returns a XML file used by browser.php
23 */
24
25ob_start();
26
27require 'config.inc.php'; // This include the main.inc.php
28require 'connector.lib.php';
29
30if (!$Config['Enabled']) {
31 SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.inc.php" file');
32}
33
34DoResponse();
35
41function DoResponse()
42{
43 if (!isset($_GET)) {
44 global $_GET;
45 }
46 if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) {
47 return;
48 }
49
50 // Get the main request informaiton.
51 $sCommand = $_GET['Command'];
52 $sResourceType = $_GET['Type'];
53 $sCurrentFolder = GetCurrentFolder();
54
55 // Check if it is an allowed command
56 if (!IsAllowedCommand($sCommand)) {
57 SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
58 }
59 // Check if it is an allowed type.
60 if (!IsAllowedType($sResourceType)) {
61 SendError(1, 'Invalid type specified');
62 }
63
64 // File Upload doesn't have to Return XML, so it must be intercepted before anything.
65 if ($sCommand == 'FileUpload') {
66 FileUpload($sResourceType, $sCurrentFolder, $sCommand);
67 return;
68 }
69
70 CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
71
72 // Execute the required command.
73 switch ($sCommand) {
74 case 'GetFolders':
75 GetFolders($sResourceType, $sCurrentFolder);
76 break;
77 case 'GetFoldersAndFiles':
78 GetFoldersAndFiles($sResourceType, $sCurrentFolder);
79 break;
80 case 'CreateFolder':
81 CreateFolder($sResourceType, $sCurrentFolder);
82 break;
83 }
84
85 CreateXmlFooter();
86
87 exit;
88}
This class is used to manage file upload using ajax.