| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/baberankings.com/wp-content/plugins/age-gate/src/Controller/ |
Upload File : |
<?php
namespace AgeGate\Controller;
use AgeGate\Utility\Cookie;
use AgeGate\Common\Content;
use AgeGate\Common\Form\Submit;
use AgeGate\Presentation\ClassNames;
use AgeGate\Common\Controller\AbstractController;
use AgeGate\Common\Interfaces\ControllerInterface;
class StandardController extends AbstractController implements ControllerInterface
{
use ClassNames;
public static $errors = [];
public function __construct(Content $c)
{
parent::__construct($c);
$postData = wp_unslash($_POST); // phpcs:ignore WordPress.Security.NonceVerification.Missing
if (isset($postData['age_gate'])) {
$response = (new Submit($postData, $this->settings))->validate();
if ($response['status'] === true) {
if ($response['set_cookie']) {
Cookie::set($this->settings->getCookieName(), $response['data']['user_age'], $response['cookieLength'] ?? 0);
if (filter_var(wp_unslash($_COOKIE[$this->settings->getCookieName() . '_failed'] ?? false, FILTER_VALIDATE_BOOLEAN))) {
Cookie::destroy($this->settings->getCookieName() . '_failed');
}
} else {
$_COOKIE[$this->settings->getCookieName()] = $response['data']['user_age'];
}
do_action('age_gate/passed', $response);
wp_safe_redirect(esc_url_raw($response['redirect']), 303, 'AGE-GATE');
exit;
}
global $wp;
if ($response['set_cookie']) {
Cookie::set($this->settings->getCookieName() . '_failed', 1);
}
if ($wp->request !== $response['redirect']) {
wp_redirect(esc_url_raw($response['redirect']), 303, 'AGE-GATE');
}
if ($this->settings->method === 'standard' && !$this->settings->rechallenge) {
$this->settings->lockout = true;
StandardController::$errors = [
$this->settings->errorFailed,
];
}
self::$errors = $response['errors'];
}
}
public function init(): void
{
$cookie = $this->settings->getCookieName() . '_failed';
if ($this->settings->method === 'standard' && !$this->settings->rechallenge && Cookie::get($cookie)) {
remove_all_actions('age_gate/fields');
remove_all_actions('age_gate/custom/after');
$this->settings->lockout = true;
StandardController::$errors = [
$this->settings->errorFailed,
];
}
add_filter('template_include', [$this, 'template']);
}
public function assets(): void
{
wp_register_script('age-gate-stepped', AGE_GATE_URL . 'dist/stepped.js', [], AGE_GATE_VERSION, true);
wp_localize_script('age-gate-stepped', 'ag_stepped', ['age' => $this->content->getAge()]);
if ($this->content->isRestricted()) {
wp_enqueue_script('age-gate-standard', AGE_GATE_URL . 'dist/standard.js', [], AGE_GATE_VERSION, true);
}
}
public function template($template)
{
$show = apply_filters('age_gate/show', true, $this->content);
if ($this->content->isRestricted() && $show) {
wp_enqueue_style('age-gate');
return AGE_GATE_PATH . 'src/Controller/ViewController.php';
}
return $template;
}
}