@@ -7,61 +7,61 @@ |
||
7 | 7 | } |
8 | 8 | |
9 | 9 | switch ($_POST['action']) { |
10 | - case 'hide': |
|
11 | - // Set cookie |
|
12 | - ScwCookie\ScwCookie::setCookie('scwCookieHidden', 'true', 52, 'weeks'); |
|
13 | - header('Content-Type: application/json'); |
|
14 | - die(json_encode(['success' => true])); |
|
15 | - break; |
|
10 | + case 'hide': |
|
11 | + // Set cookie |
|
12 | + ScwCookie\ScwCookie::setCookie('scwCookieHidden', 'true', 52, 'weeks'); |
|
13 | + header('Content-Type: application/json'); |
|
14 | + die(json_encode(['success' => true])); |
|
15 | + break; |
|
16 | 16 | |
17 | - case 'toggle': |
|
18 | - $scwCookie = new ScwCookie\ScwCookie(); |
|
19 | - $return = []; |
|
17 | + case 'toggle': |
|
18 | + $scwCookie = new ScwCookie\ScwCookie(); |
|
19 | + $return = []; |
|
20 | 20 | |
21 | - // Update if cookie allowed or not |
|
22 | - $choices = $scwCookie->getCookie('scwCookie'); |
|
23 | - if ($choices == false) { |
|
24 | - $choices = []; |
|
25 | - $enabledCookies = $scwCookie->enabledCookies(); |
|
26 | - foreach ($enabledCookies as $name => $label) { |
|
27 | - $choices[$name] = $scwCookie->config['unsetDefault']; |
|
21 | + // Update if cookie allowed or not |
|
22 | + $choices = $scwCookie->getCookie('scwCookie'); |
|
23 | + if ($choices == false) { |
|
24 | + $choices = []; |
|
25 | + $enabledCookies = $scwCookie->enabledCookies(); |
|
26 | + foreach ($enabledCookies as $name => $label) { |
|
27 | + $choices[$name] = $scwCookie->config['unsetDefault']; |
|
28 | + } |
|
29 | + $scwCookie->setCookie('scwCookie', $scwCookie->encrypt($choices), 52, 'weeks'); |
|
30 | + } else { |
|
31 | + $choices = $scwCookie->decrypt($choices); |
|
28 | 32 | } |
29 | - $scwCookie->setCookie('scwCookie', $scwCookie->encrypt($choices), 52, 'weeks'); |
|
30 | - } else { |
|
31 | - $choices = $scwCookie->decrypt($choices); |
|
32 | - } |
|
33 | - $choices[$_POST['name']] = $_POST['value'] == 'true' ? 'allowed' : 'blocked'; |
|
33 | + $choices[$_POST['name']] = $_POST['value'] == 'true' ? 'allowed' : 'blocked'; |
|
34 | 34 | |
35 | - // Remove cookies if now disabled |
|
36 | - if ($choices[$_POST['name']] == 'blocked') { |
|
37 | - $removeCookies = $scwCookie->clearCookieGroup($_POST['name']); |
|
38 | - $return['removeCookies'] = $removeCookies; |
|
39 | - } |
|
35 | + // Remove cookies if now disabled |
|
36 | + if ($choices[$_POST['name']] == 'blocked') { |
|
37 | + $removeCookies = $scwCookie->clearCookieGroup($_POST['name']); |
|
38 | + $return['removeCookies'] = $removeCookies; |
|
39 | + } |
|
40 | 40 | |
41 | - $choices = $scwCookie->encrypt($choices); |
|
42 | - $scwCookie->setCookie('scwCookie', $choices, 52, 'weeks'); |
|
41 | + $choices = $scwCookie->encrypt($choices); |
|
42 | + $scwCookie->setCookie('scwCookie', $choices, 52, 'weeks'); |
|
43 | 43 | |
44 | - header('Content-Type: application/json'); |
|
45 | - die(json_encode($return)); |
|
46 | - break; |
|
44 | + header('Content-Type: application/json'); |
|
45 | + die(json_encode($return)); |
|
46 | + break; |
|
47 | 47 | |
48 | - case 'load': |
|
49 | - $scwCookie = new ScwCookie\ScwCookie(); |
|
50 | - $return = []; |
|
48 | + case 'load': |
|
49 | + $scwCookie = new ScwCookie\ScwCookie(); |
|
50 | + $return = []; |
|
51 | 51 | |
52 | - $removeCookies = []; |
|
52 | + $removeCookies = []; |
|
53 | 53 | |
54 | - foreach ($scwCookie->disabledCookies() as $cookie => $label) { |
|
55 | - $removeCookies = array_merge($removeCookies, $scwCookie->clearCookieGroup($cookie)); |
|
56 | - } |
|
57 | - $return['removeCookies'] = $removeCookies; |
|
54 | + foreach ($scwCookie->disabledCookies() as $cookie => $label) { |
|
55 | + $removeCookies = array_merge($removeCookies, $scwCookie->clearCookieGroup($cookie)); |
|
56 | + } |
|
57 | + $return['removeCookies'] = $removeCookies; |
|
58 | 58 | |
59 | - header('Content-Type: application/json'); |
|
60 | - die(json_encode($return)); |
|
61 | - break; |
|
59 | + header('Content-Type: application/json'); |
|
60 | + die(json_encode($return)); |
|
61 | + break; |
|
62 | 62 | |
63 | - default: |
|
64 | - header('HTTP/1.0 403 Forbidden'); |
|
65 | - throw new Exception("Action not recognised"); |
|
66 | - break; |
|
63 | + default: |
|
64 | + header('HTTP/1.0 403 Forbidden'); |
|
65 | + throw new Exception("Action not recognised"); |
|
66 | + break; |
|
67 | 67 | } |