DarkHeroes

Untitled

Oct 6th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. function ScanDirectory($Directory, $tableau=false){
  3. $slash = '';
  4. $MyDirectory = opendir($Directory) or die('Erreur');
  5. while($Entry = @readdir($MyDirectory)){
  6. if($Entry != '.' && $Entry != '..' && $Entry != 'index.php' && $Entry != ".htaccess" && $Entry != "indexold.php" && $Entry != "test.php" && $Entry != "libraries"){
  7. if(is_dir($Directory.'/'.$Entry)&& $Entry != '.' && $Entry != '..'){
  8. $slash = '/';
  9. }
  10. else
  11. {
  12. $slash = '';
  13. }
  14. $tableau[] = substr($Directory.'/'.$Entry, strlen(strstr($Directory.'/'.$Entry, '/', true))+1).$slash;
  15. }
  16. if(is_dir($Directory.'/'.$Entry)&& $Entry != '.' && $Entry != '..'){
  17. $tableau = ScanDirectory($Directory.'/'.$Entry, $tableau);
  18. }
  19. }
  20. closedir($MyDirectory);
  21. return $tableau;
  22. }
  23.  
  24. Header('Content-type: text/xml');
  25. $xml = new SimpleXMLElement('<xml/>');
  26.  
  27. $base = $xml->addChild('ListBucketResult');
  28. $base->addChild('Name', "ressources");
  29. $base->addChild('Prefix');
  30. $base->addChild('Marker');
  31. $base->addChild('MaxKeys', "1000");
  32. $base->addChild('IsTruncated', 'false');
  33.  
  34. foreach(ScanDirectory('.') as $key => $value){
  35. $stat = stat($value);
  36. $content = $base->addChild('Contents');
  37. $content->addChild('Key', htmlentities($value));
  38. $content->addChild('LastModified', date("Y-m-d\TH:i:s.000\Z", filemtime($value)));
  39.  
  40. if(is_dir($value)&& $value != '.' && $value != '..'){
  41. $content->addChild('MD5', md5($value));
  42. $content->addChild('Size', 0);
  43. }else{
  44. $content->addChild('Size', $stat['size']);
  45. $content->addChild('MD5', md5_file($value));
  46. }
  47. $content->addChild('StorageClass', 'STANDARD');
  48. }
  49.  
  50. print($xml->asXML());
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment