• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP validateEmailAddress函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中validateEmailAddress函数的典型用法代码示例。如果您正苦于以下问题:PHP validateEmailAddress函数的具体用法?PHP validateEmailAddress怎么用?PHP validateEmailAddress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了validateEmailAddress函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: createNewUser

 /**
  * Create a DB user
  *
  * @return unknown_type
  */
 public function createNewUser()
 {
     // Do nothing if the user to be added is not DB type
     if (flattenText(Yii::app()->request->getPost('user_type')) != 'DB') {
         return;
     }
     $oEvent = $this->getEvent();
     $new_user = flattenText(Yii::app()->request->getPost('new_user'), false, true);
     $new_email = flattenText(Yii::app()->request->getPost('new_email'), false, true);
     if (!validateEmailAddress($new_email)) {
         $oEvent->set('errorCode', self::ERROR_INVALID_EMAIL);
         $oEvent->set('errorMessageTitle', gT("Failed to add user"));
         $oEvent->set('errorMessageBody', gT("The email address is not valid."));
         return;
     }
     $new_full_name = flattenText(Yii::app()->request->getPost('new_full_name'), false, true);
     $new_pass = createPassword();
     $iNewUID = User::model()->insertUser($new_user, $new_pass, $new_full_name, Yii::app()->session['loginID'], $new_email);
     if (!$iNewUID) {
         $oEvent->set('errorCode', self::ERROR_ALREADY_EXISTING_USER);
         $oEvent->set('errorMessageTitle', '');
         $oEvent->set('errorMessageBody', gT("Failed to add user"));
         return;
     }
     Permission::model()->setGlobalPermission($iNewUID, 'auth_db');
     $oEvent->set('newUserID', $iNewUID);
     $oEvent->set('newPassword', $new_pass);
     $oEvent->set('newEmail', $new_email);
     $oEvent->set('newFullName', $new_full_name);
     $oEvent->set('errorCode', self::ERROR_NONE);
 }
开发者ID:BrunoChauvet,项目名称:LimeSurvey,代码行数:36,代码来源:Authdb.php


