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


PHP Validator::is_email方法代码示例

本文整理汇总了PHP中Validator::is_email方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::is_email方法的具体用法?PHP Validator::is_email怎么用?PHP Validator::is_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


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

示例1: testValidEmail

    function testValidEmail() {
        // Common emails
        $this->assert(Validator::is_email('jared@domain.tld'));
        $this->assert(Validator::is_email('jared12@domain.tld'));
        $this->assert(Validator::is_email('jared.12@domain.tld'));
        $this->assert(Validator::is_email('jared_12@domain.tld'));
        $this->assert(Validator::is_email('jared-12@domain.tld'));
        $this->assert(Validator::is_email('jared+ost@domain.tld'));

        // Illegal or unsupported
        $this->assert(!Validator::is_email('jared r@domain.tld'));
        $this->assert(!Validator::is_email('jared'));
        $this->assert(!Validator::is_email('jared@'));
        $this->assert(!Validator::is_email('@domain.tld'));
        $this->assert(!Validator::is_email('@domain.tld, @domain2.tld'));

        // Odd cases, but legal
        $this->assert(Validator::is_email('jared@host'));
        $this->assert(Validator::is_email('jared@[127.0.0.1]'));
        $this->assert(Validator::is_email('jared@[ipv6:::1]'));
        $this->assert(Validator::is_email('*@domain.tld'));
        $this->assert(Validator::is_email("'@domain.tld"));
        $this->assert(Validator::is_email('"jared r"@domain.tld'));

        // RFC 6530
        #$this->assert(Validator::is_email('Pelé@example.com'));
        #$this->assert(Validator::is_email('δοκιμή@παράδειγμα.δοκιμή'));
        #$this->assert(Validator::is_email('甲斐@黒川.日本'));
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:29,代码来源:test.validation.php

示例2: load

 function load($var = '')
 {
     if (!$var && !($var = $this->getId())) {
         return false;
     }
     $sql = 'SELECT staff.created as added, grp.*, staff.* ' . ' FROM ' . STAFF_TABLE . ' staff ' . ' LEFT JOIN ' . GROUP_TABLE . ' grp ON(grp.group_id=staff.group_id)
            WHERE ';
     if (is_numeric($var)) {
         $sql .= 'staff_id=' . db_input($var);
     } elseif (Validator::is_email($var)) {
         $sql .= 'email=' . db_input($var);
     } elseif (is_string($var)) {
         $sql .= 'username=' . db_input($var);
     } else {
         return null;
     }
     if (!($res = db_query($sql)) || !db_num_rows($res)) {
         return NULL;
     }
     $this->ht = db_fetch_array($res);
     $this->id = $this->ht['staff_id'];
     $this->teams = $this->ht['teams'] = array();
     $this->group = $this->dept = null;
     $this->departments = $this->stats = array();
     $this->config = new Config('staff.' . $this->id);
     //WE have to patch info here to support upgrading from old versions.
     if ($time = strtotime($this->ht['passwdreset'] ? $this->ht['passwdreset'] : $this->ht['added'])) {
         $this->ht['passwd_change'] = time() - $time;
     }
     //XXX: check timezone issues.
     if ($this->ht['timezone_id']) {
         $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']);
     } elseif ($this->ht['timezone_offset']) {
         $this->ht['tz_offset'] = $this->ht['timezone_offset'];
     }
     return $this->id;
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:37,代码来源:class.staff.php

示例3: update

 function update($vars, &$errors)
 {
     global $thisstaff;
     if (!$thisstaff) {
         $errors['err'] = __('Access Denied');
         return false;
     }
     // TODO: Make sure the username is unique
     if (!$vars['timezone_id']) {
         $errors['timezone_id'] = __('Time zone selection is required');
     }
     // Changing password?
     if ($vars['passwd1'] || $vars['passwd2']) {
         if (!$vars['passwd1']) {
             $errors['passwd1'] = __('New password is required');
         } elseif ($vars['passwd1'] && strlen($vars['passwd1']) < 6) {
             $errors['passwd1'] = __('Must be at least 6 characters');
         } elseif ($vars['passwd1'] && strcmp($vars['passwd1'], $vars['passwd2'])) {
             $errors['passwd2'] = __('Passwords do not match');
         }
     }
     // Make sure the username is not an email.
     if ($vars['username'] && Validator::is_email($vars['username'])) {
         $errors['username'] = __('Users can always sign in with their email address');
     }
     if ($errors) {
         return false;
     }
     $this->set('timezone_id', $vars['timezone_id']);
     $this->set('dst', isset($vars['dst']) ? 1 : 0);
     $this->set('username', $vars['username']);
     if ($vars['passwd1']) {
         $this->set('passwd', Passwd::hash($vars['passwd1']));
         $this->setStatus(UserAccountStatus::CONFIRMED);
     }
     // Set flags
     foreach (array('pwreset-flag' => UserAccountStatus::REQUIRE_PASSWD_RESET, 'locked-flag' => UserAccountStatus::LOCKED, 'forbid-pwchange-flag' => UserAccountStatus::FORBID_PASSWD_RESET) as $ck => $flag) {
         if ($vars[$ck]) {
             $this->setStatus($flag);
         } else {
             $this->clearStatus($flag);
         }
     }
     return $this->save(true);
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:45,代码来源:class.user.php

示例4: die

<?php

if (!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$filter) {
    die('Access Denied');
}
$qstr = '';
$select = 'SELECT rule.* ';
$from = 'FROM ' . EMAIL_FILTER_RULE_TABLE . ' rule ';
$where = 'WHERE rule.filter_id=' . db_input($filter->getId());
$search = false;
if ($_REQUEST['q'] && strlen($_REQUEST['q']) > 3) {
    $search = true;
    if (strpos($_REQUEST['q'], '@') && Validator::is_email($_REQUEST['q'])) {
        $where .= ' AND rule.val=' . db_input($_REQUEST['q']);
    } else {
        $where .= ' AND rule.val LIKE "%' . db_input($_REQUEST['q'], false) . '%"';
    }
} elseif ($_REQUEST['q']) {
    $errors['q'] = 'Term too short!';
}
//TODO: Add search here..
$sortOptions = array('email' => 'rule.val', 'status' => 'isactive', 'created' => 'rule.created', 'created' => 'rule.updated');
$orderWays = array('DESC' => 'DESC', 'ASC' => 'ASC');
$sort = $_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])] ? strtolower($_REQUEST['sort']) : 'email';
//Sorting options...
if ($sort && $sortOptions[$sort]) {
    $order_column = $sortOptions[$sort];
}
$order_column = $order_column ? $order_column : 'rule.val';
if ($_REQUEST['order'] && $orderWays[strtoupper($_REQUEST['order'])]) {
    $order = $orderWays[strtoupper($_REQUEST['order'])];
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:31,代码来源:banlist.inc.php

示例5: save

 function save($id, $vars, &$errors)
 {
     include_once INCLUDE_DIR . 'class.dept.php';
     if ($id && $id != $vars['staff_id']) {
         $errors['err'] = 'Error Interno';
     }
     if (!$vars['firstname'] || !$vars['lastname']) {
         $errors['name'] = 'Nombre y apellidos requerido';
     }
     if (!$vars['username'] || strlen($vars['username']) < 3) {
         $errors['username'] = 'Nombre de usuario requerido';
     } else {
         //check if the username is already in-use.
         $sql = 'SELECT staff_id FROM ' . STAFF_TABLE . ' WHERE username=' . db_input($vars['username']);
         if ($id) {
             $sql .= ' AND staff_id!=' . db_input($id);
         }
         if (db_num_rows(db_query($sql))) {
             $errors['username'] = 'Este nombre de usuario ya esta en uso';
         }
     }
     if (!$vars['email'] || !Validator::is_email($vars['email'])) {
         $errors['email'] = 'Se requiere email Valido';
     } elseif (Email::getIdByEmail($vars['email'])) {
         $errors['email'] = 'Este Email ya se esta usando como Email del sistema';
     }
     if ($vars['phone'] && !Validator::is_phone($vars['phone'])) {
         $errors['phone'] = 'Numero de tel&aacute;fono requerido';
     }
     if ($vars['mobile'] && !Validator::is_phone($vars['mobile'])) {
         $errors['mobile'] = 'Numero de movil Requerido';
     }
     if ($vars['npassword'] || $vars['vpassword'] || !$id) {
         if (!$vars['npassword'] && !$id) {
             $errors['npassword'] = 'Contrase&ntilde;a temporal requerida';
         } elseif ($vars['npassword'] && strcmp($vars['npassword'], $vars['vpassword'])) {
             $errors['vpassword'] = 'La contrase&ntilde;a no coinside';
         } elseif ($vars['npassword'] && strlen($vars['npassword']) < 6) {
             $errors['npassword'] = 'La contrase&ntilde;a debe tener al menos 6 caracteres.';
         }
     }
     if (!$vars['dept_id']) {
         $errors['dept'] = 'Departamento requerido';
     }
     if (!$vars['group_id']) {
         $errors['group'] = 'Grupo requerido';
     }
     if (!$errors) {
         $sql = ' SET updated=NOW() ' . ',isadmin=' . db_input($vars['isadmin']) . ',isactive=' . db_input($vars['isactive']) . ',isvisible=' . db_input(isset($vars['isvisible']) ? 1 : 0) . ',onvacation=' . db_input(isset($vars['onvacation']) ? 1 : 0) . ',dept_id=' . db_input($vars['dept_id']) . ',group_id=' . db_input($vars['group_id']) . ',username=' . db_input(Format::striptags($vars['username'])) . ',firstname=' . db_input(Format::striptags($vars['firstname'])) . ',lastname=' . db_input(Format::striptags($vars['lastname'])) . ',email=' . db_input($vars['email']) . ',phone="' . db_input($vars['phone'], false) . '"' . ',phone_ext=' . db_input($vars['phone_ext']) . ',mobile="' . db_input($vars['mobile'], false) . '"' . ',signature=' . db_input(Format::striptags($vars['signature']));
         if ($vars['npassword']) {
             $sql .= ',passwd=' . db_input(md5($vars['npassword']));
         }
         if (isset($vars['resetpasswd'])) {
             $sql .= ',change_passwd=1';
         }
         if ($id) {
             $sql = 'UPDATE ' . STAFF_TABLE . ' ' . $sql . ' WHERE staff_id=' . db_input($id);
             if (!db_query($sql) || !db_affected_rows()) {
                 $errors['err'] = 'No se puede actualizar el usuario. Error interno';
             }
         } else {
             $sql = 'INSERT INTO ' . STAFF_TABLE . ' ' . $sql . ',created=NOW()';
             if (db_query($sql) && ($uID = db_insert_id())) {
                 return $uID;
             }
             $errors['err'] = 'No se puede crear el usuario. Error interno';
         }
     }
     return $errors ? false : true;
 }
开发者ID:e-gob,项目名称:chilesinpapeleo-soporte,代码行数:70,代码来源:class.staff.php

示例6: array

        case 'install':
            if ($installer->install($_POST)) {
                $_SESSION['info'] = array('name' => ucfirst($_POST['fname'] . ' ' . $_POST['lname']), 'email' => $_POST['admin_email'], 'URL' => URL);
                //TODO: Go to subscribe step.
                $_SESSION['ost_installer']['s'] = 'done';
            } elseif (!($errors = $installer->getErrors()) || !$errors['err']) {
                $errors['err'] = 'Error installing osTicket - correct the errors below and try again.';
            }
            break;
        case 'subscribe':
            if (!trim($_POST['name'])) {
                $errors['name'] = 'Required';
            }
            if (!$_POST['email']) {
                $errors['email'] = 'Required';
            } elseif (!Validator::is_email($_POST['email'])) {
                $errors['email'] = 'Invalid';
            }
            if (!$_POST['alerts'] && !$_POST['news']) {
                $errors['notify'] = 'Check one or more';
            }
            if (!$errors) {
                $_SESSION['ost_installer']['s'] = 'done';
            }
            break;
    }
} elseif ($_GET['s'] && $_GET['s'] == 'ns' && $_SESSION['ost_installer']['s'] == 'subscribe') {
    $_SESSION['ost_installer']['s'] = 'done';
}
switch (strtolower($_SESSION['ost_installer']['s'])) {
    case 'config':
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:31,代码来源:install.php

示例7: define

define('TICKET_MESSAGE_TABLE', TABLE_PREFIX . 'ticket_message');
define('TICKET_RESPONSE_TABLE', TABLE_PREFIX . 'ticket_response');
define('TICKET_ATTACHMENT_TABLE', TABLE_PREFIX . 'ticket_attachment');
define('TICKET_PRIORITY_TABLE', TABLE_PREFIX . 'ticket_priority');
define('TICKET_LOCK_TABLE', TABLE_PREFIX . 'ticket_lock');
define('EMAIL_TABLE', TABLE_PREFIX . 'email');
define('POP3_TABLE', TABLE_PREFIX . 'email_pop3');
define('EMAIL_TEMPLATE_TABLE', TABLE_PREFIX . 'email_template');
define('BANLIST_TABLE', TABLE_PREFIX . 'email_banlist');
define('TIMEZONE_TABLE', TABLE_PREFIX . 'timezone');
#Connect to the DB && get configuration from database
$ferror = null;
$cfg = new Config();
if (!db_connect(DBHOST, DBUSER, DBPASS) || !db_select_database(DBNAME)) {
    $ferror = 'Unable to connect to the DB';
} elseif (!$cfg->load(1)) {
    $ferror = 'Unable to load config info';
}
if ($ferror) {
    //Fatal error
    if (defined(ADMIN_EMAIL) && Validator::is_email(ADMIN_EMAIL)) {
        Misc::sendmail(ADMIN_EMAIL, 'Fatal DB Error', $ferror, ADMIN_EMAIL);
    }
    die("<b>Fatal Error:</b> Contact site admin.");
    exit;
}
//Set default timezone...staff will overwrite it.
list($mysqltz) = db_fetch_row(db_query('SELECT @@session.time_zone '));
$cfg->setMysqlTZ($mysqltz);
$_SESSION['TZ_OFFSET'] = $cfg->getTZoffset();
$_SESSION['daylight'] = $cfg->observeDaylightSaving();
开发者ID:googlecode-mirror,项目名称:barbos,代码行数:31,代码来源:main.inc.php

示例8: save

 function save($id, $vars, &$errors)
 {
     $vars['username'] = Format::striptags($vars['username']);
     $vars['firstname'] = Format::striptags($vars['firstname']);
     $vars['lastname'] = Format::striptags($vars['lastname']);
     if ($id && $id != $vars['id']) {
         $errors['err'] = 'Internal Error';
     }
     if (!$vars['firstname']) {
         $errors['firstname'] = 'First name required';
     }
     if (!$vars['lastname']) {
         $errors['lastname'] = 'Last name required';
     }
     $error = '';
     if (!$vars['username'] || !Validator::is_username($vars['username'], $error)) {
         $errors['username'] = $error ? $error : 'Username required';
     } elseif (($uid = Staff::getIdByUsername($vars['username'])) && $uid != $id) {
         $errors['username'] = 'Username already in use';
     }
     if (!$vars['email'] || !Validator::is_email($vars['email'])) {
         $errors['email'] = 'Valid email required';
     } elseif (Email::getIdByEmail($vars['email'])) {
         $errors['email'] = 'Already in-use system email';
     } elseif (($uid = Staff::getIdByEmail($vars['email'])) && $uid != $id) {
         $errors['email'] = 'Email already in use by another staff member';
     }
     if ($vars['phone'] && !Validator::is_phone($vars['phone'])) {
         $errors['phone'] = 'Valid number required';
     }
     if ($vars['mobile'] && !Validator::is_phone($vars['mobile'])) {
         $errors['mobile'] = 'Valid number required';
     }
     if ($vars['passwd1'] || $vars['passwd2'] || !$id) {
         if ($vars['passwd1'] && strcmp($vars['passwd1'], $vars['passwd2'])) {
             $errors['passwd2'] = 'Password(s) do not match';
         } elseif ($vars['backend'] != 'local' || $vars['welcome_email']) {
             // Password can be omitted
         } elseif (!$vars['passwd1'] && !$id) {
             $errors['passwd1'] = 'Temp. password required';
             $errors['temppasswd'] = 'Required';
         } elseif ($vars['passwd1'] && strlen($vars['passwd1']) < 6) {
             $errors['passwd1'] = 'Must be at least 6 characters';
         }
     }
     if (!$vars['dept_id']) {
         $errors['dept_id'] = 'Department required';
     }
     if (!$vars['group_id']) {
         $errors['group_id'] = 'Group required';
     }
     if (!$vars['timezone_id']) {
         $errors['timezone_id'] = 'Time zone required';
     }
     if ($errors) {
         return false;
     }
     $sql = 'SET updated=NOW() ' . ' ,isadmin=' . db_input($vars['isadmin']) . ' ,isactive=' . db_input($vars['isactive']) . ' ,isvisible=' . db_input(isset($vars['isvisible']) ? 1 : 0) . ' ,onvacation=' . db_input(isset($vars['onvacation']) ? 1 : 0) . ' ,assigned_only=' . db_input(isset($vars['assigned_only']) ? 1 : 0) . ' ,dept_id=' . db_input($vars['dept_id']) . ' ,group_id=' . db_input($vars['group_id']) . ' ,timezone_id=' . db_input($vars['timezone_id']) . ' ,daylight_saving=' . db_input(isset($vars['daylight_saving']) ? 1 : 0) . ' ,username=' . db_input($vars['username']) . ' ,firstname=' . db_input($vars['firstname']) . ' ,lastname=' . db_input($vars['lastname']) . ' ,email=' . db_input($vars['email']) . ' ,backend=' . db_input($vars['backend']) . ' ,phone="' . db_input(Format::phone($vars['phone']), false) . '"' . ' ,phone_ext=' . db_input($vars['phone_ext']) . ' ,mobile="' . db_input(Format::phone($vars['mobile']), false) . '"' . ' ,signature=' . db_input(Format::sanitize($vars['signature'])) . ' ,notes=' . db_input(Format::sanitize($vars['notes']));
     if ($vars['passwd1']) {
         $sql .= ' ,passwd=' . db_input(Passwd::hash($vars['passwd1']));
         if (isset($vars['change_passwd'])) {
             $sql .= ' ,change_passwd=1';
         }
     } elseif (!isset($vars['change_passwd'])) {
         $sql .= ' ,change_passwd=0';
     }
     if ($id) {
         $sql = 'UPDATE ' . STAFF_TABLE . ' ' . $sql . ' WHERE staff_id=' . db_input($id);
         if (db_query($sql) && db_affected_rows()) {
             return true;
         }
         $errors['err'] = 'Unable to update the user. Internal error occurred';
     } else {
         $sql = 'INSERT INTO ' . STAFF_TABLE . ' ' . $sql . ', created=NOW()';
         if (db_query($sql) && ($uid = db_insert_id())) {
             return $uid;
         }
         $errors['err'] = 'Unable to create user. Internal error';
     }
     return false;
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:81,代码来源:class.staff.php

示例9: update

 function update($vars, &$errors)
 {
     $valid = true;
     $forms = $this->getForms($vars);
     foreach ($forms as $cd) {
         if (!$cd->isValid()) {
             $valid = false;
         }
         if ($cd->get('type') == 'O' && ($form = $cd->getForm($vars)) && ($f = $form->getField('name')) && $f->getClean() && ($o = Organization::lookup(array('name' => $f->getClean()))) && $o->id != $this->getId()) {
             $valid = false;
             $f->addError('Organization with the same name already exists');
         }
     }
     if ($vars['domain']) {
         foreach (explode(',', $vars['domain']) as $d) {
             if (!Validator::is_email('t@' . trim($d))) {
                 $errors['domain'] = 'Enter a valid email domain, like domain.com';
             }
         }
     }
     if ($vars['manager']) {
         switch ($vars['manager'][0]) {
             case 's':
                 if ($staff = Staff::lookup(substr($vars['manager'], 1))) {
                     break;
                 }
             case 't':
                 if ($vars['manager'][0] == 't' && ($team = Team::lookup(substr($vars['manager'], 1)))) {
                     break;
                 }
             default:
                 $errors['manager'] = 'Select a staff member or team from the list';
         }
     }
     if (!$valid || $errors) {
         return false;
     }
     foreach ($this->getDynamicData() as $cd) {
         if (($f = $cd->getForm()) && $f->get('type') == 'O' && ($name = $f->getField('name'))) {
             $this->name = $name->getClean();
             $this->save();
         }
         $cd->save();
     }
     // Set flags
     foreach (array('collab-all-flag' => Organization::COLLAB_ALL_MEMBERS, 'collab-pc-flag' => Organization::COLLAB_PRIMARY_CONTACT, 'assign-am-flag' => Organization::ASSIGN_AGENT_MANAGER) as $ck => $flag) {
         if ($vars[$ck]) {
             $this->setStatus($flag);
         } else {
             $this->clearStatus($flag);
         }
     }
     // Set staff and primary contacts
     $this->set('domain', $vars['domain']);
     $this->set('manager', $vars['manager'] ?: '');
     if ($vars['contacts'] && is_array($vars['contacts'])) {
         foreach ($this->allMembers() as $u) {
             $u->setPrimaryContact(array_search($u->id, $vars['contacts']) !== false);
             $u->save();
         }
     }
     return $this->save();
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:63,代码来源:class.organization.php

示例10: create

 function create($vars, &$errors, $origin, $autorespond = true, $alertstaff = true)
 {
     global $cfg, $thisclient, $_FILES;
     //Check for 403
     if ($vars['email'] && Validator::is_email($vars['email'])) {
         //Make sure the email address is not banned
         if (EmailFilter::isBanned($vars['email'])) {
             $errors['err'] = 'Ticket denied. Error #403';
             Sys::log(LOG_WARNING, 'Ticket denied', 'Banned email - ' . $vars['email']);
             return 0;
         }
         //Make sure the open ticket limit hasn't been reached. (LOOP CONTROL)
         if ($cfg->getMaxOpenTickets() > 0 && strcasecmp($origin, 'staff') && ($client = Client::lookupByEmail($vars['email'])) && ($openTickets = $client->getNumOpenTickets()) && $opentickets >= $cfg->getMaxOpenTickets()) {
             $errors['err'] = "You've reached the maximum open tickets allowed.";
             Sys::log(LOG_WARNING, 'Ticket denied -' . $vars['email'], sprintf('Max open tickets (%d) reached for %s ', $cfg->getMaxOpenTickets(), $vars['email']));
             return 0;
         }
     }
     // Make sure email contents should not be rejected
     if (($email_filter = new EmailFilter($vars)) && ($filter = $email_filter->shouldReject())) {
         $errors['err'] = 'Ticket denied. Error #403';
         Sys::log(LOG_WARNING, 'Ticket denied', sprintf('Banned email - %s by filter "%s"', $vars['email'], $filter->getName()));
         return 0;
     }
     $id = 0;
     $fields = array();
     $fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
     $fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
     $fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
     $fields['message'] = array('type' => 'text', 'required' => 1, 'error' => 'Message required');
     switch (strtolower($origin)) {
         case 'web':
             $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Select help topic');
             break;
         case 'staff':
             $fields['deptId'] = array('type' => 'int', 'required' => 1, 'error' => 'Dept. required');
             $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Topic required');
             $fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY');
         case 'api':
             $fields['source'] = array('type' => 'string', 'required' => 1, 'error' => 'Indicate source');
             break;
         case 'email':
             $fields['emailId'] = array('type' => 'int', 'required' => 1, 'error' => 'Email unknown');
             break;
         default:
             # TODO: Return error message
             $errors['err'] = $errors['origin'] = 'Invalid origin given';
     }
     $fields['priorityId'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
     $fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Valid phone # required');
     if (!Validator::process($fields, $vars, $errors) && !$errors['err']) {
         $errors['err'] = 'Missing or invalid data - check the errors and try again';
     }
     //Make sure phone extension is valid
     if ($vars['phone_ext']) {
         if (!is_numeric($vars['phone_ext']) && !$errors['phone']) {
             $errors['phone'] = 'Invalid phone ext.';
         } elseif (!$vars['phone']) {
             //make sure they just didn't enter ext without phone # XXX: reconsider allowing!
             $errors['phone'] = 'Phone number required';
         }
     }
     //Make sure the due date is valid
     if ($vars['duedate']) {
         if (!$vars['time'] || strpos($vars['time'], ':') === false) {
             $errors['time'] = 'Select time';
         } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) === false) {
             $errors['duedate'] = 'Invalid duedate';
         } elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) <= time()) {
             $errors['duedate'] = 'Due date must be in the future';
         }
     }
     # Perform email filter actions on the new ticket arguments XXX: Move filter to the top and check for reject...
     if (!$errors && $email_filter) {
         $email_filter->apply($vars);
     }
     # Some things will need to be unpacked back into the scope of this
     # function
     if (isset($vars['autorespond'])) {
         $autorespond = $vars['autorespond'];
     }
     //Any error above is fatal.
     if ($errors) {
         return 0;
     }
     // OK...just do it.
     $deptId = $vars['deptId'];
     //pre-selected Dept if any.
     $priorityId = $vars['priorityId'];
     $source = ucfirst($vars['source']);
     $topic = NULL;
     // Intenal mapping magic...see if we need to overwrite anything
     if (isset($vars['topicId']) && ($topic = Topic::lookup($vars['topicId']))) {
         //Ticket created via web by user/or staff
         $deptId = $deptId ? $deptId : $topic->getDeptId();
         $priorityId = $priorityId ? $priorityId : $topic->getPriorityId();
         if ($autorespond) {
             $autorespond = $topic->autoRespond();
         }
         $source = $vars['source'] ? $vars['source'] : 'Web';
//.........这里部分代码省略.........
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:101,代码来源:class.ticket.php

示例11: save

 function save($id, $vars, &$errors)
 {
     global $cfg;
     //very basic checks
     if ($id && $id != $vars['email_id']) {
         $errors['err'] = 'Erro interno.';
     }
     if (!$vars['email'] || !Validator::is_email($vars['email'])) {
         $errors['email'] = 'Email válido obrigatório';
     } elseif (($eid = Email::getIdByEmail($vars['email'])) && $eid != $id) {
         $errors['email'] = 'Email já existe.';
     } elseif (!strcasecmp($cfg->getAdminEmail(), $vars['email'])) {
         $errors['email'] = 'Email já usado como email do administrador!';
     } else {
         //make sure the email doesn't belong to any of the staff
         $sql = 'SELECT staff_id FROM ' . STAFF_TABLE . ' WHERE email=' . db_input($vars['email']);
         if (($res = db_query($sql)) && db_num_rows($res)) {
             $errors['email'] = 'Email em uso por um membro do suporte.';
         }
     }
     if (!$vars['dept_id'] || !is_numeric($vars['dept_id'])) {
         $errors['dept_id'] = 'Você deve selecionar um departamento.';
     }
     if (!$vars['priority_id']) {
         $errors['priority_id'] = 'Você deve selecionar uma prioridade';
     }
     if ($vars['mail_active'] || $vars['smtp_active'] && $vars['smtp_auth']) {
         if (!$vars['userid']) {
             $errors['userid'] = 'Nome de usuário ausente';
         }
         if (!$vars['userpass']) {
             $errors['userpass'] = 'Senha obrigatória';
         }
     }
     if ($vars['mail_active']) {
         //Check pop/imapinfo only when enabled.
         if (!function_exists('imap_open')) {
             $errors['mail_active'] = 'IMAP não existe. PHP deve ser compilado com IMAP habilitado.';
         }
         if (!$vars['mail_host']) {
             $errors['mail_host'] = 'Nome do host obrigatório';
         }
         if (!$vars['mail_port']) {
             $errors['mail_port'] = 'Porta obrigatória';
         }
         if (!$vars['mail_protocol']) {
             $errors['mail_protocol'] = 'Selecione protocolo';
         }
         if (!$vars['mail_fetchfreq'] || !is_numeric($vars['mail_fetchfreq'])) {
             $errors['mail_fetchfreq'] = 'Buscar intervalo obrigatório';
         }
         if (!$vars['mail_fetchmax'] || !is_numeric($vars['mail_fetchmax'])) {
             $errors['mail_fetchmax'] = 'Máximo de emails exigidos';
         }
     }
     if ($vars['smtp_active']) {
         if (!$vars['smtp_host']) {
             $errors['smtp_host'] = 'Nome do host obrigatório';
         }
         if (!$vars['smtp_port']) {
             $errors['smtp_port'] = 'Porta obrigatória';
         }
     }
     if (!$errors && ($vars['mail_host'] && $vars['userid'])) {
         $sql = 'SELECT email_id FROM ' . EMAIL_TABLE . ' WHERE mail_host=' . db_input($vars['mail_host']) . ' AND userid=' . db_input($vars['userid']);
         if ($id) {
             $sql .= ' AND email_id!=' . db_input($id);
         }
         if (db_num_rows(db_query($sql))) {
             $errors['userid'] = $errors['host'] = 'Outro departamento está usando combinação de nome/host.';
         }
     }
     if (!$errors && $vars['mail_active']) {
         //note: password is unencrypted at this point...MailFetcher expect plain text.
         $fetcher = new MailFetcher($vars['userid'], $vars['userpass'], $vars['mail_host'], $vars['mail_port'], $vars['mail_protocol'], $vars['mail_encryption']);
         if (!$fetcher->connect()) {
             $errors['userpass'] = '<br>Login Inválido. Verifique as ' . $vars['mail_protocol'] . ' configurações';
             $errors['mail'] = '<br>' . $fetcher->getLastError();
         }
     }
     if (!$errors && $vars['smtp_active']) {
         //Check SMTP login only.
         require_once 'Mail.php';
         // PEAR Mail package
         $smtp = mail::factory('smtp', array('host' => $vars['smtp_host'], 'port' => $vars['smtp_port'], 'auth' => $vars['smtp_auth'] ? true : false, 'username' => $vars['userid'], 'password' => $vars['userpass'], 'timeout' => 20, 'debug' => false));
         $mail = $smtp->connect();
         if (PEAR::isError($mail)) {
             $errors['userpass'] = '<br>Incapaz de fazer o login. Verifique as configurações SMTP.';
             $errors['smtp'] = '<br>' . $mail->getMessage();
         } else {
             $smtp->disconnect();
             //Thank you, sir!
         }
     }
     if (!$errors) {
         $sql = 'updated=NOW(),mail_errors=0, mail_lastfetch=NULL' . ',email=' . db_input($vars['email']) . ',name=' . db_input(Format::striptags($vars['name'])) . ',dept_id=' . db_input($vars['dept_id']) . ',priority_id=' . db_input($vars['priority_id']) . ',noautoresp=' . db_input(isset($vars['noautoresp']) ? 1 : 0) . ',userid=' . db_input($vars['userid']) . ',userpass=' . db_input(Misc::encrypt($vars['userpass'], SECRET_SALT)) . ',mail_active=' . db_input($vars['mail_active']) . ',mail_host=' . db_input($vars['mail_host']) . ',mail_protocol=' . db_input($vars['mail_protocol'] ? $vars['mail_protocol'] : 'POP') . ',mail_encryption=' . db_input($vars['mail_encryption']) . ',mail_port=' . db_input($vars['mail_port'] ? $vars['mail_port'] : 0) . ',mail_fetchfreq=' . db_input($vars['mail_fetchfreq'] ? $vars['mail_fetchfreq'] : 0) . ',mail_fetchmax=' . db_input($vars['mail_fetchmax'] ? $vars['mail_fetchmax'] : 0) . ',mail_delete=' . db_input(isset($vars['mail_delete']) ? $vars['mail_delete'] : 0) . ',smtp_active=' . db_input($vars['smtp_active']) . ',smtp_host=' . db_input($vars['smtp_host']) . ',smtp_port=' . db_input($vars['smtp_port'] ? $vars['smtp_port'] : 0) . ',smtp_auth=' . db_input($vars['smtp_auth']);
         if ($id) {
             //update
             $sql = 'UPDATE ' . EMAIL_TABLE . ' SET ' . $sql . ' WHERE email_id=' . db_input($id);
             if (!db_query($sql) || !db_affected_rows()) {
//.........这里部分代码省略.........
开发者ID:ricardowarhead,项目名称:osticket_pt_BR,代码行数:101,代码来源:class.email.php

示例12: _t

			if (strlen($_POST['userpw']) < 4) {
				$errors['userpw3'] = _t('비밀번호는 4자 이상으로 해 주세요.');
			}
		}

		if (empty($_POST['useremail'])) {
			$errors['useremail1'] =  _t('이메일 주소를 입력해주세요.');
		}
		
	}

	if (!empty($_POST['userid']) && !empty($_POST['userpw']) && !empty($_POST['useremail'])) {
		if (!Validator::is_alnum($_POST['userid'])) {
			$errors['userid2'] = _t('아이디에 잘못된 문자가 포함되어 있습니다.');
		}
		if (!Validator::is_email($_POST['useremail'])) {
			$errors['useremail2'] =  _t('이메일 주소가 잘못되었습니다.');
		}
		if ($_POST['userpw'] != $_POST['userpw2']) {
			$errors['userpw4'] = _t('두 비밀번호가 일치하지 않습니다.');
		}

		if (count($errors) == 0) {
			requireComponent('Bloglounge.Model.Users');
			if (User::doesLoginIdExists($_POST['userid'])) {
				$errors['userid4'] = _t('이미 존재하는 아이디입니다.');
			} else {
				if (User::add($_POST['userid'], $_POST['userpw'], $_POST['username'], $_POST['useremail'])) {
					login($_POST['userid'], $_POST['userpw'], false);
				} else {
					$errors['usererror'] = _t('회원가입에 실패했습니다.');
开发者ID:ncloud,项目名称:bloglounge,代码行数:31,代码来源:join.php

示例13: open

 static function open($vars, &$errors)
 {
     global $thisstaff, $cfg;
     if (!$thisstaff || !$thisstaff->canCreateTickets()) {
         return false;
     }
     if ($vars['source'] && !in_array(strtolower($vars['source']), array('email', 'phone', 'other'))) {
         $errors['source'] = 'Invalid source - ' . Format::htmlchars($vars['source']);
     }
     if (!$vars['uid']) {
         //Special validation required here
         if (!$vars['email'] || !Validator::is_email($vars['email'])) {
             $errors['email'] = 'Valid email required';
         }
         if (!$vars['name']) {
             $errors['name'] = 'Name required';
         }
     }
     if (!$thisstaff->canAssignTickets()) {
         unset($vars['assignId']);
     }
     if (!($ticket = Ticket::create($vars, $errors, 'staff', false))) {
         return false;
     }
     $vars['msgId'] = $ticket->getLastMsgId();
     // post response - if any
     $response = null;
     if ($vars['response'] && $thisstaff->canPostReply()) {
         // unpack any uploaded files into vars.
         if ($_FILES['attachments']) {
             $vars['files'] = AttachmentFile::format($_FILES['attachments']);
         }
         $vars['response'] = $ticket->replaceVars($vars['response']);
         if ($response = $ticket->postReply($vars, $errors, false)) {
             //Only state supported is closed on response
             if (isset($vars['ticket_state']) && $thisstaff->canCloseTickets()) {
                 $ticket->setState($vars['ticket_state']);
             }
         }
     }
     // Not assigned...save optional note if any
     if (!$vars['assignId'] && $vars['note']) {
         $ticket->logNote('New Ticket', $vars['note'], $thisstaff, false);
     } else {
         // Not assignment and no internal note - log activity
         $ticket->logActivity('New Ticket by Staff', 'Ticket created by staff -' . $thisstaff->getName());
     }
     $ticket->reload();
     if (!$cfg->notifyONNewStaffTicket() || !isset($vars['alertuser']) || !($dept = $ticket->getDept())) {
         return $ticket;
     }
     //No alerts.
     //Send Notice to user --- if requested AND enabled!!
     if (($tpl = $dept->getTemplate()) && ($msg = $tpl->getNewTicketNoticeMsgTemplate()) && ($email = $dept->getEmail())) {
         $message = (string) $ticket->getLastMessage();
         if ($response) {
             $message .= $cfg->isHtmlThreadEnabled() ? "<br><br>" : "\n\n";
             $message .= $response->getBody();
         }
         if ($vars['signature'] == 'mine') {
             $signature = $thisstaff->getSignature();
         } elseif ($vars['signature'] == 'dept' && $dept && $dept->isPublic()) {
             $signature = $dept->getSignature();
         } else {
             $signature = '';
         }
         $attachments = $cfg->emailAttachments() && $response ? $response->getAttachments() : array();
         $msg = $ticket->replaceVars($msg->asArray(), array('message' => $message, 'signature' => $signature, 'response' => $response ? $response->getBody() : '', 'recipient' => $ticket->getOwner(), 'staff' => $thisstaff));
         $references = $ticket->getLastMessage()->getEmailMessageId();
         if (isset($response)) {
             $references = array($response->getEmailMessageId(), $references);
         }
         $options = array('references' => $references, 'thread' => $ticket->getLastMessage());
         $email->send($ticket->getEmail(), $msg['subj'], $msg['body'], $attachments, $options);
     }
     return $ticket;
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:77,代码来源:class.ticket.php

示例14: tryLogin

 function tryLogin($ticketID, $email, $auth = null)
 {
     global $ost;
     $cfg = $ost->getConfig();
     # Only consider auth token for GET requests, and for GET requests,
     # REQUIRE the auth token
     $auto_login = $_SERVER['REQUEST_METHOD'] == 'GET';
     //Check time for last max failed login attempt strike.
     $loginmsg = 'Invalid login';
     # XXX: SECURITY: Max attempts is enforced client-side via the PHP
     #      session cookie.
     if ($_SESSION['_client']['laststrike']) {
         if (time() - $_SESSION['_client']['laststrike'] < $cfg->getClientLoginTimeout()) {
             $loginmsg = 'Excessive failed login attempts';
             $errors['err'] = 'You\'ve reached maximum failed login attempts allowed. Try again later or <a href="open.php">open a new ticket</a>';
         } else {
             //Timeout is over.
             //Reset the counter for next round of attempts after the timeout.
             $_SESSION['_client']['laststrike'] = null;
             $_SESSION['_client']['strikes'] = 0;
         }
     }
     //See if we can fetch local ticket id associated with the ID given
     if (!$errors && is_numeric($ticketID) && Validator::is_email($email) && ($ticket = Ticket::lookupByExtId($ticketID))) {
         //At this point we know the ticket is valid.
         //TODO: 1) Check how old the ticket is...3 months max?? 2) Must be the latest 5 tickets??
         //Check the email given.
         # Require auth token for automatic logins
         if (!$auto_login || $auth === $ticket->getAuthToken()) {
             if ($ticket->getId() && strcasecmp($ticket->getEmail(), $email) == 0) {
                 //valid match...create session goodies for the client.
                 $user = new ClientSession($email, $ticket->getId());
                 $_SESSION['_client'] = array();
                 //clear.
                 $_SESSION['_client']['userID'] = $ticket->getEmail();
                 //Email
                 $_SESSION['_client']['key'] = $ticket->getExtId();
                 //Ticket ID --acts as password when used with email. See above.
                 $_SESSION['_client']['token'] = $user->getSessionToken();
                 $_SESSION['TZ_OFFSET'] = $cfg->getTZoffset();
                 $_SESSION['TZ_DST'] = $cfg->observeDaylightSaving();
                 //Log login info...
                 $msg = sprintf("%s/%s logged in [%s]", $ticket->getEmail(), $ticket->getExtId(), $_SERVER['REMOTE_ADDR']);
                 $ost->logDebug('User login', $msg);
                 //Redirect tickets.php
                 session_write_close();
                 session_regenerate_id();
                 @header("Location: tickets.php?id=" . $ticket->getExtId());
                 require_once 'tickets.php';
                 //Just incase. of header already sent error.
                 exit;
             }
         }
     }
     //If we get to this point we know the login failed.
     $_SESSION['_client']['strikes'] += 1;
     if (!$errors && $_SESSION['_client']['strikes'] > $cfg->getClientMaxLogins()) {
         $loginmsg = 'Access Denied';
         $errors['err'] = 'Forgot your login info? Please <a href="open.php">open a new ticket</a>.';
         $_SESSION['_client']['laststrike'] = time();
         $alert = 'Excessive login attempts by a client?' . "\n" . 'Email: ' . $_POST['lemail'] . "\n" . 'Ticket#: ' . $_POST['lticket'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'Time:' . date('M j, Y, g:i a T') . "\n\n" . 'Attempts #' . $_SESSION['_client']['strikes'];
         $ost->logError('Excessive login attempts (client)', $alert, $cfg->alertONLoginError());
     } elseif ($_SESSION['_client']['strikes'] % 2 == 0) {
         //Log every other failed login attempt as a warning.
         $alert = 'Email: ' . $_POST['lemail'] . "\n" . 'Ticket #: ' . $_POST['lticket'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'TIME: ' . date('M j, Y, g:i a T') . "\n\n" . 'Attempts #' . $_SESSION['_client']['strikes'];
         $ost->logWarning('Failed login attempt (client)', $alert);
     }
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:68,代码来源:class.client.php

示例15: save

 function save($id, $vars, &$errors)
 {
     $vars['username'] = Format::striptags($vars['username']);
     $vars['firstname'] = Format::striptags($vars['firstname']);
     $vars['lastname'] = Format::striptags($vars['lastname']);
     if ($id && $id != $vars['id']) {
         $errors['err'] = __('Internal Error');
     }
     if (!$vars['firstname']) {
         $errors['firstname'] = __('First name required');
     }
     if (!$vars['lastname']) {
         $errors['lastname'] = __('Last name required');
     }
     $error = '';
     if (!$vars['username'] || !Validator::is_username($vars['username'], $error)) {
         $errors['username'] = $error ? $error : __('Username is required');
     } elseif (($uid = Staff::getIdByUsername($vars['username'])) && $uid != $id) {
         $errors['username'] = __('Username already in use');
     }
     if (!$vars['email'] || !Validator::is_email($vars['email'])) {
         $errors['email'] = __('Valid email is required');
     } elseif (Email::getIdByEmail($vars['email'])) {
         $errors['email'] = __('Already in use system email');
     } elseif (($uid = Staff::getIdByEmail($vars['email'])) && $uid != $id) {
         $errors['email'] = __('Email already in use by another agent');
     }
     if ($vars['phone'] && !Validator::is_phone($vars['phone'])) {
         $errors['phone'] = __('Valid phone number is required');
     }
     if ($vars['mobile'] && !Validator::is_phone($vars['mobile'])) {
         $errors['mobile'] = __('Valid phone number is required');
     }
     if ($vars['passwd1'] || $vars['passwd2'] || !$id) {
         if ($vars['passwd1'] && strcmp($vars['passwd1'], $vars['passwd2'])) {
             $errors['passwd2'] = __('Passwords do not match');
         } elseif ($vars['backend'] != 'local' || $vars['welcome_email']) {
             // Password can be omitted
         } elseif (!$vars['passwd1'] && !$id) {
             $errors['passwd1'] = __('Temporary password is required');
             $errors['temppasswd'] = __('Required');
         } elseif ($vars['passwd1'] && strlen($vars['passwd1']) < 6) {
             $errors['passwd1'] = __('Password must be at least 6 characters');
         }
     }
     if (!$vars['dept_id']) {
         $errors['dept_id'] = __('Department is required');
     }
     if (!$vars['group_id']) {
         $errors['group_id'] = __('Group is required');
     }
     if (!$vars['timezone_id']) {
         $errors['timezone_id'] = __('Time zone selection is required');
     }
     // Ensure we will still have an administrator with access
     if ($vars['isadmin'] !== '1' || $vars['isactive'] !== '1') {
         $sql = 'select count(*), max(staff_id) from ' . STAFF_TABLE . ' WHERE isadmin=1 and isactive=1';
         if (($res = db_query($sql)) && (list($count, $sid) = db_fetch_row($res))) {
             if ($count == 1 && $sid == $id) {
                 $errors['isadmin'] = __('Cowardly refusing to remove or lock out the only active administrator');
             }
         }
     }
     if ($errors) {
         return false;
     }
     $sql = 'SET updated=NOW() ' . ' ,isadmin=' . db_input($vars['isadmin']) . ' ,isactive=' . db_input($vars['isactive']) . ' ,isvisible=' . db_input(isset($vars['isvisible']) ? 1 : 0) . ' ,onvacation=' . db_input(isset($vars['onvacation']) ? 1 : 0) . ' ,assigned_only=' . db_input(isset($vars['assigned_only']) ? 1 : 0) . ' ,dept_id=' . db_input($vars['dept_id']) . ' ,group_id=' . db_input($vars['group_id']) . ' ,timezone_id=' . db_input($vars['timezone_id']) . ' ,daylight_saving=' . db_input(isset($vars['daylight_saving']) ? 1 : 0) . ' ,username=' . db_input($vars['username']) . ' ,firstname=' . db_input($vars['firstname']) . ' ,lastname=' . db_input($vars['lastname']) . ' ,email=' . db_input($vars['email']) . ' ,backend=' . db_input($vars['backend']) . ' ,phone="' . db_input(Format::phone($vars['phone']), false) . '"' . ' ,phone_ext=' . db_input($vars['phone_ext']) . ' ,mobile="' . db_input(Format::phone($vars['mobile']), false) . '"' . ' ,signature=' . db_input(Format::sanitize($vars['signature'])) . ' ,notes=' . db_input(Format::sanitize($vars['notes']));
     if ($vars['passwd1']) {
         $sql .= ' ,passwd=' . db_input(Passwd::hash($vars['passwd1']));
         if (isset($vars['change_passwd'])) {
             $sql .= ' ,change_passwd=1';
         }
     } elseif (!isset($vars['change_passwd'])) {
         $sql .= ' ,change_passwd=0';
     }
     if ($id) {
         $sql = 'UPDATE ' . STAFF_TABLE . ' ' . $sql . ' WHERE staff_id=' . db_input($id);
         if (db_query($sql) && db_affected_rows()) {
             return true;
         }
         $errors['err'] = sprintf(__('Unable to update %s.'), __('this agent')) . ' ' . __('Internal error occurred');
     } else {
         $sql = 'INSERT INTO ' . STAFF_TABLE . ' ' . $sql . ', created=NOW()';
         if (db_query($sql) && ($uid = db_insert_id())) {
             return $uid;
         }
         $errors['err'] = sprintf(__('Unable to create %s.'), __('this agent')) . ' ' . __('Internal error occurred');
     }
     return false;
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:90,代码来源:class.staff.php


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