Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565

    Problema script autenticazione

    Salve ragazzi!
    Ho un problema,
    ho scaricato da freephp.html.it
    un file contenente del codice da mettere nella pagina che vuoi proteggere con password.
    Questo è il codice

    codice:
    <?php 
    //
    // Copyright 2001 Xavier Media Group
    // http://www.xaviermedia.com/php/
    //
    // If you need help or have suggestions, please visit
    // http://www.xaviermedia.com/forum/index.php or
    // http://www.xaviermedia.com/php/password.phtml
    //
    if(!isset($PHP_AUTH_USER)) 
    {
    	Header("WWW-Authenticate: Basic realm=\"Xavier Protection\""); 
    	Header("HTTP/1.0 401 Unauthorized"); 
    	echo "Text to send if user hits Cancel button\n"; 
    	exit; 
    } 
    else
    {
    	$user_passwords = array (
    		// user1 is the login name and password1 
    		// is that users password. Add as many
    		// lines as you like.
    		"user1" => "password1", 
    		"user2" => "password2",
    		"user3" => "password3",
    		"user4" => "password4"
    		);
    
    	if (($PHP_AUTH_USER == "") || ($PHP_AUTH_PW == ""))
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    	else if (strcmp($user_passwords[$PHP_AUTH_USER],$PHP_AUTH_PW) == 0)
    	{
    		// This is the page that should be password protected.
    		echo "This is the password protected page.";
    		exit;
    	}
    	else
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    } 
    ?>
    Lui mi riconosce,ma il fatto è che lui anche se ti ha riconosciuto blocca tutto il codice che viene dopo di lui!

    Io non so nulla di PHP quindi mi potreste dire gentilmente cosa devo modificare il codice.

    Ciao e grazie in anticipo per le risposte
    Nulla

  2. #2
    innanzitutto è un vecchio script.. le variabili $PHP_AUTH_USER e $PHP_AUTH_PW cambiale con $_SERVER['PHP_AUTH_USER'] $_SERVER['PHP_AUTH_PW']

    mi pare siano queste le versioni attuali.. altrimenti poi cerco..

    in secondo luogo non funziona se php gira come fastcgi (quindi ad esempio su webserver IIS)


  3. #3
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565
    Ho fatto come mi hai detto tu:

    codice:
          <?php 
    //
    // Copyright 2001 Xavier Media Group
    // http://www.xaviermedia.com/php/
    //
    // If you need help or have suggestions, please visit
    // http://www.xaviermedia.com/forum/index.php or
    // http://www.xaviermedia.com/php/password.phtml
    //
    if(!isset($PHP_AUTH_USER)) 
    {
    	Header("WWW-Authenticate: Basic realm=\"Xavier Protection\""); 
    	Header("HTTP/1.0 401 Unauthorized"); 
    	echo "Text to send if user hits Cancel button\n"; 
    	exit; 
    } 
    else
    {
    	$user_passwords = array (
    		// user1 is the login name and password1 
    		// is that users password. Add as many
    		// lines as you like.
    		"user1" => "password1", 
    		"user2" => "password2",
    		"user3" => "password3",
    		"user4" => "password4"
    		);
    
    	if (($_SERVER['PHP_AUTH_USER'] == "") || ($_SERVER['PHP_AUTH_PW'] == ""))
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    	else if (strcmp($user_passwords $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'] ) == 0)
    	{
    		// This is the page that should be password protected.
    		echo "This is the password protected page.";
    		exit;
    	}
    	else
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    } 
    ?>
    Ma mi da questo errore:

    Parse error: parse error, unexpected T_VARIABLE in /xxxx/xxxxx/xxxxx.php on line 58

    Comunque,sono su altervista

    Aiutami,per favore!

    Ciao e grazie in anticipo
    Nulla

  4. #4
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565
    Up
    Nulla

  5. #5
    dovresti almeno dire qual'è la riga 58... :rollo:

  6. #6
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565
    Questa:

    Codice PHP:
    else if  (strcmp($user_passwords[$PHP_AUTH_USER],$PHP_AUTH_PW) == 0
    Nulla

  7. #7
    Originariamente inviato da }gu|do[z]{®©
    innanzitutto è un vecchio script.. le variabili $PHP_AUTH_USER e $PHP_AUTH_PW cambiale con $_SERVER['PHP_AUTH_USER'] $_SERVER['PHP_AUTH_PW']

    mi pare siano queste le versioni attuali.. altrimenti poi cerco..

    in secondo luogo non funziona se php gira come fastcgi (quindi ad esempio su webserver IIS)

    quoto quello che ha detto guidoz, dai un'altra occhiata al tuo codice, perché ci sono ancora le variabili all'antica...

  8. #8
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565
    Il fatto è che io non so ninte di php,ho scaricato questo script solo perchè non voglio che una pagina del sito venga vista.
    Quindi per favore potresti dargliela tu un occhiata?
    Grazie in anticipo
    Nulla

  9. #9
    codice:
    <?php 
    //
    // Copyright 2001 Xavier Media Group
    // http://www.xaviermedia.com/php/
    //
    // If you need help or have suggestions, please visit
    // http://www.xaviermedia.com/forum/index.php or
    // http://www.xaviermedia.com/php/password.phtml
    //
    if(!isset($_SERVER['PHP_AUTH_USER'])) 
    {
    	Header("WWW-Authenticate: Basic realm=\"Xavier Protection\""); 
    	Header("HTTP/1.0 401 Unauthorized"); 
    	echo "Text to send if user hits Cancel button\n"; 
    	exit; 
    } 
    else
    {
    	$user_passwords = array (
    		// user1 is the login name and password1 
    		// is that users password. Add as many
    		// lines as you like.
    		"user1" => "password1", 
    		"user2" => "password2",
    		"user3" => "password3",
    		"user4" => "password4"
    		);
    
    	if (($_SERVER['PHP_AUTH_USER'] == "") || ($_SERVER['PHP_AUTH_PW'] == ""))
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    	else if (strcmp($user_passwords  $_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_
    AUTH_PW'] ) == 0)
    	{
    		// This is the page that should be password protected.
    		echo "This is the password protected page.";
    		exit;
    	}
    	else
    	{
    		Header("HTTP/1.0 401 Unauthorized"); 
    		echo "Sorry, could find your password!";
    		exit;
    	}
    } 
    ?>
    prova così...avevi dimenticato una sostituzione...

  10. #10
    Utente di HTML.it L'avatar di Electro
    Registrato dal
    Dec 2003
    Messaggi
    565
    OK,domani provo!

    Grazie mille!
    Nulla

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.