You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * ownCloud - ajax frontend
  4. *
  5. * @author Robin Appelman
  6. * @copyright 2010 Robin Appelman icewind1991@gmail.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. // Init owncloud
  23. require_once('../lib/base.php');
  24. // Check if we are a user
  25. OC_Util::checkLoggedIn();
  26. // Load the files we need
  27. OC_Util::addStyle( "files", "files" );
  28. OC_Util::addScript( "files", "files" );
  29. OC_Util::addScript( 'files', 'filelist' );
  30. OC_Util::addScript( 'files', 'fileactions' );
  31. if(!isset($_SESSION['timezone'])){
  32. OC_Util::addScript( 'files', 'timezone' );
  33. }
  34. OC_App::setActiveNavigationEntry( "files_index" );
  35. // Load the files
  36. $dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
  37. // Redirect if directory does not exist
  38. if(!OC_Filesystem::is_dir($dir)) {
  39. header("Location: ".$_SERVER['PHP_SELF']."");
  40. }
  41. $files = array();
  42. foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
  43. $i["date"] = OC_Util::formatDate($i["mtime"] );
  44. if($i['type']=='file'){
  45. $fileinfo=pathinfo($i['name']);
  46. $i['basename']=$fileinfo['filename'];
  47. if (!empty($fileinfo['extension'])) {
  48. $i['extention']='.' . $fileinfo['extension'];
  49. }
  50. else {
  51. $i['extention']='';
  52. }
  53. }
  54. if($i['directory']=='/'){
  55. $i['directory']='';
  56. }
  57. $files[] = $i;
  58. }
  59. // Make breadcrumb
  60. $breadcrumb = array();
  61. $pathtohere = "";
  62. foreach( explode( "/", $dir ) as $i ){
  63. if( $i != "" ){
  64. $pathtohere .= "/".str_replace('+','%20', urlencode($i));
  65. $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
  66. }
  67. }
  68. // make breadcrumb und filelist markup
  69. $list = new OC_Template( "files", "part.list", "" );
  70. $list->assign( "files", $files );
  71. $list->assign( "baseURL", OC_Helper::linkTo("files", "index.php")."?dir=");
  72. $list->assign( "downloadURL", OC_Helper::linkTo("files", "download.php")."?file=");
  73. $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" );
  74. $breadcrumbNav->assign( "breadcrumb", $breadcrumb );
  75. $breadcrumbNav->assign( "baseURL", OC_Helper::linkTo("files", "index.php")."?dir=");
  76. $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
  77. $post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
  78. $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
  79. $freeSpace=OC_Filesystem::free_space('/');
  80. $freeSpace=max($freeSpace,0);
  81. $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
  82. $tmpl = new OC_Template( "files", "index", "user" );
  83. $tmpl->assign( "fileList", $list->fetchPage() );
  84. $tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
  85. $tmpl->assign( 'dir', $dir);
  86. $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir));
  87. $tmpl->assign( "files", $files );
  88. $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
  89. $tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
  90. $tmpl->printPage();
  91. ?>