browser.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. //define('NOTOKENRENEWAL',1); // Disables token renewal
  22. //require '../../../../main.inc.php';
  23. require '../../connectors/php/config.inc.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
  24. global $Config;
  25. top_httphead();
  26. ?>
  27. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
  28. <html>
  29. <head>
  30. <title><?php echo $langs->trans("MediaBrowser").' - '.$Config['UserFilesAbsolutePathRelative']; ?></title>
  31. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  32. <?php
  33. print '<!-- Includes CSS for Dolibarr theme -->'."\n";
  34. // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
  35. $themepath = dol_buildpath($conf->css, 1);
  36. $themesubdir = '';
  37. if (!empty($conf->modules_parts['theme'])) { // This slow down
  38. foreach ($conf->modules_parts['theme'] as $reldir) {
  39. if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
  40. $themepath = dol_buildpath($reldir.$conf->css, 1);
  41. $themesubdir = $reldir;
  42. break;
  43. }
  44. }
  45. }
  46. //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
  47. $themeparam = '';
  48. print '<link rel="stylesheet" type="text/css" href="'.$themepath.$themeparam.'">'."\n";
  49. ?>
  50. <script type="text/javascript" src="js/fckxml.js"></script>
  51. <script type="text/javascript">
  52. // Automatically detect the correct document.domain (#1919).
  53. (function()
  54. {
  55. var d = document.domain ;
  56. while ( true )
  57. {
  58. // Test if we can access a parent property.
  59. try
  60. {
  61. var test = window.opener.document.domain ;
  62. break ;
  63. }
  64. catch( e )
  65. {}
  66. // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
  67. d = d.replace( /.*?(?:\.|$)/, '' );
  68. if ( d.length == 0 )
  69. break ; // It was not able to detect the domain.
  70. try
  71. {
  72. document.domain = d ;
  73. }
  74. catch (e)
  75. {
  76. break ;
  77. }
  78. }
  79. })();
  80. function GetUrlParam( paramName )
  81. {
  82. var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
  83. var oMatch = oRegex.exec( window.top.location.search );
  84. if ( oMatch && oMatch.length > 1 )
  85. return decodeURIComponent( oMatch[1] );
  86. else
  87. return '' ;
  88. }
  89. var oConnector = new Object();
  90. oConnector.CurrentFolder = '/' ;
  91. var sConnUrl = GetUrlParam( 'Connector' );
  92. // Gecko has some problems when using relative URLs (not starting with slash).
  93. if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
  94. sConnUrl = window.location.href.replace( /browser.php.*$/, '' ) + sConnUrl ;
  95. oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' );
  96. var sServerPath = GetUrlParam( 'ServerPath' );
  97. if ( sServerPath.length > 0 )
  98. oConnector.ConnectorUrl += 'ServerPath=' + encodeURIComponent( sServerPath ) + '&' ;
  99. /* @CHANGE LDR Overwrite value coming from parameters for security purpose */
  100. oConnector.ConnectorUrl = '<?php echo DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php?'; ?>';
  101. console.log('ConnectorUrl='+oConnector.ConnectorUrl);
  102. oConnector.ResourceType = GetUrlParam( 'Type' );
  103. oConnector.ShowAllTypes = ( oConnector.ResourceType.length == 0 );
  104. if ( oConnector.ShowAllTypes )
  105. oConnector.ResourceType = 'File' ;
  106. oConnector.SendCommand = function( command, params, callBackFunction )
  107. {
  108. var sUrl = this.ConnectorUrl + 'Command=' + command ;
  109. sUrl += '&Type=' + this.ResourceType ;
  110. sUrl += '&CurrentFolder=' + encodeURIComponent( this.CurrentFolder );
  111. if ( params ) sUrl += '&' + params ;
  112. // Add a random salt to avoid getting a cached version of the command execution
  113. sUrl += '&uuid=' + new Date().getTime();
  114. var oXML = new FCKXml();
  115. if ( callBackFunction )
  116. oXML.LoadUrl( sUrl, callBackFunction ); // Asynchronous load.
  117. else
  118. return oXML.LoadUrl( sUrl );
  119. return null ;
  120. }
  121. oConnector.CheckError = function( responseXml )
  122. {
  123. var iErrorNumber = 0 ;
  124. var oErrorNode = responseXml.SelectSingleNode( 'Connector/Error' );
  125. if ( oErrorNode )
  126. {
  127. iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value, 10 );
  128. switch ( iErrorNumber )
  129. {
  130. case 0:
  131. break;
  132. case 1: // Custom error. Message placed in the "text" attribute.
  133. alert( oErrorNode.attributes.getNamedItem('text').value );
  134. break;
  135. case 101:
  136. alert( 'Folder already exists' );
  137. break;
  138. case 102:
  139. alert( 'Invalid folder name' );
  140. break;
  141. case 103:
  142. alert( 'You have no permissions to create the folder' );
  143. break;
  144. case 110:
  145. alert( 'Unknown error creating folder' );
  146. break;
  147. default:
  148. alert( 'Error on your request. Error number: ' + iErrorNumber );
  149. break;
  150. }
  151. }
  152. return iErrorNumber ;
  153. }
  154. var oIcons = new Object();
  155. oIcons.AvailableIconsArray = [
  156. 'ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js',
  157. 'mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip' ] ;
  158. oIcons.AvailableIcons = new Object();
  159. for ( var i = 0 ; i < oIcons.AvailableIconsArray.length ; i++ )
  160. oIcons.AvailableIcons[ oIcons.AvailableIconsArray[i] ] = true ;
  161. oIcons.GetIcon = function( fileName )
  162. {
  163. var sExtension = fileName.substr( fileName.lastIndexOf('.') + 1 ).toLowerCase();
  164. if ( this.AvailableIcons[ sExtension ] == true )
  165. return sExtension ;
  166. else
  167. return 'default.icon' ;
  168. }
  169. function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
  170. {
  171. if (errorNumber == "1")
  172. window.frames['frmUpload'].OnUploadCompleted( errorNumber, customMsg );
  173. else
  174. window.frames['frmUpload'].OnUploadCompleted( errorNumber, fileName );
  175. }
  176. </script>
  177. </head>
  178. <frameset cols="200,*" framespacing="3" border="1" style="border: 2px solid #CCCCCC;">
  179. <frame name="frmFolders" src="frmfolders.php" scrolling="auto" frameborder="1">
  180. <frameset rows="50,*,70" framespacing="0">
  181. <frame name="frmActualFolder" src="frmactualfolder.php" scrolling="no" frameborder="0">
  182. <frame name="frmResourcesList" src="frmresourceslist.php" scrolling="auto" frameborder="0">
  183. <frameset cols="200,*" framespacing="0" border="0">
  184. <frame name="frmCreateFolder" src="frmcreatefolder.php" scrolling="no" frameborder="0">
  185. <frame name="frmUpload" src="frmupload.php" scrolling="no" frameborder="0">
  186. <frame name="frmUploadWorker" src="javascript:void(0)" scrolling="no" frameborder="0">
  187. </frameset>
  188. </frameset>
  189. </frameset>
  190. </html>