- 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;
}
}
?>