SHARE
TWEET

Untitled

a guest Feb 12th, 2015 186 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// PRECONDITION for the test: two servers with both IPv4 AND IPv6 address ///
  2.  
  3. /// SCRIPT RETURNING YOUR REMOTE ADDRESS ///
  4. /// PLACE THIS ONE ON SERVER 1 ///
  5. <?php
  6. $ip = $_SERVER['REMOTE_ADDR'];
  7. $ts = isset($_GET['ts']) ? $_GET['ts'] : null;
  8. $v = isset($_GET['v']) ? $_GET['v'] : null;
  9. $str = "IP: " . $ip . " ts: " . $ts . " v: " . $v;
  10. echo $str;
  11. ?>
  12.  
  13. //// TEST-SCRIPT ////
  14. //// PLACE THIS SCRIPT ON SERVER 2 and edit your.host ////
  15. <?php
  16. function get_remote_ip ($v)
  17. {
  18.         $ch = curl_init();
  19.         $url = "your.host/myip.php?ts=" . rand(1000,5000) . "&v=" . $v;
  20.         curl_setopt($ch, CURLOPT_URL, $url);
  21.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22.         curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
  23.  
  24.         if($v == 4) {
  25.                 curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); }
  26.         elseif($v == 6) {
  27.                 curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6 ); }
  28.         else {
  29.                 curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER );  }
  30.  
  31.         $ret = curl_exec($ch);
  32.         curl_close($ch);
  33.         unset($ch);
  34. return $ret;
  35. }
  36.  
  37. $whatever = get_remote_ip("1");
  38. $v4 = get_remote_ip("4");
  39. $v6 = get_remote_ip("6");
  40.  
  41. echo "whatever: $whatever";
  42. echo "<br />";
  43. echo "v4: $v4";
  44. echo "<br />";
  45. echo "v6: $v6";
  46. echo "<br />";
  47. ?>
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