Por que el siguiente script solo me fuciona con navegador Netscape 7.2 y ultima version de Explorer mas no en versiones anteriores de Netscape (7.1 por ejemplo), Mozilla FireFox u otros navegadores?
![Pensando](http://static.forosdelweb.com/fdwtheme/images/smilies/scratchchin.gif)
Código PHP:
<?php
session_start();
function login_error()
{
die;
}
if (!isset($PHP_AUTH_USER) || strlen($PHP_AUTH_USER) == 0)
{
header("WWW-Authenticate: Basic realm=\"Informaweb\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user hits cancel button
login_error();
}
else
{
//check the login and password
if('=>test on login and password<=')
{
define ('ADODB_ASSOC_CASE',0);
define ('ADODB_FETCH_ASSOC',0);
include_once ('adodb/adodb.inc.php');
$base = "rsn";
$motor = trae_motor();
$usu = "informa";
$pass = "informa";
switch ($motor)
{
case "Oci8po":
$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$_SERVER["SERVER_ADDR"].")(PORT=1521)) (CONNECT_DATA=(SID=$base)))";
$db = ADONewConnection($motor);
$db->Connect($cstr, $usu, $pass);
break;
case "postgres":
$db = ADONewConnection('postgres7');
$connex="host=".$_SERVER["SERVER_ADDR"]." port=5432 dbname=rsn user=postgres";
$db->Connect($connex);
break;
default :
$dsn = "informix://informix:informix@$INFORMIXSERVER/$base";
$db = ADONewConnection($dsn);
if (!$db) die($dns.' '.$db->ErrorMsg() . " " . "ABRIRBD ---> " . " " . $dsn);
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$db->CursorType=0;
break;
}
$fmtf =& $db->GetRow("Select fmtfecha from iden");
$fmtfecha = trim($fmtf['fmtfecha']);
switch ($fmtfecha) {
case "MDY":
$fmt = "MM/DD/YYYY";
break;
case "DMY":
$fmt = "DD/MM/YYYY";
break;
case "YMD":
$fmt = "YYYY/MM/DD";
break;
default:
$fmt = "MM/DD/YYYY";
break;
}
if ($motor == "Oci8po")
{
$db->BeginTrans();
$db->Execute("ALTER SESSION SET nls_date_format='$fmt'");
$db->Execute("ALTER SESSION SET nls_numeric_characters='.,'");
$db->CommitTrans();
}
$sql = "select usr_pass, f_expira_p, iden.fmtfecha from nue_usuario, iden
where usuario = '$PHP_AUTH_USER'";
$qpass=$db->GetRow($sql);
if (count($qpass) > 0)
{ // Existe el usuario
include_once ('fechas.php');
if (strlen(trim($qpass['usr_pass'])) != 0) // Tiene Password Registrado
{
if ($qpass['usr_pass'] == md5($PHP_AUTH_PW))
{ // Password Ok
$fmt = trim($qpass['fmtfecha']);
$fmtfecha = $fmt;
$hoy = hoy($fmtfecha);
$fexpira = $qpass['f_expira_p'];
$expi = fecha_menos_fecha($fexpira,$hoy,$fmtfecha);
if ($expi == 0)
{
?> <script> alert ("<? echo 'Su vigencia en el sistema expirara el dia de hoy\nCominiquese con el Administrador del Sistema' ?>") </script> <?
}
if ($expi < 11 && $expi > 0)
{
?> <script> alert ("<? echo 'Su vigencia en el sistema expirara el '.$fexpira.'\nCominiquese con el Administrador del Sistema' ?>") </script> <?
}
if ($expi < 0)
{
?> <script> alert ("<? echo 'Su vigencia en el sistema ha expirado\nCominiquese con el Administrador del Sistema' ?>") </script> <?
die;
}
}
else
{ // Password Errado
header( "WWW-Authenticate: Basic realm=\"Informaweb\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user does not give good login and pass
login_error();
}
}
else
{ // No tiene Password Registrado
if (strlen(trim($PHP_AUTH_PW)) == 0) // No Ingreso Password
{
header( "WWW-Authenticate: Basic realm=\"Informaweb\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user does not give good login and pass
login_error();
}
else
{ // Ingreso Password
$pass = md5($PHP_AUTH_USER);
$rs = $db->Execute("Update nue_usuario set usr_pass = '$pass' WHERE
usuario='$PHP_AUTH_USER'");
if (!$rs)
die;
?> <script> alert ("Su Calve Ha Sido Asignada\n No la olvide por fa
vor");
</script>
<?
}
}
}
else
{ // No existe el usuario
header( "WWW-Authenticate: Basic realm=\"Informaweb\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user does not give good login and pass
login_error();
}
}
else
{
//This re-asks three times the login and password.
header( "WWW-Authenticate: Basic realm=\"Test Authentication System\"");
header("HTTP/1.0 401 Unauthorized");
//Result if user does not give good login and pass
login_error();
}
}
function trae_motor()
{
if (strlen($motor) == 0)
{
if (file_exists("../logon.txt"))
{
$gestor = fopen("../logon.txt","r");
$a = 0;
while ($info_usuario = fscanf($gestor, "%s"))
{
list ($motor) = $info_usuario;
}
fclose($gestor);
}
else
$motor = "informix";
}
if (strlen($motor) == 0)
$motor = "informix";
return($motor);
}
?>
Mil gracias por sus observaciones