예제 #1
0
function editUser($u, $p)
{
    $fileName = file('/etc/squid3/basic.passwd');
    $users = array();
    foreach ($fileName as $key => $value) {
        list($k, $v) = preg_split("/:/", $value);
        print "key = " . $k . " :: val = " . $v . "<br>";
        $users[$k] = $v;
    }
    print "<br>====  BEFORE EDITING ====<br>";
    displayArray($users);
    $users[$u] = htpasswd($p);
    print "<br>====  AFTER EDITING ====<br>";
    displayArray($users);
    //print $u." gets new password ".$p." {".$users[$u]."}<br>";
    if (!($fp = fopen('/etc/squid3/basic.passwd', 'w+'))) {
        print "Cannot open file (" . $fileName . ")";
        exit;
    }
    if ($fp) {
        foreach ($users as $uname => $pass) {
            fwrite($fp, $uname . ":" . $pass);
        }
        fclose($fp);
    }
}
예제 #2
0
 function htpasswd_add($filename, $username, $password)
 {
     $data = $username . ":" . htpasswd($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";
     }
 }
예제 #3
0
        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $name = $name . $tmp;
        $i++;
    }
    return $name;
}
//Fonction de génération de mot de passe Apache - fichier ".htpasswd"
function htpasswd($motdepasse)
{
    $pass = crypt(trim($motdepasse), CRYPT_STD_DES);
    return $pass;
}
//Generation du htpasswd dans le répertoire crée
$rand_motdepasse = rand_str(5);
$htpasswd = htpasswd($rand_motdepasse);
$fichier_mot_de_passe = fopen($conf['absolute_path_download'] . "files/{$folder}/.htpasswd", "a");
fputs($fichier_mot_de_passe, $frommail . ":" . $htpasswd . "\n");
fclose($fichier_mot_de_passe);
$update = "";
if (($handle = fopen($conf['name_folder_log'] . "log_attachment.log", "r")) !== FALSE) {
    while (($data = fgets($handle)) !== FALSE) {
        $explode_data = explode(" | ", $data);
        if ($explode_data[3] == $folder) {
            $update .= $explode_data[0] . ' | ' . $explode_data[1] . ' | ' . $explode_data[2] . ' | From : ' . $frommail . ' | ' . $explode_data[3] . ' | ' . $explode_data[4] . ' | Notify : ' . htmlspecialchars(@$_POST["noti"]) . "/" . htmlspecialchars(@$_POST["every"]) . ' | Only One : ' . htmlspecialchars(@$_POST["only"]) . ' | ' . $explode_data[5] . ' | ' . $explode_data[6];
        } else {
            $update .= $data;
        }
    }
    fclose($handle);
}