browscap and php.ini

microbiz

New Member
Messages
1
Reaction score
0
Points
1
To: bdistler or other knowledgeable members, Dec. 17, 2016
In order to better serve clients visiting my site, I would like to keep a db log of visits, including date/time, agent, screen & window sizes (all easy), and MAC (as a rough client identifier, to distinguish repeat visitors) and type of device (using get_browser.php, if possible). These latter two are giving me fits (MAC and device). I am using php, html, and javascript.
The php function requires a version of browscap (lite_php_browscap is acceptable) and an entry in php.ini pointing to the browscap config file.
I see from your explanations (Nov. 8, 2015 and Nov. 24, 2016) that "[due] to the large security risk - x10hosting's free-hosting users do not have access to the [ php.ini ] file."
Is there a work-around for this problem? I have not worked with a browscap file before, so I am reluctant to guess at solutions. I am tempted to try renaming "lite_php_browscap" to simply "browscap" and putting the file in my x10 "/" root directory. I don't see any other obvious place to put it.
I am betting you know what I should do.
Thanks in advance. Paulz
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

I'm not familiar with browscap, but some quick checks online seem to show it analyzes the user's user agent to find out what the browser is capable of. This really isn't necessary for what you're trying to do.

I would like to keep a db log of visits, including date/time, agent, screen & window sizes (all easy), and MAC (as a rough client identifier, to distinguish repeat visitors) and type of device (using get_browser.php, if possible). These latter two are giving me fits (MAC and device). I am using php, html, and javascript.
Like you said, you can use some standard parts of PHP to get the date/time and user agent, and window sizes would have to be done through JavaScript.

It is completely impossible for any website to get the MAC address of a visitor. The user's MAC address is only known on their local network; it is never communicated by the browser to an external server. Browscap will not allow you to do this either.

You mentioned you wanted to find the MAC address in order to distinguish repeat visitors. Here are some ways you could consider, depending on your use case for this:
  • You could place a cookie on the visitor, and so you can then check the presence of that cookie on subsequent page visits. This is what most services use to find repeat visitors. However, cookies can be cleared by the user at any time.
  • You could track the user's IP address, rather than MAC address. However, IP addresses can change, and multiple users can have the same IP address (e.g. in a public place).
  • You could use browser fingerprinting to generate a hash based on all known factors of the visitor using JavaScript. However, multiple people can share the same fingerprint (e.g. if they have identical computers), and since this is client-side, they can change.
You can find the user's browser and operating system by looking at the user's User Agent. For example, if the User Agent contains "Windows NT", you can assume the user is on Windows.
 
Top