[PHP] Protect Folder Via File .Htaccess
<?php
echo "<form method='POST'>
<title>[Protect] Folder Via Htaccess</title>
<center>
<br><br>\<font face='Tahoma' size='5'><b><font color='red'>Protect</font> Folder Via Htaccess</b></font><font face='Tahoma' size='2'></font><br><br>
<font face='Tahoma' size='2'>Path: <input type='text' name='path' value='/home/".@get_current_user()."/' size='50'><br>
<input type='text' name='username' placeholder='Username'>
<input type='text' name='password' placeholder='Password'>
<input type='submit' value='Generate Protection' name='submit'></font></form></center>";
# POSTS
$username = $_POST['username'];
$password = $_POST['password'];
$path = $_POST['path'];
# htaccess
$htaccess = "IyBHZW5lcmF0ZWQgQnkgeFNlY3VyaXR5IAojIERlVi1Qb2luVC5Db00KCkF1dGhUeXBlIEJhc2ljCkF1dGhOYW1lICJQcm90ZWN0ZWRbeFNlY3VyaXR5XSIKQXV0aFVzZXJGaWxlICN4c2VjdXJpdHkjLy5odHBhc3N3ZApSZXF1aXJlIHZhbGlkLXVzZXI=";
$b0x = str_replace("#xsecurity#" ,$path ,base64_decode($htaccess));
$crypt = crypt($password, base64_encode($password));
# Create
if($_POST['submit'])
{
$htpasswd = fopen($path.'.htpasswd', 'w');
if($htpasswd)
{
$s = $username.":".$crypt;
$x = fwrite($htpasswd,$s);
if($x)
{
print "<center><font face='Tahoma' size='2'>[+] <b>.htpasswd</b> Created </center></font>";
}
}
$htx = fopen('.htaccess','w');
if($htx)
{
$xx = fwrite($htx, $b0x);
if($xx)
{
print "<center><font face='Tahoma' size='2'>[+] <b>.htaccess</b> Created</font>";
}
}
}
?>
[PHP] Protect Folder Via File .Htaccess
Reviewed by Nguyen Nam Hong
on
10:39 AM
Rating:
