PHP Classes
elePHPant
Icontem

no tests, no examples, no doc

Recommend this page to a friend!

      htaccess_advanced  >  All threads  >  no tests, no examples, no doc  >  (Un) Subscribe thread alerts  
Subject:no tests, no examples, no doc
Summary:Package rating comment
Messages:3
Author:Brandon Sussman
Date:2010-12-08 16:11:29
Update:2012-06-08 11:58:03
 

Brandon Sussman rated this package as follows:

Utility: Not sure
Consistency: Not sure

  1. no tests, no examples, no doc   Reply   Report abuse  
Brandon Sussman - 2010-12-08 16:11:29
no tests, no examples, no doc

  2. Re: no tests, no examples, no doc   Reply   Report abuse  
ztk - 2012-06-08 11:32:39 - In reply to message 1 from Brandon Sussman
after changing line 120 to
fputs($file,$newUserlist[$i][0].":".$newUserlist[$i][1]."\n");
you can try

<?php
include('htaccess.class.php');
$ht = new htmodel();
$ht->setFHtpasswd('/var/www/.htpasswd');

if(isset($_POST['b3'])) {
$ht->addUser($_POST['anew_jmeno'],$_POST['anew_heslo']);
}

if(isset($_POST['b1']) && isset($_POST['del_user']) && count($_POST['del_user']) > 0 ) {
$c = count($_POST['del_user']);
for($i=0;$i<$c;$i++)
$ht->delUser($_POST['del_user'][$i]);
}

if(isset($_POST['b2']) && isset($_POST['del_user']) && count($_POST['del_user']) > 0 ) {
$c = count($_POST['del_user']);
for($i=0;$i<$c;$i++)
$ht->setPasswd($_POST['del_user'][$i], $_POST['new_heslo'][$i]);
}



$users = $ht->getUsers();
?>


<form method="POST">


<table>
<?php
$c = count($users);
for($i=0;$i<$c;$i++) {
?>
<tr>
<td><?php echo $users[$i]['jmeno']; ?></td>
<td><input type="password" name="new_heslo[]" value="" /></td>
<td><input type="checkbox" name="del_user[]" value="<?php echo $users[$i]['jmeno']; ?>" /></td>
</tr>
<?php } ?>

<tr><td colspan="3"><p><br /></p></td></tr>
<tr> <td>&nbsp;</td>
<td><input type="submit" value="delete" name="b1" /></td>
<td><input type="submit" value="save" name="b2" />
</tr>

<tr><td colspan="3"><hr /></td></tr>

<tr>
<td><input type="text" name="anew_jmeno" value="" /></td>
<td><input type="password" name="anew_heslo" value="" /></td>
<td><input type="submit" value="add" name="b3" /></td>
</tr>

</form>


just played five minutes with that so forgive me :D

  3. Re: no tests, no examples, no doc   Reply   Report abuse  
ztk - 2012-06-08 11:58:03 - In reply to message 2 from ztk
yeah quick'n'dirty

function delUser($username){
$lines = explode("\n", file_get_contents($this->fPasswd));
$linesc= count($lines);
$newcon= '';
$deleted = false;
for($i=0;$i<$linesc;$i++) {
$temp = explode(":", $lines[$i]);
if($temp[0] != '' && $temp[1] != '') {
if($username != $temp[0]) $newcon .= $temp[0].':'.$temp[1]."\n";
if($username == $temp[0]) $deleted = true;
}
}
file_put_contents($this->fPasswd, $newcon);
return $deleted;
}


but heck it works