Fratozzi Posted January 19, 2020 Share Posted January 19, 2020 Hi everyone, I'm trying to get the name of the machine in use. If I use this feature locally, it works. function visitor_machine_name(){ $machine_name = gethostbyaddr($_SERVER['REMOTE_ADDR']); return $machine_name; } But as soon as I try it on an online server I get the DNS name back, like this: mob-3-91-125-82.net.vodafone.it What can I do? Quote Link to comment Share on other sites More sharing options...
requinix Posted January 19, 2020 Share Posted January 19, 2020 You cannot get the name of the computer. The internet does not work that way. Quote Link to comment Share on other sites More sharing options...
Fratozzi Posted January 19, 2020 Author Share Posted January 19, 2020 1 minute ago, requinix said: You cannot get the name of the computer. The internet does not work that way. Is there no way to get it? For example using JS. That is, how does DropBox, for example, obtain the name of the logged device? Quote Link to comment Share on other sites More sharing options...
requinix Posted January 19, 2020 Share Posted January 19, 2020 Just now, Fratozzi said: That is, how does DropBox, for example, obtain the name of the logged device? By installing software. Quote Link to comment Share on other sites More sharing options...
Fratozzi Posted January 19, 2020 Author Share Posted January 19, 2020 Just now, requinix said: By installing software. I don't have any software installed on my pc regarding DropBox, yet it gets my device name. If I connect to their site Quote Link to comment Share on other sites More sharing options...
requinix Posted January 19, 2020 Share Posted January 19, 2020 1 minute ago, Fratozzi said: I don't have any software installed on my pc regarding DropBox, yet it gets my device name. If I connect to their site It is not possible for some website on the internet to get the name of your computer. I don't know what you're doing or looking at. Quote Link to comment Share on other sites More sharing options...
Fratozzi Posted January 19, 2020 Author Share Posted January 19, 2020 2 minutes ago, requinix said: It is not possible for some website on the internet to get the name of your computer. I don't know what you're doing or looking at. what I need is the name of the device I am using to access a site. for example PC-Fra. Anyway thank you for replying 😊 Quote Link to comment Share on other sites More sharing options...
requinix Posted January 19, 2020 Share Posted January 19, 2020 1 minute ago, Fratozzi said: what I need is the name of the device I am using to access a site. for example PC-Fra. Anyway thank you for replying 😊 Then I was understanding you correctly. It is not possible. Not through PHP or Javascript or anything other than installing software on the user's computer. Quote Link to comment Share on other sites More sharing options...
Fratozzi Posted January 25, 2020 Author Share Posted January 25, 2020 On 1/19/2020 at 12:21 PM, requinix said: Then I was understanding you correctly. It is not possible. Not through PHP or Javascript or anything other than installing software on the user's computer. In case using $ _SERVER ["REMOTE_ADDR"]; to get the name of the dns how can I remove all those characters and know only the final part? For example: With that function I get this: mob-3-91-125-82.net.vodafone.it host86-197-dynamic.3-87-r.retail.telecomitalia.it 93-32-55-29.ip32.fastwebnet.it mob-5-90-154-87.net.vodafone.it I would like this instead: net.vodafone.it retail.telecomitalia.it ip32.fastwebnet.it That should be the name of the internet provider I connect to. Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted January 25, 2020 Share Posted January 25, 2020 try function getISP($str) { $k = strlen($str); while (!ctype_digit($str[--$k])) ; $p = strpos($str, '.', $k); return substr($str, $p+1); } echo getISP('host86-197-dynamic.3-87-r.retail.telecomitalia.it'); //--> retail.telecomitalia.it Quote Link to comment Share on other sites More sharing options...
Barand Posted January 25, 2020 Share Posted January 25, 2020 On second thoughts function getISP($str) { $a = explode('.', $str); return join('.', array_slice($a, -3)); } Quote Link to comment Share on other sites More sharing options...
Fratozzi Posted January 25, 2020 Author Share Posted January 25, 2020 Thanks so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.