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

PHP mail_isvalid函数代码示例

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

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



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

示例1: _getAvatarURL

 /**
  * Main function to determine the avatar to use
  */
 function _getAvatarURL($user, &$title, &$size)
 {
     global $auth;
     if (!$size || !is_int($size)) {
         $size = $this->getConf('size');
     }
     // check first if a local image for the given user exists
     $userinfo = $auth->getUserData($user);
     if (is_array($userinfo)) {
         if ($userinfo['name'] && !$title) {
             $title = hsc($userinfo['name']);
         }
         $avatar = $this->getConf('namespace') . ':' . $user;
         $formats = array('.png', '.jpg', '.gif');
         foreach ($formats as $format) {
             $img = mediaFN($avatar . $format);
             if (!@file_exists($img)) {
                 continue;
             }
             $src = ml($avatar . $format, array('w' => $size, 'h' => $size));
             break;
         }
         if (!$src) {
             $mail = $userinfo['mail'];
         }
     } else {
         $mail = $user;
     }
     if (!$src) {
         $seed = md5($mail);
         if (function_exists('imagecreatetruecolor')) {
             // we take the monster ID as default
             $file = 'monsterid.php?seed=' . $seed . '&size=' . $size . '&.png';
         } else {
             // GDlib is not availble - resort to default images
             switch ($size) {
                 case 20:
                 case 40:
                 case 80:
                     $file = 'images/default_' . $size . '.png';
                     break;
                 default:
                     $file = 'images/default_120.png';
             }
         }
         $default = ml(DOKU_URL . '/lib/plugins/avatar/' . $file, 'cache=recache', true, '&', true);
         // do not pass invalid or empty emails to gravatar site...
         if (mail_isvalid($mail) && $size <= 80) {
             $src = ml('http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . $seed . '&default=' . urlencode($default) . '&size=' . $size . '&rating=' . $this->getConf('rating') . '&.jpg', 'cache=recache');
             // show only default image if invalid or empty email given
         } else {
             $src = $default;
         }
     }
     if (!$title) {
         $title = obfuscate($mail);
     }
     return $src;
 }
开发者ID:JamieFlournoy,项目名称:monsterid,代码行数:62,代码来源:helper.php


示例2: _validate

 function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && !mail_isvalid($value)) {
         throw new Exception(sprintf($this->getLang('e_email'), hsc($this->getParam('label'))));
     }
 }
开发者ID:nefercheprure,项目名称:dokuwiki-plugin-bureaucracy,代码行数:8,代码来源:email.php


示例3: validate

 /**
  * Validate
  *
  * @param int|string $rawvalue
  * @return int|string
  */
 public function validate($rawvalue)
 {
     $rawvalue = parent::validate($rawvalue);
     $mail = $this->config['prefix'] . $rawvalue . $this->config['postfix'];
     if (!mail_isvalid($mail)) {
         throw new ValidationException('Mail invalid', $mail);
     }
     return $rawvalue;
 }
开发者ID:cosmocode,项目名称:dokuwiki-plugin-struct,代码行数:15,代码来源:Mail.php


示例4: test_plugininfo

 /**
  * Simple test to make sure the plugin.info.txt is in correct format
  */
 public function test_plugininfo()
 {
     $file = __DIR__ . '/../plugin.info.txt';
     $this->assertFileExists($file);
     $info = confToHash($file);
     $this->assertArrayHasKey('base', $info);
     $this->assertArrayHasKey('author', $info);
     $this->assertArrayHasKey('email', $info);
     $this->assertArrayHasKey('date', $info);
     $this->assertArrayHasKey('name', $info);
     $this->assertArrayHasKey('desc', $info);
     $this->assertArrayHasKey('url', $info);
     $this->assertEquals('svgpureinsert', $info['base']);
     $this->assertRegExp('/^https?:\\/\\//', $info['url']);
     $this->assertTrue(mail_isvalid($info['email']));
     $this->assertRegExp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/', $info['date']);
     $this->assertTrue(false !== strtotime($info['date']));
 }
开发者ID:xudianyang,项目名称:wiki.phpboy.net,代码行数:21,代码来源:general.test.php


