-2

So why am I need my own ip by using get content? I want to use some tv channels which is m3u8 file and using m3u8?wmsAuthSign=code

wmsAuthSign code is changing everytime the page refresh it self and they are getting ip adrress inside of that code.

So i can't play the tv channel by my servers ip !

the code i gave down below is just an example :D

<?php
   $myURL = "https://whatismyipaddress.com/ip-lookup";
   $lines = file($myURL);
   echo $lines[145];
?>

Is there any way that i can change it to my one ip adresse?

Zabi
  • 23
  • 9
  • 5
    Because you are requesting the site from your domain. PHP code is all generated server-side, not with your user's data. – aynber Mar 12 '18 at 15:37
  • 3
    Possible duplicate of [How to get the client IP address in PHP?](https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php) – aynber Mar 12 '18 at 15:37
  • 1
    @aynber so there is no way i can change it? – Zabi Mar 12 '18 at 15:38

2 Answers2

1

If you mean the client (browsers) IP: That code is being executed on your server, so the machine fetching that URL is your server. The response then has your server's IP address.

If you want to get the IP address of the user that's accessing the server, you could use some of the $_SERVER variables (like $_SERVER['REMOTE_ADDR']) but due to the way the internet works, that may not be the user's IP address.

Your best bet there is to use javascript that runs on the user's browser to identify the user's IP address - though, since that is really under the user's control, you can't be certain it's accurate either.

If you mean you're getting the IP of a different server, not your web server: the method you're using only determines the IP address of the server acting as a gateway to the greater internet. If your web server is behind a firewall, you'll be getting the IP of the firewall. You may want to identify the web server's local IP address instead.

Tim Lytle
  • 17,549
  • 10
  • 60
  • 91
0

Because the server is executing the PHP code and is requesting the website, if you want to get the IP address of the current user see How to get the client IP address in PHP?

MPAvance
  • 34
  • 4