Jump to content
cristian.pana

Detecteaza orice brower real

Recommended Posts

M-am uitat pe sursa, trebuie sa fii nebun sa scrii asa ceva.

Nebunia este o provocare pt mine ;) Acolo sunt cateva ore zilnice de-a lungul a 1-2 luni, incluzand teste peste teste astfel incat codul sa citeasca perfect si corect :)

Pe afara a plouat putin.

Apropo, daca dai scrool rapid in php-ul ala, ai impresia ca se misca stanga-dreapta textul:))

Codul este tabulat :)

Link to comment
Share on other sites

HTTP Request:


GET / HTTP/1.1
Host: www.tinytop.mobi
User-Agent: <span style="font-size: 150px;">SCRIPT INUTIL!!!</span>
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

Link to comment
Share on other sites

Firefox11 +User Agent Switcher

***********************

FAKE: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

REAL: iPhone 3

************************

FAKE: RST/1.0 (Linux)

REAL: Unknown

*************************

FAKE: Mozilla/5.0 (compatible; Googlebot/2.1; +Googlebot - Webmaster Tools Help)

REAL: Googlebot/2.1

Link to comment
Share on other sites

@cristian.pana Cum s-a mai spus, ai prea mult if-uri. Foloseste foreach, e mult mai simplu.

Cam asa:

<?php

/**
* @author last1devil
* @copyright 2012
*/

function ua()
{

$agent = $_SERVER["HTTP_USER_AGENT"];

$useragent = array("|NK([^\s\;\-\_\/\(\)]*)|", "|Nokia-([^\s\;\_\/\(\)\.]*)|i",
"|Nokia(\/)?([^\;\-\_\/\(\)\.]*)|i", "etc etc etc");

foreach ($useragent as $ua) {
if (preg_match($ua, $agent, $match)) {
return $match[0];
} else {
return "Unknown";
}

}
}

echo ua();
?>

Are 950 linii de cod dar nu e prea util, useragent-ul se poate schimba usor.

Link to comment
Share on other sites

@cristian.pana Cum s-a mai spus, ai prea mult if-uri. Foloseste foreach, e mult mai simplu.

Cam asa:

<?php

/**
* @author last1devil
* @copyright 2012
*/

function ua()
{

$agent = $_SERVER["HTTP_USER_AGENT"];

$useragent = array("|NK([^\s\;\-\_\/\(\)]*)|", "|Nokia-([^\s\;\_\/\(\)\.]*)|i",
"|Nokia(\/)?([^\;\-\_\/\(\)\.]*)|i", "etc etc etc");

foreach ($useragent as $ua) {
if (preg_match($ua, $agent, $match)) {
return $match[0];
} else {
return "Unknown";
}

}
}

echo ua();
?>

Are 950 linii de cod dar nu e prea util, useragent-ul se poate schimba usor.

mult mai bine si mai simplu. ai cam pierdut timp degeaba in loc sa faci ceva util (OP)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...