-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathajax.php
More file actions
42 lines (36 loc) · 1.15 KB
/
ajax.php
File metadata and controls
42 lines (36 loc) · 1.15 KB
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
<?php
require './includes/user_init.php';
$cmd = get_param('cmd');
$q = get_param('query');
$limit = 20;
switch ($cmd) {
case 'userOk':
if (!empty($q)) {
$foo = sql_qquery("SELECT user_id FROM ".$db_prefix."user WHERE user_id='$q' LIMIT 1");
if (!empty($foo) || !preg_match("/^[[:alnum:]]+$/", $q)) {
flush_json(0) ;
} else {
flush_json(1);
} // 1 = username is ok
}
flush_json(0) ;
break;
case 'emailOk':
if (!empty($q)) {
if ($isLogin) {
$foo = sql_qquery("SELECT user_email FROM ".$db_prefix."user WHERE (user_email='$q') AND (user_id!='$current_user_id') LIMIT 1");
} else {
$foo = sql_qquery("SELECT user_email FROM ".$db_prefix."user WHERE user_email='$q' LIMIT 1");
}
if (!empty($foo) || !validate_email_address($q)) {
flush_json(0);
} else {
flush_json(1);
} // 1 = email is ok
}
flush_json(0) ;
break;
default:
flush_json(9999, 'Undefined ajax mode '.$cmd);
break;
}