Guest User

Untitled

a guest
Nov 28th, 2016
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.78 KB | None | 0 0
  1. if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
  2. Phar::interceptFileFuncs();
  3. set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
  4. Phar::webPhar(null, $web);
  5. include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
  6. return;
  7. }
  8.  
  9. if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
  10. Extract_Phar::go(true);
  11. $mimes = array(
  12. 'phps' => 2,
  13. 'c' => 'text/plain',
  14. 'cc' => 'text/plain',
  15. 'cpp' => 'text/plain',
  16. 'c++' => 'text/plain',
  17. 'dtd' => 'text/plain',
  18. 'h' => 'text/plain',
  19. 'log' => 'text/plain',
  20. 'rng' => 'text/plain',
  21. 'txt' => 'text/plain',
  22. 'xsd' => 'text/plain',
  23. 'php' => 1,
  24. 'inc' => 1,
  25. 'avi' => 'video/avi',
  26. 'bmp' => 'image/bmp',
  27. 'css' => 'text/css',
  28. 'gif' => 'image/gif',
  29. 'htm' => 'text/html',
  30. 'html' => 'text/html',
  31. 'htmls' => 'text/html',
  32. 'ico' => 'image/x-ico',
  33. 'jpe' => 'image/jpeg',
  34. 'jpg' => 'image/jpeg',
  35. 'jpeg' => 'image/jpeg',
  36. 'js' => 'application/x-javascript',
  37. 'midi' => 'audio/midi',
  38. 'mid' => 'audio/midi',
  39. 'mod' => 'audio/mod',
  40. 'mov' => 'movie/quicktime',
  41. 'mp3' => 'audio/mp3',
  42. 'mpg' => 'video/mpeg',
  43. 'mpeg' => 'video/mpeg',
  44. 'pdf' => 'application/pdf',
  45. 'png' => 'image/png',
  46. 'swf' => 'application/shockwave-flash',
  47. 'tif' => 'image/tiff',
  48. 'tiff' => 'image/tiff',
  49. 'wav' => 'audio/wav',
  50. 'xbm' => 'image/xbm',
  51. 'xml' => 'text/xml',
  52. );
  53.  
  54. header("Cache-Control: no-cache, must-revalidate");
  55. header("Pragma: no-cache");
  56.  
  57. $basename = basename(__FILE__);
  58. if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
  59. chdir(Extract_Phar::$temp);
  60. include $web;
  61. return;
  62. }
  63. $pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
  64. if (!$pt || $pt == '/') {
  65. $pt = $web;
  66. header('HTTP/1.1 301 Moved Permanently');
  67. header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
  68. exit;
  69. }
  70. $a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
  71. if (!$a || strlen(dirname($a)) < strlen(
  72. 0x65f1855, 760, Extract_Phar::$temp)) {
  73. header('HTTP/1.0 404 Not Found');
  74. echo "<html>\n <head>\n  <title>File Not Found<title>\n </head>\n <body>\n  <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
  75. exit;
  76. }
  77. $b = pathinfo($a);
  78. if (!isset($b['extension'])) {
  79. header('Content-Type: text/plain');
  80. header('Content-Length: ' . filesize($a));
  81. readfile($a);
  82. exit;
  83. }
  84. if (isset($mimes[$b['extension']])) {
  85. if ($mimes[$b['extension']] === 1) {
  86. include $a;
  87. exit;
  88. }
  89. if ($mimes[$b['extension']] === 2) {
  90. highlight_file($a);
  91. exit;
  92. }
  93. header('Content-Type: ' .$mimes[$b['extension']]);
  94. header('Content-Length: ' . filesize($a));
  95. readfile($a);
  96. exit;
  97. }
  98. }
  99.  
  100. class Extract_Phar
  101. {
  102. static $temp;
  103. static $origdir;
  104. const GZ = 0x1000;
  105. const BZ2 = 0x2000;
  106. const MASK = 0x3000;
  107. const START = '
Add Comment
Please, Sign In to add comment