Detect Real User Agent (Original Code)

Started on the old forum in February 2012 · view the original in the archive · old links redirect here

29 replies · 3,924 views · started 14 years ago · 1 min read

TL;DR · summary of 29 replies
  • Detecting real user agent with the provided code is still unresolved as no fix or conclusion was reached.
  • The code has been updated multiple times, but issues related to detecting real user agents persist.
  • Users suggest improvements such as using arrays and loops for better performance and accuracy.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

14 participants
just_m3. Developer · 199 posts #2

cu ce l-ai scris de e in valuri asa ? 🙂)

en: what php editor did u used () ;

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

stolen_moment Developer · 77 posts #3

i just edited user agent in firefox to nokia 600 but its detect nokia 600 not mozilla firefox agent then how it detecting real user agent?

mobidev Senior · 312 posts #5

It works with me after I changed my browser identification on my blackberry to to mozilla ?????

FAKE: Mozilla/5.0 (BlackBerry; U; BlackBerry 9780; en) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.546 Mobile Safari/534.8+ (code update - 02.02.2012, 02.02 Ro)

REAL: BlackBerry 9780

gorillaz Junior · 21 posts #6

maybe this code will detect real ua.

<?php
$real=$_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$real = strtok($real, "/");
$brow = $_SERVER['HTTP_USER_AGENT'];
$brow = strtok($brow, "/");
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])){
$ua = $real;
} else {
$ua = $brow;
}
Parag Junior · 42 posts #7

Nice Script and it is fully Working,,,,,,,,,

m4ster_v4 Developer · 125 posts #9

It's Mine. Just a few code.

function getoribrowser($_mob_browser){
if(preg_match('/(google|bot)/i',strtolower($_mob_browser))){
$position = strpos(strtolower($_mob_browser),"bot");
$_mob_browser = substr($_mob_browser, $position-30, $position+2);
$_browser = explode (" ", $_mob_browser);
$_browser = array_reverse($_browser); 
}else if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {
$_mob_browser = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}else {
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}
return $_browser[0];
}

Visit my WEBSITE Project: http://www.aspirewap.net

kiss Senior · 294 posts #12

Ohhh, why you post offtopic? Don't ask why the code it write in some way, download & use it..if you know how 😀

www.inbuzunar.mobi -Your mobile portal pocket

slcash Developer · 75 posts #13

Oh . . .boring kiss . . Why you dont code behind the operamini agent , . . Aha. . . Why

arnage Lead · 811 posts #16

Should be more. 🙂

For example, no need suppressing ;-_ and so when only needs delimiters and quantifiers suppressed, which are:

\ | ( ) [ { ^ $ * + ? . < >

Note where are only left brackets.

\s you should change, it is not only white space, it is line brakes and tabs also. You probably know what happens with php in the new line. 😉 Replace it with:

\p{Zs}

This is only white space. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
kiss Senior · 294 posts #17

Thank you arnage, next week i'll make a test with your ideas, till now check new update 🙂

www.inbuzunar.mobi -Your mobile portal pocket

arnage Lead · 811 posts #18

You are welcome. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
something else Fellow · 2,296 posts #20

hey kiss nice script you may want to think about using an array and using a for/while loop as 95% of your script is returning $match[0] so it would reduce the amount of hard coding and make it run faster

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close