{$ax['log_new_reg']}:
| {$ax['log_un']}: | {$uName} |
| {$ax['log_em']}: | {$eMail} |
| {$ax['log_date_time']}: | ".IDtoDD(date('Y-m-d'))." {$ax['at_time']} ".ITtoDT(date("H:i"))." |
{$ax['log_pw_msg']}: {$set['calendarTitle']}:
{$ax['log_un']}: {$user['name']} {$ax['or']} {$ax['log_em']}: {$user['email']}
{$ax['log_pw']}: {$newPw}
"; $result = sendEml($ax['log_pw_subject'],$msgBody,$user['email'],1,0,0); //send email $user['un_em'] = $user['name']; //save for login if (!$result) { $msg = $ax['log_em_problem_not_sent']; } if ($set['selfRegNot']) { $result = notifyReg($user['name'],$user['email']); if (!$result and empty($msg)) { $msg = $ax['log_em_problem_not_noti']; } } } while (false); return $msg; } function changeUser($user) { //change user data global $ax, $rxEmail, $xCode, $nowTS; $msg = ''; $lNewPw = isset($_POST["lNewPw"]) ? trim($_POST["lNewPw"]) : ''; do { if (!$xCode OR $xCode > $nowTS OR $xCode < $nowTS-300) { $msg = $ax['log_time_out']; break; } if (!$user['name']) { $msg = $ax['log_no_un_em']; break; } if (!preg_match("~^[\w\s-.]{2,}$~", $user['name'])) { $msg = $ax['log_un_invalid']; break; } if (!preg_match($rxEmail,$user['email'])) { $msg = $ax['log_em_invalid']; break; } if ($user['phone'] and !preg_match("~^\+?[\d]{4,19}$~",$user['phone'])) { $msg = $ax['log_ph_invalid']; break; } if ($user['pword'] != $user['pword2']) { $msg = $ax['log_pw_error']; break; } $stH = stPrep("SELECT `name`,`email` FROM `users` WHERE `ID` = ?"); stExec($stH,array($user['ID'])); $row = $stH->fetch(PDO::FETCH_NUM); //fetch user details $stH = null; if (!$row) { $msg = $ax['log_un_em_pw_invalid']; break; } list($name,$email) = $row; if ($name != $user['name']) { //username changed $stH = stPrep("SELECT `ID` FROM `users` WHERE `ID` != ? AND `name` = ? AND `status` >= 0"); stExec($stH,array($user['ID'],$user['name'])); if ($stH->fetchAll()) { $msg = $ax['log_new_un_exists']; break; } //un already exists } if ($email != $user['email']) { //email changed $stH = stPrep("SELECT `ID` FROM `users` WHERE `ID` != ? AND `email` = ? AND `status` >= 0"); stExec($stH,array($user['ID'],$user['email'])); if ($stH->fetchAll()) { $msg = $ax['log_new_em_exists']; break; } //em already exists } $stH = stPrep("UPDATE `users` SET `name` = ?,`email` = ?,`phone` = ?,`number` = ?,`language` = ? WHERE `ID` = ?"); stExec($stH,array($user['name'],$user['email'],$user['phone'],$user['usrNr'],$user['lang'],$user['ID'])); if ($user['pword']) { $md5Pw = md5($user['pword']); $stH = stPrep("UPDATE `users` SET `password` = ? WHERE `ID` = ?"); stExec($stH,array($md5Pw,$user['ID'])); } $_SESSION['cL'] = $user['lang']; //set cL to selected language } while (false); return $msg; } function sendNewPw($user) { //send new password global $ax, $set; $msg = ''; do { if (!$user['un_em']) { $msg = $ax['log_no_un_em']; break; } $stH = stPrep("SELECT `name`,`email` FROM `users` WHERE (`name` = ? OR `email` = ?) AND `status` >= 0"); stExec($stH,array($user['un_em'],$user['un_em'])); $row = $stH->fetch(PDO::FETCH_ASSOC); //fetch user details $stH = null; if (!$row) { $msg = $ax['log_un_em_invalid']; break; } $sendto = $row['email']; $uname = $row['name']; $newPw = substr(md5($user['un_em'].microtime()),0,8); $cryptpw = md5($newPw); $stH = stPrep("UPDATE `users` SET `tPassword` = ? WHERE `name` = ? OR `email` = ?"); stExec($stH,array(md5($newPw),$user['un_em'],$user['un_em'])); $msgBody = "{$ax['log_pw_msg']}: {$set['calendarTitle']}:
{$ax['log_un']}: {$uname} {$ax['or']} {$ax['log_em']}: {$sendto}
{$ax['log_pw']}: {$newPw}
"; $result = sendEml($ax['log_npw_subject'],$msgBody,$sendto,1,0,0); //send email if (!$result) { $msg = $ax['log_em_problem_not_sent']; } } while (false); return $msg; } function loginForm($user) { //send new password global $calID, $ax, $set, $lcI, $nowTS; if (!empty($user['name'])) { $user['un_em'] = $user['name']; } echo " \n"; } function registerForm($user) { //register form global $ax, $lcI, $nowTS; if ($user['un_em']) { if (strpos($user['un_em'],'@')) { $user['email'] = $user['un_em']; } else { $user['name'] = $user['un_em']; } } echo " \n"; } function changeForm($user) { //change my data global $ax, $lcI, $nowTS; $stH = stPrep("SELECT `ID`,`name`,`email`,`phone`,`number`,`language` FROM `users` WHERE `ID` = ?"); stExec($stH,array($user['ID'])); $row = $stH->fetch(PDO::FETCH_ASSOC); //fetch user details $stH = null; echo " \n"; } //control logic $msg = ''; $class = 'error'; $action = isset($_POST['action']) ? $_POST['action'] : ''; switch ($action) { case "logExe": //login $msg = loginUser($user,0); $action = 'back'; break; case "logChg": //login user to change data $msg = loginUser($user,1); $action = !$msg ? 'chg' : 'back'; break; case "logSpw": //send new password $msg = sendNewPw($user); if (!$msg) { $msg = $ax['log_npw_sent']; $class == 'confirm'; } $action = 'back'; break; case "rgrExe": //register $msg = registerUser($user); if (!$msg) { $msg = $ax['log_registered']; $class == 'confirm'; } $action = 'rgr'; //register form break; case "chgExe": //change data $msg = changeUser($user); if (!$msg) { $msg = $ax['usr_updated']; $class == 'confirm';} $action = 'chg'; break; } //display form echo "{$msg}