dolibarr  x.y.z
browser.php
1 <?php
2 /* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
4  *
5  * Source modified from part of fckeditor (http://www.fckeditor.net)
6  * retrieved as GPL v2 or later
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 //define('NOTOKENRENEWAL',1); // Disables token renewal
23 //require '../../../../main.inc.php';
24 require '../../connectors/php/config.inc.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
25 
26 global $Config;
27 
28 top_httphead();
29 
30 ?>
31 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
32 <html>
33  <head>
34  <title><?php echo $langs->trans("MediaBrowser").' - '.$Config['UserFilesAbsolutePathRelative']; ?></title>
35  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
36 <?php
37 print '<!-- Includes CSS for Dolibarr theme -->'."\n";
38 // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
39 $themepath = dol_buildpath($conf->css, 1);
40 $themesubdir = '';
41 if (!empty($conf->modules_parts['theme'])) { // This slow down
42  foreach ($conf->modules_parts['theme'] as $reldir) {
43  if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
44  $themepath = dol_buildpath($reldir.$conf->css, 1);
45  $themesubdir = $reldir;
46  break;
47  }
48  }
49 }
50 
51 //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
52 print '<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.'">'."\n";
53 ?>
54  <script type="text/javascript" src="js/fckxml.js"></script>
55  <script type="text/javascript">
56 // Automatically detect the correct document.domain (#1919).
57 (function()
58 {
59  var d = document.domain ;
60 
61  while ( true )
62  {
63  // Test if we can access a parent property.
64  try
65  {
66  var test = window.opener.document.domain ;
67  break ;
68  }
69  catch( e )
70  {}
71 
72  // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
73  d = d.replace( /.*?(?:\.|$)/, '' );
74 
75  if ( d.length == 0 )
76  break ; // It was not able to detect the domain.
77 
78  try
79  {
80  document.domain = d ;
81  }
82  catch (e)
83  {
84  break ;
85  }
86  }
87 })();
88 
89 function GetUrlParam( paramName )
90 {
91  var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
92  var oMatch = oRegex.exec( window.top.location.search );
93 
94  if ( oMatch && oMatch.length > 1 )
95  return decodeURIComponent( oMatch[1] );
96  else
97  return '' ;
98 }
99 
100 var oConnector = new Object();
101 oConnector.CurrentFolder = '/' ;
102 
103 var sConnUrl = GetUrlParam( 'Connector' );
104 
105 // Gecko has some problems when using relative URLs (not starting with slash).
106 if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
107  sConnUrl = window.location.href.replace( /browser.php.*$/, '' ) + sConnUrl ;
108 
109 oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' );
110 
111 var sServerPath = GetUrlParam( 'ServerPath' );
112 if ( sServerPath.length > 0 )
113  oConnector.ConnectorUrl += 'ServerPath=' + encodeURIComponent( sServerPath ) + '&' ;
114 
115 /* @CHANGE LDR Overwrite value coming from parameters for security purpose */
116 oConnector.ConnectorUrl = '<?php echo DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php?'; ?>';
117 console.log('ConnectorUrl='+oConnector.ConnectorUrl);
118 
119 oConnector.ResourceType = GetUrlParam( 'Type' );
120 oConnector.ShowAllTypes = ( oConnector.ResourceType.length == 0 );
121 
122 if ( oConnector.ShowAllTypes )
123  oConnector.ResourceType = 'File' ;
124 
125 oConnector.SendCommand = function( command, params, callBackFunction )
126 {
127  var sUrl = this.ConnectorUrl + 'Command=' + command ;
128  sUrl += '&Type=' + this.ResourceType ;
129  sUrl += '&CurrentFolder=' + encodeURIComponent( this.CurrentFolder );
130 
131  if ( params ) sUrl += '&' + params ;
132 
133  // Add a random salt to avoid getting a cached version of the command execution
134  sUrl += '&uuid=' + new Date().getTime();
135 
136  var oXML = new FCKXml();
137 
138  if ( callBackFunction )
139  oXML.LoadUrl( sUrl, callBackFunction ); // Asynchronous load.
140  else
141  return oXML.LoadUrl( sUrl );
142 
143  return null ;
144 }
145 
146 oConnector.CheckError = function( responseXml )
147 {
148  var iErrorNumber = 0 ;
149  var oErrorNode = responseXml.SelectSingleNode( 'Connector/Error' );
150 
151  if ( oErrorNode )
152  {
153  iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value, 10 );
154 
155  switch ( iErrorNumber )
156  {
157  case 0:
158  break;
159  case 1: // Custom error. Message placed in the "text" attribute.
160  alert( oErrorNode.attributes.getNamedItem('text').value );
161  break;
162  case 101:
163  alert( 'Folder already exists' );
164  break;
165  case 102:
166  alert( 'Invalid folder name' );
167  break;
168  case 103:
169  alert( 'You have no permissions to create the folder' );
170  break;
171  case 110:
172  alert( 'Unknown error creating folder' );
173  break;
174  default:
175  alert( 'Error on your request. Error number: ' + iErrorNumber );
176  break;
177  }
178  }
179  return iErrorNumber ;
180 }
181 
182 var oIcons = new Object();
183 
184 oIcons.AvailableIconsArray = [
185  'ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js',
186  'mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip' ] ;
187 
188 oIcons.AvailableIcons = new Object();
189 
190 for ( var i = 0 ; i < oIcons.AvailableIconsArray.length ; i++ )
191  oIcons.AvailableIcons[ oIcons.AvailableIconsArray[i] ] = true ;
192 
193 oIcons.GetIcon = function( fileName )
194 {
195  var sExtension = fileName.substr( fileName.lastIndexOf('.') + 1 ).toLowerCase();
196 
197  if ( this.AvailableIcons[ sExtension ] == true )
198  return sExtension ;
199  else
200  return 'default.icon' ;
201 }
202 
203 function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
204 {
205  if (errorNumber == "1")
206  window.frames['frmUpload'].OnUploadCompleted( errorNumber, customMsg );
207  else
208  window.frames['frmUpload'].OnUploadCompleted( errorNumber, fileName );
209 }
210 
211  </script>
212  </head>
213  <frameset cols="200,*" framespacing="3" border="1" style="border: 2px solid #CCCCCC;">
214  <frame name="frmFolders" src="frmfolders.php" scrolling="auto" frameborder="1">
215  <frameset rows="50,*,70" framespacing="0">
216  <frame name="frmActualFolder" src="frmactualfolder.php" scrolling="no" frameborder="0">
217  <frame name="frmResourcesList" src="frmresourceslist.php" scrolling="auto" frameborder="0">
218  <frameset cols="200,*" framespacing="0" border="0">
219  <frame name="frmCreateFolder" src="frmcreatefolder.php" scrolling="no" frameborder="0">
220  <frame name="frmUpload" src="frmupload.php" scrolling="no" frameborder="0">
221  <frame name="frmUploadWorker" src="javascript:void(0)" scrolling="no" frameborder="0">
222  </frameset>
223  </frameset>
224  </frameset>
225 </html>
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1436
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:122