Himeshvyas26

no redirect

Mar 6th, 2020
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <?php
  2. function stripFile($in){
  3. $pieces = explode("/", $in);
  4. if(count($pieces) < 4) return $in . "/";
  5. if(strpos(end($pieces), ".") !== false){
  6. array_pop($pieces);
  7. }elseif(end($pieces) !== ""){
  8. $pieces[] = "";
  9. }
  10. return implode("/", $pieces). "/";
  11. }
  12.  
  13.  
  14. function url_get_contents ($url) {
  15. if (function_exists('curl_exec')){
  16. $conn = curl_init($url);
  17. curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
  18. curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
  19. curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
  20. $url_get_contents_data = (curl_exec($conn));
  21. curl_close($conn);
  22. }elseif(function_exists('file_get_contents')){
  23. $url_get_contents_data = file_get_contents($url);
  24. }elseif(function_exists('fopen') && function_exists('stream_get_contents')){
  25. $handle = fopen ($url, "r");
  26. $url_get_contents_data = stream_get_contents($handle);
  27. }else{
  28. $url_get_contents_data = false;
  29. }
  30. $data = str_replace('<a href="','<a href="'.'http://' . $_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"].'?url='.stripFile($url),$url_get_contents_data);
  31. $data = str_replace('<head>','<head><base href="'.stripFile($url).'">',$data);
  32. return $data;
  33. }
  34. if(!isset($_GET['url'])){ ?>
  35. <form><span>URL: </span><input name="url" value="" type="text"><input value="GO" type="submit"></form>
  36. <?php
  37. }
  38. else{
  39.  
  40. if(substr($_GET['url'], 0, 4) == 'http'){
  41. echo '<center><form><span>URL: </span><input name="url" value="'.htmlspecialchars($_GET['url']).'" type="text"><input value="GO" type="submit"></form></center>';
  42. echo url_get_contents (htmlspecialchars($_GET['url']));
  43. }
  44. else{
  45. ?>
  46. <?php
  47. echo '<form><span>URL: </span><input name="url" value="'.htmlspecialchars($_GET['url']).'" type="text"><input value="GO" type="submit"></form>';
  48. echo "Sorry Bro.<br> Check your URL<br>Only http or https protocols are allowed<br> NO SSRF Here :)</center>";
  49. }
  50. }
Add Comment
Please, Sign In to add comment