<?php /** * eSales Media Legal Age Check * * Copyright (C) 2013-2015 eSalesMedia * * @package legalAgeCheck * @link http://www.esales-media.de * @license commercial * * @author Benjamin Roth <benjamin@esales-media.de> */ namespace legalAgeCheck; /** * AJAX check */ if(!$_SERVER['HTTP_X_REQUESTED_WITH'] || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { header('HTTP/1.1 403 Forbidden'); die("File cannot be executed directly"); } /** * Initialize the system */ define('TL_SCRIPT', 'system/modules/legalAgeCheck/ajax/Ajax.php'); define('TL_MODE', 'FE'); require '../../../initialize.php'; class LegalAgeCheckAsync extends \Frontend { public function __construct() { \Controller::setStaticUrls(); \Controller::loadLanguageFile('default'); parent::__construct(); } public function run() { $strBuffer = ''; switch(\Input::get('do')) { case 'legalage_authentication': if (!is_null(\Input::get('legalage_commit'))) { $strBuffer = json_encode(array('status'=>(LegalAgeCheck::ajaxUnlockPage() ? 'OK' : 'FAILED'))); } else { $this->preconditionFailed(); } break; default: $this->preconditionFailed(); break; } header('Content-Type: application/json; charset=utf-8'); echo $strBuffer; exit; } protected function preconditionFailed() { header('HTTP/1.1 412 Precondition Failed'); echo 'Precondition failed'; exit(); } } $Ajax = new LegalAgeCheckAsync(); $Ajax->run();