Location: PHPKode > scripts > Static Parser Engine,Parser-class > static-parser-engine/make_htaccess.php
<?
# **************************************************************
# make htaccess !
#
# 1. set all rights (chmod 777)
# 2. place this file into the directory you want to protect
# 3. start the script (http://..../make_htaccess.php
# 4. enter login and password
# 5. press the button 'make'
# 6. ready
#
# Lars Brinkmann
# email: hide@address.com
#
# **************************************************************


if (($user) && ($passwort))
{
        # get url

        $url = $DOCUMENT_ROOT . dirname($PHP_SELF) . "/.htpasswd";

        #         make .htaccess and .htpasswd

        $htaccess_txt  = "AuthType Basic" . "\n";
        $htaccess_txt .= "AuthName \"protected area\"" . "\n";
        $htaccess_txt .= "AuthUserFile $url" . "\n";
        $htaccess_txt .= "require valid-user" . "\n";

        $htaccess_txt .= "php_value magic_quotes_gpc 0" . "\n";
        $htaccess_txt .= "DirectoryIndex index.php" . "\n";

    $htpasswd_txt .= "$user:".crypt($passwort,CRYPT_STD_DES)."\n";

        # save files

        $htaccess= fopen(".htaccess", "w");
        $htpasswd= fopen(".htpasswd", "w");

        fputs($htaccess, $htaccess_txt);
        fputs($htpasswd, $htpasswd_txt);
        fclose($htaccess);
        fclose($htpasswd);

        # output

        die ("OK!<HR>" . nl2br($htaccess_txt) . "<HR>" . nl2br($htpasswd_txt) . "<br /><a href='index.php'><b>click here to get back</b></a>");

}

?>
<HTML><HEAD><TITLE> MAKE .htaccess + .htpasswd </TITLE></HEAD>
<BODY>
<FORM METHOD="POST" ACTION="<? echo $PHP_SELF; ?>">
<p>Username: <INPUT TYPE="TEXT" NAME="user"></p>
<p>Passwort: <INPUT TYPE="TEXT" NAME="passwort"></p>
<p><INPUT TYPE="submit" VALUE="make"></p>
</FORM>
</BODY></HTML>


Return current item: Static Parser Engine,Parser-class