browser.php 6.3 KB

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