PHP to get real client info IP or host name - php

I need to get real local ipaddress so that I can restrict only the specific computer in the organization can access web system.
I understand that $_SERVER['REMOTE_ADDR'] will return the internet client IP but I really need to get the local ip address that has been assigned. Or is there any a way to determine the specific source?

Related

Is there any option to know from which Wifi/network request comment?

I plan to make a web application. The workflow will be the client scan QR code using his phone to go to some specific URL.
But interested to me is there any option to I can limit visit that URL if the request didn't comment from a specific WiFi network? I do not want to anybody take a photo and fake requests.
There are multiple ways to do it:
If your specific WiFi network has a fixed WAN IP / IP range, you can write your application to detect the client IP and check if they came from there. You may check $_SERVER['REMOTE_ADDR'] for the client's IP (if your server is not behind reverse proxy). Your server is still publicly available, but your PHP code will only allow the whitelisted IP to access the certain URL path.
If you want even better security, you may place your server in your local network. You can use local IP in your QR code for users to access it. This way, the server will not be available on the internet at all.

Why am i getting different ip by using get content - PHP

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?
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.
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?

How can we get Wifi IP in php (wordpress) and will the IP of connected user will be same as of wifi?

We need to give our website pages access to free users only and only if they are logged in through our Wifi.
Is it possible that we can define such Wifi IP in the admin panel and user connecting through it will only have access to our website pages.
Our website is having paid subscription, so free user can also access the same only if they are connected through my wifi
Please advice
See Carlos Fdev's comment - or in other words: That's not possible.
The Webserver will only receive the IP of the connection the Client used to receive the website. So a Webserver has no chance to gather any other IP used than the one that is used for the web-request.
So you can't get the specific WiFi IP via PHP, but you can check the connection (WiFi) and get the local IP and transmit these values in the web-request:
How do I check connection type (WiFi/LAN/WWAN) using HTML5/JavaScript? Note: The state of this feature is experimental and Mozilla only (in Sep 2016).
Next you can try to retrieve the local IP adress: Can You Get A Users Local LAN IP Address Via JavaScript?.
In your special case maybe it's enough to just check for the local IP adress (without checking for WiFi) if the ip-range of the WiFi is known and does not change.

N-Computing:-Get Client IP of virtual desktops in php?

I am using N-Computing(N-Computing is hardware which create virtual desktops which enable multiple users to simultaneously share a single operating system instance.) server to run the project on LAN.
I run the system at client PC using server ip insted of localhost
i.e.192.168.1.33/demo/demo.php .
My Problem is i want to fetch ip address of client PC using php code which run at server.
I tried some code which gives the ip address of server.
This is not possible because with N-Computing, it actually creates multiple OS users on the same physical computer. In reality its like multiple users logged in onto one laptop/computer with different accounts. And as you might suspect, it means these users share the same hardware, mac addresses and ip address on all the network interfaces that they have.
If you do ipconfig on any of you users you will notice the ip address will always be 192.168.1.33. This means PHP will give you the same IP address for all your logged in users..
That said, you could maybe give more information as to what exactly you want to achieve, so that we can suggest a workaround.
EDIT
To get different IPs please try NComputing IP Utility, this will give different ips for your clients, THEN you can use the php script.
echo $_SERVER['REMOTE_ADDR'];
to get the IP address of the user.....

accessing application from different computer

I have an application created in php and using MySQL for back-end. I connect to the front-end of application on my PC by typing
(http://localhost:8080/my_data/login.php)
in the browser. the database is in my computer and php files are also in my computer. i don't know how can other users can get access to the application from the browser in their pc..i am not good with networking stuff.
(I am assuming Windows). At your machine at a command prompt type ipconfig to get your IP address:
specific instructions:
click windows orb,
then type cmd in text area
type ipconfig and press enter
line reading IPv4 Address will have an IP address x.x.x.x... use that IP address in place of localhost.
Assuming others on network are within the same subnet and not have vlans and what not, it should work.
a URL uses something called DNS or a hosts file to lookup that name and translate that common name to an IP address, by specifying the IP address and port, you avoid the need for the DNS, assuming the IP address is "Routable" for the users needed to access it.
Here's an example: Type http://74.125.225.176 in a browser and you get google search! There's a lot more to this really, but this is just the basic workings.

Categories