function create_account($dirty_email) { $email = escape($dirty_email); if (user_count($email) != 0) { echo "signup-failure"; return; } if (validate_email($email) == false) { echo "signup-failure"; return; } $pending_verification = "pending-verification"; $sql1 = "INSERT INTO account_head (account, email, status)"; $sql1 .= " VALUES (null, '{$email}', '{$pending_verification}');"; query($sql1); if (user_count($email) == 1) { $new_account_num = account_id_from_email($email); $time = time(); $signupString = generate_string(); $sql2 = "INSERT INTO account_signup (account, code, date_requested)"; $sql2 .= " VALUES ({$new_account_num}, '{$signupString}', {$time});"; query($sql2); $sql3 = "SELECT * FROM account_signup WHERE account={$new_account_num}"; $result = query($sql3); $count = mysqli_num_rows($result); //mail($email,"ProjectPortfolio - Complete signup", "This is the msg telling you to sign up, fart."); send_signup_email($email, $signupString); if ($count == 1) { echo "signup-success"; return; } else { $sql4 = "DELETE FROM account_signup WHERE account={$new_account_num}"; $sql5 = "DELETE FROM account_head WHERE account={$new_account_num}"; query($sql4); query($sql5); } } else { echo "deleting head table failed"; $sql6 = "DELETE FROM account_head WHERE email={$email}"; query($sql6); } echo "signup-failure"; }
function check_input($details) { global $ALERT, $this_page; $errors = array(); // Check each of the things the user has input. // If there is a problem with any of them, set an entry in the $errors array. // This will then be used to (a) indicate there were errors and (b) display // error messages when we show the form again. // Check email address is valid and unique. if ($details["email"] == "") { $errors["email"] = "Please enter your email address"; } elseif (!validate_email($details["email"])) { // validate_email() is in includes/utilities.php $errors["email"] = "Please enter a valid email address"; } if (!ctype_digit($details['pid']) && $details['pid'] != '') { $errors['pid'] = 'Please choose a valid person'; } # if (!$details['keyword']) # $errors['keyword'] = 'Please enter a search term'; if ((get_http_var('submitted') || get_http_var('only')) && !$details['pid'] && !$details['keyword']) { $errors['keyword'] = 'Please choose a person and/or enter a keyword'; } // Send the array of any errors back... return $errors; }
function check_input($details) { $errors = array(); // Check each of the things the user has input. // If there is a problem with any of them, set an entry in the $errors array. // This will then be used to (a) indicate there were errors and (b) display // error messages when we show the form again. // Check email address is valid and unique. if (!$details['email']) { $errors["email"] = "Please enter your email address"; } elseif (!validate_email($details["email"])) { // validate_email() is in includes/utilities.php $errors["email"] = "Please enter a valid email address"; } if ($details['pid'] && !ctype_digit($details['pid'])) { $errors['pid'] = 'Please choose a valid person'; } # if (!$details['keyword']) # $errors['keyword'] = 'Please enter a search term'; if ((get_http_var('submitted') || get_http_var('only')) && !$details['pid'] && !$details['keyword']) { $errors['keyword'] = 'Please choose a person and/or enter a keyword'; } if (strpos($details['keyword'], '..')) { $errors['keyword'] = 'You probably don’t want a date range as part of your criteria, as you won’t be alerted to anything new!'; } // Send the array of any errors back... return $errors; }
function check_account_email($email) { $result = array('error' => false, 'message' => ''); // Caution: empty email isn't counted as an error in this function. // Check for empty value separately. if (!strlen($email)) { return $result; } if (!valid_email($email) || !validate_email($email)) { $result['message'] .= t('Not a valid email address') . EOL; } elseif (!allowed_email($email)) { $result['message'] = t('Your email domain is not among those allowed on this site'); } else { $r = q("select account_email from account where account_email = '%s' limit 1", dbesc($email)); if ($r) { $result['message'] .= t('Your email address is already registered at this site.'); } } if ($result['message']) { $result['error'] = true; } $arr = array('email' => $email, 'result' => $result); call_hooks('check_account_email', $arr); return $arr['result']; }
function formCheck($params) { global $_keys; $recaptcha_valid = FALSE; $errs = array(); if (!is_null($params["recaptcha_response_field"])) { $resp = recaptcha_check_answer($_keys['private'], $_SERVER["REMOTE_ADDR"], $params["recaptcha_challenge_field"], $params["recaptcha_response_field"]); if ($resp->is_valid) { $recaptcha_valid = TRUE; } else { $errs['recaptcha_error'] = $resp->error; } } if (!$recaptcha_valid) { $errs['recaptcha'] = "Please complete the anti-spam test"; } if (!$params['email']) { $errs['email'] = "Please enter the recipient's email address"; } else { if (!validate_email($params['email'])) { $errs['email'] = "Please enter a valid email address for the recipient"; } } if (!$params['name']) { $errs['name'] = "Please enter your name"; } return $errs; }
/** * Validate Registration Form * Registration Form Validation steps: * - check that no fields are empty. * - check that the e-mail is valid. * - check that the username is valid. * - check that both repeated user passwords match. * - check that the user password is valid. * @param string $user_email User email provided by the user. * @param string $user_name Username provided by the user. * @param string $user_password Password provided by the user. * @param string $user_password2 Repeated password provided by the user. * @return integer The function result code (for error handling) **/ function validate_registration_form($user_email, $user_name, $user_password, $user_password2) { $validation_result = SUCCESS_NO_ERROR; if (check_empty_form([$user_email, $user_name, $user_password, $user_password2]) == TRUE) { $validation_result = VALIDATE_REGISTER_EMPTY_FORM; return $validation_result; } // check if e-mail address is valid. $validation_result = validate_email($user_email); if ($validation_result != SUCCESS_NO_ERROR) { return $validation_result; } // check if user name is valid $validation_result = validate_username($user_name); if ($validation_result != SUCCESS_NO_ERROR) { return $validation_result; } // check if our passwords match. $validation_result = check_password_match($user_password, $user_password2); if ($validation_result != SUCCESS_NO_ERROR) { return $validation_result; } // check if user password is valid $validation_result = validate_password($user_password); if ($validation_result != SUCCESS_NO_ERROR) { return $validation_result; } return $validation_result; }
function validation($usernew) { global $CFG; $usernew = (object) $usernew; $user = get_record('user', 'id', $usernew->id); $err = array(); // validate email if (!validate_email($usernew->email)) { $err['email'] = get_string('invalidemail'); } else { if ($usernew->email !== $user->email and record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) { $err['email'] = get_string('emailexists'); } } if ($usernew->email === $user->email and over_bounce_threshold($user)) { $err['email'] = get_string('toomanybounces'); } /// Next the customisable profile fields $err += profile_validation($usernew); if (count($err) == 0) { return true; } else { return $err; } }
function login($dirty_email, $dirty_password) { $email = escape($dirty_email); $password = escape($dirty_password); if (!validate_email($email)) { echo "login-invalid-email"; return; } if (!validate_password($password)) { echo "login-invalid-password"; return; } $account_id = account_id_from_email($email); if ($account_id == -1) { echo "DEBUG: email or password invalid"; return; } if (correct_password($account_id, $password) == false) { echo "DEBUG: email or password invalid"; return; } session_regenerate_id(); fresh_logon($account_id); $username = username_from_account_id($account_id); setcookie('LOGGED_IN', $username, time() + 3600); echo "login-success"; }
function wikiplugin_subscribenewsletter($data, $params) { global $prefs, $user; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); $smarty = TikiLib::lib('smarty'); global $nllib; include_once 'lib/newsletters/nllib.php'; extract($params, EXTR_SKIP); if ($prefs['feature_newsletters'] != 'y') { return tra('Feature disabled'); } if (empty($nlId)) { return tra('Incorrect param'); } $info = $nllib->get_newsletter($nlId); if (empty($info) || $info['allowUserSub'] != 'y') { return tra('Incorrect param'); } if (!$userlib->user_has_perm_on_object($user, $nlId, 'newsletter', 'tiki_p_subscribe_newsletters')) { return; } if ($user) { $alls = $nllib->get_all_subscribers($nlId, false); foreach ($alls as $all) { if (strtolower($all['db_email']) == strtolower($user)) { return; } } } $wpSubscribe = ''; $wpError = ''; $subscribeEmail = ''; if (isset($_REQUEST['wpSubscribe']) && $_REQUEST['wpNlId'] == $nlId) { if (!$user && empty($_REQUEST['wpEmail'])) { $wpError = tra('Invalid Email'); } elseif (!$user && !validate_email($_REQUEST['wpEmail'], $prefs['validateEmail'])) { $wpError = tra('Invalid Email'); $subscribeEmail = $_REQUEST['wpEmail']; } elseif ($user && $nllib->newsletter_subscribe($nlId, $user, 'y', 'n') || !$user && $nllib->newsletter_subscribe($nlId, $_REQUEST['wpEmail'], 'n', $info['validateAddr'])) { $wpSubscribe = 'y'; $smarty->assign('subscribeThanks', empty($thanks) ? $data : $thanks); } else { $wpError = tra('Already subscribed'); } } $smarty->assign_by_ref('wpSubscribe', $wpSubscribe); $smarty->assign_by_ref('wpError', $wpError); $smarty->assign('subscribeEmail', $subscribeEmail); $smarty->assign('subcribeMessage', empty($button) ? $data : $button); $smarty->assign_by_ref('subscribeInfo', $info); $res = $smarty->fetch('wiki-plugins/wikiplugin_subscribenewsletter.tpl'); if (isset($params["wikisyntax"]) && $params["wikisyntax"] == 1) { return $res; } else { // if wikisyntax != 1 : no parsing of any wiki syntax return '~np~' . $res . '~/np~'; } }
/** Tarkasta sisaankirjautumislomake * @param $email string * @param $password string * @return boolean */ function validate($email, $password) { if (validate_email($email) && validate_password($password)) { return true; } else { return false; } }
private function validateDetails($email, $postcode) { $valid = true; if (!$email || !validate_email($email)) { $valid = false; } if (!$postcode || !validate_postcode($postcode)) { $valid = false; } return $valid; }
function send_token() { $email = validate_email(@$_POST['email']); if (email_overlap($email)) { echo "email overlap"; die; } $mail = new PHPMailer(); //实例化 $mail->IsSMTP(); // 启用SMTP $mail->Host = $GLOBALS['smtp_server']; //SMTP服务器 以163邮箱为例子 $mail->Port = $GLOBALS['smtp_server_port']; //邮件发送端口 $mail->SMTPAuth = true; //启用SMTP认证 $mail->CharSet = "UTF-8"; //字符集 $mail->Encoding = "base64"; //编码方式 $mail->Username = $GLOBALS['smtp_user_mail']; //你的邮箱 $mail->Password = $GLOBALS['smtp_user_pass']; //你的密码 $mail->Subject = "NutLab SS Token"; //邮件标题 $mail->From = $GLOBALS['smtp_user_mail']; //发件人地址(也就是你的邮箱) $mail->FromName = "NutLab"; //发件人姓名 $address = $email; //收件人email $mail->AddAddress($address, "Dear"); //添加收件人(地址,昵称) $mail->IsHTML(true); //支持html格式内容 $token = generate_token(); $mail->Body = "感谢您在我站注册了新帐号。<br/><br/>你的验证码为" . $token; //邮件主体内容 if (!$mail->Send()) { echo "token sending fail:" . $mail->ErrorInfo; echo "token sending fail"; } else { echo "token sending success"; } $count = count($GLOBALS['DB']->query("SELECT * FROM user WHERE email=? ", array($email))); if ($count > 0) { $result = $GLOBALS['DB']->query("UPDATE user SET token=? WHERE email=?", array($token, $email)); } else { $result = $GLOBALS['DB']->query("INSERT INTO user (email,pass,passwd,u,d,transfer_enable,port,enable,activated,token) VALUES (?,'','','0','0','0',?,'0','0',?)", array($email, generate_port(), $token)); } }
function success() { global $systemArr; global $messageArr; $SystemEmailAccount = $systemArr; $email = $systemArr["email"]; $error = ""; $returnMessage = ""; $success = true; $messageheading = $messageArr["messageHead"]; $messageSubject = $messageArr["messageSubject"]; $responseHeading = $messageArr["responseHead"]; $responseMessage = $messageArr["responseMessage"]; $responseSig = $messageArr["responseSig"]; $responseSubject = $messageArr["responseSubject"]; $responseEnd = $messageArr["responseEnd"]; if (isset($_POST["email"])) { //$emailClient = mysql_real_escape_string($_POST["email"]); $emailClient = $_POST["email"]; if (validate_email($emailClient)) { $name = $_POST["name"]; //$emailClient = $_POST["email"]; $title = $_POST["title"]; $message = $_POST["message"]; $messageContent = " <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n </head>\n <body style='font-family: calibri, sans-serif; font-size: 16px;'>\n \n <h1 style='padding: 10px; background-color: #1f1f1f; color: #ffffff; font-size: 28px;'>Hi there! You've received {$messageheading} from your website :)</h1>\n \n <table style='border-spacing: 0px; border: 1px solid #ccc; border-bottom: none;'>\n <tr>\n <td width='20%' style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Name</td>\n <td width='80%' style='padding: 5px; border-bottom: 1px solid #ccc;'>{$name}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Email Address</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$emailClient}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Message Title</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$title}</td>\n </tr>\n <tr>\n <td style='padding: 5px; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;'>Enquirer's Message</td>\n <td style='padding: 5px; border-bottom: 1px solid #ccc;'>{$message}</td>\n </tr>\n </table>\n \n <h2 style='padding: 10px; background-color: #1f1f1f; color: #ffffff; font-size: 28px;'>Enjoy your day!</h2>\n \n <p style='padding: 10px; background-color: #eee; color: #777; font-size: 12px;'>Brought to you by <b>Epicdev</b><sup>tm</sup>. Please do not hesitate to contact us for any general or support related queries at info@epicdev.co.za</p>\n \n </body>\n </html> "; //////////////////////////////////// HTML CODE FOR CLIENT ENQUIRY EMAIL //////////////////////////////////// $status = sendMail(array($email), $SystemEmailAccount, $messageSubject, $messageContent, null); if ($status["status"] == true) { $returnMessage = "Message Sent"; $messageRespond = " <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n </head>\n <body style='font-family: calibri, sans-serif; font-size: 16px;'>\n \n <h1 style='padding: 10px; background-color: #00CB16; color: #ffffff; font-size: 28px;'>{$responseHeading}</h1>\n \n <table style='border-spacing: 0px; border: 1px solid #ccc; border-bottom: none;'>\n <tr>\n <td width='100%' style='padding: 5px; border-bottom: 1px solid #ccc;'>{$responseMessage}</td>\n </tr>\n </table>\n \n <p style='padding: 10px 0 0 0; color: #00CB16; font-size: 24px; font-weight: bold; margin: 0'>{$responseEnd}</p>\n <p style='padding: 0; color: #00CB16; font-size: 18px; margin: 0 0 10px 0'>{$responseSig}</p>\n \n <p style='padding: 10px; background-color: #eee; color: #777; font-size: 11px;'>Brought to you by <b>Epicdev</b><sup>tm</sup> - www.epicdev.co.za. Please do not hesitate to contact us for any general or support related queries at info@epicdev.co.za</p>\n \n </body>\n </html> "; //////////////////////////////////// HTML CODE FOR CLIENT RESPONSE EMAIL //////////////////////////////////// if (validate_email($emailClient)) { $status2 = sendMail(array($emailClient), $SystemEmailAccount, $responseSubject, $messageRespond, null); if ($status2["status"] != true) { } } } else { $returnMessage = "Failed to send message"; $success = false; } } else { $returnMessage = "Invalid Email Address"; $success = false; } } header('Content-type: application/json'); if ($success == true) { $success = 1; } else { $success = 0; } echo "{\"status\":" . $success . ", \"message\":\"" . $returnMessage . "\"}"; }
/** * Creates necessary fields in the messaging config form. * @param object $mform preferences form class */ function config_form($preferences) { global $USER, $OUTPUT; $inputattributes = array('size' => '30', 'name' => 'email_email', 'value' => $preferences->email_email); $string = get_string('email', 'message_email') . ': ' . html_writer::empty_tag('input', $inputattributes); if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) { $string .= ' (' . get_string('default') . ': ' . s($preferences->userdefaultemail) . ')'; } if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) { $string .= $OUTPUT->container(get_string('invalidemail'), 'error'); } return $string; }
function account_register_new($unix_name, $realname, $password1, $password2, $email, $language, $timezone, $mail_site, $mail_va, $language_id, $timezone) { global $feedback; if (db_numrows(db_query("SELECT user_id FROM users WHERE user_name LIKE '{$unix_name}'")) > 0) { $feedback .= "That username already exists."; return false; } // Check that username is not identical with an existing unix groupname (groups) helix 22.06.2001 if (db_numrows(db_query("SELECT unix_group_name FROM groups WHERE unix_group_name LIKE '{$unix_name}'")) > 0) { $feedback .= "That username is identical with the unixname of an existing group."; return false; } // End of change helix 22.06.2001 if (!$unix_name) { $feedback .= "You must supply a username."; return false; } if (!$password1) { $feedback .= "You must supply a password."; return false; } if ($password1 != $password2) { $feedback .= "Passwords do not match."; return false; } if (!account_pwvalid($password1)) { $feedback .= ' Password must be at least 6 characters. '; return false; } if (!account_namevalid($unix_name)) { $feedback .= ' Invalid Unix Name '; return false; } if (!validate_email($email)) { $feedback .= ' Invalid Email Address '; return false; } // if we got this far, it must be good $confirm_hash = substr(md5($session_hash . $HTTP_POST_VARS['form_pw'] . time()), 0, 16); $result = db_query("INSERT INTO users (user_name,user_pw,unix_pw,realname,email,add_date," . "status,confirm_hash,mail_siteupdates,mail_va,language,timezone) " . "VALUES ('{$unix_name}'," . "'" . md5($password1) . "'," . "'" . account_genunixpw($password1) . "'," . "'" . "{$realname}'," . "'{$email}'," . "'" . time() . "'," . "'P'," . "'{$confirm_hash}'," . "'" . ($mail_site ? "1" : "0") . "'," . "'" . ($mail_va ? "1" : "0") . "'," . "'{$language_id}'," . "'{$timezone}')"); $user_id = db_insertid($result, 'users', 'user_id'); if (!$result || !$user_id) { $feedback .= ' Insert Failed ' . db_error(); return false; } else { // send mail $message = "Thank you for registering on the " . $GLOBALS['sys_default_name'] . " web site. In order\n" . "to complete your registration, visit the following url: \n\n" . "https://" . $GLOBALS['HTTP_HOST'] . "/account/verify.php?confirm_hash={$confirm_hash}\n\n" . "Enjoy the site.\n\n" . " -- the " . $GLOBALS['sys_default_name'] . " staff\n"; mail($email, $GLOBALS['sys_default_name'] . " Account Registration", $message, "From: noreply@" . $GLOBALS['sys_default_domain']); return $user_id; } }
function validate_input() { global $errors; $email = stripslashes(trim($_POST['email'])); // Did the user enter anything? if ($email == '') { $errors['email'] = '<b><font color="red">***Email' . ' address?***</font><b>'; } else { $ok = validate_email($email); if (!$ok) { $errors['email'] = '<b><font color="red">***Invalid' . ' email address***</font></b>'; } } }
function validate_reset_password_form() { $errors = array(); // Validate email field if ($_POST['email']) { if (validate_email(format_trim($_POST['email']))) { //Do Nothing } else { $errors[] = "Email is not valid."; } } else { $errors[] = "Must provide a valid email address."; } return $errors; }
function validation($data) { global $CFG; $errors = array(); $authplugin = get_auth_plugin($CFG->registerauth); if (record_exists('user', 'username', $data['username'], 'mnethostid', $CFG->mnet_localhost_id)) { $errors['username'] = get_string('usernameexists'); } else { if (empty($CFG->extendedusernamechars)) { $string = eregi_replace("[^(-\\.[:alnum:])]", '', $data['username']); if (strcmp($data['username'], $string)) { $errors['username'] = get_string('alphanumerical'); } } } //check if user exists in external db //TODO: maybe we should check all enabled plugins instead if ($authplugin->user_exists($data['username'])) { $errors['username'] = get_string('usernameexists'); } if (!validate_email($data['email'])) { $errors['email'] = get_string('invalidemail'); } else { if (record_exists('user', 'email', $data['email'])) { $errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>'; } } if (empty($data['email2'])) { $errors['email2'] = get_string('missingemail'); } else { if ($data['email2'] != $data['email']) { $errors['email2'] = get_string('invalidemail'); } } if (!isset($errors['email'])) { if ($err = email_is_not_allowed($data['email'])) { $errors['email'] = $err; } } if (!check_password_policy($data['password'], $errmsg)) { $errors['password'] = $errmsg; } if (0 == count($errors)) { return true; } else { return $errors; } }
function validate_form(&$user) { $json_send = array(); foreach ($user as $k => $v) { // if ( $data['fields'][$k][2] == true ) { if ($k == 'email') { if ($v == '' || !validate_email($v)) { $user['__error'][$k] = true; } } else { if ($v == '') { $user['__error'][$k] = true; } } // } } return $user['__error'] ? false : true; }
function validation($data, $files) { $errors = parent::validation($data, $files); if (isset($data['email'])) { $emails = preg_split('~[; ]+~', $data['email']); if (count($emails) < 1) { $errors['email'] = get_string('invalidemails', 'forumng'); } else { foreach ($emails as $email) { if (!validate_email($email)) { $errors['email'] = get_string('invalidemails', 'forumng'); break; } } } } return $errors; }
/** * Validates form data */ public function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); if (!validate_email($data['email'])) { $errors['email'] = get_string('invalidemail'); } else { $check = new stdClass(); $check->backpackurl = $data['backpackurl']; $check->email = $data['email']; $bp = new OpenBadgesBackpackHandler($check); $request = $bp->curl_request('user'); if (isset($request->status) && $request->status == 'missing') { $errors['email'] = get_string('error:nosuchuser', 'badges'); } } return $errors; }
/** * @param int $oldversion the version we are upgrading from * @return bool result */ function xmldb_auth_manual_upgrade($oldversion) { global $CFG, $DB, $OUTPUT; if ($oldversion < 2011022700) { // force creation of missing passwords $createpassword = hash_internal_user_password(''); $rs = $DB->get_recordset('user', array('password' => $createpassword, 'auth' => 'manual')); foreach ($rs as $user) { if (validate_email($user->email)) { $DB->set_field('user', 'password', 'to be created', array('id' => $user->id)); unset_user_preference('auth_forcepasswordchange', $user); set_user_preference('create_password', 1, $user); } } $rs->close(); upgrade_plugin_savepoint(true, 2011022700, 'auth', 'manual'); } return true; }
function update_user($id, $email, $full_name, $location, $web, $bio) { $this->verify_user_id($id); validate_email($email); validate_50($full_name); validate_50($location); validate_url($web); validate_bio($bio); $query = "UPDATE `users` SET `E-mail` = '@v', `Full_name` = '@v', `Location` = '@v', `Web` = '@v', `Bio` = '@v' WHERE `ID` = '@v' LIMIT 1"; $this->query($query, $email, $full_name, $location, $web, $bio, $id); }
function validation($data, $files) { $errors = parent::validation($data, $files); // seats per token if ($data['seatspertoken'] < 1 || $data['seatspertoken'] > 200) { $errors['seatspertoken'] = get_string('seatsoutofrange', 'block_enrol_token_manager'); } // number of token if ($data['tokennumber'] < 1 || $data['tokennumber'] > 200) { $errors['tokennumber'] = get_string('tokensoutofrange', 'block_enrol_token_manager'); } // email address if (isset($data['emailaddress']) === true && trim($data['emailaddress'] != '')) { if (validate_email($data['emailaddress']) === false) { $errors['emailaddress'] = get_string('invalidemail'); } } return $errors; }
/** * Prüft ob die Regeln für einen Email Alias bei der HAW-HAmburg eingehalten werden * @param string $alias emailalias * @return boolean <p> * TRUE wenn die Regeln für einen gültigen Alias eingehalten sind <p> * FALSE wenn die Regeln für einen gültigen Alias NICHT eingehalten worden sind */ function checkemailsyntax($alias) { $nichterlaubtezeichen = array("_", "!", "\$", "%", "&", "/", "=", "?", "+", "*", "~", "'", "#", "`", "|"); //$ma = filter_var($alias."@haw-hamburg.de", FILTER_VALIDATE_EMAIL); $ma = validate_email($alias . "@haw-hamburg.de"); if (!$ma) { //echo "unvalite email"; return false; } //nur einen Punkt ? if (substr_count($alias, ".") != 1) { //echo "mehr als einer oder kein Punkt"; return false; } //Punkt nicht erster und nicht letzter buchstabe //if ((substr_compare($alias, ".", 0, 1) == 0) || (substr_compare($alias, ".", -1, 1) == 0)){ // echo "hier bin ich"; // return false; //} //unerlaubte Zeichen ? foreach ($nichterlaubtezeichen as $zeichen) { if (substr_count($alias, $zeichen) >= 1) { //echo "unerlaubtes zeichen"; return false; } } //alle erlaubten Zahlen entfernen $nalias = preg_replace("/[0-9]/", "", $alias); $aliasteile = explode(".", $nalias); $pattern = "/" . $aliasteile[0] . "/i"; if (!preg_match($pattern, stringbereinigen($_SESSION['vorname']))) { echo "vorne stimmt nicht"; return false; } $pattern = "/" . $aliasteile[1] . "/i"; if (!preg_match($pattern, stringbereinigen($_SESSION['nachname']))) { echo "hinten stimmt nicht"; return false; } //substr_compare($alias, $vorname) return true; }
function validation($data) { global $CFG; $errors = array(); if (!empty($data['username']) and !empty($data['email']) or empty($data['username']) and empty($data['email'])) { $errors['username'] = get_string('usernameoremail'); $errors['email'] = get_string('usernameoremail'); } else { if (!empty($data['email'])) { if (!validate_email($data['email'])) { $errors['email'] = get_string('invalidemail'); } else { if (count_records('user', 'email', $data['email']) > 1) { $errors['email'] = get_string('forgottenduplicate'); } else { if ($user = get_complete_user_data('email', $data['email'])) { if (empty($user->confirmed)) { $errors['email'] = get_string('confirmednot'); } } if (!$user and empty($CFG->protectusernames)) { $errors['email'] = get_string('emailnotfound'); } } } } else { if ($user = get_complete_user_data('username', $data['username'])) { if (empty($user->confirmed)) { $errors['email'] = get_string('confirmednot'); } } if (!$user and empty($CFG->protectusernames)) { $errors['username'] = get_string('usernamenotfound'); } } } if (0 == count($errors)) { return true; } else { return $errors; } }
public function save() { // Can't save if there are pre-existing errors if (!empty($this->errors)) { return false; } // check to see if e-mail is valid if (!validate_email($this->Email)) { $this->errors[] = "Please enter a valid e-mail address."; return false; } if ($this->create()) { $this->send_ourselves_mail(); return true; } else { // File was not moved. $this->errors[] = "The data could not be saved."; return false; } }
/** Tarkasta rekister\"{o}intilomake * @param $email string * @param $password string * @param $username string * @return boolean */ function validate($email, $password, $username) { if (!validate_email($email)) { echo "email wrong"; return false; } else { if (!validate_password($password)) { echo "password wrong"; return false; } else { if (!validate_username($username)) { echo "username wrong"; return false; } else { echo "correct validation"; return true; } } } }
function form_validation($uname, $pwd, $email, $dob, $sex, $state, $city, $news) { $error_message = ""; $error_message = validate_username($uname, $error_message); $error_message = validate_password($pwd, $error_message); $error_message = validate_email($email, $error_message); $error_message = validate_dob($dob, $error_message); $error_message = validate_sex($sex, $error_message); $error_message = validate_state($state, $error_message); $error_message = validate_city($city, $error_message); $error_message = validate_newsletter($news, $error_message); if ($error_message) { echo "<br>I am sorry, but you haven't filled the form correctly. Please check the following.<br><br>" . $error_message; // echo "I am now redirecting you to the previous page. Please fill it correctly this time."; // header ( "Location: ../Client/signup.html" ); return 0; } else { return 1; } }
function validation($data, $files) { global $CFG, $DB; $errors = parent::validation($data, $files); if (!validate_email($data['email']) || $data['email'] != strtolower($data['email'])) { $errors['email'] = get_string('invalidemail'); } if (empty($data['username'])) { $errors['username'] = get_string('missingemail'); } else { if ($data['username'] != $data['email']) { $errors['username'] = get_string('invalidemail'); } } if (!isset($errors['email'])) { if ($DB->record_exists('user', array('email' => $data['email']))) { $errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>'; } } $errmsg = ''; if (!check_password_policy($data['password'], $errmsg)) { $errors['password'] = $errmsg; } // If reCAPTCHA is setup we would have used it - so check it! if (!empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey)) { $recaptcha_element = $this->_form->getElement('recaptcha_element'); if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) { $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field']; $response_field = $this->_form->_submitValues['recaptcha_response_field']; if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) { $errors['recaptcha'] = $result; } } else { $errors['recaptcha'] = get_string('missingrecaptchachallengefield'); } } if (!empty($errors)) { $errors['form_errors'] = get_string('form_errors', 'local_obu_application'); } return $errors; }