- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
<?php
if(!isset($legal_include)) { header("HTTP/1.0 404 Not Found"); die(); }
if(!isset($_POST['login']) OR !isset($_POST['password']) OR !isset($_POST['password_retype'])) {
text(gic('tpl/register_form.html'));
} else {
$_POST = postget();
$error = array();
if(strlen($_POST['login']) < 4 OR empty($_POST['login'])) {
array_push($error, 'len_login');
} else {
if(preg_match('/^[a-z0-9]+$/', $_POST['login'])) {
if(check_avalaibility($_POST['login']) != true) {
array_push($error, 'login_used');
}
} else {
array_push($error, 'inc_login');
}
}
if(strlen($_POST['password']) < 4 OR empty($_POST['password'])) {
array_push($error, 'len_passwd');
} else {
if($_POST['password'] != $_POST['password_retype']) {
array_push($error, 'inc_passwds');
}
}
if(count($error) > 0) {
$fields = array('inc_login' => language($_SESSION['lang'], 'inc_login'),
'len_login' => language($_SESSION['lang'], 'len_login'),
'len_passwd' => language($_SESSION['lang'], 'len_passwd'),
'login_used' => language($_SESSION['lang'], 'login_used'),
'inc_passwds' => language($_SESSION['lang'], 'inc_passwds'));
$text = language($_SESSION['lang'], 'have_errs').'<ul>';
foreach($error as $value) {
$text .= '<li>'.$fields[$value].'</li>';
}
$text .= '</ul>';
error($text, 'text');
sendback('?register');
} else {
$SQL = 'INSERT INTO `'.pr.'users` (`login`, `password`, `levels`) VALUES (\''.$_POST['login'].'\', \''.md5($_POST['password']).'\', 1)';
mysql_query($SQL);
$_SESSION['logined'] = true;
$_SESSION['levels'] = 1;
$_SESSION['name'] = $_POST['login'];
}
}
function check_avalaibility($username) {
$SQL = 'SELECT `login` FROM `'.pr.'users` WHERE `login` = \''.$username.'\'';
$result = mysql_query($SQL);
if(mysql_num_rows($result) > 0) {
return false;
} else {
return true;
}
}
?>
scriptin 18.12.2011 20:08 # −1
killro0000 18.12.2011 20:12 # 0
killro0000 18.12.2011 23:55 # +4
dos_ 19.12.2011 00:03 # +3
Lure Of Chaos 19.12.2011 01:11 # 0
killro0000 19.12.2011 08:16 # 0
Vasiliy 19.12.2011 12:57 # +1
array_push($error, 'len_login'); // // Не кошерно.
sendback('?register'); // Мило. Интересно есть ли ? sendnext('?register'); и чем они отличаются
Короче не достойно быть запощенно на ГК.
guest8 09.04.2019 12:24 # −999