-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalidate-user.php
57 lines (49 loc) · 1.26 KB
/
validate-user.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
<?php
/*
* License: GPLv3
* Author: Paul Tagliamonte <paultag@whube.com>
* Description:
* AJAX callbacks for checking username
*/
session_start();
// requireLogin();
include( "conf/site.php" );
include( "libs/php/globals.php" );
$app_root = dirname( __FILE__ ) . "/";
include( $app_root . "model/user.php" );
$s = new sql();
$d['errors'] = true;
$d['success'] = false;
$d['message'] = "Unknown error";
if ( isset ( $_GET['p'] ) ) {
$id = clean( $_GET['p'] );
if ( $_GET['p'] != "" ) {
$p = new user();
$p->searchByKey( "username", $id );
$d['message'] = "Query executed with success " . $id . ".";
$d['numrows'] = $p->numRows();
if ( $p->numRows() < 1 ) {
$d['message'] = "No project matches " . $id . ".";
$d['bestmatch'] = "";
$d['success'] = false;
} else {
$row = $p->getNext();
$d['message'] = "We have a result for " . $id . ".";
$d['bestmatch'] = $row['username'];
if ( $row['username'] == $id ) {
$d['success'] = true;
$d['descr'] = $row['real_name'];
}
}
} else {
$d['errors'] = true;
$d['success'] = false;
$d['message'] = "";
}
} else {
$d['errors'] = true;
$d['success'] = false;
$d['message'] = "I don't know what user to lookup!";
}
echo json_encode( $d );
?>