-
Notifications
You must be signed in to change notification settings - Fork 0
/
inscription_c.php
79 lines (70 loc) · 2.08 KB
/
inscription_c.php
1
2
3
4
5
6
7
8
9
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require('./config/config.php');
require('./code/init.php');
require('./code/dbaccess.class.php');
require('./code/dbaccess-users.class.php');
require('./code/misc.php');
if (isset($_COOKIE['login'])) {
header(URL_HEADER . 'logout_c.php?prj=' . $_GET['prj']);
exit;
}
// spambot ?
$now = time();
if (!isset($_SESSION['nospambot_time']) or ($now - $_SESSION['nospambot_time']) < 6) {
// it is assumed that if the fields are filled too quickly (less than 6 sec.), this is a spambot
$_SESSION['nospambot_errors'] = (isset($_SESSION['nospambot_errors'])) ? ++$_SESSION['nospambot_errors'] : 0;
if ($_SESSION['nospambot_errors'] >= 3) {
// no message, no information
header(URL_HEADER);
}
else {
setSysMsg('_newusererror');
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
}
exit;
}
// not a spambot
$login = trim($_POST['login']);
$email = trim($_POST['email']);
$name = trim($_POST['name']);
$name = ($name != '') ? $name : '[?]';
// login checking
if ($login == '') {
setSysMsg('_emptylogin');
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
exit;
}
if (!preg_match('`^[a-zA-Z][a-zA-Z0-9_]+$`', $login)) {
setSysMsg('_wronglogin');
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
exit;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
setSysMsg('_invalidemail');
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
exit;
}
if ($_POST['iAgree'] != 'ON') {
setSysMsg('_licenseagreement');
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
exit;
}
// action
$db = new Database();
if (!$db->connx) {
setSysMsg('_nobase');
header(URL_HEADER . 'home.php?prj=' . $_GET['prj']);
exit;
}
$pw = generatePassword(8);
$dbaUsers = new dbaccessUsers($db);
list($ok, $msgcode) = $dbaUsers->createUser($login, $name, $pw, $email, $_GET['prj']);
if ($ok) {
setSysMsg('inscrok');
header(URL_HEADER . 'dictionary.php?prj=' . $_GET['prj']);
}
else {
setSysMsg($msgcode);
header(URL_HEADER . 'inscription.php?prj=' . $_GET['prj']);
}
?>