Punto informatico Network
Login Esegui login | Non sei registrato? Iscriviti ora (è gratuito!)
Username: Password:
  • Annuncio Pubblicitario

codice corretto?

Cerchi consigli per migliorare il tuo sito? Vuoi aprire un sito in poco tempo?
Discuti con altri webmaster, chiedi chiarimenti ed opinioni in tutta libertà.
Lo spam verrà cancellato.

codice corretto?

Messaggioda jonni125 » ven lug 11, 2008 11:39 am

ragazzi c'è uno che dice che in questo codice c'è un bug, ma io non lo ho trovato e lui nn me lo vuole dire , mi potreste dirmiper favore dov'è?

Codice: Seleziona tutto
#
<?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
#
#
#
###############################################################
#
 
#
/*
#
-------------------------------------------------------------------
#
SAMPLE if you only want to request login and password on login form.
#
Each row represents different user.
#
 
#
$LOGIN_INFORMATION = array( //prima la psw e poi il nick
#
'aa' => 'dd',
#
'test' => 'testpass',
#
'admin' => 'passwd'
#
);
#
 
#
--------------------------------------------------------------------
#
SAMPLE if you only want to request only password on login form.
#
Note: only passwords are listed
#
 
#
$LOGIN_INFORMATION = array(
#
'root',
#
'testpass',
#
'passwd'
#
);
#
 
#
--------------------------------------------------------------------
#
*/
#
 
#
##################################################################
#
# SETTINGS START
#
##################################################################
#
//form action="password_only.php" method="post"
#
 
#
// Add login/password pairs below, like described above
#
// NOTE: all rows except last must have comma "," at the end of line
#
// Set a private page for login
#
$login=$_GET['pag'];
#
include($login);
#
/*
#
---------------------------------------------------------------------
#
*/
#
$LOGIN_INFORMATION = array(//prima il nick poi la password
#
'nome' => 'psw',
#
'
#
 
#
 
#
 
#
 
#
 
#
);
#
 
#
// request login? true - show login and password boxes, false - password box only
#
define('USE_USERNAME', true);
#
 
#
// time out after NN minutes of inactivity. Set to 0 to not timeout
#
define('TIMEOUT_MINUTES', 0);
#
 
#
// This parameter is only useful when TIMEOUT_MINUTES is not zero
#
// true - timeout time from last activity, false - timeout time from login
#
define('TIMEOUT_CHECK_ACTIVITY', true);
#
 
#
##################################################################
#
# SETTINGS END
#
##################################################################
#
 
#
 
#
///////////////////////////////////////////////////////
#
// do not change code below
#
///////////////////////////////////////////////////////
#
 
#
// show usage example
#
if(isset($_GET['help'])) {
#
die('Include following code into every page you would like to protect, at the very beginning (first line):<br>&lt;?php include("' . __FILE__ . '"); ?&gt;');
#
}
#
 
#
// timeout in seconds
#
$timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);
#
 
#
// logout?
#
if(isset($_GET['logout'])) {
#
setcookie("verify", '', $timeout, '/'); // clear password;
#
die("Logged out.");
#
}
#
 
#
if(!function_exists('showLoginPasswordProtect')) {
#
 
#
// show login form
#
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
#
// stop at this point
#
die();
#
}
#
}
#
 
#
// user provided password
#
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 {
#
// set cookie if password was validated
#
setcookie("verify", md5($pass), $timeout, '/');
#
 
#
// Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
#
// So need to clear password protector variables
#
unset($_POST['access_login']);
#
unset($_POST['access_password']);
#
unset($_POST['Submit']);
#
}
#
 
#
}
#
 
#
else {
#
 
#
// check if password cookie is set
#
if (!isset($_COOKIE['verify'])) {
#
showLoginPasswordProtect("");
#
}
#
 
#
// check if cookie is good
#
$found = false;
#
foreach($LOGIN_INFORMATION as $key=>$val) {
#
if ($_COOKIE['verify'] == md5($val)) {
#
$found = true;
#
// prolong timeout
#
if (TIMEOUT_CHECK_ACTIVITY) {
#
setcookie("verify", md5($val), $timeout, '/');
#
}
#
break;
#
}
#
}
#
if (!$found) {
#
showLoginPasswordProtect("");
#
}
#
 
#
}
#
 
#
?>
www.jonnicomputer.helloweb.eu
Avatar utente
jonni125
Bronze Member
Bronze Member
 
Messaggi: 914
Iscritto il: ven gen 04, 2008 3:21 pm
Località: Casa mia!

Messaggioda dararag » ven lug 11, 2008 1:14 pm

tu permetti l'inclusione di un file esterno, da url, senza neanche sapere che cosa sia:
Codice: Seleziona tutto
$login=$_GET['pag'];
#
include($login);

