Hi,
I would like to ask how can I get the visitors' computer name?
I tried gethostname() and php_uname('n') but it's showing the server (host) name not the client!
Hi,
I would like to ask how can I get the visitors' computer name?
I tried gethostname() and php_uname('n') but it's showing the server (host) name not the client!
jrhama wrote:it's showing the server (host) name not the client!
Of course. PHP has no clue about the client as it's done processing before the client receives the data.
I guess that's why you put this question in the Clientside forum?
http://stackoverflow.com/questions/922476/how-can-i-read-the-clients-machine-computer-name-from-the-browser
http://forums.asp.net/t/1490314.aspx?how+do+get+Client+Machnine+Name+through+Javascript
In short, this is what companies like Norton, Sophos, and Kapersky get $$$ for, right?
And if you do have a legitimate reason, (why not, you might ... intranet?) ... it's still not possible without some piece of code running on the client that's got more access than you can get from a typical browser (and with good reason).
Both php_uname('n') and gethostname are executed on the server running PHP, which means they will only reveal local information. Do note that ”local” is always in relation to the executing code. So if php_uname runs on your server, then ”local” means your server.
Are you aware that the computer name returned by these functions can be set by any user with admin rights on a computer? Are you aware that these names have no practival use on the internet. They are intended for use on a local subnet.
What are you intending to do with the computer name?
i just want to get more info about the visitor in addition to the IP address for event log and audit purpose
what's your advise?
Install Google Analytics on your web site. Use CLF (Common Log Format) in your server logs.
A Web Server using CLF for Apache Logs[code wrote:173.198.27.178 - - [09/Feb/2015:11:33:16 -0800] "GET /images/misc/nophoto.gif HTTP/1.1" 200 103 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/536.30.1 (KHTML, like Gecko)"[/code]
but I want to audit the login to monitor successful and failed login and from which source the user signed or tried to sign in
jrahma;11045165 wrote:but I want to audit the login to monitor successful and failed login and from which source the user signed or tried to sign in
You, my boss, the NSA, and everyone else Personally, I want a pony, or perhaps to audit the changing area for today's edition of Sports Illustrated. But, as the Rolling Stones said, "You can't always get what you want."
CLF will give you an IP address and the UA string that (supposedly) are coming from the browser and computer in question. The "Referer" field is also in there, for whatever good it is.
If you tweak your Apache config, I think you can get the PTR name for the IP. That's about it for WAN requests. Google has a little more data that it extrapolates based on the fact that it owns about half the logs on the Internet; that's why I suggested installing and using their tools.
In reality the computer name doesn't really tell you anything and is actually useless. My computer name is "Main". How is that useful to you in any way? Not to mention there are probably tens of thousands of people out there who have the same computer name, and every time someone formats their computer they have the opportunity to rename their computer, further making them pointless in terms of "tracking".
The main computers on my home LAN are named [font=monospace]Y320[/font], [font=monospace]30263C000000[/font], [font=monospace]DIGGA[/font], and [font=monospace]calvin[/font]; a work cluster has [font=monospace]fool[/font], [font=monospace]magus[/font], [font=monospace]priestess[/font], [font=monospace]empress[/font], [font=monospace]emperor[/font], and [font=monospace]hierophant[/font], and next month we'll be adding [font=monospace]lovers[/font] and [font=monospace]chariot[/font].
Glad to help.
I feel I should point out that every computer, phone, iPad, and device in my house connects to the internet via the same IP address. When we visit a web server, all these different devices will use one and the same identical IP address at any given time. Note that this IP address changes periodically thanks to my ISP doing weird network stuff. To any web servers we may visit, this public IP address is the best way to locate us.
You can easily find out what your public ip address is by visiting http://ipchicken.com/
If you are interested in knowing more about your visitors, the name of their computer is not especially helpful at all. You'd probably find more interesting information in $_SERVER["HTTP_USER_AGENT"] which will probably tell you what kind of device they are using, what OS, and possibly other things (or whether they are a the GoogleBot). If you want to track some user's behavior, send them a unique cookie and track what they do on your site. As long as they don't remove that cookie, you should be able to connect their various actions and behaviors together.
Google Analytics is a very handy tool for better understanding how users interact with your site.
Bonesnap;11045205 wrote:In reality the computer name doesn't really tell you anything and is actually useless. My computer name is "Main". How is that useful to you in any way? Not to mention there are probably tens of thousands of people out there who have the same computer name, and every time someone formats their computer they have the opportunity to rename their computer, further making them pointless in terms of "tracking".
<?php
$file = "/usr/share/dict/words";
$lines = trim( str_replace( $file, '', exec("wc -l $file") ) );
$line = rand(0,$lines);
$name = exec("< $file head -n $line | tail -n +$line");
exec("sudo hostname $name");
Run from cron(8) every 4 hours :p
:evilgrin:
Weedpacket;11045229 wrote:The main computers on my home LAN are named [font=monospace]Y320[/font], [font=monospace]30263C000000[/font], [font=monospace]DIGGA[/font], and [font=monospace]calvin[/font]; a work cluster has [font=monospace]fool[/font], [font=monospace]magus[/font], [font=monospace]priestess[/font], [font=monospace]empress[/font], [font=monospace]emperor[/font], and [font=monospace]hierophant[/font], and next month we'll be adding [font=monospace]lovers[/font] and [font=monospace]chariot[/font].
Glad to help.
I think "lovers" should be added sooner, like this weekend....
dalecosp;11045249 wrote:I think "lovers" should be added sooner, like this weekend....
You know, I never thought of that (which I guess means the naming scheme is working); I just may create a DNS alias for it for the occasion in the meantime...
dalecosp;11045247 wrote:
<?php $file = "/usr/share/dict/words"; $lines = trim( str_replace( $file, '', exec("wc -l $file") ) ); $line = rand(0,$lines); $name = exec("< $file head -n $line | tail -n +$line"); exec("sudo hostname $name");
Run from cron(8) every 4 hours :p
:evilgrin:
What does exec starting with < do?? I know < and > are redirection commands, but I've never seen a command that starts with it like that.
I guess somehow it ends up equivalent to "head -n $line $file", except that head is reading from stdin instead of an explicit file, so kind of like "cat" but for commands rather than filenames. (I keep picturing the shell's own I/O streams shorting out and the file jumping straight across!)
Weedpacket;11045255 wrote:I guess somehow it ends up equivalent to "head -n $line $file", except that head is reading from stdin instead of an explicit file
As noted by man head
DESCRIPTION
This filter displays the first count lines or bytes of each of the specified files, or of the standard
input if no files are specified.
And it does not matter if you place redirection before or after the command.
$ < words head -n 10
$ 0< words head -n 10
$ head -n 10 < words
$ head -n 10 0< words