Hi,
I wanted to make an htpasswd registration form.
I found this code on the internet but have no idea how to use it.
Can anyone help?
<?php
// Register User
function regUser() {
$filename = 'members/password/.htpasswd';
$data = $_POST['username'].":".htpasswd($_POST['password'])."n";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $data) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
// echo "Success, wrote ($data) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
}
// Show all Users and Passwords
function showUser()
{
$file = file('members/password/.htpasswd');
$array = array();
$count = count($file);
for ($i = 0; $i < $count; $i++)
{
list($username, $password) = explode(':', $file[$i]);
$array[] = array("username" => $username, "password" => $password);
}
return $array;
}
function delUser($username) {
$fileName = file('members/password/.htpasswd');
$pattern = "/". $username."/";
foreach ($fileName as $key => $value) {
if(preg_match($pattern, $value)) { $line = $key; }
}
unset($fileName[$line]);
if (!$fp = fopen('members/password/.htpasswd', 'w+'))
{
print "Cannot open file ($fileName)";
exit;
}
if($fp)
{
foreach($fileName as $line) { fwrite($fp,$line); }
fclose($fp);
}
}
// Encrypt Passwords
function htpasswd($pass)
{
$pass = crypt(trim($pass),base64_encode(CRYPT_STD_DES));
return $pass;
}
Writting a script to arrange images........ need some help
Ok so here is the linkhttp://hmtotc.com/dev/projects/vrassociates/jeweler_dev/admin/index.php?id=arrange&loc=4I am wondering if there is a way to have the text field hold a hidden value so I
Undefined index on my form
ok im getting Undefined index on this line.. print_r($_REQUEST['form']);below is the full script its formCode: <?phpini_set("display_errors",
Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I need to make it do user groups. See the groups are defined by numbers:0 - banned1 - registered2 -
writing my own sobel filter convolution - something is wrong
I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help point me to the right direction?!! Code: { int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; int
Can't find the problem (no error message)!
OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm going to try and make it as easy as possible. Here's a breakdown of what the user should do:1. The
php file erros / need help please
HelloSomeone decoded a zend file for me.. after uploaded it on ftp i get some errors, i tryed to fix but (dont know if what it did is right, i dont have skills in php) now im stuck and i dont know
puting for loop in 1 value
hi ,how do i put this code in 1 value:Code: <?phpfor ($i=1; $i<=5; $i++) { echo $i ; }?>the output will be: 12345how do i put the result in one value ,some thing like :if the
Preg_match question
I want to use preg_match to make sure a string is always 6 characters long and only contains 0-9 and the letters A-F.I have this but it does not work:'/^[0-9A-F]{6}$/'
PHP File Upload Problem
Hi, I have written a very simple file upload script but it fails for reasons I can't explain. Hopefully someone here can help me out. I have checked php.ini and file uploads are on with a limit of
present value of sequence?
Hi