ytthumbs.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. function curlGet($url) {
  3. if(in_array('curl', get_loaded_extensions())){
  4. $appSettings = parse_ini_file('../config/config.ini',true);
  5. $ch = curl_init($url);
  6. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0');
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_HEADER, 0);
  9. //curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  10. if($appSettings["Proxy"]["type"]) {
  11. curl_setopt($ch, CURLOPT_PROXY, $appSettings["Proxy"]["type"]."://".$appSettings["Proxy"]["domain"].":".$appSettings["Proxy"]["port"]);
  12. curl_setopt($ch, CURLOPT_PROXYUSERPWD, $appSettings["Proxy"]["username"].":".$appSettings["Proxy"]["password"]);
  13. }
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  15. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  16. $result = curl_exec($ch);
  17. curl_close($ch);
  18. return $result;
  19. }
  20. return FALSE;
  21. }
  22. header("Content-type: image/jpeg");
  23. $thumbparts = explode("|",$_GET["data"]);
  24. $i = count($thumbparts)-1;
  25. $thumbdata = explode("#",$thumbparts[$i]);
  26. $base_url = $thumbparts[0];
  27. $thumbs = imagecreatetruecolor($thumbdata[0]*$thumbdata[3],$thumbdata[1]*ceil($thumbdata[2]/$thumbdata[3]));
  28. for($j=0;$j<ceil($thumbdata[2]/($thumbdata[3]*$thumbdata[4]));$j++) {
  29. $link = str_replace('$L',$i-1,$base_url)."&";
  30. $link = str_replace('$N',$thumbdata[6],$link);
  31. $link = str_replace('$M',$j,$link)."sigh=".$thumbdata[7];
  32. $thumb = imagecreatefromstring(curlGet($link));
  33. imagecopy($thumbs,$thumb,0,$j*$thumbdata[1]*$thumbdata[4],0,0,$thumbdata[0]*$thumbdata[3],$thumbdata[1]*$thumbdata[4]);
  34. }
  35. imagejpeg($thumbs);
  36. ?>