public function is_valid($reg = false) { global $DB; $errors = array(); if ($this->born != "") { $this->birthday = $this->born; } $this->birthday = str_replace('.', '-', $this->birthday); $this->birthday = trim($this->birthday, '-'); if ($this->full_name == "") { $errors['full_name'][] = "A teljes név megadása kötelező!"; } elseif (strlen($this->full_name) > 100) { $errors['full_name'][] = "A teljes név maximum 100 karakter hosszú lehet!"; } if ($this->username == "") { $errors['username'][] = "A felhasználónév megadása kötelező!"; } elseif (strlen($this->username) > 50) { $errors['username'][] = "A felhasználónév maximum 50 karakter hosszú lehet!"; } elseif ($reg === true) { $sth = $DB->prepare('SELECT COUNT(*) FROM users WHERE username=:username'); $sth->bindParam(':username', $this->username, PDO::PARAM_STR); $sth->execute(); if ($sth->fetchColumn() > 0) { $errors['username'][] = "Ez a felhasználónév már foglalt!"; } } if ($reg === true && $this->password == "") { $errors['password'][] = "A jelszó megadása kötelező!"; } elseif (strlen($this->password) > 50) { $errors['password'][] = "A jelszó maximum 50 karakter hosszú lehet!"; } elseif ($this->password != "" && $this->password != $this->password2) { $errors['password'][] = "Nem egyezik meg a két jelszó!"; } if ($this->email == "") { $errors['email'][] = "Az email cím megadása kötelező!"; } elseif (@(!STRING::validEmail($this->email))) { $errors['email'][] = "Hibás email cím!"; } elseif (strlen($this->email) > 200) { $errors['email'][] = "Az email cím maximum 200 karakter hosszú lehet!"; } elseif ($reg === true) { $sth = $DB->prepare('SELECT COUNT(*) FROM users WHERE email=:email'); $sth->bindParam(':email', $this->email, PDO::PARAM_STR); $sth->execute(); if ($sth->fetchColumn() > 0) { $errors['email'][] = "Ezzel az email címmel már van regisztált felhasználónk!"; } } if ($this->phone == "") { $errors['phone'][] = "A telefonszám megadása kötelező!"; } elseif (!is_numeric($this->phone)) { $errors['phone'][] = "A telefonszám csak számokat tartalmazhat!"; } elseif (strlen($this->phone) > 20) { $errors['phone'][] = "A telefonszám maximum 20 karakter hosszú lehet!"; } if ($this->birthday != "" && strtotime($this->birthday) === false) { $errors['born'][] = "A születésnapot ÉÉÉÉ-HH-NN formátumban kell megadni!"; } if ($this->discount != "" && !is_numeric($this->discount)) { $errors['discount'][] = "A kedvezmény mértéke csak szám lehet!"; } if ($reg === true && $this->tos != "true") { $errors['tos'][] = "Az ÁSZF-et kötelező elfogadnod!"; } if (count($errors) > 0) { return $errors; } $this->valid = true; return true; }