I create php script that remove user duplication create random password
and send email to users. But I don't test it.

<?php

function generatePassword($length=9, $strength=0) {
        $vowels = 'aeuy';
        $consonants = 'bdghjmnpqrstvz';
        if ($strength & 1) {
                $consonants .= 'BDGHJLMNPQRSTVWXZ';
        }
        if ($strength & 2) {
                $vowels .= "AEUY";
        }
        if ($strength & 4) {
                $consonants .= '23456789';
        }
        if ($strength & 8) {
                $consonants .= '@#$%';
        }
 
        $password = '';
        $alt = time() % 2;
        for ($i = 0; $i < $length; $i++) {
                if ($alt == 1) {
                        $password .= $consonants[(rand() % 
strlen($consonants))];
                        $alt = 0;
                } else {
                        $password .= $vowels[(rand() % strlen($vowels))];
                        $alt = 1;
                }
        }
        return $password;
}

mysql_connect('localhost', ...);
mysql_select_db('openclipart_aiki');

$query = 'SELECT username, email, count(username) AS n FROM aiki_users GROUP BY 
username HAVING n > 1';

$res = mysql_query($query);
if ($res) {
  while($row = mysql_fetch_row($res)) {
    $users[] = array("username"=> $row[0], "email"=>$row[1]);
  }
}

foreach ($users as $user) {
  $res = mysql_query("DELETE FROM aiki_users WHERE username = '". 
$user['username'] . "'");
  if ($res) {
  
    $passwd = generatePassword(6,2|4);
    $res = mysql_query("INSERT INTO aiki_users(username, email, password, 
usergroup) VALUES('" . 
                       $user['username'] . "', '" . $user['email'] . "', '" . 
md5(md5($passwd))
                       "', 3)");
    if ($res) {
       mail($user["email"], "Your OpenClipart account",
           "We have some problems with user account registration. If you 
created " .
           "account and can't login to it and what to use our library to share 
yo" . 
           "ur work you can do it now. We need to reset your password, its now: 
\n\n" .
           "     $passwd\n\n" .
           "You can change it when you're login." .
           "--\n" .
           "OpenClipart Developers");
    }
       
}

?>

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : aikiframework-devel@lists.launchpad.net
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to