oltretutto inserisci tutte le variabili get in variabili locali senza neanche controllare il contenuto
Maledette aziende produttrici, l'unico telefilm interessante degli ultimi tempi l'hanno interrotto alla decima puntata... e chi voleva sapere la fine?
Avatar utente
dararag
Silver Member
Silver Member
 
Messaggi: 1116
Iscritto il: mar gen 22, 2008 8:57 pm
Località: Casoria

Messaggioda jonni125 » ven lug 11, 2008 1:49 pm

quindi come deve essere in modo sicuro?
www.jonnicomputer.helloweb.eu
Avatar utente
jonni125
Bronze Member
Bronze Member
 
Messaggi: 914
Iscritto il: ven gen 04, 2008 3:21 pm
Località: Casa mia!


Messaggioda dararag » ven lug 11, 2008 2:04 pm

dipende dai file che dev includere, fanne una lista con un array, e poi controlla che corrispondano, ma impara le basi della sicurezza, le trovi in una delle guide di http://php.html.it
Maledette aziende produttrici, l'unico telefilm interessante degli ultimi tempi l'hanno interrotto alla decima puntata... e chi voleva sapere la fine?
Avatar utente
dararag
Silver Member
Silver Member
 
Messaggi: 1116
Iscritto il: mar gen 22, 2008 8:57 pm
Località: Casoria

Messaggioda jonni125 » ven lug 11, 2008 2:23 pm

non ne devo includere nessuno!io quel modulo lo ho preso da html.it e poi uno dice asp che te lo correggo che ci sono i bug ma siccome nn mi ci fido credo che me ne ha messi anche di + di prima quello sarebbe un modulo dilog-in al mio sito , semmai tipo ne conosci cose che fanno la stessa cosa ma sono senza bug?
www.jonnicomputer.helloweb.eu
Avatar utente
jonni125
Bronze Member
Bronze Member
 
Messaggi: 914
Iscritto il: ven gen 04, 2008 3:21 pm
Località: Casa mia!

Messaggioda jonni125 » ven lug 11, 2008 3:26 pm

Ma allora un altra cosa , come faccio a creare una cosa simile a quella ma sicura al 100% e senza bug?Che possa gestire tante password e tanti nick?
www.jonnicomputer.helloweb.eu
Avatar utente
jonni125
Bronze Member
Bronze Member
 
Messaggi: 914
Iscritto il: ven gen 04, 2008 3:21 pm
Località: Casa mia!

Messaggioda dararag » ven lug 11, 2008 3:46 pm

come fanno tutti, molto semplicemente, un database ed un if
Maledette aziende produttrici, l'unico telefilm interessante degli ultimi tempi l'hanno interrotto alla decima puntata... e chi voleva sapere la fine?
Avatar utente
dararag
Silver Member
Silver Member
 
Messaggi: 1116
Iscritto il: mar gen 22, 2008 8:57 pm
Località: Casoria

Messaggioda jonni125 » ven lug 11, 2008 5:09 pm

si ma io lo volevo fare in modo che un nick è associato a una psw
www.jonnicomputer.helloweb.eu
Avatar utente
jonni125
Bronze Member
Bronze Member
 
Messaggi: 914
Iscritto il: ven gen 04, 2008 3:21 pm
Località: Casa mia!

Messaggioda bluesummer » ven lug 11, 2008 9:56 pm

jonni125 ha scritto:si ma io lo volevo fare in modo che un nick è associato a una psw

Eh già...purtroppo è risaputo che un database può gestire al massimo un campo per tabella.
Peccato.
Sarebbe veramente il massimo se in un db si potessero gestire record con coppie di campi (nick,pwd) in modo da associare ad ogni nick la sua password. [cry+]
Avatar utente
bluesummer
Aficionado
Aficionado
 
Messaggi: 104
Iscritto il: lun mag 19, 2008 12:47 pm

Messaggioda dararag » lun lug 14, 2008 9:49 am

@bluesummer: spiega quando è ironia, pensavo di avere un super db [sh] [bleh] [:D]
Maledette aziende produttrici, l'unico telefilm interessante degli ultimi tempi l'hanno interrotto alla decima puntata... e chi voleva sapere la fine?
Avatar utente
dararag
Silver Member
Silver Member
 
Messaggi: 1116
Iscritto il: mar gen 22, 2008 8:57 pm
Località: Casoria

Messaggioda bluesummer » lun lug 14, 2008 12:03 pm

dararag ha scritto:@bluesummer: spiega quando è ironia, pensavo di avere un super db [sh] [bleh] [:D]
[fischio]
Avatar utente
bluesummer
Aficionado
Aficionado
 
Messaggi: 104
Iscritto il: lun mag 19, 2008 12:47 pm


Torna a Sviluppo Web

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron
Powered by phpBB © 2002, 2005, 2007, 2008 phpBB Group
Traduzione Italiana phpBB.it

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