[ create a new paste ] login | about

Link: http://codepad.org/zfMgS3XP    [ raw code | output | fork ]

misterunknown - PHP, pasted on Jul 21:
<?php
	// Code for the htpasswd-Generator on misterunknown.de

	unset($lines);
	
	if(isset($_POST['subbut'])&&$_POST['subbut']=='reset')
		$lines = array();
	else {
		$lines = explode(';', $_POST['lines']);
			$lines = array_filter($lines);
	}
	if(    isset($_POST['subbut'])
		&& $_POST['subbut']=='Generate .htpasswd'
		&& isset($_POST['user'])
		&& isset($_POST['pass'])
		&& $_POST['user']!=""
		&& $_POST['pass']!=""
	) {
		$lines[] = $_POST['user'].':{SHA}'.base64_encode(sha1($_POST["pass"], true));
	}
	print '<form method="post" id="toolform"><fieldset><legend>new user</legend><table><tr><td>username:</td><td><input type="text" name="user" size="40" /></td></tr><tr><td>password:</td><td><input type="text" name="pass" size="40"/></td></tr></table><input type="hidden" name="lines" value="'.implode(';',$lines).'" /><input type="submit" name="subbut" value="Generate .htpasswd" /> <input type="submit" name="subbut" value="reset" /></fieldset></form><textarea id="htpasswd" name="htpasswd" rows="10" cols="80" style="display:block;">';
		foreach($lines as $item) print $item."\n";
	print '</textarea>';
?>


Output:
1
<form method="post" id="toolform"><fieldset><legend>new user</legend><table><tr><td>username:</td><td><input type="text" name="user" size="40" /></td></tr><tr><td>password:</td><td><input type="text" name="pass" size="40"/></td></tr></table><input type="hidden" name="lines" value="" /><input type="submit" name="subbut" value="Generate .htpasswd" /> <input type="submit" name="subbut" value="reset" /></fieldset></form><textarea id="htpasswd" name="htpasswd" rows="10" cols="80" style="display:block;"></textarea>


Create a new paste based on this one


Comments: