-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjob.php
More file actions
47 lines (39 loc) · 999 Bytes
/
job.php
File metadata and controls
47 lines (39 loc) · 999 Bytes
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
<?
header("X-Powered-By: Castfire");
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// Incorrect method
header("HTTP/1.1 418 I'm a teapot");
header("Allow: POST");
header("X-Reason: Bad method");
exit;
}
if ($_SERVER['CONTENT_TYPE'] != 'application/job') {
// Incorrect MIME type
header("HTTP/1.1 418 I'm a teapot");
header("X-Reason: Bad MIME type");
exit;
}
$data = json_decode(file_get_contents("php://input"), true);
if ($data === NULL) {
// Not Valid JSON
header("HTTP/1.1 418 I'm a teapot");
header("X-Reason: Bad JSON");
exit;
}
if (isset($data['name']) && isset($data['email']) && isset($data['intro']) && isset($data['links'])) {
// Success
$name = $data['name'];
$mail = $data['email'];
$intro = $data['intro'];
$links = $data['links'];
// Enter in jobs database here
header("HTTP/1.1 202 Accepted");
header("Thank-You: We'll be in touch!");
exit;
} else {
// Missing field
header("HTTP/1.1 418 I'm a teapot");
header("X-Reason: Missing Field");
exit;
}
?>