-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetCookie.php
83 lines (76 loc) · 2.6 KB
/
setCookie.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
try {
$form = $_POST;
if(empty($form['api_key'])) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Api Key Required",
"info_error" => 'Failing validation, there may be fields that are not filled in.',
'data' => null
], JSON_PRETTY_PRINT);
die;
}
if(empty($form['api_key_secret'])) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Api Key Secret Required",
"info_error" => 'Failing validation, there may be fields that are not filled in.',
'data' => null
], JSON_PRETTY_PRINT);
die;
}
if(empty($form['authentication'])) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Authentication Required",
"info_error" => 'Failing validation, there may be fields that are not filled in.',
'data' => null
], JSON_PRETTY_PRINT);
die;
}
if(empty($form['storage_uuid'])) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Storage UUID Required",
"info_error" => 'Failing validation, there may be fields that are not filled in.',
'data' => null
], JSON_PRETTY_PRINT);
die;
}
if(empty($form['hosting_uuid'])) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Hosting UUID Required",
"info_error" => 'Failing validation, there may be fields that are not filled in.',
'data' => null
], JSON_PRETTY_PRINT);
die;
}
setcookie('onedionys_apillon_api_key', $form['api_key'], time() + 3600, '/');
setcookie('onedionys_apillon_api_key_secret', $form['api_key_secret'], time() + 3600, '/');
setcookie('onedionys_apillon_authentication', $form['authentication'], time() + 3600, '/');
setcookie('onedionys_apillon_storage_uuid', $form['storage_uuid'], time() + 3600, '/');
setcookie('onedionys_apillon_hosting_uuid', $form['hosting_uuid'], time() + 3600, '/');
echo json_encode([
'status' => 1,
'status_code' => 200,
'message' => "Successfully added the data into the cookie",
"info_error" => null,
'data' => null
], JSON_PRETTY_PRINT);
die;
} catch (Exception $e) {
echo json_encode([
'status' => 0,
'status_code' => 422,
'message' => "Failed to add data to the cookie",
"info_error" => $e->getMessage(),
'data' => null
], JSON_PRETTY_PRINT);
die;
}