GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/ve.anqa.it/wp-content/plugins/depicter/app/src/Rules/Condition/Advanced/Cookie.php
<?php

namespace Depicter\Rules\Condition\Advanced;

use Averta\Core\Utility\Arr;
use Depicter\Rules\Condition\Base as ConditionBase;

class Cookie extends ConditionBase
{
	/**
	 * @inheritdoc
	 */
	public $slug = 'Advanced_Cookie';

	/**
	 * @inheritdoc
	 */
	public $control = 'paramComparison';

	/**
	 * @inheritdoc
	 */
	protected $belongsTo = 'Advanced';

	/**
	 * @inheritdoc
	 */
	public function getLabel(): ?string{
		return __('Cookie Value', 'depicter' );
	}

	/**
	 * @inheritDoc
	 */
	public function getControlOptions(): array{
		return [
			"targetParamPlaceholder" => "cookie_name"
		];
	}

	/**
	 * @inheritdoc
	 */
	public function check( $value = null ): bool{

		$value = $value ?? $this->value;
		$isIncluded = empty( $value );
		if ( ! $isIncluded ) {
			$value = Arr::merge( $value, [
				'targetParam' => '',
				'comparisonFunction' => 'equal',
				'targetValue' => ''
			]);

			if ( !empty( $_COOKIE[ $value['targetParam'] ] ) ) {
				$isIncluded = $this->compare( $_COOKIE[ $value['targetParam'] ], $value['comparisonFunction'], $value['targetValue'] );
			}
		}

		return $this->selectionMode === 'include' ? $isIncluded : ! $isIncluded;
	}
}