-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkfield.php
executable file
·70 lines (64 loc) · 2 KB
/
checkfield.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
<?php
include_once('internal/Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include_once(mnminclude.'smartyvariables.php');
$type=sanitize($_REQUEST['type'], 2);
$name=js_urldecode($_POST["name"]);
switch ($type) {
case 'username':
if (utf8_strlen($name)<3) { // if username is less than 3 characters
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_UserShort");
return;
}
if (preg_match('/\pL/u', 'a')) { // Check if PCRE was compiled with UTF-8 support
if (!preg_match('/^[_\-\d\p{L}\p{M}]+$/iu', $name)) { // if username contains invalid characters
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_InvalidChars");
return;
}
} else {
if (!preg_match('/^[^~`@%&=\\/;:\\.,<>!"\\\'\\^\\.\\[\\]\\$\\(\\)\\|\\*\\+\\-\\?\\{\\}\\\\]+$/', $name)) { // if username contains invalid characters
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_InvalidChars");
return;
}
}
if(user_exists($name)) { // if username already exists
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_UserExists");
return;
}
$vars = array('name' => $name);
check_actions('register_check_field', $vars);
if ($vars['error'])
echo $vars['error'];
else
echo "OK";
break;
case 'email':
if (!check_email($name)) { // if email contains invald characters
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_EmailInvalid");
return;
}
if(email_exists($name)) { // if email already exists
echo $main_smarty->get_config_vars("PLIGG_Visual_CheckField_EmailExists");
return;
}
$vars = array('email' => $name);
check_actions('register_check_field', $vars);
if ($vars['error'])
echo $vars['error'];
else
echo "OK";
break;
case 'password':
if(strlen($name) < 5 ) { // if password is less than 5 characters
echo $main_smarty->get_config_vars('PLIGG_Visual_Register_Error_FiveCharPass');
return;
}else{
echo "OK";
}
break;
default:
echo "KO";
}
?>