Jump to content

Recommended Posts

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?
   

Link to comment
https://forums.phpfreaks.com/topic/309902-php-get-machine-name/
Share on other sites

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.

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 😊

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.

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

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.