dolibarr  7.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  *
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  * http://www.gnu.org/licenses/gpl.html
13  *
14  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15  * http://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 DoResponse();
37 
43 function DoResponse()
44 {
45  if (!isset($_GET)) {
46  global $_GET;
47  }
48  if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
49  return;
50 
51  // Get the main request informaiton.
52  $sCommand = $_GET['Command'] ;
53  $sResourceType = $_GET['Type'] ;
54  $sCurrentFolder = GetCurrentFolder();
55 
56  // Check if it is an allowed command
57  if (! IsAllowedCommand($sCommand))
58  {
59  SendError(1, 'The "' . $sCommand . '" command isn\'t allowed');
60  }
61  // Check if it is an allowed type.
62  if (! IsAllowedType($sResourceType))
63  SendError(1, 'Invalid type specified');
64 
65  // File Upload doesn't have to Return XML, so it must be intercepted before anything.
66  if ( $sCommand == 'FileUpload' )
67  {
68  FileUpload($sResourceType, $sCurrentFolder, $sCommand);
69  return;
70  }
71 
72  CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
73 
74  // Execute the required command.
75  switch ( $sCommand )
76  {
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 }
This class is used to manage file upload using ajax.