Solved

get user info

Posted on 2004-08-08
6
246 Views
Last Modified: 2008-01-09
I am looking for a way to somehow get information about the visiting use through PHP (not Javascript).  I am looking for a way to get resolution and color depth.  I am pretty sure that there is a way to get this information through PHP, but I can't seem to find it on the net.  Also, if possible the screen width and height would be nice as well as javascript version.  Chances are that the last 3 wont be able to be acheived, but I am not sure.

Thanks!
Matt
0
Comment
Question by:mattjp88
  • 3
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 63 total points
ID: 11747961
Hi

I'm not experienced enough in PHP to tell you how to do that. The only things I know are how to get the user's IP:
$_SERVER['REMOTE_ADDR'];

and the host of the address:

gethostbyaddr($_SERVER['REMOTE_ADDR']);


However, I can tell you how to do these things in Javascript. (screen resolution is just screen width by screen height)
[I know you mainly want it in PHP, but this is just for reference for Javascript just in case]

====================================================
function getIP() {
   //This requires the user to have Java enabled. Use $_SERVER['REMOTE_ADDR'] instead.
   if (!document.all && navigator.javaEnabled()) {
      return(java.net.InetAddress.getLocalHost().getHostAddress());
   }
   return false;
}

function getScreenWidth() {
   if (window.screen) {
      return(window.screen.width);
   }
   return(getScreenWidthJava());
}

function getScreenWidthJava() {
   if (navigator.appName=="Netscape" && navigator.javaEnabled()) {
      return(java.awt.Toolkit.getDefaultToolkit().getScreenSize().width);
   }
   return false;
}

function getScreenHeight() {
   if (window.screen) {
      return(window.screen.height);
   }
   return(getScreenHeightJava());
}

function getScreenHeightJava() {
   if (navigator.appName=="Netscape" && navigator.javaEnabled()) {
      return(java.awt.Toolkit.getDefaultToolkit().getScreenSize().height);
   }
   return false;
}

function isJavaEnabled() {
   if (navigator.javaEnabled()) {return true;}
   return false;
}

function getBrowserName() {
   return(navigator.appName);
}

function getPlatform() {
   return(navigator.platform);
}

function getBrowserCodeName() {
   return(navigator.appCodeName);
}

function getMaxScreenWidth() {
   if (window.screen) {
      return(window.screen.availWidth);
   }
   return false;
}

function getMaxScreenHeight() {
   if (window.screen) {
      return(window.screen.availHeight);
   }
   return false;
}

function antiAliasingFonts() {
   return(window.screen.fontSmoothingEnabled);
}

function getBrowserVersion() {
   return(navigator.appVersion);
}

function getColorDepth() {
   if (window.screen) {
      return(window.screen.colorDepth);
   }
   return false;
}

function getNumberOfColors() {
   if (window.screen) {
      return(Math.pow(2,window.screen.colorDepth));
   }
   return false;
}

function hasCSS() {
   var bool = (document.all) ? checkcss : document.checkcss;
   return(bool);
}

function getLanguage() {
   var bool = (document.all) ? navigator.browserLanguage : navigator.language;
   return(bool);
}

function getReferrer() {
  return(document.referrer);
}

function getHistoryLen() {
  return(history.length);
}


Regards,
Zyloch
0
 
LVL 25

Assisted Solution

by:Squinky
Squinky earned 62 total points
ID: 11747970
You can't get this directly through PHP because at the time the script runs, it's on the server, not the client. You will have to get this data using Javascript, which you can then report back to a PHP script. This is an example as used by the summary web log analyser:

http://summary.net/manual/javascript.html

In this case it's relying on making static requests that can be later analysed in the logs, but you'll just need to get it to call a PHP script with the parameters instead, at which point you can do what you like with them, so change this line:

ls="/log____image.gif?...

to

ls="/userparams.php?...
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11747987
Hmm.. had a look at that. If that's the case, this function:

function getColorDepth() {
   if (window.screen.colorDepth) {
      return(window.screen.colorDepth);
   } else if (window.screen.pixelDepth) {
      return(window.screen.pixelDepth);
   }
   return false;
}
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 25

Expert Comment

by:Squinky
ID: 11748054
The Javascript summary provides is pretty old and clunky, so I wouldn't follow it too much - it's lacking some basic things like type attributes, and its installation instructions break W3C validation, however, it will do the trick. Your function collection is far neater, it just needs a higher-level function to gather all that info and turn it into a request, so the answer is somewhere between the two. Fancy writing it?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11748933
True, I'll have to wait and see how he wants it though, (and I'm prolonging it ;)
0
 
LVL 6

Author Comment

by:mattjp88
ID: 11825982
Well, I wanted a way for me to get some of the user datails only through PHP, not javascript.  And from what you said and also what many internet sites say; it's impossible.  Thanks for your help!

-Matt
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now