forked from hypercities/hypercities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkPassword.php
44 lines (29 loc) · 897 Bytes
/
checkPassword.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
<?php
include_once("includes/serverSession.inc");
include_once("includes/dbUtil.inc");
include_once("includes/user.inc");
// Start session
cServerSession::start();
HC_checkReferer();
$HC_POST = HC_sanitizeInput($_POST, array('id'=>'int', 'password'=>'str'),
array('id', 'password'), NULL);
$id = $HC_POST['id'];
$password = $HC_POST['password'];
try {
$result = select("objects", "id = $id");
if (strcmp($result[0]['password'], $password) == 0)
$auth = true;
else
$auth = false;
header('Content-type: application/json');
echo json_encode(array('auth' => $auth, 'id' => $id));
} catch (MysqlException $e) {
$message = 'Caught exception: '.$e->getMessage();
HC_errorLog($message);
HC_reportDBError("check password");
} catch (Exception $e) {
$message = 'Caught exception: '.$e->getMessage();
HC_errorLog($message);
HC_reportGeneralError("check password");
}
?>