stuppid_bot

Untitled

Apr 12th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. $url = $_GET['url'];
  4.  
  5. if ( $url && preg_match('#^(http|https)//:#i', $url) ) {
  6.     $ch = curl_init();
  7.     curl_setopt_array($ch, array(
  8.         CURLOPT_URL => $url,
  9.         CURLOPT_HEADER => 1,
  10.         CURLOPT_NOBODY => 1,
  11.         CURLOPT_RETURNTRANSFER => 1 ,
  12.         CURLOPT_TIMEOUT, 5
  13.     ));
  14.     $response = curl_exec($ch);
  15.     $lines = explode("\r\n", $response);
  16.     $headers = array();
  17.  
  18.     foreach ($lines as $line) {
  19.         $temp = explode(': ', $line);
  20.         $headers[strtolower($temp[0]) ] = $temp[1];
  21.     }
  22.  
  23.     if ( isset($headers['content-type']) && isset($headers['content-length']) && $headers['accept-ranges'] == 'bytes' ) {
  24.         if ( !preg_match('#^image/(png|jpeg)$#', $headers['content-type']) ) {
  25.             die('ERROR:INVALID_TYPE');
  26.         }
  27.         else if ( $headers['content-length'] < 20000 ) {
  28.             die('ERROR:TOO_SMALL');
  29.         }
  30.         else if ( $headers['content-length'] > 1000000 ) {
  31.             die('ERROR:TOO_BIG');
  32.         }
  33.        
  34.         if ( ( $data = file_get_contents($url) ) !== false ) {
  35.             die( 'data:' + $headers['content-type'] . ';base64,' . base64_encode($data) );
  36.         }
  37.     }
  38. }
  39.  
  40. echo('ERROR');
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment