
htaccess
hi,
um ein verzeichnis zu schützen nutze ich
htaccess Creator:
access.php
einfach ins verzeichnis(was geschützt werden soll) kopieren & über browser starten.
es nur ein harken es kann keine datein überschreiben!
um ein verzeichnis zu schützen nutze ich
htaccess Creator:
access.php
Code: Alles auswählen
<?php
// Userliste
$userlist = ( isset($_POST['userlist']) ) ? $_POST['userlist'] : '';
if ( isset( $_POST['add'] ) && $_POST['name'] != '' && $_POST['pw'] != '' )
{
$userlist.= $_POST['name'] . ":" . crypt( $_POST['pw'] ) . "\n";
}
// htpasswd
$pw_file = ".htpasswd";
// htaccess
$path = $_SERVER['SCRIPT_FILENAME'];
$path = ereg_replace('/access.php', '', $path);
$acc_start = "AuthUserFile $path/$pw_file\nAuthName Privat\nAuthType Basic\nrequire valid-user";
$acc_file = "./.htaccess";
$access = ( isset($_POST['access']) ) ? $_POST['access'] : $acc_start;
if ( isset( $_POST['save'] ) && $userlist != '' && $access != '' && !( file_exists("./$pw_file") ) && !( file_exists($acc_file) ) )
{
// htpasswd
$file = fopen("./$pw_file", "w+");
if(!fwrite($file, $userlist)) $error = TRUE;
fclose($file);
// htaccess
$file = fopen($acc_file, "w+");
if(!fwrite($file, $access)) $error = TRUE;
fclose($file);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>htaccess Creator</title>
</head>
<body>
<form method="post" action="access.php" name="post">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td><b>.htaccess</b>:</td>
</tr>
<tr>
<td colspan="5"><textarea name="access" rows="7" cols="35" wrap="virtual" style="width:100%" class="post"><?php echo($access) ?></textarea></td>
</tr>
<tr>
<td><b>.htpasswd</b>:</td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="name" maxlength="80" style="width:200px" /></td>
<td>Passwort:</td>
<td><input type="text" name="pw" maxlength="80" style="width:200px" /></td>
<td><input type="submit" name="add" value="Hinzufügen" /></td>
</tr>
<tr>
<td colspan="5"><textarea name="userlist" rows="7" cols="35" wrap="virtual" style="width:100%" class="post"><?php echo($userlist) ?></textarea></td>
</tr>
<tr>
<td colspan="5" align="center"><input type="submit" name="save" value="Speichern" /></td>
</tr>
</table>
</form>
es nur ein harken es kann keine datein überschreiben!
MfG
Tecwar
Tecwar