Ledger Nano X - The secure hardware wallet
SHARE
TWEET

fsockopen exif_imagetype

krot Mar 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $url = parse_url('https://site/file.jpg');
  2. $host = $url['host'];
  3. $port = $url['port'];
  4. $path = $url['path'];
  5. $query = $url['query'];
  6. if(!$port)$port = 80 ;//tcp
  7. $request = "GET $path HTTP/1.1\r\n"
  8.           ."Host: $host\r\n"
  9.           ."User-Agent: Mozilla/5.0\r\n"
  10.           ."Connection: close\r\n"
  11.           ."\r\n";
  12. /////////////
  13. $fp = ($url['scheme']=='https' )?
  14.                                     fsockopen("ssl://{$host}", 443, $errno, $errstr, 30):
  15.                                     fsockopen("tcp://{$host}", 80, $errno, $errstr, 30);
  16.                                    
  17. $imgName=tempnam(sys_get_temp_dir(),'img');
  18. $hnd = fopen($imgName, 'w');
  19. ob_start(function($buffer) use($hnd){fwrite($hnd, $buffer);}, 1);
  20. $type=false;
  21. $bStart=true;                              
  22. if ( $fp  ) {
  23.     if ( fwrite($fp, $request) ) {
  24.         while ( !feof($fp) ) {
  25.                  $out=fread($fp, 1024);
  26.                  if($bStart){
  27.                      echo $h=substr($out, strpos($out, "\r\n\r\n") + 4);
  28.                     $type=exif_imagetype($imgName);
  29.                     if($type==false)break;
  30.                     $bStart=false;
  31.                 }else{
  32.                     echo $out;
  33.                 }
  34.              
  35.         }
  36.     }
  37.     fclose($fp);
  38.  
  39. }
  40. ob_end_clean();
  41. fclose($hnd);
  42. echo ($type);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top