示例5: _cleanData

 /**
  * Makes sure the given data fits with the given type
  */
 function _cleanData($value, $type)
 {
     $value = trim($value);
     if (!$value) {
         return '';
     }
     if (is_array($type)) {
         if (isset($type['enum']) && !preg_match('/(^|,\\s*)' . preg_quote_cb($value) . '($|\\s*,)/', $type['enum'])) {
             return '';
         }
         $type = $type['type'];
     }
     switch ($type) {
         case 'dt':
             if (preg_match('/^(\\d\\d\\d\\d)-(\\d\\d?)-(\\d\\d?)$/', $value, $m)) {
                 return sprintf('%d-%02d-%02d', $m[1], $m[2], $m[3]);
             }
             return '';
         case 'url':
             if (!preg_match('!^[a-z]+://!i', $value)) {
                 $value = 'http://' . $value;
             }
             return $value;
         case 'mail':
             $email = '';
             $name = '';
             $part = '';
             $parts = preg_split('/\\s+/', $value);
             do {
                 $part = array_shift($parts);
                 if (!$email && mail_isvalid($part)) {
                     $email = strtolower($part);
                     continue;
                 }
                 $name .= $part . ' ';
             } while ($part);
             return trim($email . ' ' . $name);
         case 'page':
         case 'nspage':
             return cleanID($value);
         default:
             return $value;
     }
 }
开发者ID:rsnitsch,项目名称:dokuwiki-plugin-data,代码行数:47,代码来源:helper.php


示例6: update

 /**
  *  update setting with user provided value $input
  *  if value fails error check, save it
  *
  *  @return true if changed, false otherwise (incl. on error)
  */
 function update($input)
 {
     if (is_null($input)) {
         return false;
     }
     if ($this->is_protected()) {
         return false;
     }
     $value = is_null($this->_local) ? $this->_default : $this->_local;
     if ($value == $input) {
         return false;
     }
     // replace variables with pseudo values
     $test = $input;
     $test = str_replace('@USER@', 'joe', $test);
     $test = str_replace('@NAME@', 'Joe Schmoe', $test);
     $test = str_replace('@MAIL@', '[email protected]', $test);
     // now only check the address part
     if (preg_match('#(.*?)<(.*?)>#', $test, $matches)) {
         $text = trim($matches[1]);
         $addr = $matches[2];
     } else {
         $addr = $test;
     }
     if (!mail_isvalid($addr)) {
         $this->_error = true;
         $this->_input = $input;
         return false;
     }
     $this->_local = $input;
     return true;
 }
开发者ID:Kirill,项目名称:dokuwiki,代码行数:38,代码来源:config.class.php


示例7: update

 /**
  * update setting with user provided value $input
  * if value fails error check, save it
  *
  * @param mixed $input
  * @return boolean true if changed, false otherwise (incl. on error)
  */
 function update($input)
 {
     if (is_null($input)) {
         return false;
     }
     if ($this->is_protected()) {
         return false;
     }
     $value = is_null($this->_local) ? $this->_default : $this->_local;
     if ($value == $input) {
         return false;
     }
     if ($input === '') {
         $this->_local = $input;
         return true;
     }
     $mail = $input;
     if ($this->_placeholders) {
         // replace variables with pseudo values
         $mail = str_replace('@USER@', 'joe', $mail);
         $mail = str_replace('@NAME@', 'Joe Schmoe', $mail);
         $mail = str_replace('@MAIL@', '[email protected]', $mail);
     }
     // multiple mail addresses?
     if ($this->_multiple) {
         $mails = array_filter(array_map('trim', explode(',', $mail)));
     } else {
         $mails = array($mail);
     }
     // check them all
     foreach ($mails as $mail) {
         // only check the address part
         if (preg_match('#(.*?)<(.*?)>#', $mail, $matches)) {
             $addr = $matches[2];
         } else {
             $addr = $mail;
         }
         if (!mail_isvalid($addr)) {
             $this->_error = true;
             $this->_input = $input;
             return false;
         }
     }
     $this->_local = $input;
     return true;
 }
开发者ID:kevinlovesing,项目名称:dokuwiki,代码行数:53,代码来源:config.class.php


