Esempio n. 1
0
 /**
  * Lenght: 8
  * Formato: 99999-999
  * @param type $cep
  * @return type
  */
 public static function cep($cep)
 {
     if (VALIDAR::cep($cep)) {
         $cep = preg_replace('/[^0-9]/', '', $cep);
         return preg_replace('/([0-9]{5})([0-9]{3})/', '$1-$2', $cep);
     }
     return null;
 }
Esempio n. 2
0
 function getEmail()
 {
     return VALIDAR::email($this->Email) ? strtolower($this->Email) : null;
 }
Esempio n. 3
0
 function check()
 {
     /** @var usersModel */
     $model = APP::getInstance('UsersModel');
     # Tipo de conta
     if (!$model->getType($this->getType())) {
         throw new Exception('Tipo inválido.');
     }
     # E-mail
     if ($this->Email and !$this->getEmail()) {
         throw new Exception('E-mail inválido.');
     } else {
         if ($this->getEmail() and count($model->Lista('WHERE a.email = :email AND a.id != :id LIMIT 1', ['email' => $this->getEmail(), 'id' => $this->getId()]))) {
             throw new Exception('E-mail já está sendo utilizado por outro usuário.');
         }
     }
     # Login
     if (is_string($teste = VALIDAR::username($this->Login))) {
         throw new Exception(strip_tags($teste));
     }
     # Criptografando a senha
     if (strlen($this->Senha) != PASSWORD_LENG) {
         if (is_string($teste = VALIDAR::password($this->Senha))) {
             throw new Exception(strip_tags($teste));
         }
         $this->Senha = password($this->Senha);
     }
     return true;
 }