Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/04/2011, 07:07
gdls
 
Fecha de Ingreso: febrero-2010
Ubicación: Republica Dominicana
Mensajes: 53
Antigüedad: 14 años, 2 meses
Puntos: 4
Respuesta: requiero una mano con esto que me esta volviendo loco

Hermano Prueba el siguiente codigo y dime k tal, solo le cambie una variable.
Luego me dices k tal

<?php

/* Config Section */

$pass = array('123', 'marvinx15', 'jtomasx15', 'hendy', 'shary'); // Set the password.
$cookiename = 'sascookie'; // Optional change: Give the cookie a name. Default is sascookie
$expirytime = time()-3600; // Optional change: Set an expiry time for the password (in seconds). Default is 1 hour.
$msg = 'Password Incorrecto'; // Optional change: Error message displayed when password is incorrect. Default is "Password incorrect".

/* End Config */

/* Logout Stuff - Sept 5, 2005 */

if (isset($_REQUEST['logout'])) {
setcookie($cookiename,'',$expirytime); // remove cookie/password
if (substr($_SERVER['REQUEST_URI'],-12)=='?logout=true') { // if there is '?logout=true' in the URL
$url=str_replace('?logout=true','',$_SERVER['REQUEST_URI']); // remove the string '?logout=true' from the URL
header('Location: '.$url); // redirect the browser to original URL
}
show_login_page('');
exit();
}

$logout_button='<form action="'.$_SERVER['REQUEST_URI'].'" method="post"><input type="submit" name="logout" value="Logout" /></form>';
$logout_text='<a href="'.$_SERVER['REQUEST_URI'].'?logout=true">Logout</a>';

/* End Logout Stuff */

/* FUNCTIONS */
$encrypt_pass = array();
$submitted_pass = '';
foreach($pass as $password)
{
$encrypt_pass[] = (md5($password)); // encrypt password
}


function setmycookie() {
global $cookiename,$encrypt_pass,$expirytime, $submitted_pass;
setcookie($cookiename,$submitted_pass,$expirytime) ;
}

function show_login_page($msg) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Authorization Required</title>
<style type="text/css">
<!--
.error {color:#A80000}
body {font:90% Verdana, Arial, sans-serif;color:#404040}
#wrapper {width:800px;margin:0 auto;border:1px solid #606060}
#main {text-align:center;padding:15px}
#header {font:bold 130% Verdana, Arial, sans-serif;color:#DDDDDD;width:100%;height:5em;text-align:center;background:#A80000;line-height:5em}
#mid {margin:5em 0 5em 0}
#footer {font-size:75%;text-align:center;width:100%}
input {border:1px solid #606060; background: #DDDDDD}
-->
</style>
</head>
<body bgcolor="#000000">
<div id="wrapper">
<div id="header"><font color="#FFFFFF">Autorizacion Requerida</font></div>
<div id="main">
<div id="mid">

<form action="" method="POST">
<b><font face="Lucida Sans" size="6"><font color="#CC3300">PD</font><font color="#FFFFFF">Jupiter.info
| Canales Premium en Vivo<br>
<br>
</font></font><font face="Lucida Sans" size="3" color="#FFFF00">Su
sesión ha sido terminada por inactividad, favor ingrese su password
nuevamente.</font></b><p><font color="#FFFFFF"><b>Password</b></font><b><font color="#FFFFFF">:</font></b>&nbsp;<input type="password" name="password" size="20">&nbsp;
<input type="submit" value="Login">
<input type="hidden" name="sub" value="sub">
</p>
</form>
<div class=error><?=$msg?></div>
</div>
</div>
</div>
<div id="footer"><b><font color="#FFFFFF">Authentication by </font> <a href="http://www.pdjupiter.info">
pdjupiter.info</a><font color="#FFFFFF">&nbsp; Copyright 2011.</font></b></div>
</body>
</html>
<? }

/* END FUNCTIONS */

$errormsg='';
if (substr($_SERVER['REQUEST_URI'],-7)!='sas.php') {// if someone tries to request sas.php
if (isset($_POST['sub'])) { // if form has been submitted
$submitted_pass=md5($_POST['password']); // encrypt submitted password
if (!in_array($submitted_pass, $encrypt_pass)) { // if password is incorrect
$errormsg=$msg;
show_login_page($errormsg);
exit();
} else { // if password is correct
setmycookie();
}
} else {
if (isset($_COOKIE[$cookiename])) { // if cookie isset
if ($_COOKIE[$cookiename]==$encrypt_pass) { // if cookie is correct
// do nothing
} else { // if cookie is incorrect
show_login_page($errormsg);
exit();
}
} else { // if cookie is not set
show_login_page($errormsg);
exit();
}
}
} else {
echo 'Try requesting demo.php';
}
?>

Última edición por gdls; 09/04/2011 a las 07:13