Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get user info

Posted on 2004-08-08
6
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 252 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:Marcus Bointon
Marcus Bointon earned 248 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Expert Comment

by:Marcus Bointon
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

670 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