示例2: validateAttribute

 public function validateAttribute($object, $attribute)
 {
     if ($object->{$attribute} == '' && $this->allowEmpty) {
         return;
     }
     if ($this->allowMultiple) {
         $aEmailAdresses = explode(';', $object->{$attribute});
     } else {
         $aEmailAdresses = array($object->{$attribute});
     }
     foreach ($aEmailAdresses as $sEmailAddress) {
         if (!validateEmailAddress($sEmailAddress)) {
             $this->addError($object, $attribute, gT('Invalid email address.'));
             return;
         }
     }
     return;
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:18,代码来源:LSYii_EmailIDNAValidator.php


示例3: foreach

 foreach ($_POST as $key => $value) {
     $_POST[$key] = removeEmailInjection(trim($value));
 }
 // Check the required fields and make sure they match our needs
 foreach ($requiredInputs as $field) {
     // the field has been submitted
     if (!array_key_exists($field, $_POST)) {
         array_push($Validation, $field);
     }
     // check if there is information in the field
     if ($_POST[$field] == '') {
         array_push($Validation, $field);
     }
     // validate the email address supplied
     if ($field == 'email') {
         if (!validateEmailAddress($_POST[$field])) {
             array_push($Validation, $field);
         }
     }
 }
 // basic validation result
 if (count($Validation) == 0) {
     // Prepare our content string
     $emailContent = 'New Website Comment: ' . "\n\n";
     // simple email content
     foreach ($_POST as $key => $value) {
         if ($key != 'submit') {
             $emailContent .= $key . ': ' . $value . "\n";
         }
     }
     // if validation passed the right way, then send the email
开发者ID:ramkeshsehara,项目名称:socialmoney,代码行数:31,代码来源:mailer.php


示例4: moduser

 /**
  * Modify User POST
  */
 function moduser()
 {
     $clang = Yii::app()->lang;
     $postuser = Yii::app()->request->getPost("user");
     $postemail = Yii::app()->request->getPost("email");
     $postuserid = Yii::app()->request->getPost("uid");
     $postfull_name = Yii::app()->request->getPost("full_name");
     $display_user_password_in_html = Yii::app()->getConfig("display_user_password_in_html");
     $addsummary = '';
     $aViewUrls = array();
     $sresult = User::model()->findAllByAttributes(array('uid' => $postuserid, 'parent_id' => Yii::app()->session['loginID']));
     $sresultcount = count($sresult);
     if ((Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 || $postuserid == Yii::app()->session['loginID'] || $sresultcount > 0 && Yii::app()->session['USER_RIGHT_CREATE_USER']) && !(Yii::app()->getConfig("demoMode") == true && $postuserid == 1)) {
         $users_name = html_entity_decode($postuser, ENT_QUOTES, 'UTF-8');
         $email = html_entity_decode($postemail, ENT_QUOTES, 'UTF-8');
         $sPassword = html_entity_decode(Yii::app()->request->getPost('pass'), ENT_QUOTES, 'UTF-8');
         if ($sPassword == '%%unchanged%%') {
             $sPassword = '';
         }
         $full_name = html_entity_decode($postfull_name, ENT_QUOTES, 'UTF-8');
         if (!validateEmailAddress($email)) {
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing user"), $clang->gT("Could not modify user data."), "warningheader", $clang->gT("Email address is not valid."), $this->getController()->createUrl('admin/user/modifyuser'), $clang->gT("Back"), array('uid' => $postuserid));
         } else {
             if (empty($sPassword)) {
                 $uresult = User::model()->updateByPk($postuserid, array('email' => $this->escape($email), 'full_name' => $this->escape($full_name)));
             } else {
                 $uresult = User::model()->updateByPk($postuserid, array('email' => $this->escape($email), 'full_name' => $this->escape($full_name), 'password' => hash('sha256', $sPassword)));
             }
             if (empty($sPassword)) {
                 $extra = $clang->gT("Username") . ": {$users_name}<br />" . $clang->gT("Password") . ": (" . $clang->gT("Unchanged") . ")<br />\n";
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing user"), $clang->gT("Success!"), "successheader", $extra);
             } elseif ($uresult && !empty($sPassword)) {
                 if ($sPassword != 'password') {
                     Yii::app()->session['pw_notify'] = FALSE;
                 }
                 if ($sPassword == 'password') {
                     Yii::app()->session['pw_notify'] = TRUE;
                 }
                 if ($display_user_password_in_html === true) {
                     $displayedPwd = $sPassword;
                 } else {
                     $displayedPwd = preg_replace('/./', '*', $sPassword);
                 }
                 $extra = $clang->gT("Username") . ": {$users_name}<br />" . $clang->gT("Password") . ": {$displayedPwd}<br />\n";
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing user"), $clang->gT("Success!"), "successheader", $extra);
             } else {
                 // Username and/or email adress already exists.
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing user"), $clang->gT("Could not modify user data. Email address already exists."), 'warningheader');
             }
         }
     }
     $this->_renderWrappedTemplate('user', $aViewUrls);
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:56,代码来源:useraction.php


示例5: import


//.........这里部分代码省略.........
                         $invalidformatlist[] = $recordcount;
                         $recordcount++;
                         continue;
                     }
                     $writearray = array_combine($firstline, $line);
                     //kick out ignored columns
                     foreach ($ignoredcolumns as $column) {
                         unset($writearray[$column]);
                     }
                     $dupfound = false;
                     $invalidemail = false;
                     if ($filterduplicatetoken != false) {
                         $dupquery = "SELECT count(tid) from {{tokens_" . intval($iSurveyId) . "}} where 1=1";
                         foreach ($filterduplicatefields as $field) {
                             if (isset($writearray[$field])) {
                                 $dupquery .= " and " . Yii::app()->db->quoteColumnName($field) . " = " . Yii::app()->db->quoteValue($writearray[$field]);
                             }
                         }
                         $dupresult = Yii::app()->db->createCommand($dupquery)->queryScalar();
                         if ($dupresult > 0) {
                             $dupfound = true;
                             $duplicatelist[] = Yii::app()->db->quoteValue($writearray['firstname']) . " " . Yii::app()->db->quoteValue($writearray['lastname']) . " (" . Yii::app()->db->quoteValue($writearray['email']) . ")";
                         }
                     }
                     $writearray['email'] = trim($writearray['email']);
                     //treat blank emails
                     if ($filterblankemail && $writearray['email'] == '') {
                         $invalidemail = true;
                         $invalidemaillist[] = $line[0] . " " . $line[1] . " ( )";
                     }
                     if ($writearray['email'] != '') {
                         $aEmailAddresses = explode(';', $writearray['email']);
                         foreach ($aEmailAddresses as $sEmailaddress) {
                             if (!validateEmailAddress($sEmailaddress)) {
                                 $invalidemail = true;
                                 $invalidemaillist[] = $line[0] . " " . $line[1] . " (" . $line[2] . ")";
                             }
                         }
                     }
                     if (isset($writearray['token'])) {
                         $writearray['token'] = sanitize_token($writearray['token']);
                     }
                     if (!$dupfound && !$invalidemail) {
                         // unset all empty value
                         foreach ($writearray as $key => $value) {
                             if ($writearray[$key] == "") {
                                 unset($writearray[$key]);
                             }
                             if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
                                 // Fix CSV quote
                                 $value = substr($value, 1, -1);
                             }
                         }
                         // Some default value : to be moved to Token model rules in future release ?
                         // But think we have to accept invalid email etc ... then use specific scenario
                         $writearray['emailstatus'] = isset($writearray['emailstatus']) ? $writearray['emailstatus'] : "OK";
                         $writearray['language'] = isset($writearray['language']) ? $writearray['language'] : $sBaseLanguage;
                         $oToken = Token::create($iSurveyId);
                         foreach ($writearray as $key => $value) {
                             //if(in_array($key,$oToken->attributes)) Not needed because we filter attributes before
                             $oToken->{$key} = $value;
                         }
                         $ir = $oToken->save();
                         if (!$ir) {
                             $duplicatelist[] = $writearray['firstname'] . " " . $writearray['lastname'] . " (" . $writearray['email'] . ")";
                         } else {
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:67,代码来源:tokens.php


示例6: actionIndex

 /**
  * register::index()
  * Process register form data and take appropriate action
  * @return
  */
 function actionIndex($surveyid = null)
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('replacements');
     $postlang = Yii::app()->request->getPost('lang');
     if ($surveyid == null) {
         $surveyid = Yii::app()->request->getPost('sid');
     }
     if (!$surveyid) {
         Yii::app()->request->redirect(Yii::app()->baseUrl);
     }
     // Get passed language from form, so that we dont loose this!
     if (!isset($postlang) || $postlang == "" || !$postlang) {
         $baselang = Survey::model()->findByPk($surveyid)->language;
         Yii::import('application.libraries.Limesurvey_lang');
         Yii::app()->lang = new Limesurvey_lang($baselang);
         $clang = Yii::app()->lang;
     } else {
         Yii::import('application.libraries.Limesurvey_lang');
         Yii::app()->lang = new Limesurvey_lang($postlang);
         $clang = Yii::app()->lang;
         $baselang = $postlang;
     }
     $thissurvey = getSurveyInfo($surveyid, $baselang);
     $register_errormsg = "";
     // Check the security question's answer
     if (function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen', $thissurvey['usecaptcha'])) {
         if (!isset($_POST['loadsecurity']) || !isset($_SESSION['survey_' . $surveyid]['secanswer']) || Yii::app()->request->getPost('loadsecurity') != $_SESSION['survey_' . $surveyid]['secanswer']) {
             $register_errormsg .= $clang->gT("The answer to the security question is incorrect.") . "<br />\n";
         }
     }
     //Check that the email is a valid style address
     if (!validateEmailAddress(Yii::app()->request->getPost('register_email'))) {
         $register_errormsg .= $clang->gT("The email you used is not valid. Please try again.");
     }
     // Check for additional fields
     $attributeinsertdata = array();
     foreach (GetParticipantAttributes($surveyid) as $field => $data) {
         if (empty($data['show_register']) || $data['show_register'] != 'Y') {
             continue;
         }
         $value = sanitize_xss_string(Yii::app()->request->getPost('register_' . $field));
         if (trim($value) == '' && $data['mandatory'] == 'Y') {
             $register_errormsg .= sprintf($clang->gT("%s cannot be left empty"), $thissurvey['attributecaptions'][$field]);
         }
         $attributeinsertdata[$field] = $value;
     }
     if ($register_errormsg != "") {
         $_SESSION['survey_' . $surveyid]['register_errormsg'] = $register_errormsg;
         Yii::app()->request->redirect(Yii::app()->createUrl('survey/index/sid/' . $surveyid));
     }
     //Check if this email already exists in token database
     $query = "SELECT email FROM {{tokens_{$surveyid}}}\n" . "WHERE email = '" . sanitize_email(Yii::app()->request->getPost('register_email')) . "'";
     $usrow = Yii::app()->db->createCommand($query)->queryRow();
     if ($usrow) {
         $register_errormsg = $clang->gT("The email you used has already been registered.");
         $_SESSION['survey_' . $surveyid]['register_errormsg'] = $register_errormsg;
         Yii::app()->request->redirect(Yii::app()->createUrl('survey/index/sid/' . $surveyid));
         //include "index.php";
         //exit;
     }
     $mayinsert = false;
     // Get the survey settings for token length
     //$this->load->model("surveys_model");
     $tlresult = Survey::model()->findAllByAttributes(array("sid" => $surveyid));
     if (isset($tlresult[0])) {
         $tlrow = $tlresult[0];
     } else {
         $tlrow = $tlresult;
     }
     $tokenlength = $tlrow['tokenlength'];
     //if tokenlength is not set or there are other problems use the default value (15)
     if (!isset($tokenlength) || $tokenlength == '') {
         $tokenlength = 15;
     }
     while ($mayinsert != true) {
         $newtoken = randomChars($tokenlength);
         $ntquery = "SELECT * FROM {{tokens_{$surveyid}}} WHERE token='{$newtoken}'";
         $usrow = Yii::app()->db->createCommand($ntquery)->queryRow();
         if (!$usrow) {
             $mayinsert = true;
         }
     }
     $postfirstname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_firstname')));
     $postlastname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_lastname')));
     $starttime = sanitize_xss_string(Yii::app()->request->getPost('startdate'));
     $endtime = sanitize_xss_string(Yii::app()->request->getPost('enddate'));
     /*$postattribute1=sanitize_xss_string(strip_tags(returnGlobal('register_attribute1')));
       $postattribute2=sanitize_xss_string(strip_tags(returnGlobal('register_attribute2')));   */
     // Insert new entry into tokens db
     Tokens_dynamic::sid($thissurvey['sid']);
     $token = new Tokens_dynamic();
     $token->firstname = $postfirstname;
     $token->lastname = $postlastname;
     $token->email = Yii::app()->request->getPost('register_email');
//.........这里部分代码省略.........
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:101,代码来源:RegisterController.php


示例7: _createNewUser

 /**
  * Create a LDAP user
  *
  * @param string $new_user
  * @return null|string New user ID
  */
 private function _createNewUser($new_user)
 {
     $oEvent = $this->getEvent();
     // Get configuration settings:
     $ldapserver = $this->get('server');
     $ldapport = $this->get('ldapport');
     $ldapmode = $this->get('ldapmode');
     $searchuserattribute = $this->get('searchuserattribute');
     $extrauserfilter = $this->get('extrauserfilter');
     $usersearchbase = $this->get('usersearchbase');
     $binddn = $this->get('binddn');
     $bindpwd = $this->get('bindpwd');
     $mailattribute = $this->get('mailattribute');
     $fullnameattribute = $this->get('fullnameattribute');
     // Try to connect
     $ldapconn = $this->createConnection();
     if (!is_resource($ldapconn)) {
         $oEvent->set('errorCode', self::ERROR_LDAP_CONNECTION);
         $oEvent->set('errorMessageTitle', '');
         $oEvent->set('errorMessageBody', $ldapconn['errorMessage']);
         return null;
     }
     if (empty($ldapmode) || $ldapmode == 'simplebind') {
         $oEvent->set('errorCode', self::ERROR_LDAP_MODE);
         $oEvent->set('errorMessageTitle', gT("Failed to add user"));
         $oEvent->set('errorMessageBody', gT("Simple bind LDAP configuration doesn't allow LDAP user creation"));
         return null;
     }
     // Search email address and full name
     if (empty($binddn)) {
         // There is no account defined to do the LDAP search,
         // let's use anonymous bind instead
         $ldapbindsearch = @ldap_bind($ldapconn);
     } else {
         // An account is defined to do the LDAP search, let's use it
         $ldapbindsearch = @ldap_bind($ldapconn, $binddn, $bindpwd);
     }
     if (!$ldapbindsearch) {
         $oEvent->set('errorCode', self::ERROR_LDAP_NO_BIND);
         $oEvent->set('errorMessageTitle', gT('Could not connect to LDAP server.'));
         $oEvent->set('errorMessageBody', gT(ldap_error($ldapconn)));
         ldap_close($ldapconn);
         // all done? close connection
         return null;
     }
     // Now prepare the search fitler
     if ($extrauserfilter != "") {
         $usersearchfilter = "(&({$searchuserattribute}={$new_user}){$extrauserfilter})";
     } else {
         $usersearchfilter = "({$searchuserattribute}={$new_user})";
     }
     // Search for the user
     $dnsearchres = ldap_search($ldapconn, $usersearchbase, $usersearchfilter, array($mailattribute, $fullnameattribute));
     $rescount = ldap_count_entries($ldapconn, $dnsearchres);
     if ($rescount == 1) {
         $userentry = ldap_get_entries($ldapconn, $dnsearchres);
         $new_email = flattenText($userentry[0][$mailattribute][0]);
         $new_full_name = flattenText($userentry[0][strtolower($fullnameattribute)][0]);
     } else {
         $oEvent->set('errorCode', self::ERROR_LDAP_NO_SEARCH_RESULT);
         $oEvent->set('errorMessageTitle', gT('Username not found in LDAP server'));
         $oEvent->set('errorMessageBody', gT('Verify username and try again'));
         ldap_close($ldapconn);
         // all done? close connection
         return null;
     }
     if (!validateEmailAddress($new_email)) {
         $oEvent->set('errorCode', self::ERROR_INVALID_EMAIL);
         $oEvent->set('errorMessageTitle', gT("Failed to add user"));
         $oEvent->set('errorMessageBody', gT("The email address is not valid."));
         return null;
     }
     $new_pass = createPassword();
     // If user is being auto created we set parent ID to 1 (admin user)
     if (isset(Yii::app()->session['loginID'])) {
         $parentID = Yii::app()->session['loginID'];
     } else {
         $parentID = 1;
     }
     $iNewUID = User::model()->insertUser($new_user, $new_pass, $new_full_name, $parentID, $new_email);
     if (!$iNewUID) {
         $oEvent->set('errorCode', self::ERROR_ALREADY_EXISTING_USER);
         $oEvent->set('errorMessageTitle', '');
         $oEvent->set('errorMessageBody', gT("Failed to add user"));
         return null;
     }
     Permission::model()->setGlobalPermission($iNewUID, 'auth_ldap');
     $oEvent->set('newUserID', $iNewUID);
     $oEvent->set('newPassword', $new_pass);
     $oEvent->set('newEmail', $new_email);
     $oEvent->set('newFullName', $new_full_name);
     $oEvent->set('errorCode', self::ERROR_NONE);
     return $iNewUID;
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:100,代码来源:AuthLDAP.php


示例8: afterSurveyComplete

 /**
  * This event is fired by when a response is submitted
  * available for a survey.
  * @param PluginEvent $event
  */
 public function afterSurveyComplete()
 {
     // This method will send a notification email
     $event = $this->getEvent();
     $surveyId = $event->get('surveyId');
     // Only process the afterSurveyComplete if the plugin is Enabled for this survey and if the survey is Active
     if ($this->get('emailCount', 'Survey', $surveyId) < 1 || Survey::model()->findByPk($surveyId)->active != "Y") {
         // leave gracefully
         return true;
     }
     // Retrieve response and survey properties
     $responseId = $event->get('responseId');
     $response = $this->pluginManager->getAPI()->getResponse($surveyId, $responseId);
     $sitename = $this->pluginManager->getAPI()->getConfigKey('sitename');
     $surveyInfo = getSurveyInfo($surveyId);
     $adminemail = $surveyInfo['adminemail'];
     $bounce_email = $surveyInfo['bounce_email'];
     $isHtmlEmail = $surveyInfo['htmlemail'] == 'Y';
     $baseLang = $surveyInfo['language'];
     for ($i = 1; $i <= $this->get('emailCount', 'Survey', $surveyId); $i++) {
         // Let's check if there is at least a valid destination email address
         $aTo = array();
         $aAttachTo = array();
         $aDestEmail = explode(';', $this->pluginManager->getAPI()->EMevaluateExpression($this->get('emailDestinations_' . $i, 'Survey', $surveyId)));
         $aDestEmail = array_map('trim', $aDestEmail);
         $aUploadQuestions = explode(';', $this->pluginManager->getAPI()->EMevaluateExpression($this->get('emailAttachFiles_' . $i, 'Survey', $surveyId)));
         $aUploadQuestions = array_map('trim', $aUploadQuestions);
         // prepare an array of valid destination email addresses
         foreach ($aDestEmail as $destemail) {
             if (validateEmailAddress($destemail)) {
                 $aTo[] = $destemail;
             }
         }
         // prepare an array of valid attached files from upload-questions
         foreach ($aUploadQuestions as $uploadQuestion) {
             $sgqa = 0;
             $qtype = '';
             if (isset($response[$uploadQuestion])) {
                 // get SGQA code from question-code. Ther might be a better way to do this though...
                 $sgqa = $this->pluginManager->getAPI()->EMevaluateExpression('{' . $uploadQuestion . '.sgqa}');
                 $qtype = $this->pluginManager->getAPI()->EMevaluateExpression('{' . $uploadQuestion . '.type}');
             }
             // Only add the file if question is relevant
             if ($sgqa != 0 && $qtype == "|" && \LimeExpressionManager::QuestionIsRelevant($sgqa)) {
                 $aFiles = json_decode($response[$uploadQuestion]);
                 if (!is_null($aFiles) && is_array($aFiles)) {
                     foreach ($aFiles as $file) {
                         if (property_exists($file, 'name') && property_exists($file, 'filename')) {
                             $name = $file->name;
                             $filename = $file->filename;
                             $aAttachTo[] = array(0 => $this->pluginManager->getAPI()->getConfigKey('uploaddir') . "/surveys/{$surveyId}/files/" . $filename, 1 => $name);
                         }
                     }
                 }
             }
         }
         if (count($aTo) >= 1) {
             // Retrieve the language to use for the notification email
             $emailLang = $this->get('emailLang_' . $i, 'Survey', $surveyId);
             if ($emailLang == '--') {
                 // in this case let's select the language used when submitting the response
                 $emailLang = $response['startlanguage'];
             }
             $subjectTemplate = $this->get("emailSubject_{$i}_{$emailLang}", 'Survey', $surveyId);
             if ($subjectTemplate == "") {
                 // If subject is not translated, use subject and body from the baseLang
                 $emailLang = $baseLang;
                 $subjectTemplate = $this->get("emailSubject_{$i}_{$emailLang}", 'Survey', $surveyId);
             }
             // Process the email subject and body through ExpressionManager
             $subject = $this->pluginManager->getAPI()->EMevaluateExpression($subjectTemplate);
             // Prepare an {ANSWERTABLE} variable
             if ($surveyInfo['datestamp'] == 'N') {
                 //$aFilteredFields=array('id', 'submitdate', 'lastpage', 'startlanguage');
                 // Let's filter submitdate if survey is not datestampped
                 $aFilteredFields = array('submitdate');
             } else {
                 //$aFilteredFields=array('id', 'lastpage', 'startlanguage');
                 $aFilteredFields = array();
             }
             $replacementfields = array('ANSWERTABLE' => $this->translateAnswerTable($surveyId, $responseId, $emailLang, $isHtmlEmail, $aFilteredFields));
             // Process emailBody through EM and replace {ANSWERTABLE}
             $body = \LimeExpressionManager::ProcessString($this->get("emailBody_{$i}_{$emailLang}", 'Survey', $surveyId), NULL, $replacementfields);
             // At last it's time to send the email
             SendEmailMessage($body, $subject, $aTo, $adminemail, $sitename, $isHtmlEmail, $bounce_email, $aAttachTo);
         }
         // END BLOCK 'if' aTo[] not emtpy
     }
     // END BLOCK 'for' emailCount
 }
开发者ID:lemeur,项目名称:Limesurvey-Plugin-ConfirmByEmail,代码行数:95,代码来源:ConfirmByEmail.php


示例9: _saveSettings

 private function _saveSettings()
 {
     if ($_POST['action'] !== "globalsettingssave") {
         return;
     }
     if (!Permission::model()->hasGlobalPermission('settings', 'update')) {
         $this->getController()->redirect(array('/admin'));
     }
     $clang = $this->getController()->lang;
     Yii::app()->loadHelper('surveytranslator');
     $maxemails = $_POST['maxemails'];
     if (sanitize_int($_POST['maxemails']) < 1) {
         $maxemails = 1;
     }
     $defaultlang = sanitize_languagecode($_POST['defaultlang']);
     $aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages']));
     if (!in_array($defaultlang, $aRestrictToLanguages)) {
         // Force default language in restrictToLanguages
         $aRestrictToLanguages[] = $defaultlang;
     }
     if (count(array_diff(array_keys(getLanguageData(false, Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) {
         $aRestrictToLanguages = '';
     } else {
         $aRestrictToLanguages = implode(' ', $aRestrictToLanguages);
     }
     setGlobalSetting('defaultlang', $defaultlang);
     setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages));
     setGlobalSetting('sitename', strip_tags($_POST['sitename']));
     setGlobalSetting('updatecheckperiod', (int) $_POST['updatecheckperiod']);
     setGlobalSetting('updatenotification', strip_tags($_POST['updatenotification']));
     setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode']));
     setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode']));
     setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode']));
     setGlobalSetting('defaulttemplate', sanitize_paranoid_string($_POST['defaulttemplate']));
     setGlobalSetting('admintheme', sanitize_paranoid_string($_POST['admintheme']));
     setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir") . DIRECTORY_SEPARATOR . sanitize_paranoid_string($_POST['admintheme']) . DIRECTORY_SEPARATOR . 'iconsize')));
     setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod']));
     setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost')));
     if (returnGlobal('emailsmtppassword') != 'somepassword') {
         setGlobalSetting('emailsmtppassword', strip_tags(returnGlobal('emailsmtppassword')));
     }
     setGlobalSetting('bounceaccounthost', strip_tags(returnGlobal('bounceaccounthost')));
     setGlobalSetting('bounceaccounttype', strip_tags(returnGlobal('bounceaccounttype')));
     setGlobalSetting('bounceencryption', strip_tags(returnGlobal('bounceencryption')));
     setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser')));
     if (returnGlobal('bounceaccountpass') != 'enteredpassword') {
         setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass')));
     }
     setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl', '')));
     setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug', '0')));
     setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser')));
     setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml']));
     $warning = '';
     // make sure emails are valid before saving them
     if (Yii::app()->request->getPost('siteadminbounce', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminbounce'))) {
         setGlobalSetting('siteadminbounce', strip_tags(Yii::app()->request->getPost('siteadminbounce')));
     } else {
         $warning .= $clang->gT("Warning! Admin bounce email was not saved because it was not valid.") . '<br/>';
     }
     if (Yii::app()->request->getPost('siteadminemail', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminemail'))) {
         setGlobalSetting('siteadminemail', strip_tags(Yii::app()->request->getPost('siteadminemail')));
     } else {
         $warning .= $clang->gT("Warning! Admin email was not saved because it was not valid.") . '<br/>';
     }
     setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname']));
     setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer']));
     setGlobalSetting('showxquestions', $_POST['showxquestions']);
     setGlobalSetting('showgroupinfo', $_POST['showgroupinfo']);
     setGlobalSetting('showqnumcode', $_POST['showqnumcode']);
     $repeatheadingstemp = (int) $_POST['repeatheadings'];
     if ($repeatheadingstemp == 0) {
         $repeatheadingstemp = 25;
     }
     setGlobalSetting('repeatheadings', $repeatheadingstemp);
     setGlobalSetting('maxemails', sanitize_int($maxemails));
     $iSessionExpirationTime = (int) $_POST['iSessionExpirationTime'];
     if ($iSessionExpirationTime == 0) {
         $iSessionExpirationTime = 7200;
     }
     setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime);
     setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']);
     setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']);
     setGlobalSetting('googleanalyticsapikey', $_POST['googleanalyticsapikey']);
     setGlobalSetting('googletranslateapikey', $_POST['googletranslateapikey']);
     setGlobalSetting('force_ssl', $_POST['force_ssl']);
     setGlobalSetting('surveyPreview_require_Auth', $_POST['surveyPreview_require_Auth']);
     setGlobalSetting('RPCInterface', $_POST['RPCInterface']);
     setGlobalSetting('rpc_publish_api', (bool) $_POST['rpc_publish_api']);
     //added by Gaurang 2014-04-14
     setGlobalSetting('Project_Manager', (int) $_POST['Project_Manager']);
     //setGlobalSetting('Sales_Person', (int) $_POST['Sales_Person']);
     setGlobalSetting('Own_Panel', (int) $_POST['Own_Panel']);
     // EOF Gaurang
     //added by Gaurang 2014-04-17
     // set global status of project
     setGlobalSetting('project_status_run', (int) $_POST['project_status_run']);
     setGlobalSetting('project_status_test', (int) $_POST['project_status_test']);
     setGlobalSetting('project_status_hold', (int) $_POST['project_status_hold']);
     setGlobalSetting('project_status_completed', (int) $_POST['project_status_completed']);
     setGlobalSetting('project_status_closed', (int) $_POST['project_status_closed']);
//.........这里部分代码省略.........
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:101,代码来源:globalsettings.php


示例10: import


//.........这里部分代码省略.........
                     $bDuplicateFound = false;
                     $bInvalidEmail = false;
                     $aWriteArray['email'] = isset($aWriteArray['email']) ? trim($aWriteArray['email']) : "";
                     $aWriteArray['firstname'] = isset($aWriteArray['firstname']) ? $aWriteArray['firstname'] : "";
                     $aWriteArray['lastname'] = isset($aWriteArray['lastname']) ? $aWriteArray['lastname'] : "";
                     $aWriteArray['language'] = isset($aWriteArray['language']) ? $aWriteArray['language'] : $sBaseLanguage;
                     if ($bFilterDuplicateToken) {
                         $aParams = array();
                         $oCriteria = new CDbCriteria();
                         $oCriteria->condition = "";
                         foreach ($aFilterDuplicateFields as $field) {
                             if (isset($aWriteArray[$field])) {
                                 $oCriteria->addCondition("{$field} = :{$field}");
                                 $aParams[":{$field}"] = $aWriteArray[$field];
                             }
                         }
                         if (!empty($aParams)) {
                             $oCriteria->params = $aParams;
                         }
                         $dupresult = TokenDynamic::model($iSurveyId)->count($oCriteria);
                         if ($dupresult > 0) {
                             $bDuplicateFound = true;
                             $aDuplicateList[] = sprintf(gt("Line %s : %s %s (%s)"), $iRecordCount, $aWriteArray['firstname'], $aWriteArray['lastname'], $aWriteArray['email']);
                         }
                     }
                     //treat blank emails
                     if (!$bDuplicateFound && $bFilterBlankEmail && $aWriteArray['email'] == '') {
                         $bInvalidEmail = true;
                         $aInvalidEmailList[] = sprintf(gt("Line %s : %s %s"), $iRecordCount, CHtml::encode($aWriteArray['firstname']), CHtml::encode($aWriteArray['lastname']));
                     }
                     if (!$bDuplicateFound && $aWriteArray['email'] != '') {
                         $aEmailAddresses = explode(';', $aWriteArray['email']);
                         foreach ($aEmailAddresses as $sEmailaddress) {
                             if (!validateEmailAddress($sEmailaddress)) {
                                 if ($bAllowInvalidEmail) {
                                     $iInvalidEmailCount++;
                                     if (empty($aWriteArray['emailstatus']) || strtoupper($aWriteArray['emailstatus'] == "OK")) {
                                         $aWriteArray['emailstatus'] = "invalid";
                                     }
                                 } else {
                                     $bInvalidEmail = true;
                                     $aInvalidEmailList[] = sprintf(gt("Line %s : %s %s (%s)"), $iRecordCount, CHtml::encode($aWriteArray['firstname']), CHtml::encode($aWriteArray['lastname']), CHtml::encode($aWriteArray['email']));
                                 }
                             }
                         }
                     }
                     if (!$bDuplicateFound && !$bInvalidEmail && isset($aWriteArray['token'])) {
                         $aWriteArray['token'] = sanitize_token($aWriteArray['token']);
                         // We allways search for duplicate token (it's in model. Allow to reset or update token ?
                         if (Token::model($iSurveyId)->count("token=:token", array(":token" => $aWriteArray['token']))) {
                             $bDuplicateFound = true;
                             $aDuplicateList[] = sprintf(gt("Line %s : %s %s (%s) - token : %s"), $iRecordCount, CHtml::encode($aWriteArray['firstname']), CHtml::encode($aWriteArray['lastname']), CHtml::encode($aWriteArray['email']), CHtml::encode($aWriteArray['token']));
                         }
                     }
                     if (!$bDuplicateFound && !$bInvalidEmail) {
                         // unset all empty value
                         foreach ($aWriteArray as $key => $value) {
                             if ($aWriteArray[$key] == "") {
                                 unset($aWriteArray[$key]);
                             }
                             if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
                                 // Fix CSV quote
                                 $value = substr($value, 1, -1);
                             }
                         }
                         // Some default value : to be moved to Token model rules in future release ?
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:67,代码来源:tokens.php


示例11: import


//.........这里部分代码省略.........
                         $invalidformatlist[] = $recordcount;
                         $recordcount++;
                         continue;
                     }
                     $writearray = array_combine($firstline, $line);
                     //kick out ignored columns
                     foreach ($ignoredcolumns as $column) {
                         unset($writearray[$column]);
                     }
                     $dupfound = false;
                     $invalidemail = false;
                     if ($filterduplicatetoken != false) {
                         $dupquery = "SELECT count(tid) from {{tokens_" . intval($iSurveyId) . "}} where 1=1";
                         foreach ($filterduplicatefields as $field) {
                             if (isset($writearray[$field])) {
                                 $dupquery .= " and " . Yii::app()->db->quoteColumnName($field) . " = " . Yii::app()->db->quoteValue($writearray[$field]);
                             }
                         }
                         $dupresult = Yii::app()->db->createCommand($dupquery)->queryScalar();
                         if ($dupresult > 0) {
                             $dupfound = true;
                             $duplicatelist[] = Yii::app()->db->quoteValue($writearray['firstname']) . " " . Yii::app()->db->quoteValue($writearray['lastname']) . " (" . Yii::app()->db->quoteValue($writearray['email']) . ")";
                         }
                     }
                     $writearray['email'] = trim($writearray['email']);
                     //treat blank emails
                     if ($filterblankemail && $writearray['email'] == '') {
                         $invalidemail = true;
                         $invalidemaillist[] = $line[0] . " " . $line[1] . " ( )";
                     }
                     if ($writearray['email'] != '') {
                         $aEmailAddresses = explode(';', $writearray['email']);
                         foreach ($aEmailAddresses as $sEmailaddress) {
                             if (!validateEmailAddress($sEmailaddress)) {
                                 $invalidemail = true;
                                 $invalidemaillist[] = $line[0] . " " . $line[1] . " (" . $line[2] . ")";
                             }
                         }
                     }
                     if (!isset($writearray['token'])) {
                         $writearray['token'] = '';
                     } else {
                         $writearray['token'] = sanitize_token($writearray['token']);
                     }
                     if (!$dupfound && !$invalidemail) {
                         if (!isset($writearray['emailstatus']) || $writearray['emailstatus'] == '') {
                             $writearray['emailstatus'] = "OK";
                         }
                         if (!isset($writearray['usesleft']) || $writearray['usesleft'] == '') {
                             $writearray['usesleft'] = 1;
                         }
                         if (!isset($writearray['language']) || $writearray['language'] == "") {
                             $writearray['language'] = $sBaseLanguage;
                         }
                         if (isset($writearray['validfrom']) && trim($writearray['validfrom'] == '')) {
                             unset($writearray['validfrom']);
                         }
                         if (isset($writearray['validuntil']) && trim($writearray['validuntil'] == '')) {
                             unset($writearray['validuntil']);
                         }
                         // sanitize it before writing into table
                         foreach ($writearray as $key => $value) {
                             if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
                                 $value = substr($value, 1, -1);
                             }
                             $sanitizedArray[Yii::app()->db->quoteColumnName($key)] = Yii::app()->db->quoteValue($value);
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:67,代码来源:tokens.php


示例12: getRegisterErrors

 /**
  * Validate a register form
  * @param $iSurveyId Survey Id to register
  * @return array of errors when try to register (empty array => no error)
  */
 public function getRegisterErrors($iSurveyId)
 {
     $aSurveyInfo = getSurveyInfo($iSurveyId, App()->language);
     // Check the security question's answer
     if (function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen', $aSurveyInfo['usecaptcha'])) {
         $sLoadsecurity = Yii::app()->request->getPost('loadsecurity', '');
         $sSecAnswer = isset($_SESSION['survey_' . $iSurveyId]['secanswer']) ? $_SESSION['survey_' . $iSurveyId]['secanswer'] : "";
         if ($sLoadsecurity != $sSecAnswer) {
             $this->aRegisterErrors[] = gT("The answer to the security question is incorrect.");
         }
     }
     $aFieldValue = $this->getFieldValue($iSurveyId);
     $aRegisterAttributes = $this->getExtraAttributeInfo($iSurveyId);
     //Check that the email is a valid style address
     if ($aFieldValue['sEmail'] == "") {
         $this->aRegisterErrors[] = gT("You must enter a valid email. Please try again.");
     } elseif (!validateEmailAddress($aFieldValue['sEmail'])) {
         $this->aRegisterErrors[] = gT("The email you used is not valid. Please try again.");
     }
     //Check and validate attribute
     foreach ($aRegisterAttributes as $key => $aAttribute) {
         if ($aAttribute['show_register'] == 'Y' && $aAttribute['mandatory'] == 'Y' && empty($aFieldValue['aAttribute'][$key])) {
             $this->aRegisterErrors[] = sprintf(gT("%s cannot be left empty") . ".", $aAttribute['caption']);
         }
     }
 }
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:31,代码来源:RegisterController.php


示例13: validateEmailAddress

     case 'admin':
         if (in_array($_POST['role'], array('admin', 'content-creator'))) {
             $permission = true;
         }
         break;
     case 'content-creator':
         if (in_array($_POST['role'], array('content-creator'))) {
             $permission = true;
         }
         break;
     default:
         break;
 }
 if ($permission) {
     //debugBreak();
     $response = validateEmailAddress("c52G6yeXPCx9k7FF2bnNwZC2CLn8447ArGwGKFj2E", "free-cupones.com", $_POST['email']);
     $invitecode = randomString(50);
     if (!empty($response->isValid)) {
         if (strtoupper($response->isValid) == 'NO') {
             $json->status = 'ERROR';
             $json->message = 'Invalid email address';
         } else {
             $ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP validateEntry函数代码示例发布时间:2022-05-23
下一篇:
PHP validateEmail函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap