Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. function get($url, $includeHeader=false) {
  2. $urlp = parse_url($url);
  3. $fp = fsockopen($urlp['host'],80);
  4. $path = explode('/',$url,4);
  5. $path = ((count($path)>=4)?$path[3]:"");
  6. $req = "GET /$path HTTP/1.1\r\n";
  7. $req .= "Host: $urlp[2`host]\r\n";
  8. $req .= "Connection: Close\r\n\r\n";
  9. fputs($fp, $req);
  10. $res = "";
  11. while(!feof($fp)) $res .= fgets($fp, 4096);
  12. fclose($fp);
  13. if($includeHeader) return $res;
  14. $res = explode("\r\n\r\n",$res,2);
  15. return $res[1];
  16. }
  17. /**
  18. * A utility function to get all text beween $start and $end
  19. * @param $content The content from which we are grabbing data
  20. * @param $start where to start grabbing from
  21. * @param $end the end of the content to grab
  22. */
  23. function getBetween($content,$start,$end){
  24. $r = explode($start, $content);
  25. if (isset($r[1])){
  26. $r = explode($end, $r[1]);
  27. return $r[0];
  28. }
  29. return '';
  30. }
  31.  
  32. }
  33.  
  34. }
  35. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement