Guest User

Untitled

a guest
Mar 12th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.93 KB | None | 0 0
  1. <?php
  2.  
  3. function directoryScan($dir) {
  4.         $result = array();
  5.         $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir,FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
  6.         foreach($objects as $path => $object){  
  7.  
  8.  
  9.             $result[dirname($object->getPathname())][]=array(
  10.       'type'=>$object->getExtension(),
  11.     'path'=>$object->getPathname(),
  12.         'file'=>$object->getFilename(),
  13.         'size'=>$object->getSize(),
  14.         'changed'=>$object->getMTime(),
  15.         'permission'=>substr(sprintf('%o', fileperms($path)), -4)
  16.            );    
  17.         }
  18.        
  19.         return $result;
  20.    
  21. }
  22. $allowed = array('pdf','png','jpeg','jpg','gif');
  23. $result = '';
  24. $directory = './';
  25. foreach(directoryScan($directory) as $path => $dir){
  26. $result .= '<div class="info"><h2 class="short">'.$path.'</h2><ul class="long">'."\n";
  27.  foreach($dir as $file){
  28.  if(in_array($file['type'],$allowed))
  29.   $result .= '<li><a href="'.urlencode($file['path']).'">'.$file['path'].'</a></li>'."\n";
  30.  }
  31. $result .= '</ul></div>'."\n";
  32. }
  33.  header("Content-type:text/html;charset=utf-8");  
  34.  
  35. ?>
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  37.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  38. <head>
  39. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  40. <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
  41. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  42. <title>Grambow & Widmer</title>
  43. <style type="text/css">
  44. @charset "utf-8";
  45. .info {
  46.     background-image: url('');
  47.     background-position: 0px 2px;
  48.     background-repeat: no-repeat;
  49.     padding: 0px 0px 0px 17px;
  50.     cursor: pointer;
  51.     list-style:none;
  52. }
  53. .info ul {
  54.     display: none;
  55.     list-style:none;  
  56. }
  57. body {
  58.      width:600px;
  59.      height:100%;
  60.      margin:0 auto;
  61.      text-align:center;
  62.      color:#6C6C6C;
  63.      font-family:Arial;
  64. }
  65. li a {
  66.     list-style:none;
  67.     width:600px;
  68.     float:left;
  69.     border-bottom:1px solid #000;
  70.     padding-top:10px;
  71.     padding-bottom:15px;
  72.     font-weight:bold;
  73.     font-size:20px;
  74.     text-align:left;
  75. }
  76. ul li a{
  77.     color: #6C6C6C;
  78.     font-size: 18px;
  79.     text-decoration: none;
  80.     text-transform: uppercase;
  81.     font-weight:normal;
  82.     list-style:none;
  83. }
  84. h1 {
  85.      color: #6C6C6C;
  86. }
  87. .short {
  88.      border-bottom:1px solid #000;
  89.      padding-bottom:10px;
  90.      text-align:left;
  91.      padding-left:20px;
  92. }
  93. img {
  94.     margin-top:10px;
  95. }
  96. </style>
  97. </head>
  98. <body>
  99.  
  100. <img src="logo.png"/>
  101. <h1>Kunden Akten</h1>
  102. <?php echo $result ?>
  103. <script type="text/javascript">
  104. $('.short').toggle(function() {
  105.     $('.long', $(this).parent()).show();
  106.     $(this).parent().css( '');
  107. }, function() {
  108.     $('.long', $(this).parent()).hide();
  109.     $(this).parent().css( '');
  110. });
  111. </script>
  112.  
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment