function sendValidationEmails($record) { $code = md5($record["salt"] . "5263610"); $params = array('code' => $code, 'email' => $record["officialEmail"], 'salt' => $record["salt"]); sendValidationEmail("acEmail", $record["officialEmail"], $record["salt"]); //http_post("eval01.france-ioi.org", 80, "/castor/sendMail.php", $params);//OLD }
public function __construct() { $this->email = $_SESSION['act_email']; //check if an activation code exists and generate one if it doesnt exist $this->code = $this->act_code_exists($this->email); //reuire our email file require_once ISVIPI_FUNCTIONS_BASE . 'emails/reg_emails.php'; //send email global $isv_siteDetails, $isv_siteSettings; sendValidationEmail($this->email, "Member", $this->code, $isv_siteDetails['s_email'], $isv_siteDetails['s_title'], $isv_siteDetails['s_url'], $isv_siteSettings['logo']); //unset our session email unset($_SESSION['act_email']); //redirect to homepage with success message $_SESSION['isv_success'] = "We have sent an email with an activation code to {$this->email}. Follow instructions in the email to activate your account."; header('location:' . ISVIPI_URL . ''); exit; }
<?php require_once "mail/email.php"; $hash = md5(rand(0, 1000)); $email = "*****@*****.**"; if (sendValidationEmail($hash, $email) == true) { echo "positive"; } else { echo "failed"; } /* require("phpmailer/class.phpmailer.php"); echo "staring mail\n"; $mail = new PHPMailer(); echo "new mailer\n"; $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // SMTP authentication $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; // SMTP server $mail->Port = 465; // SMTP Port $mail->Username = "******"; // SMTP account username $mail->Password = "******"; // SMTP account password $mail->SetFrom('*****@*****.**', 'WDZ App'); // FROM $mail->AddReplyTo('*****@*****.**', 'WDZ App'); // Reply TO //$mail->AddAddress('*****@*****.**', 'Jane Doe'); // recipient email $mail->AddAddress('*****@*****.**'); // recipient email
public function __construct($userFields) { //check if supplied/empty foreach ($userFields as $field => $value) { if (!isSupplied($value)) { $array['err'] = true; $array['message'] = 'Please fill in ' . $field . '!'; echo json_encode($array); exit; } } //assign our variables $this->username = $userFields['Username']; $this->name = $userFields['Full Name']; $this->email = $userFields['Email']; $this->password = $userFields['Password']; $this->rPassword = $userFields['Repeat Password']; $this->country = $userFields['Country']; $this->dob = $userFields['Date of Birth']; $this->sex = $userFields['Gender']; //validate username /*(allow only alphanumeric,hyphen and underscores) */ if (preg_match('/[^a-z_\\-0-9]/i', $this->username)) { $array['err'] = true; $array['message'] = 'Username cannot have any space. It MUST be one word with 8 or more characters.'; echo json_encode($array); exit; } if (strlen($this->username) < 6) { $array['err'] = true; $array['message'] = 'Username MUST be 6 or more characters.'; echo json_encode($array); exit; } //check if the username is already taken if ($this->isRegistered($this->username, 'username')) { $array['err'] = true; $array['message'] = '' . $this->username . ' is taken. Please try another.'; echo json_encode($array); exit; } //validate email if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) { $array['err'] = true; $array['message'] = 'Your email is invalid.'; echo json_encode($array); exit; } //check if a user with the same email exists if ($this->isRegistered($this->email, 'email')) { $array['err'] = true; $array['message'] = 'A user with this email is already registered.'; echo json_encode($array); exit; } //check if passwords is long enough if (strlen($this->password) < 8) { $array['err'] = true; $array['message'] = 'Password MUST be 8 or more characters.'; echo json_encode($array); exit; } //check if the two passwords match if ($this->password !== $this->rPassword) { $array['err'] = true; $array['message'] = 'Password and Re-enter Password do not match.'; echo json_encode($array); exit; } //validate date format $format = "d/m/Y"; $this->dob = $this->validateDate($this->dob, $format); //hash the password $hashedPWD = password_hash($this->password, PASSWORD_DEFAULT); //save in a database global $isv_db; $stmt = $isv_db->prepare("INSERT INTO users (username,email,pwd,reg_date,last_activity) VALUES (?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP())"); $stmt->bind_param('sss', $this->username, $this->email, $hashedPWD); $stmt->execute(); //retrieve new user id $stmt->prepare("SELECT id FROM users WHERE email=?"); $stmt->bind_param('s', $this->email); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($userID); $stmt->fetch(); //save other details in user_profile table $stmt->prepare("INSERT INTO user_profile (user_id,fullname,gender,dob,country) VALUES (?,?,?,?,?)"); $stmt->bind_param('issss', $userID, $this->name, $this->sex, $this->dob, $this->country); $stmt->execute(); $stmt->close(); //send activation email if this is enabled $siteInfo = new siteManager(); $isv_siteSettings = $siteInfo->getSiteSettings(); $isv_siteDetails = $siteInfo->getSiteInfo(); if ($isv_siteSettings['user_validate'] === 1) { /* generate our validation code */ $validCode = $this->getValidationCode($hashedPWD); /* include our email functions file */ require_once ISVIPI_FUNCTIONS_BASE . 'emails/reg_emails.php'; /*send the email */ sendValidationEmail($this->email, $this->name, $validCode, $isv_siteDetails['s_email'], $isv_siteDetails['s_title'], $isv_siteDetails['s_url'], $isv_siteSettings['logo']); $msg = 'Account created. We have sent an email with an activation code to ' . $this->email . '. Follow instructions in the email to activate your account.'; } else { $msg = 'Account created. You can now login.'; } //notify admin if this is enabled if ($isv_siteSettings['notifyAdmin_newUser'] === 1) { notifyAdmin($this->name, 'New User', $isv_siteDetails['s_email'], $isv_siteDetails['s_title']); } //return success notice $array['err'] = false; $array['message'] = $msg; echo json_encode($array); exit; }