dolibarr 21.0.0-alpha
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['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) {
44 return;
45 }
46
47 // Get the main request information.
48 $sCommand = GETPOST('Command');
49 $sResourceType = GETPOST('Type');
50 $sCurrentFolder = GetCurrentFolder();
51
52 // Check if it is an allowed command
53 if (!IsAllowedCommand($sCommand)) {
54 SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
55 }
56 // Check if it is an allowed type.
57 if (!IsAllowedType($sResourceType)) {
58 SendError(1, 'Invalid type specified');
59 }
60
61 // File Upload doesn't have to Return XML, so it must be intercepted before anything.
62 if ($sCommand == 'FileUpload') {
63 FileUpload($sResourceType, $sCurrentFolder, $sCommand);
64 return;
65 }
66
67 CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
68
69 // Execute the required command.
70 switch ($sCommand) {
71 case 'GetFolders':
72 GetFolders($sResourceType, $sCurrentFolder);
73 break;
74 case 'GetFoldersAndFiles':
75 GetFoldersAndFiles($sResourceType, $sCurrentFolder);
76 break;
77 case 'CreateFolder':
78 CreateFolder($sResourceType, $sCurrentFolder);
79 break;
80 }
81
82 CreateXmlFooter();
83
84 exit;
85}
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.