PHP Website authentication

Home › Forum Archive › PC Discussion › PC Game Discussion › PHP Website authentication

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7833
    yousillyGoose
    Spectator

    Hey hey. I am playing around with an upload feature on my website (so that I can upload a file from anywhere without having to ftp with filezilla or something fun like that). The upload feature works fine. I want to now password the page where you upload files (so random people can’t access it). I know how to use .htaccess and all that, but I do not want an entire directory passworded- just the one page.

     

    This works on one server but not another because the second server is in cgi-php mode:

     

    if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) {
    /* No values: send headers causing dialog box to appear */
      	header('WWW-Authenticate: Basic realm="My Private Stuff"');
      	header('HTTP/1.0 401 Unauthorized');
      	echo 'Authorization Required.';
      	exit;
    
    } else if ((isset($PHP_AUTH_USER)) && (isset($PHP_AUTH_PW))){
    
      	/* Values contain some values, so check to see if they're correct */
    
      	if (($PHP_AUTH_USER != "user") || ($PHP_AUTH_PW != "password")) {
    	   /* If either the username entered is incorrect, or the password entered is incorrect, send the headers causing dialog box to appear */
    	   header('WWW-Authenticate: Basic realm="My Private Stuff"');
    	   header('HTTP/1.0 401 Unauthorized');
    	   echo 'Authorization Required.';
    	   exit;
      	} else if (($PHP_AUTH_USER == "user") || ($PHP_AUTH_PW == "password")) {
    	   /* if both values are correct, print success message */
    	   echo "<P>You're authorized!</p>";
      	}
    } 
    ?>

     

    Do you have any idea how to make this work under cgi? I read and attempted:

    http://www.francey.org/articles/http-authe…on-php-cgi.html

    but it didn’t work (though I’m an idiot and may have been trying it wrong).

    Any help is appreciated.

     

    PS.

    I’m a TOTAL php noob so don’t assume I know anything in your response!

     

    Rob

    #88911
    MasterP
    Spectator

    Windows or Linux box and do you have Cpanel installed?

    #88913
    yousillyGoose
    Spectator

    It is a dreamhoster server (not my own personal one). And it is a linux box :).

    #88915
    MasterP
    Spectator

    MasterP said:

    do you have Cpanel installed?
    #88917
    yousillyGoose
    Spectator

    Heh, what is cpanel?

     

    I have the panel.dreamhoster….. stuff I can access it with. Is that cpanel?

    #88973
    Derrick LeBrocq
    Spectator

    yousillyGoose said:

    Heh, what is cpanel?

     

    And some shlub on the internet allows YOU do have a server?

     

    Blasphemy….

    #88975
    MasterP
    Spectator

    If you have a linux box I highly recommend you use it.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘PC Game Discussion’ is closed to new topics and replies.