--- inc/pgRegistracija.php 2001/09/25 15:38:04 1.1 +++ inc/pgRegistracija.php 2001/09/26 13:04:28 1.2 @@ -76,40 +76,8 @@ if (!$zanimanje) $error |= 16; if (!$nesto && !$spec_0) $error |= 32; if ($error == 0) { - $ime2 = my_quote($ime, true, false); - $ime2 = strtolower(ereg_replace('[^A-Za-z0-9]', "", $ime2)); - $prezime2 = my_quote($prezime, true, false); - $prezime2 = strtolower(ereg_replace('[^A-Za-z0-9]', "", $prezime2)); - $cnt = 1; - while ($cnt <= strlen($ime2)) { - $username = substr($ime2, 0, $cnt++).$prezime2; - $sql = "SELECT username FROM users WHERE username = '$username'"; - $sth = $dbh->prepare($sql); - if (!$sth) error("Cannot prepare query: \"$sql\""); - if (!$sth->execute()) error("Cannot execute query: \"$sql\""); - $row = $sth->fetchrow_array(); - $sth->finish(); - if (!$row) break; - } - if ($cnt > strlen($ime2)) { - $username2 = $username; - $cnt = 1; - while (true) { - $username = $username2.($cnt++); - $sql = "SELECT username FROM users WHERE username = '$username'"; - $sth = $dbh->prepare($sql); - if (!$sth) error("Cannot prepare query: \"$sql\""); - if (!$sth->execute()) error("Cannot execute query: \"$sql\""); - $row = $sth->fetchrow_array(); - $sth->finish(); - if (!$row) break; - } - } - $chars = preg_split('//', "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - array_shift($chars); - array_pop($chars); - $password = ""; - for ($i = 0; $i < 8; $i++) $password .= $chars[rand(0, count($chars))]; + $username = GenerateUsername($ime, $prezime); + $password = GeneratePassword(); $titula = $titula ? my_quote($titula) : "NULL"; $ime = $ime ? my_quote($ime) : "NULL"; $prezime = $prezime ? my_quote($prezime) : "NULL"; @@ -132,9 +100,9 @@ $sql = "INSERT INTO user_spec (user_id, spec_id) VALUES ($row, ".$specs[$i]["id"].")"; $dbh->dbh_do($sql); } - $mail = "\nKorisničko ime: $username\nLozinka: $password\n\nhttp://dpavlinusic1.pliva.hr/ph/thefilez/med/?section=login&username=$username\n"; -echo "[$email] [$mail]
\n"; - $ret = mail($email, "PLIVAmed.net - Registracija", "\nKorisničko ime: $username\nLozinka: $password\n\nhttp://dpavlinusic1.pliva.hr/ph/thefilez/med/?section=login&username=$username\n", "From: registracija@plivamed.net"); + $mail = "\nKorisničko ime: $username\nLozinka: $password\n\nhttp://dpavlinusic1.pliva.hr/ph/thefilez/med/?section=prijava&username=$username\n"; +#echo "[$email] [$mail]
\n"; + $ret = mail($email, "PLIVAmed.net - Registracija", $mail, "From: registracija@plivamed.net"); } $tpl->assign("emailok", $emailok); $tpl->assign("godrodok", $godrodok);