/**
  * 测试验证类
  *
  */
 public function test()
 {
     $validator = new YUN_Validator();
     $email = 'dddd..*';
     $validator->check($email, array(array('NotEmpty', '用户名不允许为空'), array('StringLength' => array(4, 60), '用户名必须介于 4~60 个字符之间'), array('Regex' => "/^[^\\'\"\\:;,\\<\\>\\?\\/\\\\*\\=\\+\\{\\}\\[\\]\\)\\(\\^%\$#\\!`\\s ]+\$/", '用户名包含非法字符')));
     //数据校验
     if (!$validator->isValid()) {
         throw new Exception($validator->getMessage());
     }
 }
Exemplo n.º 2
0
 /**
  * 修改资料
  * @param string $uid
  * @param array $info
  */
 public function updateInfo($uid, $data)
 {
     $info = array();
     $validator = new YUN_Validator();
     $where = $this->db->quoteInto('uid=?', $uid);
     $user = $this->db->fetchRow($this->infoSql($where));
     if (empty($user)) {
         throw new Zend_Exception("用户ID '{$uid}' 不存在");
     }
     if (!empty($data['password'])) {
         //密码有变动
         $validator->check($data['password'], array(array('StringLength' => array(6, 50), '密码必须介于 6~50 个字符之间')))->check($data['confirmPwd'], array(array('NotEmpty', '确认密码不允许为空'), array('Equal' => $data['password'], '两次输入的密码不一致')));
         $info['password'] = md5(md5($data['password']));
         $info['salt'] = '';
     }
     //数据校验
     if (!$validator->isValid()) {
         throw new Zend_Exception($validator->getMessage());
     }
     if (!empty($info)) {
         $where = $this->db->quoteInto('uid=?', $uid);
         $this->db->update('user', $info, $where);
     }
 }