2 function request_password() {
4 $login=addslashes($_POST['login']);
5 $login_type=$_POST['login_type'];
6 $email=$_POST['email'];
9 $error="Please enter name or id";
13 if ((strpos($email, '@') == false) || (strpos($email, '@') == '0') || (strpos($email, '@') >= (strlen($email) - 4))) {
14 $error="Please enter correct mail";
18 switch ($login_type) {
20 $set=$db->query("select * from users where login='$login' and email='$email'");
22 $user_name=$set->getString('login');
23 $user_id=$set->getString('user_id');
26 $set=$db->query("select * from users where user_id='$login' and email='$email'");
28 $user_name=$set->getString('login');
29 $user_id=$set->getString('user_id');
33 if($set->getNumRows() == 0) {
34 $error="Name [or id] that you entered do not match your mail";
38 $vercode=md5(uniqid(rand()));
39 $vercode=substr($vercode,0,23);
41 $q="update users set hash='$vercode' where user_id='$user_id'";
44 $emailtext= "Ahoj $user_name!\nPotrebujes zmenit heslo ktore si zabudol?\nPrave od toho tu je tento email. Musim tento text trosku natiahnut aby ho spamfiltre nebrali ako spam a ty si si to svoje zabudnute heslo mohol lahko zmenit.\nTu je tvoje overovacie cislo => $vercode <= [samozrejme bez tych sipiek => a <=].\nTen musis zadat na tejto adrese => https://".SYSTEM_URL."/id/632663 kde si uz svoje heslo lahko zmenis.\n\nVela Stastia\nadmini ".SYSTEM_URL;
45 $headers = 'From: root@kyberia.cz' . "\r\n" . 'X-Mailer: kyberia';
46 mail($email,SYSTEM_URL." verification code",$emailtext,$headers );
48 $error="<h3>Verification code sent, please check your mailbox.</h3>";