deadman96385

Untitled

Mar 15th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <?php
  2.  
  3. $baseDir = "Nightly";
  4. $return_arr = array();
  5. define("ONE_K", 1024);
  6. define("KB", ONE_K);
  7. define("MB", ONE_K * KB);
  8. define("GB", ONE_K * MB);
  9. define("TB", ONE_K * GB);
  10.  
  11. function formatBytes($size, $precision = 2)
  12. {
  13. $base = log($size) / log(1024);
  14. $suffixes = array('', 'k', 'M', 'G', 'T');
  15.  
  16. return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
  17. }
  18.  
  19. if(isset($clean['basedir'])) {
  20. echo $baseDir;
  21. }
  22.  
  23. if(isset($_GET['device'])) {
  24. $device = $_GET['device'];
  25. $folder = $_GET['folder'];
  26. if(is_dir($baseDir . "/" . $device . "/" . $folder)){
  27. $row_array = array();
  28. $return_arr = array();
  29. $json = array();
  30.  
  31. if ($handle = opendir($baseDir . "/" . $device . "/" . $folder)) {
  32. $path = $baseDir . "/" . $device . "/" . $folder;
  33. while (false !== ($file = readdir($handle))) {
  34. if($file == "." or $file == ".." || $file == ".htaccess" || $file == ".users"){
  35. } else {
  36. $row_array['filename'] = $file;
  37. if(is_file($path . "/" . $file)) {
  38. $filePath = $$path . "/" . $file;
  39. $filesize = filesize($path . "/" . $file);
  40. $actfile = "http://www.drdevs.com/devs/teamliquid/" . $path . "/" . $file;
  41. $row_array['filesize'] = formatBytes($filesize);
  42. $path = "$dev" . "/" . "$device" . "/" . "$file";
  43. $row_array['downloads'] = $actfile;
  44. }
  45. array_push($return_arr,$row_array);
  46. }
  47. }
  48. sort($return_arr);
  49. $json['dev_info'] = $return_arr;
  50. closedir($handle);
  51. }
  52. echo json_encode($json);
  53. }
  54. exit;
  55. }
  56.  
  57. if(isset($_GET['dev'])) {
  58. $dev = $clean['dev'];
  59. if(is_dir($baseDir . "/" . $dev)){
  60. $row_array = array();
  61. $json = array();
  62.  
  63.  
  64. if ($handle = opendir($baseDir . "/" . $dev)) {
  65. while (false !== ($file = readdir($handle))) {
  66. if($file == "." or $file == ".." || $file == ".htaccess" || $file == ".users"){
  67. } else {
  68. $row_array['device'] = $file;
  69. if(is_file($baseDir . "/" . "$dev" . "/" . $file)) {
  70. $filesize = filesize($baseDir . "/" . $dev . "/" . $file);
  71. $row_array['filesize'] = formatBytes($filesize);
  72. $path = "$dev" . "$device" . "/" . "$file";
  73. $row_array['downloads'] = $row['downloads'];
  74. }
  75. array_push($return_arr,$row_array);
  76. }
  77. }
  78. sort($return_arr);
  79. $json['dev_info'] = $return_arr;
  80. closedir($handle);
  81. }
  82. echo json_encode($json);
  83. }
  84. exit;
  85. }
  86.  
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment