Crushed

Untitled

Feb 1st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2. //  header('Location: /Index.php');
  3. // or die();
  4.  
  5. //  exit();
  6. ?><?php
  7.  
  8. require_once __DIR__ . '/protected/config/config.php';
  9.  
  10. $types = array(
  11.     'png'  => 'images/png/',
  12.     'jpeg' => 'images/jpeg/',
  13.     'gif'  => 'images/gif/',
  14.     'webm' => 'images/webm/',
  15. );
  16.  
  17. $index = ! (isset($_GET['type']) && isset($_GET['file']));
  18.  
  19. if ($index) {
  20.     include_once __DIR__ . '/protected/templates/index.phtml';
  21.     die();
  22. }
  23.  
  24. $type = $_GET['type'];
  25. $file = $_GET['file'];
  26.  
  27. $filelocation = __DIR__ . "/images/$type/$file.$type";
  28.  
  29. if ( ! file_exists(realpath($filelocation)) || ! array_key_exists($type, $types)) {
  30.     header('HTTP/1.0 404 Not Found');
  31.     include_once __DIR__ . '/protected/templates/error.phtml';
  32.     die();
  33. }
  34.  
  35. $filesize = filesize($filelocation);
  36.  
  37. if (RAW_IMAGE && strpos($_SERVER['HTTP_USER_AGENT'], 'Twitterbot') === false) {
  38.     $filecontents = fopen($filelocation, 'rb');
  39.  
  40.     header('Content-type: ' . $types[$type]);
  41.     header('Content-length: ' . $filesize);
  42.  
  43.     fpassthru($filecontents);
  44.     exit;
  45. } else {
  46.     $time = microtime();
  47.     $time = explode(' ', $time);
  48.     $time = $time[1] + $time[0];
  49.     $start = $time;
  50.  
  51.     require_once __DIR__ . '/protected/templates/viewer.phtml';
  52. }
Add Comment
Please, Sign In to add comment