Ejemplo n.º 1
0
 protected function validate()
 {
     parent::validate();
     if ($this->getIsValid() && !preg_match("/^([a-z0-9])([a-z0-9-_.]+)@([a-z0-9])([a-z0-9-_]+\\.)+([a-z]{2,4})\$/i", $this->getValue())) {
         $this->errors[] = 'error_invalidEmail';
     }
 }
Ejemplo n.º 2
0
 /**
  * Refreshes the properties of the class
  * @param  string $id_field Column to identify the user with
  * @param  string $field_id Value of the identification column
  * @return void
  */
 public function refreshCache($id_field, $field_id)
 {
     foreach (Sql::Query("SELECT * FROM accounts WHERE {$id_field} = '" . $field_id . "'") as $i) {
         foreach ($i as $key => $i2) {
             if (Text::validate($key, 'num')) {
                 continue;
             }
             $this->{$key} = $i2;
         }
     }
 }
Ejemplo n.º 3
0
 public function validate()
 {
     $result = parent::validate();
     if ($result) {
         if (!is_numeric($this->value()) && $this->value() != '0') {
             $result = false;
             $this->invalidate('Value is not a number');
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function validate()
 {
     $result = parent::validate();
     if ($result) {
         $result = filter_var($this->value(), FILTER_VALIDATE_EMAIL);
         if (!$result) {
             $this->invalidate('Value must be a valid email address `youremail@yourdomain.com` ');
         }
     }
     return $result;
 }
 public function validate($val)
 {
     if (!empty($this->error)) {
         return false;
     }
     if (parent::validate($val)) {
         if (Useful::stripper($val) !== false) {
             if (strlen($val) < $this->min_length) {
                 $this->error[] = sprintf('must be more than %s characters', $this->min_length);
             }
             if ($this->alphanumeric && (!preg_match("#[A-Za-z]+#", $val) || !preg_match("#[0-9]+#", $val))) {
                 $this->error[] = 'must have at least one alphabetic character and one numeric character';
             }
         }
     }
     if ($this->confirm) {
         if ($val != $_POST[$this->confirm]) {
             $form = NibbleForm::getInstance();
             $form->{$this->confirm}->error[] = 'must match password';
         }
     }
     return !empty($this->error) ? false : true;
 }
Ejemplo n.º 6
0
require_once 'system/nlb_mail.class.php';
require_once 'system/text.class.php';
require_once 'ets.php';
$db = new sqldb2($DB_CONFIG);
$user = new nlb_user($db);
$config = new nlb_config($db);
$blog = new nlb_blog($db);
$user->checkLogin();
// check for loged in user.
if ($user->isLogedIn) {
    jsRedirect("index.php");
}
include $config->langfile();
$start = mymicrotime();
$text = new Text($_POST, array('username', 'password', 'confirm-password', 'email', 'template', 'timezone'), array('custom'));
$text->validate();
$clean = $text->clean;
$baddata = false;
$problems = array();
if (!empty($_POST)) {
    if ($text->is_missing_required) {
        $baddata = true;
    }
    // if there was good submitted data...
    if ($clean['password'] != $clean['confirm-password']) {
        $baddata = true;
        $problems[] = $l['reg-badpassword'];
    }
    // valid email?
    if (!pear_check_email($clean['email'])) {
        $baddata = true;
Ejemplo n.º 7
0
 /**
  * Checks if an user exists
  * @param  string $id_field Field to identify the user with
  * @return bool             Returns true if the query was successful
  */
 static function userExists($id_field)
 {
     if (!Text::validate($id_field, 'num')) {
         $quote = "'";
     } else {
         $quote = '';
     }
     if (Sql::numRows("SELECT " . self::$id_field . " FROM accounts WHERE " . self::$id_field . " = " . $quote . $id_field . $quote) < 1) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 8
0
 /**
  * Verifies if an email is correctly formatted (Alias of Text::validate)
  * @param  string  $email Email to check
  * @return boolean        Returns true if the email is valid
  */
 static function isValid($email)
 {
     return Text::validate($email, 'email');
 }