Advertisement
Guest User

Periodt

a guest
Nov 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. /*
  3. * PHP Proxy
  4. * Responds to both HTTP GET and POST requests
  5. * Author: Abdul Qabiz
  6. * Created On: March 31st, 2006
  7. * Last Modified: Feb 22, 2015
  8. */
  9. // Get the url of to be proxied
  10. // Is it a POST or a GET?
  11. $url = ($_POST['url']) ? $_POST['url'] : $_GET['url'];
  12. $headers = ($_POST['headers']) ? $_POST['headers'] : $_GET['headers'];
  13. $mimeType =($_POST['mimeType']) ? $_POST['mimeType'] : $_GET['mimeType'];
  14. //Start the Curl session
  15. $session = curl_init($url);
  16. // If it's a POST, put the POST data in the body
  17. if ($_POST['url']) {
  18. $postvars = '';
  19. while ($element = current($_POST)) {
  20. $postvars .= key($_POST).'='.$element.'&';
  21. next($_POST);
  22. }
  23. curl_setopt($session, CURLOPT_POST, true);
  24. curl_setopt($session, CURLOPT_POSTFIELDS, $postvars);
  25. }
  26. // Don't return HTTP headers. Do return the contents of the call
  27. curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false);
  28. curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
  29. //curl_setopt($ch, CURLOPT_TIMEOUT, 4);
  30. curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  31. // Make the call
  32. $response = curl_exec($session);
  33. if ($mimeType != "") {
  34. // The web service returns XML. Set the Content-Type appropriately
  35. header("Content-Type: ".$mimeType);
  36. }
  37. echo $response;
  38. curl_close($session);
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement