function change_email_user($query, $id, $mod) { $conf = configurations(); $con = new Mongo(); $db = $con->{$conf}['base']->{$conf}['user']; try { $db->update(array('_id' => new MongoID($id)), array('$set' => $query), array('safe' => true, 'upsert' => true)); } catch (MongoCursorException $e) { trigger_error('Insert failed ' . $e->getMessage()); return 'db_error'; } switch ($mod) { case 'premail': send_valid_mail($query['new_mail'], $id, $query['mail_change_id'], $conf['lang']); return 'mailvalid'; break; case 'postmail': send_confirm_mail($query['email'], $conf['lang']); deconnect(); return echo_front_page('html5_mail_changed'); break; case 'user': return 'uservalid'; break; } }
$confirmCodeReg = uniqid(mt_srand((double) microtime() * 1000000)); if ($r) { $sql = "Update `wwd_accounts` set `confirmCodeReg`='{$confirmCodeReg}', `confirmTimeReg`='{$confirmTimeReg}', `confirmTimeReg2`=NULL WHERE uid={$uid}"; // echo "<br>sql=".$sql; // error_log("\r\n------".date("YmdHis")."sql=".$sql,3,"log_ajax_docheck_reAuthenEmail_sql.log"); $msql->init(); $msql->query($sql); $ps = " WHERE uid='" . $uid . "' "; $row = loaddata_row("wwd_accounts", $ps); if ($row['confirmCodeReg'] == $confirmCodeReg) { global $firstname, $lastname, $sex; $firstname = $row['firstname']; $lastname = $row['lastname']; $sex = $row['sex']; $email = $row['email']; if (send_confirm_mail($email, $confirmCodeReg, true)) { // $_SESSION['regClientEmail'] = $email; // unset($_SESSION['POST']); // $tool->goURL("register_client_ok.php"); echo "OK"; exit; } } else { echo "NoWork"; exit; } } else { echo "NoUser"; exit; } } elseif ($act == "chkOldPassword") {
} } // IF NO ERROR if (count($error) <= 0) { // CHECK WHETHER THE SAME EMAIL EXISTS $connected = already_email($email, $link); if ($connected != 0) { if ($connected['is_activated'] == 0) { array_push($error, 'The email is waiting to be activated.'); } else { array_push($error, 'The email is already subscribing.'); } $_SESSION['error'] = $error; header('Location:/php/mailinglist/pages/index.php'); //header('Location:/pages/'); } else { $created = create_account($email, $link); // send confirmation mail send_confirm_mail($email, $link); array_push($notification, "An email has been sent to confirm your subscription."); $_SESSION['notification'] = $notification; header('Location:/php/mailinglist/pages/index.php'); //header('Location:/pages/'); } } else { $_SESSION['email'] = $_POST['email']; $_SESSION['error'] = $error; header('Location:/php/mailinglist/pages/index.php'); //header('Location:/pages/'); } }