- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
class Registration{
protected $data;
protected $linc = "reg.php";
protected $v_log;
protected $query_login;
protected $v_pass;
protected $v_r_pass;
protected $v_pass_r_pass;
protected $v_mail;
public function __construct() {
$this->data = array('login'=> NULL, 'password'=> NULL, 'r_password'=> NULL, 'mail'=> NULL);
foreach($this->data as $key => $val) {
$this->data[$key] = $_POST[$key];
}
$this->v_log = $this->ver_login($this->data['login']);
$this->v_pass = $this->ver_pass($this->data['password']);
$this->v_r_pass = $this->ver_r_pass($this->data['r_password']);
$this->v_pass_r_pass = $this->ver_pass_r_pass($this->data['password'],$this->data['r_password']);
$this->v_mail = $this->ver_mail($this->data['mail']);
$this->error_reporting($this->v_log,$this->v_pass,$this->v_r_pass,$this->v_pass_r_pass,$this->v_mail, $this->error_log($this->linc));
}
protected function error_log($linc){
return("<p>В поле введены неверные данные!</p></br>"
. "<form action='$linc' metod='get'>"
. "<p>Вернуться и проверить<input type = 'submit' value = 'вернуться'></p>"
. "</form>");
}
protected function ver_login($login) {
if(empty($login) or (!preg_match("/^\A(\w){6,20}\Z/", $login))) {
$login = FALSE;
unset($login);
}else{
$login == TRUE;
$this->ver_db($login);
return($login);
}
}
protected function ver_db($log) {
$q = mysql_query("SELECT id FROM users WHERE login = '$log'");
$f = mysql_fetch_array($q);
if(empty($f['id']) or $f['id'] == '') {
return($log);
}else{
echo('Есть такой');
}
}
protected function ver_pass($pass) {
if(empty($pass) or (!preg_match("/^\A(\w){6,20}\Z/", $pass))) {
$pass == FALSE;
unset($pass);
}else {
$pass == TRUE;
$pass = md5($pass);
return($pass);
}
}
protected function ver_r_pass($r_pass) {
if(empty($r_pass) or (!preg_match("/^\A(\w){6,20}\Z/", $r_pass))) {
$r_pass == FALSE;
unset($r_pass);
}else {
$r_pass == TRUE;
$r_pass = md5($r_pass);
return($r_pass);
}
}
protected function ver_pass_r_pass($pass,$r_pass) {
if($pass != $r_pass) {
return(FALSE);
}else {
return (TRUE);
}
}
protected function ver_mail($mail) {
if(empty($mail) or (!preg_match("/^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,6}$/", $mail))) {
$mail == FALSE;
unset($mail);
}else {
$mail == TRUE;
return($mail);
}
}
protected function reg_ins($log,$pass,$mail) {
$date = date("d.m.y");
$const = ACCES_KEY_DEFAULT;
$ins_query = "INSERT INTO users(login,password,mail,date,acces) VALUES ('$log','$pass','$mail','$date','$const')";
$insert = mysql_query($ins_query);
if(!$insert){
echo('error');
} else {
echo('ok');
}
}
protected function error_reporting($log,$pass,$r_pass,$pass_r_pass,$mail,$error) {
if($log == FALSE or $pass == FALSE or $r_pass == FALSE or $pass_r_pass == FALSE or $mail == FALSE){
echo($error);
} else {
//выполняем если все данные введены верно
$this->reg_ins($log, $pass, $mail);
}