Ver Mensaje Individual
  #11 (permalink)  
Antiguo 20/03/2005, 11:47
coyote20
 
Fecha de Ingreso: febrero-2005
Mensajes: 867
Antigüedad: 19 años, 2 meses
Puntos: 3
y si necesita el

identificar.inc.php aqui esta

<?php
/************************************************** ************************************************** *********
Identificar el navegador
************************************************** ************************************************** *********/
/*
Author: Harald Hope, Website: http://tech.ratmachines.com/
Script Source URI: http://tech.ratmachines.com/downloads/downloads.php
Version 3, 4 February 2004
*/

//version 2, complex, but simple really.

/*
pack the browser type array, in this order
the order is important, because opera must be tested first, and ie4 tested for before ie general
same for konqueror, then safari, then gecko, since safari navigator user agent id's with 'gecko' in string.
note that $domBrowser is set for all modern dom browsers, this gives you a default to use, unfortunately we
haven't figured out a safe way to do this with actual method testing, which would be much better and reliable.
Obviously you could place a cookie based on a method test with javascript, force a page reload, and have
PHP read that cookie, but that would always depend on cookies being on.
*/

//Inicializar un par de funciones por si acaso
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
$_SERVER['HTTP_X_FORWARDED_FOR']="";}
if (!isset($_SERVER['HTTP_CLIENT_IP'])){
$_SERVER['HTTP_CLIENT_IP']="";}


function browser_detection() {

global $domBrowser, $unknownBrowser, $browser_name, $NN4, $IE4, $os, $unknownOS;
$userBrowser = $_SERVER['HTTP_USER_AGENT'];

//packs the browser array
// with browser name and if browser is dom, or modern
// do not change the order of this, since correct testing depends on this order
$a_browser_types[] = array('Opera', true);
$a_browser_types[] = array('MSIE 4', false);
$a_browser_types[] = array('MSIE', true);
$a_browser_types[] = array('Konqueror', true);
$a_browser_types[] = array('Safari', true);
$a_browser_types[] = array('Gecko', true);// covers Netscape 6-7, K-Meleon, Most linux versions
$a_browser_types[] = array('Mozilla/4', false);// this has to be last or else ie or opera might register true
//$a_browser_types[] = array('', ); // spare array fillers
//$a_browser_types[] = array('', );
//$a_browser_types[] = array('', );

/*
packs the os array
use this order since some navigator user agents will put 'macintosh' in the navigator user agent string
which would make the nt test register true
*/
$a_os = array('lin', 'mac', 'unix', 'solaris', 'bsd', 'nt', 'win');

//os tester
for ($i = 0; $i < count($a_os); $i++)
{
//unpacks os array, assigns to variable
$s_os = $a_os[$i];
$b_os_success = false;

//assign os to global os variable, os flag true on success
if (stristr($userBrowser, $s_os))
{
$os = $s_os;
$b_os_success = true;

// this is the test, you wouldnt' use this normally of course, it's just to make sure the script works
//echo("i =$i<br />os = $os<br />");
break;
}
}
//assigns defaults if the OS was not found in the loop test
if (!$b_os_success)
{
$unknownOS = true;
}

//Main browser tester array
/*
run through the browser_types array, break if you hit a match, if no match, assume old browser
or non dom browser, assigns false value to $b_success.
*/
for ($i = 0; $i < count($a_browser_types); $i++)
{
//unpacks browser array, assigns to variables
$s_browser = $a_browser_types[$i][0];
$b_dom = $a_browser_types[$i][1];
$b_success = false;

if (stristr($userBrowser, $s_browser))
{
$browser_name = $s_browser;
switch ( $browser_name )
{
case 'Mozilla/4':
$NN4 = true;
$safe_browser = false;
break;
case 'Gecko':
$rv = which_gecko( $userBrowser, 'rv' );
$release = which_gecko( $userBrowser, 'release' );
// this is to protect against Netscape 6.2 / mozilla pre version 1.0 errors
// if your CSS runs in Mozilla 0.9/netscape 6.x then this isn't necessary,
//just return true, skip this test
if ( ( $rv < 1 ) || ( $release < 20020400 ) )
{
$safe_browser = false;
}
else {
$safe_browser = true;
}
break;
default:
$safe_browser = true;
break;
}

$domBrowser = $b_dom;
$b_success = true;

// this is the test, you wouldnt' use this normally of course, it's just to make sure the script works
//echo("i =$i<br />browser = $browser_name<br />dom= $domBrowser<br />name= $s_browser<br />nua= $userBrowser<br />");
break;
}
}
//assigns defaults if the browser was not found in the loop test
if (!$b_success)
{
$safe_browser = false;
$domBrowser = false;
$unknownBrowser = true;
}
// this depends on what you want to use the function for, you can return any of the variables, or
// use the global variables anywhere in your scripts as long as this is run before you request them
// uncomment this for basic safe browser test, usually all the mozillas would pass this
return $userBrowser;
}

/*
function returns gecko rv or release date
can be used to verify browser functionality more or less,
but remember that rv versions can be very different depending on which gecko browser it is,
for example Galeon will have a different rv version for the same gecko engine in some cases, the
build date is more reliable.

go to: http://www.mozilla.org/releases/cvstags.html
for the full information on the gecko versions
*/
function which_gecko( $browser_string, $rv_or_release )
{
if ( $rv_or_release == 'rv' )
{
$rv_pos = strpos( $browser_string, 'rv:' );
$rv = substr( $browser_string, ( $rv_pos + 3 ), 3 );
return $rv;
}
elseif ( $rv_or_release == 'release' )
{
$gecko_pos = strpos( $browser_string, 'Gecko/' );
$gecko_release = substr( $browser_string, ( $gecko_pos + 6 ), 8 );
return $gecko_release;
}
}


/************************************************** ************************************************** *********
Identificar la IP
************************************************** ************************************************** *********/
function get_full_ip(){
// get client real ip
if ($_SERVER['HTTP_X_FORWARDED_FOR']):
$IP_ADDR = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
elseif($_SERVER['HTTP_CLIENT_IP']):
$IP_ADDR = $_SERVER['HTTP_CLIENT_IP'] ;
else:
$IP_ADDR = $_SERVER['REMOTE_ADDR'];
endif;

// get server ip and resolved it
$FIRE_IP_ADDR = $_SERVER['REMOTE_ADDR'];
$ip_resolved = gethostbyaddr($FIRE_IP_ADDR);

// builds server ip infos string
if ($FIRE_IP_ADDR != $ip_resolved && $ip_resolved):
$FIRE_IP_LITT = $FIRE_IP_ADDR." - ". $ip_resolved;
else:
$FIRE_IP_LITT = $FIRE_IP_ADDR;
endif;

// builds client ip full infos string
if ($IP_ADDR != $FIRE_IP_ADDR ):
$FULL_IP_INFOS = "$IP_ADDR | $FIRE_IP_LITT" ;
else:
$FULL_IP_INFOS = $FIRE_IP_LITT ;
endif;
return $FULL_IP_INFOS;

}

// Para ver los resultados
//echo browser_detection().'<br>';
//echo get_full_ip();
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
</body>
</html>