示例8: _cleanImportUser

 /**
  * Returns cleaned user data
  *
  * @param array $candidate raw values of line from input file
  * @param $error
  * @return array|bool cleaned data or false
  */
 protected function _cleanImportUser($candidate, &$error)
 {
     global $INPUT;
     // kludgy ....
     $INPUT->set('userid', $candidate[0]);
     $INPUT->set('userpass', $candidate[1]);
     $INPUT->set('username', $candidate[2]);
     $INPUT->set('usermail', $candidate[3]);
     $INPUT->set('usergroups', $candidate[4]);
     $cleaned = $this->_retrieveUser();
     list($user, $pass, $name, $mail, $grps) = $cleaned;
     if (empty($user)) {
         $error = $this->lang['import_error_baduserid'];
         return false;
     }
     // no need to check password, handled elsewhere
     if (!($this->_auth->canDo('modName') xor empty($name))) {
         $error = $this->lang['import_error_badname'];
         return false;
     }
     if ($this->_auth->canDo('modMail')) {
         if (empty($mail) || !mail_isvalid($mail)) {
             $error = $this->lang['import_error_badmail'];
             return false;
         }
     } else {
         if (!empty($mail)) {
             $error = $this->lang['import_error_badmail'];
             return false;
         }
     }
     return $cleaned;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:40,代码来源:admin.php


示例9: send_link

 function send_link($email, $url, &$valid_email)
 {
     if (!mail_isvalid($email)) {
         msg($this->getLang('bad_email') . $email);
         $valid_email = false;
         return false;
     }
     global $conf;
     $text = $this->getLang('email_confirm') . "\n\n";
     $text .= $url;
     $text .= "\n\n";
     $subject = $this->getLang('subject_confirm');
     return mail_send($email, $subject . $conf['title'], $text, $conf['mailfrom']);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:action.php


示例10: updateprofile

/**
 * Update user profile
 *
 * @author    Christopher Smith <[email protected]>
 */
function updateprofile()
{
    global $conf;
    global $INFO;
    global $lang;
    global $auth;
    if (!$auth) {
        return false;
    }
    if (empty($_POST['save'])) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    // should not be able to get here without Profile being possible...
    if (!$auth->canDo('Profile')) {
        msg($lang['profna'], -1);
        return false;
    }
    if ($_POST['newpass'] != $_POST['passchk']) {
        msg($lang['regbadpass'], -1);
        // complain about misspelled passwords
        return false;
    }
    //clean fullname and email
    $_POST['fullname'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $_POST['fullname']));
    $_POST['email'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $_POST['email']));
    if (empty($_POST['fullname']) && $auth->canDo('modName') || empty($_POST['email']) && $auth->canDo('modMail')) {
        msg($lang['profnoempty'], -1);
        return false;
    }
    if (!mail_isvalid($_POST['email']) && $auth->canDo('modMail')) {
        msg($lang['regbadmail'], -1);
        return false;
    }
    if ($_POST['fullname'] != $INFO['userinfo']['name'] && $auth->canDo('modName')) {
        $changes['name'] = $_POST['fullname'];
    }
    if ($_POST['email'] != $INFO['userinfo']['mail'] && $auth->canDo('modMail')) {
        $changes['mail'] = $_POST['email'];
    }
    if (!empty($_POST['newpass']) && $auth->canDo('modPass')) {
        $changes['pass'] = $_POST['newpass'];
    }
    if (!count($changes)) {
        msg($lang['profnochange'], -1);
        return false;
    }
    if ($conf['profileconfirm']) {
        if (!$auth->checkPass($_SERVER['REMOTE_USER'], $_POST['oldpass'])) {
            msg($lang['badlogin'], -1);
            return false;
        }
    }
    if ($result = $auth->triggerUserMod('modify', array($_SERVER['REMOTE_USER'], $changes))) {
        // update cookie and session with the changed data
        $cookie = base64_decode($_COOKIE[DOKU_COOKIE]);
        list($user, $sticky, $pass) = explode('|', $cookie, 3);
        if ($changes['pass']) {
            $pass = PMA_blowfish_encrypt($changes['pass'], auth_cookiesalt());
        }
        auth_setCookie($_SERVER['REMOTE_USER'], $pass, (bool) $sticky);
        return true;
    }
}
开发者ID:halfbyte,项目名称:rugtool,代码行数:71,代码来源:auth.php


