
<?php
###############################################################
# Page Password Protect 2.11
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
############################################################### 
#
# Usage:
# Set usernames / passwords below between SETTINGS START and SETTINGS END.
# Open it in browser with "help" parameter to get the code
# to add to all files being protected. 
#    Example: password_protect.php?help
# Include protection string which it gave you into every file that needs to be protected
#
###############################################################
##################################################################
#  SETTINGS START
##################################################################
$LOGIN_INFORMATION = array(//prima il nick poi la password
 'nick' => 'psw',
  
   
);
define('USE_USERNAME', true);
define('TIMEOUT_MINUTES', 0);
define('TIMEOUT_CHECK_ACTIVITY', true);
##################################################################
#  SETTINGS END
##################################################################
if(isset($_GET['help'])) {
  die('Include following code into every page you would like to protect, at the very beginning (first line):<br><?php include("' . __FILE__ . '"); ?>');
}
$timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);
if(isset($_GET['logout'])) {
  setcookie("verify", '', $timeout, '/'); // clear password;
  die("Logged out.");
}
if(!function_exists('showLoginPasswordProtect')) {
function showLoginPasswordProtect($error_msg) {
?>
<center><html>
<head>
  <title>Please enter password to access this page</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
  <style>
    input { border: 1px solid black; }
  </style>
  <form method="post">
    <h3>Stai per entrare nell' area privata del sito per entrare occorre registrarsi</h3>
    <font color="red"><?php echo $error_msg; ?></font><br />
<?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?>
    <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Accedi" />
 <br><br> <a href="http://jonni1995.altervista.org">Vai alla home</a><br><br>
<a href="http://jonni1995.altervista.org/dwq/registrazione.html">Registrati</a>
  </form>
  <br />
  </body>
</html></center>
<?php
  die();
}
}
if (isset($_POST['access_password'])) {
  $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  $pass = $_POST['access_password'];
  if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
  || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) 
  ) {
    showLoginPasswordProtect("Hai sbagliato qualcosa.");
  }
  else {
   
    setcookie("verify", md5($pass), $timeout, '/');
    
   
    unset($_POST['access_login']);
    unset($_POST['access_password']);
    unset($_POST['Submit']);
  }
}
else {
  
  if (!isset($_COOKIE['verify'])) {
    showLoginPasswordProtect("");
  }
  
  $found = false;
  foreach($LOGIN_INFORMATION as $key=>$val) {
    if ($_COOKIE['verify'] == md5($val)) {
      $found = true;
            if (TIMEOUT_CHECK_ACTIVITY) {
        setcookie("verify", md5($val), $timeout, '/');
      }
      break;
    }
  }
  if (!$found) {
    showLoginPasswordProtect("");
  }
}
?>
<? include('nomedelfile.php');?>



Visitano il forum: Nessuno e 9 ospiti
megalab.it: testata telematica quotidiana registrata al Tribunale di Cosenza n. 22/09 del 13.08.2009, editore Master New Media S.r.l.; © Copyright 2008 Master New Media S.r.l. a socio unico - P.I. 02947530784. GRUPPO EDIZIONI MASTER Spa Tutti i diritti sono riservati. Per la pubblicità: Master Advertising