dolibarr  16.0.5
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.
23  */
24 
25 ob_start();
26 
27 require 'config.php';
28 require 'util.php';
29 require 'io.php';
30 require 'basexml.php';
31 require 'commands.php';
32 
33 if (!$Config['Enabled']) {
34  SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
35 }
36 
37 DoResponse();
38 
44 function DoResponse()
45 {
46  if (!isset($_GET)) {
47  global $_GET;
48  }
49  if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) {
50  return;
51  }
52 
53  // Get the main request informaiton.
54  $sCommand = $_GET['Command'];
55  $sResourceType = $_GET['Type'];
56  $sCurrentFolder = GetCurrentFolder();
57 
58  // Check if it is an allowed command
59  if (!IsAllowedCommand($sCommand)) {
60  SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
61  }
62  // Check if it is an allowed type.
63  if (!IsAllowedType($sResourceType)) {
64  SendError(1, 'Invalid type specified');
65  }
66 
67  // File Upload doesn't have to Return XML, so it must be intercepted before anything.
68  if ($sCommand == 'FileUpload') {
69  FileUpload($sResourceType, $sCurrentFolder, $sCommand);
70  return;
71  }
72 
73  CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
74 
75  // Execute the required command.
76  switch ($sCommand) {
77  case 'GetFolders':
78  GetFolders($sResourceType, $sCurrentFolder);
79  break;
80  case 'GetFoldersAndFiles':
81  GetFoldersAndFiles($sResourceType, $sCurrentFolder);
82  break;
83  case 'CreateFolder':
84  CreateFolder($sResourceType, $sCurrentFolder);
85  break;
86  }
87 
88  CreateXmlFooter();
89 
90  exit;
91 }
FileUpload
This class is used to manage file upload using ajax.
Definition: fileupload.class.php:31