示例11: handle_act_preprocess

 /**
  * Handles comment actions, dispatches data processing routines
  */
 function handle_act_preprocess(&$event, $param)
 {
     global $ID;
     global $INFO;
     global $conf;
     global $lang;
     // handle newthread ACTs
     if ($event->data == 'newthread') {
         // we can handle it -> prevent others
         $event->preventDefault();
         $event->data = $this->_newThread();
     }
     // enable captchas
     if (in_array($_REQUEST['comment'], array('add', 'save'))) {
         if (@file_exists(DOKU_PLUGIN . 'captcha/action.php')) {
             $this->_captchaCheck();
         }
         if (@file_exists(DOKU_PLUGIN . 'recaptcha/action.php')) {
             $this->_recaptchaCheck();
         }
     }
     // if we are not in show mode or someone wants to unsubscribe, that was all for now
     if ($event->data != 'show' && $event->data != 'discussion_unsubscribe' && $event->data != 'discussion_confirmsubscribe') {
         return;
     }
     if ($event->data == 'discussion_unsubscribe' or $event->data == 'discussion_confirmsubscribe') {
         // ok we can handle it prevent others
         $event->preventDefault();
         if (!isset($_REQUEST['hash'])) {
             return false;
         } else {
             $file = metaFN($ID, '.comments');
             $data = unserialize(io_readFile($file));
             $themail = '';
             foreach ($data['subscribers'] as $mail => $info) {
                 // convert old style subscribers just in case
                 if (!is_array($info)) {
                     $hash = $data['subscribers'][$mail];
                     $data['subscribers'][$mail]['hash'] = $hash;
                     $data['subscribers'][$mail]['active'] = true;
                     $data['subscribers'][$mail]['confirmsent'] = true;
                 }
                 if ($data['subscribers'][$mail]['hash'] == $_REQUEST['hash']) {
                     $themail = $mail;
                 }
             }
             if ($themail != '') {
                 if ($event->data == 'discussion_unsubscribe') {
                     unset($data['subscribers'][$themail]);
                     msg(sprintf($lang['unsubscribe_success'], $themail, $ID), 1);
                 } elseif ($event->data == 'discussion_confirmsubscribe') {
                     $data['subscribers'][$themail]['active'] = true;
                     msg(sprintf($lang['subscribe_success'], $themail, $ID), 1);
                 }
                 io_saveFile($file, serialize($data));
                 $event->data = 'show';
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         // do the data processing for comments
         $cid = $_REQUEST['cid'];
         switch ($_REQUEST['comment']) {
             case 'add':
                 if (empty($_REQUEST['text'])) {
                     return;
                 }
                 // don't add empty comments
                 if (isset($_SERVER['REMOTE_USER']) && !$this->getConf('adminimport')) {
                     $comment['user']['id'] = $_SERVER['REMOTE_USER'];
                     $comment['user']['name'] = $INFO['userinfo']['name'];
                     $comment['user']['mail'] = $INFO['userinfo']['mail'];
                 } elseif (isset($_SERVER['REMOTE_USER']) && $this->getConf('adminimport') && auth_ismanager() || !isset($_SERVER['REMOTE_USER'])) {
                     if (empty($_REQUEST['name']) or empty($_REQUEST['mail'])) {
                         return;
                     }
                     // don't add anonymous comments
                     if (!mail_isvalid($_REQUEST['mail'])) {
                         msg($lang['regbadmail'], -1);
                         return;
                     } else {
                         $comment['user']['id'] = 'test' . hsc($_REQUEST['user']);
                         $comment['user']['name'] = hsc($_REQUEST['name']);
                         $comment['user']['mail'] = hsc($_REQUEST['mail']);
                     }
                 }
                 $comment['user']['address'] = $this->getConf('addressfield') ? hsc($_REQUEST['address']) : '';
                 $comment['user']['url'] = $this->getConf('urlfield') ? $this->_checkURL($_REQUEST['url']) : '';
                 $comment['subscribe'] = $this->getConf('subscribe') ? $_REQUEST['subscribe'] : '';
                 $comment['date'] = array('created' => $_REQUEST['date']);
                 $comment['raw'] = cleanText($_REQUEST['text']);
                 $repl = $_REQUEST['reply'];
                 if ($this->getConf('moderate') && !auth_ismanager()) {
                     $comment['show'] = false;
                 } else {
//.........这里部分代码省略.........
开发者ID:nickharambee,项目名称:plugin-discussion,代码行数:101,代码来源:action.php


示例12: test1

 function test1()
 {
     $tests = array();
     // our own tests
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     // FS#1447
     $tests[] = array("rfc2822+allthesechars_#*!'`/-={}[email protected]", true);
     $tests[] = array('[email protected]', true);
     // FS#1049
     $tests[] = array('[email protected]', true);
     // new ICAN rulez seem to allow this
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected].', false);
     $tests[] = array('bu(g)[email protected]', false);
     $tests[] = array('bu[g][email protected]', false);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     // tests from http://code.google.com/p/php-email-address-validation/ below
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('t*[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('{_test_}@example.com', true);
     $tests[] = array('"[[ test ]]"@example.com', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('test."test"@example.com', true);
     $tests[] = array('"test@test"@example.com', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('test@[123.123.123.123]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('[email protected]', true);
     $tests[] = array('test.example.com', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('test@[email protected]', false);
     $tests[] = array('test@@example.com', false);
     $tests[] = array('-- test [email protected]', false);
     // No spaces allowed in local part
     $tests[] = array('[test]@example.com', false);
     // Square brackets only allowed within quotes
     $tests[] = array('"test\\test"@example.com', false);
     // Quotes cannot contain backslash
     $tests[] = array('"test"test"@example.com', false);
     // Quotes cannot be nested
     $tests[] = array('()[]\\;:,<>@example.com', false);
     // Disallowed Characters
     $tests[] = array('test@.', false);
     $tests[] = array('test@example.', false);
     $tests[] = array('[email protected]', false);
     $tests[] = array('12345678901234567890123456789012345678901234567890123456789012345@example.com', false);
     // 64 characters is maximum length for local part. This is 65.
     $tests[] = array('test@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.com', false);
     // 255 characters is maximum length for domain. This is 256.
     $tests[] = array('test@example', false);
     $tests[] = array('test@[123.123.123.123', false);
     $tests[] = array('[email protected]]', false);
     foreach ($tests as $test) {
         $info = 'Testing ' . $test[0];
         $this->signal('failinfo', $info);
         if ($test[1]) {
             $this->assertTrue((bool) mail_isvalid($test[0]));
         } else {
             $this->assertFalse((bool) mail_isvalid($test[0]));
         }
     }
 }
开发者ID:ryankask,项目名称:dokuwiki,代码行数:76,代码来源:mail_isvalid.test.php


示例13: updateprofile

/**
 * Update user profile
 *
 * @author    Christopher Smith <[email protected]>
 */
function updateprofile()
{
    global $conf;
    global $lang;
    /* @var DokuWiki_Auth_Plugin $auth */
    global $auth;
    /* @var Input $INPUT */
    global $INPUT;
    if (!$INPUT->post->bool('save')) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    if (!actionOK('profile')) {
        msg($lang['profna'], -1);
        return false;
    }
    $changes = array();
    $changes['pass'] = $INPUT->post->str('newpass');
    $changes['name'] = $INPUT->post->str('fullname');
    $changes['mail'] = $INPUT->post->str('email');
    // check misspelled passwords
    if ($changes['pass'] != $INPUT->post->str('passchk')) {
        msg($lang['regbadpass'], -1);
        return false;
    }
    // clean fullname and email
    $changes['name'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['name']));
    $changes['mail'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['mail']));
    // no empty name and email (except the backend doesn't support them)
    if (empty($changes['name']) && $auth->canDo('modName') || empty($changes['mail']) && $auth->canDo('modMail')) {
        msg($lang['profnoempty'], -1);
        return false;
    }
    if (!mail_isvalid($changes['mail']) && $auth->canDo('modMail')) {
        msg($lang['regbadmail'], -1);
        return false;
    }
    $changes = array_filter($changes);
    // check for unavailable capabilities
    if (!$auth->canDo('modName')) {
        unset($changes['name']);
    }
    if (!$auth->canDo('modMail')) {
        unset($changes['mail']);
    }
    if (!$auth->canDo('modPass')) {
        unset($changes['pass']);
    }
    // anything to do?
    if (!count($changes)) {
        msg($lang['profnochange'], -1);
        return false;
    }
    if ($conf['profileconfirm']) {
        if (!$auth->checkPass($INPUT->server->str('REMOTE_USER'), $INPUT->post->str('oldpass'))) {
            msg($lang['badpassconfirm'], -1);
            return false;
        }
    }
    if (!$auth->triggerUserMod('modify', array($INPUT->server->str('REMOTE_USER'), &$changes))) {
        msg($lang['proffail'], -1);
        return false;
    }
    if ($changes['pass']) {
        // update cookie and session with the changed data
        list(, $sticky, ) = auth_getCookie();
        $pass = auth_encrypt($changes['pass'], auth_cookiesalt(!$sticky, true));
        auth_setCookie($INPUT->server->str('REMOTE_USER'), $pass, (bool) $sticky);
    } else {
        // make sure the session is writable
        @session_start();
        // invalidate session cache
        $_SESSION[DOKU_COOKIE]['auth']['time'] = 0;
        session_write_close();
    }
    return true;
}
开发者ID:janzoner,项目名称:dokuwiki,代码行数:84,代码来源:auth.php


示例14: inputToInternal


//.........这里部分代码省略.........
             }
             break;
         case 'phone':
         case 'fax':
             $value = trim($value);
             if ($value !== '') {
                 $temp = preg_replace('/\\s+/', '', $value);
                 $temp = preg_replace('/\\(([^)]+)\\)/', '\\1', $temp);
                 if (!preg_match('#^\\+?(\\d+(([-/]|/-)\\d+)*)+$#', $temp)) {
                     throw new Exception($this->getLang('badphonefax'));
                 }
             } else {
                 $value = null;
             }
             break;
         case 'monetary':
             $value = trim($value);
             if ($value !== '') {
                 $valuePattern = '/[+-]?\\d+([.,]\\d)?/';
                 if (!preg_match($valuePattern, $value)) {
                     throw new Exception($this->getLang('badmoney'));
                 }
                 // validate to have one out of these formats:
                 //  0,34 or "USD 34,00" or "5 EUR" ...
                 $temp = preg_split($valuePattern, $value);
                 if (trim($temp[1]) === '') {
                     unset($temp[1]);
                 }
                 if (trim($temp[0]) === '') {
                     unset($temp[0]);
                 }
                 if (count($temp) > 1) {
                     throw new Exception($this->getLang('badmoneytail'));
                 }
             } else {
                 $value = null;
             }
             break;
         case 'real':
             $value = trim($value);
             if ($value === '') {
                 $value = null;
             } else {
                 if (!preg_match('/^[+-]?\\d+([.,]\\d+)?$/', $value)) {
                     throw new Exception($this->getLang('badfloat'));
                 }
                 $value = doubleval(strtr($value, ',', '.'));
             }
             break;
         case 'url':
             $value = trim($value);
             if ($value !== '') {
                 $info = parse_url($value);
                 if (!is_array($info)) {
                     throw new Exception($this->getLang('badurl'));
                 }
                 if ($value !== '' && !$info['scheme']) {
                     throw new Exception($this->getLang('badurlnoabs'));
                 }
             } else {
                 $value = null;
             }
             break;
         case 'email':
             $value = trim($value);
             if ($value !== '') {
                 if (!mail_isvalid($value)) {
                     throw new Exception($this->getLang('badmail'));
                 }
                 if ($this->getConf('checkmaildomains') != false) {
                     list($box, $domain) = explode('@', $value);
                     $ip = gethostbyname($domain);
                     if ($ip === $domain || ip2long($ip) === false) {
                         if (!getmxrr($domain, $dummy)) {
                             throw new Exception($this->getLang('badmailunknown'));
                         }
                     }
                 }
             } else {
                 $value = null;
             }
             break;
         case 'acl':
             // row-based ACL rule
             if ($this->isAuthorized($this->options['mayadmin'])) {
                 $value = implode(';', $this->parseACLRule(trim($value), true));
             } else {
                 $value = null;
             }
             break;
         case 'text':
             // everything's fine here
         // everything's fine here
         default:
             if (trim($value) === '') {
                 $value = null;
             }
     }
     return $value;
 }
开发者ID:elaratain,项目名称:database2,代码行数:101,代码来源:database2.php


示例15: updateprofile

/**
 * Update user profile
 *
 * @author    Christopher Smith <[email protected]>
 */
function updateprofile()
{
    global $conf;
    global $INFO;
    global $lang;
    global $auth;
    if (empty($_POST['save'])) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    // should not be able to get here without Profile being possible...
    if (!$auth->canDo('Profile')) {
        msg($lang['profna'], -1);
        return false;
    }
    if ($_POST['newpass'] != $_POST['passchk']) {
        msg($lang['regbadpass'], -1);
        // complain about misspelled passwords
        return false;
    }
    //clean fullname and email
    $_POST['fullname'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $_POST['fullname']));
    $_POST['email'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $_POST['email']));
    if (empty($_POST['fullname']) || empty($_POST['email'])) {
        msg($lang['profnoempty'], -1);
        return false;
    }
    if (!mail_isvalid($_POST['email'])) {
        msg($lang['regbadmail'], -1);
        return false;
    }
    if ($_POST['fullname'] != $INFO['userinfo']['name'] && $auth->canDo('modName')) {
        $changes['name'] = $_POST['fullname'];
    }
    if ($_POST['email'] != $INFO['userinfo']['mail'] && $auth->canDo('modMail')) {
        $changes['mail'] = $_POST['email'];
    }
    if (!empty($_POST['newpass']) && $auth->canDo('modPass')) {
        $changes['pass'] = $_POST['newpass'];
    }
    if (!count($changes)) {
        msg($lang['profnochange'], -1);
        return false;
    }
    if ($conf['profileconfirm']) {
        if (!$auth->checkPass($_SERVER['REMOTE_USER'], $_POST['oldpass'])) {
            msg($lang['badlogin'], -1);
            return false;
        }
    }
    return $auth->modifyUser($_SERVER['REMOTE_USER'], $changes);
}
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:59,代码来源:auth.php


示例16: mail_encode_address

/**
 * Encodes an email address header
 *
 * Unicode characters will be deaccented and encoded
 * quoted_printable for headers.
 * Addresses may not contain Non-ASCII data!
 *
 * Example:
 *   mail_encode_address("föö <[email protected]>, [email protected]","TBcc");
 *
 * @param string  $string Multiple adresses separated by commas
 * @param string  $header Name of the header (To,Bcc,Cc,...)
 * @param boolean $names  Allow named Recipients?
 */
function mail_encode_address($string, $header = '', $names = true)
{
    $headers = '';
    $parts = explode(',', $string);
    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 (!mail_isvalid($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)) {
                // put the quotes outside as in =?UTF-8?Q?"Elan Ruusam=C3=A4e"?= vs "=?UTF-8?Q?Elan Ruusam=C3=A4e?="
                if (preg_match('/^"(.+)"$/', $text, $matches)) {
                    $text = '"=?UTF-8?Q?' . mail_quotedprintable_encode($matches[1], 0) . '?="';
                } else {
                    $text = '=?UTF-8?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
                }
                // additionally the space character should be encoded as =20 (or each
                // word QP encoded separately).
                // however this is needed only in mail headers, not globally in mail_quotedprintable_encode().
                $text = str_replace(" ", "=20", $text);
            }
        } else {
            $text = '';
        }
        // add to header comma seperated
        if ($headers != '') {
            $headers .= ',';
            if ($header) {
                $headers .= MAILHEADER_EOL . ' ';
            }
            // avoid overlong mail headers
        }
        $headers .= $text . ' ' . $addr;
    }
    if (empty($headers)) {
        return null;
    }
    //if headername was given add it and close correctly
    if ($header) {
        $headers = $header . ': ' . $headers . MAILHEADER_EOL;
    }
    return $headers;
}
开发者ID:yjliugit,项目名称:dokuwiki,代码行数:82,代码来源:mail.php


示例17: updateprofile

/**
 * Update user profile
 *
 * @author    Christopher Smith <[email protected]>
 */
function updateprofile()
{
    global $conf;
    global $lang;
    /* @var auth_basic $auth */
    global $auth;
    /* @var Input $INPUT */
    global $INPUT;
    if (!$INPUT->post->bool('save')) {
        return false;
    }
    if (!checkSecurityToken()) {
        return false;
    }
    if (!actionOK('profile')) {
        msg($lang['profna'], -1);
        return false;
    }
    $changes = array();
    $changes['pass'] = $INPUT->post->str('newpass');
    $changes['name'] = $INPUT->post->str('fullname');
    $changes['mail'] = $INPUT->post->str('email');
    // check misspelled passwords
    if ($changes['pass'] != $INPUT->post->str('passchk')) {
        msg($lang['regbadpass'], -1);
        return false;
    }
    // clean fullname and email
    $changes['name'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['name']));
    $changes['mail'] = trim(preg_replace('/[\\x00-\\x1f:<>&%,;]+/', '', $changes['mail']));
    // no empty name and email (except the backend doesn't support them)
    if (empty($changes['name']) && $auth->canDo('modName') || empty($changes['mail']) && $auth->canDo('modMail')) {
        msg($lang['profnoempty'], -1);
        return false;
    }
    if (!mail_isvalid($changes['mail']) && $auth->canDo('modMail')) {
        msg($lang['regbadmail'], -1);
        return false;
    }
    $changes = array_filter($changes);
    // check for unavailable capabilities
    if (!$auth->canDo('modName')) {
        unset($changes['name']);
    }
    if (!$auth->canDo('modMail')) {
        unset($changes['mail']);
    }
    if (!$auth->canDo('modPass')) {
        unset($changes['pass']);
    }
    // anything to do?
    if (!count($changes)) {
        msg($lang['profnochange'], -1);
        return false;
    }
    if ($conf['profileconfirm']) {
        if (!$auth->checkPass($_SERVER['REMOTE_USER'], $INPUT->post->str('oldpass'))) {
            msg($lang['badlogin'], -1);
            return false;
        }
    }
    if ($result = $auth->triggerUserMod('modify', array($_SERVER['REMOTE_USER'], $changes))) {
        // update cookie and session with the changed data
        if ($changes['pass']) {
            list(, $sticky, ) = auth_getCookie();
            $pass = PMA_blowfish_encrypt($changes['pass'], auth_cookiesalt(!$sticky));
            auth_setCookie($_SERVER['REMOTE_USER'], $pass, (bool) $sticky);
        }
        return true;
    }
    return false;
}
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:77,代码来源:auth.php


示例18: mail_encode_address

/**
 * Encodes an email address header
 *
 * Unicode characters will be deaccented and encoded
 * quoted_printable for headers.
 * Addresses may not contain Non-ASCII data!
 *
 * Example:
 *   mail_encode_address("föö <[email protected]>, [email protected]","TBcc");
 *
 * @param string  $string Multiple adresses separated by commas
 * @param string  $header Name of the header (To,Bcc,Cc,...)
 * @param boolean $names  Allow named Recipients?
 */
function mail_encode_address($string, $header = '', $names = true)
{
    $headers = '';
    $parts = split(',', $string);
    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 (!mail_isvalid($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?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
            }
        } else {
            $text = '';
        }
        // add to header comma seperated and in new line to avoid too long headers
        if ($headers != '') {
            $headers .= ',' . MAILHEADER_EOL . ' ';
        }
        $headers .= $text . ' ' . $addr;
    }
    if (empty($headers)) {
        return null;
    }
    //if headername was given add it and close correctly
    if ($header) {
        $headers = $header . ': ' . $headers . MAILHEADER_EOL;
    }
    return $headers;
}
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:69,代码来源:mail.php



注:本文中的mail_isvalid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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