You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.6 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>.htpasswd-Generator</title>
<style type="text/css">
body{max-width:800px;margin:auto;font: 1em/1.5em "Bitstream Vera Sans","Verdana",sans-serif}
h1{border-bottom:1px solid rgb(0,64,128);color:rgb(0,64,128)}
pre{background-color:#080808;color:#e4e4e4;border-radius:10px;padding:10px;box-shadow:3px 3px 3px 0px #666}
textarea{width:100%;min-height:250px}
pre .F{color:#87d700}
pre .N{color:#d7875f}
.r {font-size:0.8em;float:right;}
</style>
</head>
<body>
<h1>.htpasswd-Generator</h1>
<p>
Pro Zeile ein Benutzer mit Passwort, getrennt durch einen Doppelpunkt.
</p>
<form action="htpasswd.php" method="post">
<textarea name="passwd"><?php echo( (isset($_POST["show"],$_POST["passwd"]) && $_POST["show"] == "yepp") ? htmlentities($_POST["passwd"]) : "user:passwort"); ?></textarea><br>
<span class="r"><input type="checkbox" value="yepp" id="show" name="show"<?php if(isset($_POST["show"]) && $_POST["show"] == "yepp") echo(" checked=\"checked\""); ?>> <label for="show">Passw&ouml;rter wieder im Klartext anzeigen</label></span>
<input type="submit" value="Erzeugen">
</form>
<?php
function salt() {
$c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$r = "";
for($i=0;$i<rand(10,15);$i++) {
$r .= substr($c,rand(0,strlen($c)),1);
}
return $r;
}
if(isset($_POST["passwd"]) AND !empty($_POST["passwd"])) {
$lines = explode("\n",$_POST["passwd"]);
foreach($lines AS $key=>$line) {
$p = explode(":",trim($line,"\r\n"),2);
if(strlen($p[0]) === 0 || strlen($p[1]) === 0) {
unset($lines[$key]);
continue;
}
$lines[$key] = "<span class=\"F\">".htmlentities($p[0],NULL,"utf-8")."</span>:<span class=\"N\">".htmlentities(crypt($p[1],'$5$rounds='.rand(1000,2000).'$'.salt().'$'),NULL,"utf-8")."</span>";
}
echo(" <p><strong>.htpasswd</strong></p>\n <pre>".implode("\n",$lines)."</pre>\n");
?>
<p><strong>.htaccess</strong></p>
<pre>
<span class="F">AuthType</span> <span class="N">Basic</span>
<span class="F">AuthName</span> "Administrationsbereich"
<span class="F">AuthUserfile</span> /home/webpages/lima-city/<span style="color:red">username</span>/html/.htpasswd
<span class="F">Require</span> <span class="N">valid-user</span></pre>
<p style="color:#999;font-size:80%;">
Der Pfad bei <code>AuthUserfile</code> muss angepasst werden. username muss durch deinen Benutzernamen ersetzt werden und vor <code>.htpasswd</code> muss evtl. noch das Gew&uuml;nschte Unterverzeichnis eingef&uuml;gt werden.
</p>
<?php
}
?>
</body>
</html>
<?php /* vim: set ft=php : */ ?>