本文整理汇总了PHP中validEmail函数的典型用法代码示例。如果您正苦于以下问题:PHP validEmail函数的具体用法?PHP validEmail怎么用?PHP validEmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validEmail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkForm
function checkForm()
{
global $first_name, $last_name, $login, $password1, $password2, $email;
try {
$secret = filter_input(INPUT_POST, 'secret');
if (empty($last_name) || empty($first_name) || empty($login) || empty($password1) || empty($password2) || empty($email) || empty($secret)) {
throw new Exception('Нужно заполнить все поля');
}
if (!validLogin($login)) {
throw new Exception('Логин должен состоять из не мене 3-х букв латинского алфавиа цыфр и подчерка');
}
if (!validEmail($email)) {
throw new Exception('Неправильный email');
}
if ($password1 != $password1) {
throw new Exception('Пароли не совпадают');
}
if (!validUserName($first_name, $last_name)) {
throw new Exception('Имя и фамилия могут состоять только из букв');
}
if (userExists($login, $email)) {
throw new Exception('Такой логин или email уже существует.');
}
if ($secret != $_SESSION['secret']) {
throw new Exception('Неверно указано число с картинки');
}
} catch (Exception $exc) {
return $exc->getMessage();
}
}
示例2: signup
public function signup($username, $email, $password, $storeUserIndependent = 0, $options = array())
{
if (!$storeUserIndependent) {
$dbModel = $this->user_db;
} else {
$dbModel = $this->store_user_db;
}
$salt = strtolower(rand(111111, 999999));
$password = toPassword($password, $salt);
if ($this->isUsernameOccupied($username, 0, $storeUserIndependent)) {
return -3;
} elseif (!validEmail($email)) {
return -5;
} elseif ($this->isEmailOccupied($email, 0, $storeUserIndependent)) {
return -6;
} else {
$regip = ip();
$row = array('username' => $username, 'password' => $password, 'email' => $email, 'regip' => $regip, 'regtime' => SYS_TIME, 'lastloginip' => $regip, 'lastlogintime' => SYS_TIME, 'salt' => $salt);
if (is_array($options) && $options) {
foreach ($options as $k => $v) {
$row[$k] = $v;
}
}
$rt = $dbModel->insert($row, 1);
if ($rt) {
return $rt;
} else {
return 0;
}
}
}
示例3: requestRecommendation
function requestRecommendation($user_id, $author, $email, $message)
{
if (!checkLock("peer")) {
return 6;
}
$config = $GLOBALS['config'];
$user_id = escape($user_id);
$author = escape($author);
$email = escape($email);
if (!validEmail($email)) {
return 1;
}
if (strlen($author) <= 3) {
return 2;
}
//make sure there aren't too many recommendations already
$result = mysql_query("SELECT COUNT(*) FROM recommendations WHERE user_id = '{$user_id}'");
$row = mysql_fetch_row($result);
if ($row[0] >= $config['max_recommend']) {
return 4;
//too many recommendations
}
//ensure this email hasn't been asked with this user already
$result = mysql_query("SELECT COUNT(*) FROM recommendations WHERE user_id = '{$user_id}' AND email = '{$email}'");
$row = mysql_fetch_row($result);
if ($row[0] > 0) {
return 5;
//email address already asked
}
lockAction("peer");
//first create an instance
$instance_id = customCreate(customGetCategory('recommend', true), $user_id);
//insert into recommendations table
$auth = escape(uid(64));
mysql_query("INSERT INTO recommendations (user_id, instance_id, author, email, auth, status, filename) VALUES ('{$user_id}', '{$instance_id}', '{$author}', '{$email}', '{$auth}', '0', '')");
$recommend_id = mysql_insert_id();
$userinfo = getUserInformation($user_id);
//array (username, email address, name)
//send email now
$content = page_db("request_recommendation");
$content = str_replace('$USERNAME$', $userinfo[0], $content);
$content = str_replace('$USEREMAIL$', $userinfo[1], $content);
$content = str_replace('$NAME$', $userinfo[2], $content);
$content = str_replace('$AUTHOR$', $author, $content);
$content = str_replace('$EMAIL$', $email, $content);
$content = str_replace('$MESSAGE$', page_convert($message), $content);
$content = str_replace('$AUTH$', $auth, $content);
$content = str_replace('$SUBMIT_ADDRESS$', $config['site_address'] . "/recommend.php?id={$recommend_id}&user_id={$user_id}&auth={$auth}", $content);
$result = one_mail("Recommendation request", $content, $email);
if ($result) {
return 0;
} else {
return 3;
}
}
示例4: csv_reader
function csv_reader($dry_run, $options)
{
/*
* This function does all the work of removing unwanted characters,
* spaces, exclamation marks and such from the names in the users.csv
* file.
*/
$filename = $options['file'];
$conn = open_db_connection($options);
$table_exists = check_table_exists($conn, $options);
if (!$table_exists) {
echo "\nWarning! Table does not exist\n";
}
if (($handle = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
//Lower case then capitalise first
$data[0] = ucfirst(strtolower($data[0]));
//Lower case then capitalise first
$data[1] = ucfirst(strtolower($data[1]));
//Lower case the email
$data[2] = strtolower($data[2]);
//$data[2] = preg_replace('/\s+/', "", $data[2]);
// Remove trailing whitespaces
$data[0] = rtrim($data[0]);
// Remove trailing whitespaces
$data[1] = rtrim($data[1]);
// Remove trailing whitespaces
$data[2] = rtrim($data[2]);
// Remove non alphas from firstname
$data[0] = preg_replace('/[^a-z]+\\Z/i', "", $data[0]);
// Remove non alphas (except apostrophes) from surname
$data[1] = preg_replace('/[^a-z\']+\\Z/i', "", $data[1]);
// Add backslashes to escape the apostrophes
$data[0] = addslashes($data[0]);
$data[1] = addslashes($data[1]);
$data[2] = addslashes($data[2]);
echo " email is " . $data[2] . "\n";
if (validEmail($data[2])) {
if ($dry_run) {
echo $data[0] . " " . $data[1] . " " . $data[2] . " would be written to database\n";
} else {
if (!$dry_run) {
update_table($data, $conn);
}
}
} else {
echo $data[0] . " " . $data[1] . " " . $data[2] . " will NOT be written to database as email is invalid\n";
}
}
fclose($handle);
$conn = null;
}
}
示例5: contact_callback
function contact_callback()
{
add_filter('wp_die_ajax_handler', 'filter_ajax_hander');
// Clean up the input values
foreach ($_POST as $key => $value) {
if (ini_get('magic_quotes_gpc')) {
$_POST[$key] = stripslashes($_POST[$key]);
}
$_POST[$key] = htmlspecialchars(strip_tags($_POST[$key]));
}
// Assign the input values to variables for easy reference
$name = isset($_POST["name"]) ? $_POST["name"] : '';
$email = isset($_POST["email"]) ? $_POST["email"] : '';
$message = isset($_POST["message"]) ? $_POST["message"] : '';
// Test input values for errors
$errors = array();
if (strlen($name) < 2) {
if (!$name) {
$errors[] = "You must enter a name.";
} else {
$errors[] = "Name must be at least 2 characters.";
}
}
if (!$email) {
$errors[] = "You must enter an email.";
} else {
if (!validEmail($email)) {
$errors[] = "You must enter a valid email.";
}
}
if (strlen($message) < 10) {
if (!$message) {
$errors[] = "You must enter a message.";
} else {
$errors[] = "Message must be at least 10 characters.";
}
}
if ($errors) {
// Output errors and die with a failure message
$errortext = "";
foreach ($errors as $error) {
$errortext .= "<li>" . $error . "</li>";
}
wp_die("<span class='failure'><h3>The following errors occured:</h3><ul>" . $errortext . "</ul></span>");
}
// Send the email
$to = ot_get_option('contact_email', get_option('admin_email'));
$subject = "Contact Form: {$name}";
$message = "'{$name}' from email: {$email} sent a message for you : \n --------------- \n {$message}";
$headers = "From: {$email}";
$result = wp_mail($to, $subject, $message, $headers);
// Die with a success message
wp_die("<span class='success'>Well thank you! Your message has been sent.<br />We'll be in touch pretty soon!</span>", 'Message has been sent !');
}
示例6: csv_reader
function csv_reader($dry_run, $options)
{
/*
* Somewhere in this function there will be an if/else statement
* to test valid emails, if not valid, write to STDOUT
* else, call update table
*/
$filename = $options['file'];
/* if (dry_run)
open connection
check if table exists
parse file
don't write to table
write to STDOUT
else if (!dry_run)
open connection
check if table exists
parse file
write to table */
$conn = open_db_connection($options);
check_table_exists($conn);
$row = 1;
if (($handle = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$data[0] = ucfirst(strtolower($data[0]));
$data[1] = ucfirst(strtolower($data[1]));
$data[2] = strtolower($data[2]);
if (validEmail($data[2])) {
if ($dry_run) {
echo "\ndry_run is set\n";
echo $data[0] . " " . $data[1] . " " . $data[2] . " would be written to database";
} else {
if (!$dry_run) {
echo "\ndry_run is not set\n";
update_table($data, $conn);
}
}
} else {
//echo "\nThis email is not valid\n";
echo "\n" . $data[0] . " " . $data[1] . " " . $data[2] . " will not be written to database as email is invalid\n";
}
// echo " $num fields in line $row: \n";
$row++;
// for ($c=0; $c < $num; $c++) {
// echo $data[$c] . "\n";
// }
}
fclose($handle);
}
}
示例7: set_errors
/**
* Validate the form
*/
function set_errors($form)
{
$output = array();
// Email
if (!validEmail($form['email'])) {
$output[] = 'email';
}
// Name
$tmp = preg_replace('/[^A-Za-z]/', '', $form['name']);
if (strlen($tmp) == 0) {
$output[] = 'name';
}
// Message
$tmp = preg_replace('/[^A-Za-z]/', '', $form['message']);
if (strlen($tmp) == 0) {
$output[] = 'message';
}
return $output;
}
示例8: extract
<?php
require_once './MCAPI.class.php';
extract($_POST);
// Get your API key from http://admin.mailchimp.com/account/api/
define('MC_API_KEY', 'enter you mailchimp api key here');
// Get your list unique id from http://admin.mailchimp.com/lists/
// under settings at the bottom of the page, look for unique id
define('MC_LIST_ID', 'enter you mailchimp unique list id');
// check if email is valid
if (isset($email) && validEmail($email)) {
$api = new MCAPI(MC_API_KEY);
$listID = MC_LIST_ID;
if ($api->listSubscribe($listID, $email, '') === true) {
echo 'success';
} else {
echo 'subscribed';
}
} else {
echo 'invalid';
}
function validEmail($email = NULL)
{
return preg_match("/^[\\d\\w\\/+!=#|\$?%{^&}*`'~-][\\d\\w\\/\\.+!=#|\$?%{^&}*`'~-]*@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\\.[A-Z]{2,6}\$/ix", $email);
}
示例9: verifyUser
//register a new user. Makes plenty of checks against duplicate users and common emails
require "../common.php";
if (!empty($_GET["code"])) {
verifyUser($_GET['email'], $_GET["code"], $DATABASE);
die;
}
//TODO: Refactor this section
//if any of these are not set, the page will die
if (empty($_POST["email"]) || empty($_POST["password"]) || empty($_POST["password2"]) || empty($_POST["first-name"]) || empty($_POST["last-name"]) || empty($_POST["zip"]) || empty($_POST["phone"])) {
error("Missing Field", "You tried to register without completing a required field");
}
if ($_POST["password"] !== $_POST["password2"]) {
error("Passwords Don't Match", "Your passwords did not match");
}
if (!validEmail($_POST["email"])) {
error("Invalid Email", "Your email " . $_POST["email"] . " is invalid");
}
if (!validPassword($_POST["password"])) {
error("Invalid Password", "Your password must be longer than 8 characters in length");
}
//evaluate mailing preferences
$mailing = 1;
if (!isset($_POST["mailing"])) {
$mailing = 0;
}
//cryptify the password
$password = $_POST["password"];
$hash = password_hash($password, PASSWORD_BCRYPT);
$veriRaw = randomString();
//repackaged for easier imploding later, when creating a new user
示例10: clean_param
/**
* Clean the passed parameter
*
* @param mixed $param the variable we are cleaning
* @param int $type expected format of param after cleaning.
* @return mixed
*/
function clean_param($param, $type)
{
global $CFG, $ERROR, $HUB_FLM;
if (is_array($param)) {
$newparam = array();
foreach ($param as $key => $value) {
$newparam[$key] = clean_param($value, $type);
}
return $newparam;
}
switch ($type) {
case PARAM_TEXT:
// leave only tags needed for multilang
if (is_numeric($param)) {
return $param;
}
$param = stripslashes($param);
$param = clean_text($param);
$param = strip_tags($param, '<lang><span>');
$param = str_replace('+', '+', $param);
$param = str_replace('(', '(', $param);
$param = str_replace(')', ')', $param);
$param = str_replace('=', '=', $param);
$param = str_replace('"', '"', $param);
$param = str_replace('\'', ''', $param);
return $param;
case PARAM_HTML:
// keep as HTML, no processing
$param = stripslashes($param);
$param = clean_text($param);
return trim($param);
case PARAM_INT:
return (int) $param;
case PARAM_NUMBER:
return (double) $param;
case PARAM_ALPHA:
// Remove everything not a-z
return preg_replace('/([^a-zA-Z])/i', '', $param);
case PARAM_ALPHANUM:
// Remove everything not a-zA-Z0-9
return preg_replace('/([^A-Za-z0-9])/i', '', $param);
case PARAM_ALPHAEXT:
// Remove everything not a-zA-Z/_-
return preg_replace('/([^a-zA-Z\\/_-])/i', '', $param);
case PARAM_ALPHANUMEXT:
// Remove everything not a-zA-Z0-9-
return preg_replace('/([^a-zA-Z0-9-])/i', '', $param);
case PARAM_BOOL:
// Convert to 1 or 0
$tempstr = strtolower($param);
if ($tempstr == 'on' or $tempstr == 'yes' or $tempstr == 'true') {
$param = 1;
} else {
if ($tempstr == 'off' or $tempstr == 'no' or $tempstr == 'false') {
$param = 0;
} else {
$param = empty($param) ? 0 : 1;
}
}
return $param;
case PARAM_BOOLTEXT:
// check is an allowed text type boolean
$tempstr = strtolower($param);
if ($tempstr == 'on' or $tempstr == 'yes' or $tempstr == 'true' or $tempstr == 'off' or $tempstr == 'no' or $tempstr == 'false' or $tempstr == '0' or $tempstr == '1') {
$param = $param;
} else {
$param = "";
}
return $param;
case PARAM_PATH:
// Strip all suspicious characters from file path
$param = str_replace('\\\'', '\'', $param);
$param = str_replace('\\"', '"', $param);
$param = str_replace('\\', '/', $param);
$param = ereg_replace('[[:cntrl:]]|[<>"`\\|\':]', '', $param);
$param = ereg_replace('\\.\\.+', '', $param);
$param = ereg_replace('//+', '/', $param);
return ereg_replace('/(\\./)+', '/', $param);
case PARAM_URL:
// allow safe ftp, http, mailto urls
include_once $CFG->dirAddress . 'core/lib/url-validation.class.php';
$URLValidator = new mrsnk_URL_validation($param, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL);
if (!empty($param) && $URLValidator->isValid()) {
// all is ok, param is respected
} else {
$param = '';
// not really ok
}
return $param;
case PARAM_EMAIL:
if (validEmail($param)) {
return $param;
} else {
//.........这里部分代码省略.........
示例11: emailLogin
function emailLogin($patient_id, $message)
{
$patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($patient_id));
if ($patientData['hipaa_allowemail'] != "YES" || empty($patientData['email']) || empty($GLOBALS['patient_reminder_sender_email'])) {
return false;
}
if (!validEmail($patientData['email'])) {
return false;
}
if (!validEmail($GLOBALS['patient_reminder_sender_email'])) {
return false;
}
$mail = new MyMailer();
$pt_name = $patientData['fname'] . ' ' . $patientData['lname'];
$pt_email = $patientData['email'];
$email_subject = xl('Access Your Patient Portal');
$email_sender = $GLOBALS['patient_reminder_sender_email'];
$mail->AddReplyTo($email_sender, $email_sender);
$mail->SetFrom($email_sender, $email_sender);
$mail->AddAddress($pt_email, $pt_name);
$mail->Subject = $email_subject;
$mail->MsgHTML("<html><body><div class='wrapper'>" . $message . "</div></body></html>");
$mail->IsHTML(true);
$mail->AltBody = $message;
if ($mail->Send()) {
return true;
} else {
$email_status = $mail->ErrorInfo;
error_log("EMAIL ERROR: " . $email_status, 0);
return false;
}
}
示例12: explode
$expprice = explode("_", $curfield->getrelatedfield());
if ($_POST['' . $expprice[0]] == "nogo" || $_POST['' . $expprice[1]] == "nogo") {
$headerloc = "Location: ../../index.php?page=" . $thepage->getfoldername() . "/add/index.php&message=You must select: " . $curfield->getdisplaynameoffield() . ".";
header($headerloc);
unset($headerloc);
exit;
}
} elseif ($curfield->gettypeoffield() == "link") {
if (trim($_POST['' . $curfield->getrelatedfield()]) == "" || trim($_POST['' . $curfield->getrelatedfield()]) == "http://") {
$headerloc = "Location: ../../index.php?page=" . $thepage->getfoldername() . "/add/index.php&message=You must enter: " . $curfield->getdisplaynameoffield() . ".";
header($headerloc);
unset($headerloc);
exit;
}
} elseif ($curfield->gettypeoffield() == "email") {
if (!validEmail(trim($_POST['' . $curfield->getrelatedfield()]))) {
$headerloc = "Location: ../../index.php?page=" . $thepage->getfoldername() . "/add/index.php&message=You must enter a valid: " . $curfield->getdisplaynameoffield() . ".";
header($headerloc);
unset($headerloc);
exit;
}
} elseif ($curfield->gettypeoffield() == "date") {
$expvaldate = explode("_", $curfield->getrelatedfield());
if ($_POST['' . $expvaldate[0]] == "nogo" || $_POST['' . $expvaldate[1]] == "nogo" || $_POST['' . $expvaldate[2]] == "nogo") {
$headerloc = "Location: ../../index.php?page=" . $thepage->getfoldername() . "/add/index.php&message=You must enter a valid: " . $curfield->getdisplaynameoffield() . ".";
header($headerloc);
unset($headerloc);
exit;
}
} elseif ($curfield->gettypeoffield() == "select") {
if ($_POST['' . $curfield->getrelatedfield()] == "nogo") {
示例13: recaptcha_check_answer
echo 0;
}
$mysql->close();
exit;
}
//User key actions
if (isset($_POST['recaptcha_response_field'])) {
require_once 'recaptchalib.php';
$recap_resp = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if ($recap_resp->is_valid) {
require_once 'db.php';
require_once 'common.php';
//if we have email, validate it
$mail = Null;
if (isset($_POST['mail'])) {
if (validEmail($_POST['mail'])) {
$mail = trim($_POST['mail']);
}
}
//put new key in db
$sql = 'INSERT INTO users(userkey, mail, ip) VALUES(UNHEX(?), ?, ?)
ON DUPLICATE KEY UPDATE userkey=UNHEX(?), ip=?, ts=CURRENT_TIMESTAMP()';
$stmt = $mysql->stmt_init();
$ip = ip2long($_SERVER['REMOTE_ADDR']);
$userkey = gen_key();
$stmt->prepare($sql);
$stmt->bind_param('ssisi', $userkey, $mail, $ip, $userkey, $ip);
$stmt->execute();
$stmt->close();
//set cookie
setcookie('key', $userkey, 2147483647, '', '', false, true);
示例14: yourls_escape
break;
case "join":
$username = yourls_escape($_POST['username']);
$password = $_POST['password'];
if (captchaEnabled()) {
require_once 'recaptchalib.php';
$privatekey = YOURLS_MULTIUSER_CAPTCHA_PRIVATE_KEY;
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error_msg = "Captch is incorrect.";
require_once 'formjoin.php';
break;
}
}
if (!empty($username) && !empty($password)) {
if (validEmail($username) === false) {
$error_msg = "E-mail not recognized!";
require_once 'formjoin.php';
} else {
$table = YOURLS_DB_TABLE_USERS;
$results = $ydb->get_results("select user_email from `{$table}` where `user_email` = '{$username}'");
if ($results) {
$error_msg = "Please choose other username.";
require_once 'formjoin.php';
} else {
$token = createRandonToken();
$password = md5($password);
$ydb->query("insert into `{$table}` (user_email, user_password, user_token) values ('{$username}', '{$password}', '{$token}')");
$results = $ydb->get_results("select user_token from `{$table}` where `user_email` = '{$username}'");
if (!empty($results)) {
$token = $results[0]->user_token;
示例15: header
}
if (empty($email)) {
header('Content-Type: application/json');
echo json_encode(array('status' => 'ERROR', 'msg' => 'empty e-mail address.'));
die;
}
$files = array('testrechnung.pdf');
$path = __DIR__ . '/../assets/';
$mailto = $email;
$from_mail = 'rechnung@' . $tld;
$from_name = 'rechnung@' . $tld;
$replyto = 'hallo@' . $tld;
$subject = '€ Welcome ' . $email . '!';
$message = "Hello @ {$tld} — " . $email;
mail_attachment(array(), null, $replyto, $replyto, $replyto, $mailto, $subject, $message);
if (validEmail($email)) {
// login
$cmd = "curl -H 'Authorization: Basic {$n26_bearer}' -d 'username=" . urlencode($n26_user) . '&password=' . urlencode($n26_pass) . "&grant_type=password' -X POST {$n26_api}/oauth/token";
$response = shell_exec($cmd);
$json = json_decode($response);
$access_token = $json->access_token;
// send invitation
$cmd = "curl -H 'Authorization: bearer {$access_token}' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{email: \"" . $email . "\"}' -X POST {$n26_api}/api/aff/invite";
$response = shell_exec($cmd);
// print_r($response);
$json = json_decode($response);
// print_r($json);
// todo: response without content -- check for http status
if (isset($json->status) && $json->status == 'OK') {
$subject = '€ ' . $tld . ' Konto anlegen';
$message = '<b>Hallo!</b><br/><br/>