当前位置: 首页>>代码示例>>PHP>>正文


PHP mail_isvalid函数代码示例

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


在下文中一共展示了mail_isvalid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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@', 'joe@example.com', $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@', 'joe@example.com', $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 <chris@jalakai.co.uk>
 */
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('bugs@php.net', true);
     $tests[] = array('~someone@somewhere.com', true);
     $tests[] = array('no+body.here@somewhere.com.au', true);
     $tests[] = array('username+tag@domain.com', true);
     // FS#1447
     $tests[] = array("rfc2822+allthesechars_#*!'`/-={}are.legal@somewhere.com.au", true);
     $tests[] = array('_foo@test.com', true);
     // FS#1049
     $tests[] = array('bugs@php.net1', true);
     // new ICAN rulez seem to allow this
     $tests[] = array('.bugs@php.net1', false);
     $tests[] = array('bu..gs@php.net', false);
     $tests[] = array('bugs@php..net', false);
     $tests[] = array('bugs@.php.net', false);
     $tests[] = array('bugs@php.net.', false);
     $tests[] = array('bu(g)s@php.net1', false);
     $tests[] = array('bu[g]s@php.net1', false);
     $tests[] = array('somebody@somewhere.museum', true);
     $tests[] = array('somebody@somewhere.travel', true);
     // tests from http://code.google.com/p/php-email-address-validation/ below
     $tests[] = array('test@example.com', true);
     $tests[] = array('TEST@example.com', true);
     $tests[] = array('1234567890@example.com', true);
     $tests[] = array('test+test@example.com', true);
     $tests[] = array('test-test@example.com', true);
     $tests[] = array('t*est@example.com', true);
     $tests[] = array('+1~1+@example.com', true);
     $tests[] = array('{_test_}@example.com', true);
     $tests[] = array('"[[ test ]]"@example.com', true);
     $tests[] = array('test.test@example.com', true);
     $tests[] = array('test."test"@example.com', true);
     $tests[] = array('"test@test"@example.com', true);
     $tests[] = array('test@123.123.123.123', true);
     $tests[] = array('test@[123.123.123.123]', true);
     $tests[] = array('test@example.example.com', true);
     $tests[] = array('test@example.example.example.com', true);
     $tests[] = array('test.example.com', false);
     $tests[] = array('test.@example.com', false);
     $tests[] = array('test..test@example.com', false);
     $tests[] = array('.test@example.com', false);
     $tests[] = array('test@test@example.com', false);
     $tests[] = array('test@@example.com', false);
     $tests[] = array('-- test --@example.com', 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('test@.org', 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('test@123.123.123.123]', 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 <chris@jalakai.co.uk>
 */
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 <chris@jalakai.co.uk>
 */
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


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