Browse code

Initial commit

Benjamin Roth authored on21/03/2019 09:05:45
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,77 @@
1
+<?php
2
+/**
3
+ * eSales Media Legal Age Check
4
+ *
5
+ * Copyright (C) 2013-2015 eSalesMedia
6
+ *
7
+ * @package    legalAgeCheck
8
+ * @link       http://www.esales-media.de
9
+ * @license    commercial
10
+ *
11
+ * @author     Benjamin Roth <benjamin@esales-media.de>
12
+ */
13
+
14
+namespace legalAgeCheck;
15
+
16
+/**
17
+ * AJAX check
18
+ */
19
+
20
+if(!$_SERVER['HTTP_X_REQUESTED_WITH'] || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
21
+	header('HTTP/1.1 403 Forbidden');
22
+	die("File cannot be executed directly");
23
+}
24
+
25
+
26
+/**
27
+ * Initialize the system
28
+ */
29
+
30
+define('TL_SCRIPT', 'system/modules/legalAgeCheck/ajax/Ajax.php');
31
+define('TL_MODE', 'FE');
32
+require '../../../initialize.php';
33
+
34
+class LegalAgeCheckAsync extends \Frontend
35
+{
36
+	public function __construct()
37
+	{
38
+		\Controller::setStaticUrls();
39
+		\Controller::loadLanguageFile('default');
40
+
41
+		parent::__construct();
42
+	}
43
+
44
+	public function run()
45
+	{
46
+		$strBuffer = '';
47
+		switch(\Input::get('do'))
48
+		{
49
+			case 'legalage_authentication':
50
+				if (!is_null(\Input::get('legalage_commit')))
51
+				{
52
+					$strBuffer = json_encode(array('status'=>(LegalAgeCheck::ajaxUnlockPage() ? 'OK' : 'FAILED')));
53
+				} else {
54
+					$this->preconditionFailed();
55
+				}
56
+				break;
57
+
58
+			default:
59
+				$this->preconditionFailed();
60
+				break;
61
+		}
62
+
63
+		header('Content-Type: application/json; charset=utf-8');
64
+		echo $strBuffer;
65
+		exit;
66
+	}
67
+
68
+	protected function preconditionFailed()
69
+	{
70
+		header('HTTP/1.1 412 Precondition Failed');
71
+		echo 'Precondition failed';
72
+		exit();
73
+	}
74
+}
75
+
76
+$Ajax = new LegalAgeCheckAsync();
77
+$Ajax->run();
0 78
\ No newline at end of file