function showBanner() { if ($this->hlp->isCurrentRevisionApproved()) { $class = 'approved_yes'; } else { if ($this->hlp->isHiddenForUser()) { return; } $class = 'approved_no'; } printf('<div class="approval %s">', $class); $this->showLatestDraftIfNewer(); $this->showLatestApprovedVersion(); $this->showDraft(); $this->showApproved(); $this->showPreviousApproved(); $this->showApproveAction(); $this->showInternalNote(); echo '</div>'; global $INFO; if ($this->getConf('apr_mail_receiver') !== '' && $INFO['isadmin']) { $validator = new EmailAddressValidator(); $validator->allowLocalAddresses = true; $addr = $this->getConf('apr_mail_receiver'); if (!$validator->check_email_address($addr)) { msg(sprintf($this->getLang('mail_invalid'), htmlspecialchars($addr)), -1); } } }
public function validate($messageManager) { $field = $this->form->getField($this->fieldName); $fieldValue = $field->getValue(); if (!empty($fieldValue)) { $externalValidator = new EmailAddressValidator(); if (!$externalValidator->check_email_address($fieldValue)) { $messageManager->addMessage('invalidEmail', array($this->fieldName => $field->getCaption())); } } }
/** * Check for bad email address. Returns TRUE if bad, FALSE if ok. * @param string $mail The email address to check * @return boolean */ function isBadEmail($mail) { include 'EmailAddressValidator.php'; $validator = new EmailAddressValidator(); if ($validator->check_email_address($mail)) { // Email address is technically valid return FALSE; } else { // Email not valid return TRUE; } }
function check_email_address($email) { // uses a third party object - look at EmailAddressValidator.php // replaces original version written by the same dude in 2004 require 'third_party_utils/EmailAddressValidator.php'; $validator = new EmailAddressValidator(); if ($validator->check_email_address($email)) { // Email address is technically valid return true; } else { // Email not valid return false; } }
/** * send an email to inform about a changed page * * @param $event * @param $param * @return bool false if the receiver is invalid or there was an error passing the mail to the MTA */ function send_change_mail(&$event, $param) { global $ID; global $ACT; global $INFO; global $conf; $data = pageinfo(); if ($ACT != 'save') { return true; } // IO_WIKIPAGE_WRITE is always called twice when saving a page. This makes sure to only send the mail once. if (!$event->data[3]) { return true; } // Does the publish plugin apply to this page? if (!$this->hlp->isActive($ID)) { return true; } //are we supposed to send change-mails at all? if ($this->getConf('apr_mail_receiver') === '') { return true; } // get mail receiver $receiver = $this->getConf('apr_mail_receiver'); $validator = new EmailAddressValidator(); $validator->allowLocalAddresses = true; if (!$validator->check_email_address($receiver)) { dbglog(sprintf($this->getLang('mail_invalid'), htmlspecialchars($receiver))); return false; } // get mail sender $ReplyTo = $data['userinfo']['mail']; if ($ReplyTo == $receiver) { return true; } if ($INFO['isadmin'] == '1') { return true; } // get mail subject $timestamp = dformat($data['lastmod'], $conf['dformat']); $subject = $this->getLang('apr_mail_subject') . ': ' . $ID . ' - ' . $timestamp; $body = $this->create_mail_body('change'); $mail = new Mailer(); $mail->to($receiver); $mail->subject($subject); $mail->setBody($body); $mail->setHeader("Reply-To", $ReplyTo); $returnStatus = $mail->send(); return $returnStatus; }
/** * Sets an email address header with correct encoding * * Unicode characters will be deaccented and encoded base64 * for headers. Addresses may not contain Non-ASCII data! * * Example: * setAddress("föö <*****@*****.**>, me@somewhere.com","TBcc"); * * @param string $address Multiple adresses separated by commas * @return bool|string the prepared header (can contain multiple lines) */ public function cleanAddress($address) { // No named recipients for To: in Windows (see FS#652) $names = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? false : true; $address = preg_replace('/[\\r\\n\\0]+/', ' ', $address); // remove attack vectors $headers = ''; $parts = explode(',', $address); foreach ($parts as $part) { $part = trim($part); // parse address if (preg_match('#(.*?)<(.*?)>#', $part, $matches)) { $text = trim($matches[1]); $addr = $matches[2]; } else { $addr = $part; } // skip empty ones if (empty($addr)) { continue; } // FIXME: is there a way to encode the localpart of a emailaddress? if (!utf8_isASCII($addr)) { msg(htmlspecialchars("E-Mail address <{$addr}> is not ASCII"), -1); continue; } if (is_null($this->validator)) { $this->validator = new EmailAddressValidator(); $this->validator->allowLocalAddresses = true; } if (!$this->validator->check_email_address($addr)) { msg(htmlspecialchars("E-Mail address <{$addr}> is not valid"), -1); continue; } // text was given if (!empty($text) && $names) { // add address quotes $addr = "<{$addr}>"; if (defined('MAILHEADER_ASCIIONLY')) { $text = utf8_deaccent($text); $text = utf8_strip($text); } if (!utf8_isASCII($text)) { $text = '=?UTF-8?B?' . base64_encode($text) . '?='; } } else { $text = ''; } // add to header comma seperated if ($headers != '') { $headers .= ', '; } $headers .= $text . ' ' . $addr; } if (empty($headers)) { return false; } return $headers; }
function short($in, $to_num = false) { global $api_key; $encryptionMethod = "AES-256-CBC"; //check if variable is an email $validator = new EmailAddressValidator(); $is_email = $validator->check_email_address($in) ? true : false; if ($to_num) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { $decrypted = str_replace('892', '/', $in); $decrypted = str_replace('763', '+', $decrypted); if (function_exists('openssl_encrypt')) { $decrypted = version_compare(PHP_VERSION, '5.3.3') >= 0 ? openssl_decrypt($decrypted, $encryptionMethod, $api_key, 0, '3j9hwG7uj8uvpRAT') : openssl_decrypt($decrypted, $encryptionMethod, $api_key, 0); if (!$decrypted) { return $is_email ? $in : intval($in, 36); } } else { return $is_email ? $in : intval($in, 36); } return $decrypted == '' ? intval($in, 36) : $decrypted; } else { return $is_email ? $in : intval($in, 36); } } else { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (function_exists('openssl_encrypt')) { $encrypted = version_compare(PHP_VERSION, '5.3.3') >= 0 ? openssl_encrypt($in, $encryptionMethod, $api_key, 0, '3j9hwG7uj8uvpRAT') : openssl_encrypt($in, $encryptionMethod, $api_key, 0); if (!$encrypted) { return $is_email ? $in : base_convert($in, 10, 36); } } else { return $is_email ? $in : base_convert($in, 10, 36); } $encrypted = str_replace('/', '892', $encrypted); $encrypted = str_replace('+', '763', $encrypted); $encrypted = str_replace('=', '', $encrypted); return $encrypted; } else { return $is_email ? $in : base_convert($in, 10, 36); } } }
/** * Check if a given mail address is valid * * @param string $email the address to check * @return bool true if address is valid */ function mail_isvalid($email) { $validator = new EmailAddressValidator(); return $validator->check_email_address($email); }
function ajax_sync_sugar() { $db =& JFactory::getDBO(); $params =& JComponentHelper::getParams('com_joomailermailchimpintegration'); $paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : ''; $sugar_name = $params->get('params.sugar_name'); $sugar_pwd = $params->get('params.sugar_pwd'); $sugar_url = $params->get('params.sugar_url'); $config = $this->getModel('sync')->getConfig('sugar'); if ($config == NULL) { jimport('joomla.application.component.helper'); $cHelper = JComponentHelper::getComponent('com_comprofiler', true); $cbInstalled = $cHelper->enabled; $config = new stdClass(); $config->first_name = $cbInstalled ? 'CB' : 'core'; } $validator = new EmailAddressValidator(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomailermailchimpintegration' . DS . 'libraries' . DS . 'sugar.php'; $sugar = new SugarCRMWebServices(); $sugar->SugarCRM($sugar_name, $sugar_pwd, $sugar_url); $sugar->login(); $elements = JRequest::getVar('elements', '', 'request', 'string'); $elements = json_decode($elements); if ($elements->done == 0) { $_SESSION['abortAJAX'] = 0; unset($_SESSION['addedUsers']); } $failed = $elements->errors; $errorMsg = $elements->errorMsg; $step = $elements->step; if ($_SESSION['abortAJAX'] != 1) { if (isset($_SESSION['addedUsers'])) { $exclude = $_SESSION['addedUsers']; } else { $exclude = array(); } $addedUsers = $exclude; if (isset($exclude[0])) { $exclude = implode('","', $exclude); $exclude = '"' . $exclude . '"'; $excludeCond = 'AND id NOT IN (' . $exclude . ') '; } else { $excludeCond = ''; } if ($elements->range == 'all') { $query = 'SELECT * FROM #__users ' . 'WHERE block = 0 ' . $excludeCond . 'ORDER BY id ' . 'LIMIT ' . $step; } else { $idList = implode(" OR id = ", $elements->cid); $query = 'SELECT * FROM #__users ' . 'WHERE block = 0 ' . $excludeCond . 'AND (id = ' . $idList . ') ' . 'ORDER BY id '; } $db->setQuery($query); $users = $db->loadObjectList(); $queryJS = false; $queryCB = false; $JSand = array(); foreach ($config as $k => $v) { if ($k != 'firstname' && $k != 'lastname') { $vEx = explode(';', $v); if ($vEx[0] == 'js') { $queryJS = true; $JSand[] = $vEx[1]; } else { if ($vEx[0] == 'CB') { $queryCB = true; } } } } $JSand = implode("','", array_unique($JSand)); $data = array(); $emails = array(); $x = 0; $new = $elements->new; $updated = $elements->updated; $userIDs = array(); foreach ($users as $user) { if ($validator->check_email_address($user->email)) { $userCB = false; if ($config->first_name == 'core') { $names = explode(' ', $user->name); $first_name = $names[0]; $last_name = ''; if (isset($names[1])) { for ($i = 1; $i < count($names); $i++) { $last_name .= $names[$i] . ' '; } } $last_name = trim($last_name); } else { $query = "SELECT * FROM #__comprofiler WHERE user_id = '{$user->id}'"; $db->setQuery($query); $userCB = $db->loadObjectList(); $first_name = $userCB[0]->firstname; $last_name = $userCB[0]->lastname; if ($userCB[0]->middlename != '') { $last_name = $userCB[0]->middlename . ' ' . $last_name; } } // var_dump($first_name, $last_name); if ($queryJS) { $query = "SELECT field_id, value FROM #__community_fields_values " . "WHERE user_id = '{$user->id}' " . "AND field_id IN ('{$JSand}')"; $db->setQuery($query); $JSfields = $db->loadObjectList(); $JSfieldsArray = array(); foreach ($JSfields as $jsf) { $JSfieldsArray[$jsf->field_id] = $jsf->value; } } if ($queryCB) { if (!$userCB) { $query = "SELECT * FROM #__comprofiler WHERE user_id = '{$user->id}'"; $db->setQuery($query); $userCB = $db->loadObjectList(); } } $data[$x] = array('first_name' => $first_name, 'last_name' => $last_name, 'email1' => $user->email); foreach ($config as $k => $v) { if ($k != 'first_name' && $k != 'last_name') { if ($v) { $vEx = explode(';', $v); if ($vEx[0] == 'js') { $data[$x][$k] = isset($JSfieldsArray[$vEx[1]]) ? $JSfieldsArray[$vEx[1]] : ''; } else { $data[$x][$k] = isset($userCB[0]->{$vEx[1]}) ? str_replace('|*|', ', ', $userCB[0]->{$vEx[1]}) : ''; } } } } $emails[$x] = $user->email; $userIDs[] = $user->id; $x++; } else { $errorMsg .= '"Invalid email => ' . $user->email . '", '; $failed++; } $addedUsers[] = $user->id; } if (isset($emails[0])) { $existing_users = $sugar->findUserByEmail($emails); } else { $existing_users = array(); } $sendData = array(); $x = 0; foreach ($data as $d) { $sendData[$x] = $d; if (isset($existing_users[$d['email1']])) { $sendData[$x]['id'] = $existing_users[$d['email1']]; $updated++; } else { $new++; } $x++; } $sugarResult = $sugar->setContactMulti($sendData); if ($sugarResult !== false && isset($userIDs[0])) { $userIDsInserts = array(); foreach ($userIDs as $uid) { $userIDsInserts[] = "('sugar', '{$uid}')"; } $userIDsInsert = implode(', ', $userIDsInserts); $query = "INSERT INTO #__joomailermailchimpintegration_crm_users " . "(crm, user_id) VALUES " . $userIDsInsert; $db->setQuery($query); $db->execute(); } } else { unset($_SESSION['addedUsers']); $response['finished'] = 1; $response['addedUsers'] = ''; $response['abortAJAX'] = $_SESSION['abortAJAX']; echo json_encode($response); } if (!count($users)) { $done = $elements->total; unset($_SESSION['addedUsers']); $percent = 100; } else { $done = count($addedUsers); $_SESSION['addedUsers'] = $addedUsers; $percent = $done / $elements->total * 100; } $response['msg'] = '<div id="bg"></div>' . '<div id="progressBarContainer">' . '<div id="progressBarTitle">' . JText::_('JM_ADDING_USERS') . ' (' . $done . '/' . $total . ' ' . JText::_('JM_DONE') . ')</div>' . '<div id="progressBarBg">' . '<div id="progressBarCompleted" style="width: ' . round($percent) . '%;"></div>' . '<div id="progressBarNumber">' . round($percent) . ' %</div>' . '</div>' . '<a id="sbox-btn-close" href="javascript:joomlamailerJS.sync.abortAJAX();">abort</a>' . '</div>'; $response['done'] = $elements->run++; $response['done'] = $done; $response['newUser'] = $new; $response['updated'] = $updated; $response['errors'] = $failed; $response['errorMsg'] = $errorMsg; if ($done + $failed >= $elements->total) { unset($_SESSION['addedUsers']); $response['finished'] = 1; if ($errorMsg) { $errorMsg = substr($errorMsg, 0, -2); $msgErrors = ' ; ' . $failed . ' ' . JText::_('JM_ERRORS') . ': ' . $errorMsg . ' '; } $msg = $done . ' ' . JText::_('JM_USERS_PROCESSED'); $msg .= ' (' . $new . ' ' . JText::_('JM_NEW') . ' ; ' . $updated . ' ' . JText::_('JM_UPDATED') . ' '; if (isset($msgErrors) && $msgErrors) { $msg .= $msgErrors; } $msg .= ')'; $response['finalMessage'] = $msg; } else { $response['finished'] = 0; $response['finalMessage'] = ''; } $response['abortAJAX'] = $_SESSION['abortAJAX']; echo json_encode($response); }
session_start(); ob_start(); include "./header.php"; include "./conn_reg.inc.php"; include './php_functions/EmailAddressValidator.php'; function checkLogin() { if (!empty($_SESSION['user_logged']) && !empty($_SESSION['user_password'])) { return true; } else { return false; } } print "<body>"; include "./middle_register.php"; $validator = new EmailAddressValidator(); //execute if register button is pressed if (isset($_POST['submit']) && $_POST['submit'] == "Register") { //check that mandatory fields are not empty if (!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['first_name']) && !empty($_POST['last_name']) && $validator->check_email_address($_POST['email'])) { $username = $mysqli->real_escape_string($_POST['username']); $query = "CALL IsAccount('{$username}')"; if ($mysqli->multi_query($query)) { do { $result = $mysqli->store_result(); if ($result) { $rows = $result->num_rows; $result->close(); } } while ($mysqli->next_result()); }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ************************************************************************/ ob_start(); include "./header.php"; include "./auth_user.inc.php"; include "./conn_reg.inc.php"; include './php_functions/EmailAddressValidator.php'; print '<body onload="document.update_account.email.focus()">'; include "./middle.php"; print '<h2>Update Account Information</h2>'; $validator = new EmailAddressValidator(); //execute if update button pressed if (isset($_POST['submit']) && $_POST['submit'] == "Update") { if ($validator->check_email_address($_POST['email'])) { $email = $mysqli->real_escape_string($_POST['email']); $query = "CALL UpdateAccount('{$email}', '" . $_SESSION['user_logged'] . "',\r\n'" . $_SESSION['user_password'] . "')"; if ($mysqli->multi_query($query)) { do { $result = $mysqli->store_result(); if ($result) { $result->close(); } } while ($mysqli->next_result()); } $query = "CALL GetAllUSerInfo('" . $_SESSION['user_logged'] . "',\r\n'" . $_SESSION['user_password'] . "')"; if ($mysqli->multi_query($query)) {
/** * Accepts any valid email address. * * Uses the email validator from: * * http://code.google.com/p/php-email-address-validation/ * */ function filterParam4Email($value, $def = null) { if (!isset($value)) { return $def; } $value = trim(strval($value)); // force cast to string before we do anything if (empty($value)) { return $def; } $validator = new EmailAddressValidator(); if ($validator->check_email_address($value)) { // Email address is technically valid return $value; } return $numval; }
if (!isset($result->fieldErrors['user_name'])) { $__validator = new NoDuplicatesValidator(array('table' => 'appuser', 'fields' => array('user_name' => array('field' => 'user_name', 'type' => 'string', 'queryOperator' => '='), 'id' => array('field' => 'id', 'type' => 'int', 'queryOperator' => '<>')), 'valueName' => 'user_name', 'errorMsg' => _t('crud.appuser.validator.user_name.NoDuplicatesValidator.errorMsg', 'The selected Username is already in use.'))); $__validatorError = $__validator->validate($db, $row); if ($__validatorError != '') { $result->fieldErrors['user_name'] = $__validatorError; } } if (!isset($result->fieldErrors['email_addr'])) { $__validator = new LengthValidator(array('maxLength' => 255, 'valueName' => 'email_addr')); $__validatorError = $__validator->validate($db, $row); if ($__validatorError != '') { $result->fieldErrors['email_addr'] = $__validatorError; } } if (!isset($result->fieldErrors['email_addr']) && $row->email_addr != '') { $__validator = new EmailAddressValidator(array('valueName' => 'email_addr')); $__validatorError = $__validator->validate($db, $row); if ($__validatorError != '') { $result->fieldErrors['email_addr'] = $__validatorError; } } if (!isset($result->fieldErrors['email_addr']) && $row->email_addr != '') { $__validator = new NoDuplicatesValidator(array('table' => 'appuser', 'fields' => array('email_addr' => array('field' => 'email_addr', 'type' => 'string', 'queryOperator' => '='), 'id' => array('field' => 'id', 'type' => 'int', 'queryOperator' => '<>')), 'valueName' => 'email_addr', 'errorMsg' => _t('crud.appuser.validator.email_addr.NoDuplicatesValidator.errorMsg', 'The selected Email Address is already in use.'))); $__validatorError = $__validator->validate($db, $row); if ($__validatorError != '') { $result->fieldErrors['email_addr'] = $__validatorError; } } if (!isset($result->fieldErrors['first_name'])) { $__validator = new LengthValidator(array('maxLength' => 30, 'valueName' => 'first_name')); $__validatorError = $__validator->validate($db, $row);
function dd_is_valid_email($email) { $validator = new EmailAddressValidator(); if ($validator->check_email_address($email)) { return TRUE; } else { return FALSE; } }
<?php //Catch any errors while testing our script //Remove when going live. ini_set("display_errors", "1"); error_reporting(E_ALL); //Ensures no one loads page and does simple spam check. if (isset($_POST['name']) && empty($_POST['spam_check'])) { //Include our email validator for later use require 'email-validator.php'; $validator = new EmailAddressValidator(); //Declare our $errors variable we will be using later to store any errors. $errors = array(); //Setup our basic variables $input_name = strip_tags($_POST['name']); $input_email = strip_tags($_POST['email']); $input_subject = strip_tags($_POST['subject']); $input_message = strip_tags($_POST['message']); //We'll check and see if any of the required fields are empty. //We use an array to store the required fields. $required = array('Name field' => 'name', 'Email field' => 'email', 'Message field' => 'message'); //Loops through each required $_POST value //Checks to ensure it is not empty. foreach ($required as $key => $value) { if (isset($_POST[$value]) && $_POST[$value] !== '') { continue; } else { $errors[] = $key . ' cannot be left blank'; } } //Make sure the email is valid.
/** * Validates database and site settings. * * Checks to ensure connectivity to the database and that * the email fields are properly formed email addresses. * * @return string HTML screen with environment status * * @note This will return _displayError() if there are data issues. * otherwise it calls INST_installAndContentPlugins() * */ function INST_gotSiteInformation() { global $php55, $_GLFUSION, $LANG_INSTALL; if (($rc = _checkSession()) !== 0) { return $rc; } $_GLFUSION['currentstep'] = 'getsiteinformation'; $dbconfig_path = $_GLFUSION['dbconfig_path']; if (!file_exists($dbconfig_path . 'lib/email-address-validation/EmailAddressValidator.php')) { return _displayError(FILE_INCLUDE_ERROR, 'pathsetting', 'Error Code: ' . __LINE__); } include $dbconfig_path . 'lib/email-address-validation/EmailAddressValidator.php'; $validator = new EmailAddressValidator(); $numErrors = 0; $errText = ''; if (isset($_POST['dbtype']) && $_POST['dbtype'] != '') { $db_type = INST_stripslashes($_POST['dbtype']); } else { $db_type = ''; $numErrors++; $errText .= $LANG_INSTALL['db_type_error'] . '<br />'; } if (isset($_POST['dbhost']) && $_POST['dbhost'] != '') { $db_host = INST_stripslashes($_POST['dbhost']); } else { $db_host = ''; $numErrors++; $errText .= $LANG_INSTALL['db_hostname_error'] . '<br />'; } if (isset($_POST['dbname']) && $_POST['dbname'] != '') { $db_name = INST_stripslashes($_POST['dbname']); } else { $db_name = ''; $numErrors++; $errText .= $LANG_INSTALL['db_name_error'] . '<br />'; } if (isset($_POST['dbuser']) && $_POST['dbuser'] != '') { $db_user = INST_stripslashes($_POST['dbuser']); } else { $db_user = ''; $numErrors++; $errText .= $LANG_INSTALL['db_user_error'] . '<br />'; } if (isset($_POST['dbpass']) && $_POST['dbpass'] != '') { $db_pass = INST_stripslashes($_POST['dbpass']); } else { $db_pass = ''; } if (isset($_POST['dbprefix'])) { $db_prefix = INST_stripslashes($_POST['dbprefix']); } else { $db_prefix = ''; } $innodb = false; switch ($db_type) { case 'mysql-innodb': $innodb = true; $db_type = 'mysql'; case 'mysql': $db_type = 'mysql'; break; case 'mysqli': if (class_exists('MySQLi')) { $db_type = 'mysqli'; } else { $db_type = 'mysql'; } break; } // populate the session vars... $_GLFUSION['db_type'] = $db_type; $_GLFUSION['innodb'] = $innodb; $_GLFUSION['db_host'] = $db_host; $_GLFUSION['db_name'] = $db_name; $_GLFUSION['db_user'] = $db_user; $_GLFUSION['db_pass'] = $db_pass; $_GLFUSION['db_prefix'] = $db_prefix; if (isset($_POST['sitename']) && $_POST['sitename'] != '') { $site_name = INST_stripslashes($_POST['sitename']); } else { $site_name = ''; $numErrors++; $errText .= $LANG_INSTALL['site_name_error'] . '<br />'; } if (isset($_POST['siteslogan']) && $_POST['siteslogan'] != '') { $site_slogan = INST_stripslashes($_POST['siteslogan']); } else { $site_slogan = ''; } if (isset($_POST['siteurl']) && $_POST['siteurl'] != '') { $site_url = INST_stripslashes($_POST['siteurl']); } else { $site_url = ''; $numErrors++; $errText .= $LANG_INSTALL['site_url_error'] . '<br />'; } if (isset($_POST['siteadminurl']) && $_POST['siteadminurl'] != '') { $site_admin_url = INST_stripslashes($_POST['siteadminurl']); } else { $site_admin_url = ''; $numErrors++; $errText .= $LANG_INSTALL['site_admin_url_error'] . '<br />'; } if (isset($_POST['sitemail']) && $_POST['sitemail'] != '') { $site_mail = INST_stripslashes($_POST['sitemail']); if (!$validator->check_email_address($site_mail)) { $numErrors++; $errText .= $LANG_INSTALL['site_email_notvalid'] . '<br />'; } } else { $site_mail = ''; $numErrors++; $errText .= $LANG_INSTALL['site_email_error'] . '<br />'; } if (isset($_POST['noreplymail']) && $_POST['noreplymail'] != '') { $noreply_mail = INST_stripslashes($_POST['noreplymail']); if (!$validator->check_email_address($noreply_mail)) { $numErrors++; $errText .= $LANG_INSTALL['site_noreply_notvalid'] . '<br />'; } } else { $noreply_mail = ''; $numErrors++; $errText .= $LANG_INSTALL['site_noreply_email_error'] . '<br />'; } $_GLFUSION['site_name'] = $site_name; $_GLFUSION['site_slogan'] = $site_slogan; $_GLFUSION['site_url'] = $site_url; $_GLFUSION['site_admin_url'] = $site_admin_url; $_GLFUSION['site_mail'] = $site_mail; $_GLFUSION['noreply_mail'] = $noreply_mail; $_GLFUSION['utf8'] = isset($_POST['use_utf8']) ? 1 : 0; if ($numErrors > 0) { return _displayError(SITE_DATA_ERROR, 'getsiteinformation', $errText); } if (!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { return _displayError(NO_DB_DRIVER, 'getsiteinformation'); } if ($php55 || $db_type == 'mysqli') { $db_handle = @mysqli_connect($db_host, $db_user, $db_pass); if (!$db_handle) { return _displayError(DB_NO_CONNECT, 'getsiteinformation'); } if ($db_handle) { $connected = @mysqli_select_db($db_handle, $db_name); } if (!$connected) { return _displayError(DB_NO_DATABASE, 'getsiteinformation'); } if ($innodb) { $res = @mysqli_query($db_handle, "SHOW VARIABLES LIKE 'have_innodb'"); $A = @mysqli_fetch_array($res); if (strcasecmp($A[1], 'yes') != 0) { return _displayError(DB_NO_INNODB, 'getsiteinformation'); } } $result = @mysqli_query($db_handle, "SHOW TABLES LIKE '" . $db_prefix . "vars'"); if (@mysqli_num_rows($result) > 0) { return _displayError(DB_EXISTS, ''); } } else { $db_handle = @mysql_connect($db_host, $db_user, $db_pass); if (!$db_handle) { return _displayError(DB_NO_CONNECT, 'getsiteinformation'); } if ($db_handle) { $connected = @mysql_select_db($db_name, $db_handle); } if (!$connected) { return _displayError(DB_NO_DATABASE, 'getsiteinformation'); } if ($innodb) { $res = @mysql_query("SHOW VARIABLES LIKE 'have_innodb'"); $A = @mysql_fetch_array($res); if (strcasecmp($A[1], 'yes') != 0) { return _displayError(DB_NO_INNODB, 'getsiteinformation'); } } $result = @mysql_query("SHOW TABLES LIKE '" . $db_prefix . "vars'"); if (@mysql_numrows($result) > 0) { return _displayError(DB_EXISTS, ''); } } if ($numErrors > 0) { return _displayError(SITE_DATA_MISSING, 'getsiteinformation', $errText); } return INST_installAndContentPlugins(); }
<?php /** * Contact form PHP * Credits: http://dev-tips.com/featured/ajax-and-php-contact-form */ // If the form have been submitted and the spam check field is empty if (isset($_POST['name']) && empty($_POST['spam_check'])) { // Enter your email $mail = '*****@*****.**'; // Include our email validator for later use require 'inc/email-validator.php'; $validator = new EmailAddressValidator(); // Declare our $errors variable we will be using later to store any errors. $errors = array(); $name = strip_tags($_POST['name']); $emailfrom = strip_tags($_POST['email']); $subject = strip_tags($_POST['subject']); $message = strip_tags(utf8_decode($_POST['message'])); // Use uft8_decode to make special characters æ, ø, å, ü and é work // Set a default subject if (empty($subject)) { $subject = 'Default subject'; } // We'll check and see if any of the required fields are empty. // We use an array to store the required fields. $required = array('Name' => 'name', 'Email' => 'email', 'Message' => 'message'); // Loops through each required $_POST value // Checks to ensure it is not empty. foreach ($required as $key => $value) { if (isset($_POST[$value]) && $_POST[$value] !== '') {
/** * Check through the emails to make sure they're formatted properly. * Uh. I guess this is super-rigorous and totally overkill, but whatever. * * @return boolean returns true if any emails are invalid * @see http://code.google.com/p/php-email-address-validation/ */ private function anyInvalidEmails() { $people = $this->people; require_once 'EmailAddressValidator.php'; $validator = new EmailAddressValidator(); for ($c = 0; $c < count($people); $c++) { $email = trim($people[$c]['email']); if (!$validator->check_email_address($email)) { return true; } } return false; }
return false; } } } } return true; } /** * Check given text length is between defined bounds * @param strText Text to be checked * @param intMinimum Minimum acceptable length * @param intMaximum Maximum acceptable length * @return True if string is within bounds (inclusive), false if not */ protected function check_text_length($strText, $intMinimum, $intMaximum) { // Minimum and maximum are both inclusive $intTextLength = strlen($strText); if ($intTextLength < $intMinimum || $intTextLength > $intMaximum) { return false; } else { return true; } } } $validator = new EmailAddressValidator(); if ($validator->check_email_address($_POST["login"])) { echo "E-mail OK."; } else { echo "Błąd w adresie e-mail."; }
if ($num_carac > 2) { //echo "Usted ingreso el codigo correctamente."; } else { printf("<script>document.location.href='reg_form.php?item=" . $reg_nom . " (" . $username . ") " . $reg_cha . ".'</script>;"); die(""); } //Logins prohibidos $logpro = mysql_query("SELECT * FROM blacklogins WHERE login='******'"); $logproh = mysql_num_rows($logpro); if ($logproh > 0) { printf("<script>document.location.href='reg_form.php?item=" . $reg_nom . " (" . $username . ") " . $reg_rest . ".'</script>;"); die(""); } //Validación de email include 'EmailAddressValidator.php'; $validator = new EmailAddressValidator(); if ($validator->check_email_address($email)) { // Email address is technically valid } else { // Email not valid printf("<script>document.location.href='reg_form.php?item=El email introducido no es valido'</script>;"); die(""); } //fin //Logins prohibidos $texto_ingresado = $_POST["texto_ingresado"]; //$captcha_texto = $_SESSION["captcha_texto_session"]; $security = $_SESSION['captcha']; if ($texto_ingresado == $security) { //echo "Usted ingreso el codigo correctamente."; } else {
/** * Checks to see if email address is valid. * * This function checks to see if an email address is in the correct from. * * @param string $email Email address to verify * @return boolean True if valid otherwise false * */ function COM_isEmail($email) { global $_CONF; if (!class_exists('EmailAddressValidator')) { require_once $_CONF['path'] . 'lib/email-address-validation/EmailAddressValidator.php'; } $validator = new EmailAddressValidator(); return $validator->check_email_address($email) ? true : false; }
<?php include "../../../../wp-load.php"; //Ensures no one loads page and does simple spam check. if (isset($_POST['name']) && empty($_POST['spam_check'])) { //Include our email validator for later use require 'email-validator.php'; $validator = new EmailAddressValidator(); //Declare our $errors variable we will be using later to store any errors. $errors = array(); //Setup our basic variables $input_name = strip_tags($_POST['name']); $input_email = strip_tags($_POST['email']); $input_message = strip_tags($_POST['message']); //if($_POST['input_to_email']!='') // $input_to_email = $_POST['input_to_email']; //else $input_to_email = webmaster_email; $admin_email = get_option('admin_email'); //We'll check and see if any of the required fields are empty. //We use an array to store the required fields. $required = array('Name field' => 'name', 'Email field' => 'email', 'Message field' => 'message'); //Loops through each required $_POST value //Checks to ensure it is not empty. foreach ($required as $key => $value) { if (isset($_POST[$value]) && $_POST[$value] !== '') { continue; } else { $errors[] = $key . ' cannot be left blank'; } }
$value = strtotime($date_value2); $custom_fields_value .= $value; $custom_fields_value .= '%s%'; } else { $custom_fields_value .= $linearray[$i]; $custom_fields_value .= '%s%'; } } } } //Check if this email is previously marked as bounced, if so, we shouldn't add it $q = 'SELECT email from subscribers WHERE (email = "' . $linearray[0] . '" || email = " ' . $linearray[1] . '" || email = "' . $linearray[1] . '") AND bounced = 1'; $r = mysqli_query($mysqli, $q); if (mysqli_num_rows($r) > 0) { } else { $validator = new EmailAddressValidator(); //if CSV has only 1 column, insert into email column if ($columns == 1) { if ($validator->check_email_address(trim($linearray[0]))) { //insert email into database $query = 'INSERT INTO ' . $databasetable . ' (userID, email, list, timestamp) values(' . $userID . ', "' . trim($linearray[0]) . '", ' . $listID . ', ' . $time . ')'; mysqli_query($mysqli, $query); $inserted_id = mysqli_insert_id($mysqli); } } else { if ($columns == 2) { if ($validator->check_email_address(trim($linearray[1]))) { //insert name & email into database $query = 'INSERT INTO ' . $databasetable . ' (userID, name, email, list, timestamp) values(' . $userID . ', "' . $linearray[0] . '", "' . trim($linearray[1]) . '", ' . $listID . ', ' . $time . ')'; mysqli_query($mysqli, $query); $inserted_id = mysqli_insert_id($mysqli);
/** * Check if a given mail address is valid * * @param string $email the address to check * @return bool true if address is valid */ function mail_isvalid($email) { $validator = new EmailAddressValidator(); $validator->allowLocalAddresses = true; return $validator->check_email_address($email); }
function register() { $this->_logout(); $this->load->helper('checkemail'); $firstname = trim($this->input->post('firstname')); $lastname = trim($this->input->post('lastname')); $email = trim($this->input->post('email')); $password = trim($this->input->post('password')); $password2 = trim($this->input->post('password2')); if ($password != $password2) { $this->_index_with_error('Passwords do not match'); return; } if ($password == '') { $this->_index_with_error('Password is required'); return; } $user = get_user_by_email($email); if ($user) { $this->_index_with_error('That e-mail is already registered. Please try logging in.'); return; } $validator = new EmailAddressValidator(); if (!$validator->check_email_address($email)) { $this->_index_with_error('Invalid e-mail address.'); return; } $newUser = create_user($firstname, $lastname, $email, $password); if (!$newUser) { $this->_index_with_error('An unknown error occurred'); return; } $this->session->set_userdata('userid', $newUser->id); redirect('apply/page/1'); }