Last change
on this file since 246 was
246,
checked in by hendrikvanantwerpen, 13 years ago
|
Created first page mainmenu in new system.
Moved old pages out of project root.
Fixed RDFAPI.php case for people with proper OS'es.
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | require_once 'classes//master.php'; |
---|
4 | |
---|
5 | $rawInput = $HTTP_RAW_POST_DATA; |
---|
6 | $output = array(); |
---|
7 | $returnValue = 418; |
---|
8 | |
---|
9 | if (!empty($rawInput)) { |
---|
10 | |
---|
11 | $input = json_decode($rawInput); |
---|
12 | |
---|
13 | switch ($input->action) { |
---|
14 | case "login": |
---|
15 | $username = $input->args->username; |
---|
16 | $password = $input->args->password; |
---|
17 | $returnValue = 401; |
---|
18 | |
---|
19 | $user_results = User::get(array("name" => $username)); |
---|
20 | if (!empty($user_results)) { |
---|
21 | $user = $user_results[0]; |
---|
22 | if ($password == $user->password) { |
---|
23 | $returnValue = 200; |
---|
24 | } |
---|
25 | } |
---|
26 | break; |
---|
27 | case "register": |
---|
28 | $username = $input->args->username; |
---|
29 | $password = $input->args->password; |
---|
30 | $user_results = User::get(array("name" => $username)); |
---|
31 | if (!empty($user_results)) { |
---|
32 | $returnValue = 409; |
---|
33 | } else { |
---|
34 | $user = new User(); |
---|
35 | $user->name = $username; |
---|
36 | $user->password = $password; |
---|
37 | $user->save(); |
---|
38 | $returnValue = 200; |
---|
39 | } |
---|
40 | break; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | header("HTTP/1.1 ".$returnValue); |
---|
45 | header("Content-Type: application/json"); |
---|
46 | header("Cache-Control: no-cache, must-revalidate"); |
---|
47 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
---|
48 | echo(json_encode($output)); |
---|
49 | |
---|
50 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.