<?php

if (!defined('ABSPATH')){
    exit;
}

/* function cookieadmin_died(){
	print_r(error_get_last());
}
register_shutdown_function('cookieadmin_died'); */

// Checks if we are to update ?
function cookieadmin_update_check(){
	global $wpdb;

	$current_version = get_option('cookieadmin_version');
	$version = (int) str_replace('.', '', $current_version);

	// No update required
	if($current_version == COOKIEADMIN_VERSION){
		return true;
	}
	
	// We added a option to disable Script Delaying
	if($version < 120){
		$settings = get_option('cookieadmin_settings', []);
		$settings['block_scripts'] = true;
		
		update_option('cookieadmin_settings', $settings);
	}

	// Save the new Version
	update_option('cookieadmin_version', COOKIEADMIN_VERSION);
	
}

function cookieadmin_load_plugin(){
		
	// Check if the installed version is outdated
	cookieadmin_update_check();
	
	///////////////////////////
	// Common loading
	///////////////////////////
	
	if(wp_doing_ajax()){
		add_action('wp_ajax_cookieadmin_ajax_handler', 'cookieadmin_ajax_handler');
		add_action('wp_ajax_nopriv_cookieadmin_ajax_handler', 'cookieadmin_ajax_handler');
	}
	
	add_filter( 'kses_allowed_protocols', 'cookieadmin_kses_allowed_protocols');
	
	///////////////////////////
	// Admin loading
	///////////////////////////
	
	if(is_admin()){
		return cookieadmin_load_plugin_admin();
	}
	
	///////////////////////////
	// Enduser loading
	///////////////////////////
	
	// Check if our scanner is visiting
	if(defined('COOKIEADMIN_SCANNER')){	
		return false;
	}
	
	add_action('wp_enqueue_scripts', '\CookieAdmin\Enduser::enqueue_scripts');
	
	// Insert Cookie blocker in the head.
	//add_action('send_headers', '\CookieAdmin\Enduser::cookieadmin_block_cookie_init_php', 100);
	// add_action('init', '\CookieAdmin\Enduser::cookieadmin_block_cookie_head_js', 0);
	
	//add Cookie Banner to user page
	if(!cookieadmin_is_editor_mode()){
		add_action('wp_footer', '\CookieAdmin\Enduser::cookieadmin_show_banner');
	}
	
	add_action('template_redirect', '\CookieAdmin\Enduser::block_scripts', 1);
	
}

function cookieadmin_load_plugin_admin(){
	
	global $cookieadmin, $cookieadmin_settings;
	
	if(!is_admin() || !current_user_can('administrator')){
		return false;
	}
	
	add_action('admin_enqueue_scripts', '\CookieAdmin\Admin::enqueue_scripts');
	
	add_action('admin_menu', '\CookieAdmin\Admin::cookieadmin_plugin_menu');
	
	// === Plugin Update Notice === //
	$plugin_update_notice = get_option('softaculous_plugin_update_notice', []);
	$available_update_list = get_site_transient('update_plugins'); 
	$plugin_path_slug = 'cookieadmin/cookieadmin.php';

	if(
		!empty($available_update_list) &&
		is_object($available_update_list) && 
		!empty($available_update_list->response) &&
		!empty($available_update_list->response[$plugin_path_slug]) && 
		(empty($plugin_update_notice) || empty($plugin_update_notice[$plugin_path_slug]) || (!empty($plugin_update_notice[$plugin_path_slug]) &&
		version_compare($plugin_update_notice[$plugin_path_slug], $available_update_list->response[$plugin_path_slug]->new_version, '<')))
	){
		add_action('admin_notices', '\CookieAdmin\Admin::plugin_update_notice');
		add_filter('softaculous_plugin_update_notice', '\CookieAdmin\Admin::plugin_update_notice_filter');
	}
	// === Plugin Update Notice END === //
}

function cookieadmin_is_editor_mode(){
	
	if (isset($_GET['pagelayer-live']) || isset($_GET['fl_builder'])) {
		return true;
	}
	
	// Avada builder
	if(isset($_GET['fb-edit']) || isset($_GET['builder']) || isset($_GET['builder_id'])){
		return true;
	}
	
	// Bricks Builder
	if(isset($_GET['bricks']) || isset($_GET['brickspreview'])){
		return true;
	}
	
	if(isset($_GET['vc_action']) && $_GET['vc_action'] == 'vc_inline'){
		return true;
	}
	
	if(isset($_GET['elementor-preview']) || (isset($_GET['action']) && $_GET['action'] == 'elementor')){
		return true;
	}

	return false;
	
}

function cookieadmin_ajax_handler(){
	
	$cookieadmin_fn = (!empty($_REQUEST['cookieadmin_act']) ? sanitize_text_field(wp_unslash($_REQUEST['cookieadmin_act'])) : '');
	
	if(empty($cookieadmin_fn)){
		wp_send_json_error(array('message' => 'Action not posted'));
	}
	
	// Define a whitelist of allowed functions
	$user_allowed_actions = array();
	
	$admin_allowed_actions = array(
		'scan_cookies' => '\CookieAdmin\Admin\Scan::scan_cookies_ajax',
		'cookieadmin-edit-cookie' => '\CookieAdmin\Admin\Scan::edit_cookies',
		'cookieadmin-delete-cookie' => '\CookieAdmin\Admin\Scan::delete_cookies',
		'close-update-notice' => '\CookieAdmin\Admin::close_plugin_update_notice',
		'close-notice' => '\CookieAdmin\Admin::close_notices',
		'install_recommended_plugin' => '\CookieAdmin\Admin\Dashboard::install_recommended_plugin',
		'activate_recommended_plugin' => '\CookieAdmin\Admin\Dashboard::activate_recommended_plugin',
	);
	
	$general_actions = array(
		'categorize_cookies' => 'cookieadmin_categorize_cookies',
	);
	
	if(array_key_exists($cookieadmin_fn, $user_allowed_actions)){
		
		check_ajax_referer('cookieadmin_js_nonce', 'cookieadmin_security');
		header_remove('Set-Cookie');
		call_user_func('\CookieAdmin\Enduser::'.$user_allowed_actions[$cookieadmin_fn]);
		
	}elseif(array_key_exists($cookieadmin_fn, $admin_allowed_actions)){
		
		check_ajax_referer('cookieadmin_admin_js_nonce', 'cookieadmin_security');
	 
		if(!current_user_can('administrator')){
			wp_send_json_error(array('message' => 'Sorry, but you do not have permissions to perform this action'));
		}
		
		// TODO: Need to test this throughly
		call_user_func($admin_allowed_actions[$cookieadmin_fn]);
		
	}elseif(array_key_exists($cookieadmin_fn, $general_actions)){
		
		check_ajax_referer('cookieadmin_js_nonce', 'cookieadmin_security');
		header_remove('Set-Cookie');
		call_user_func($general_actions[$cookieadmin_fn]);
		
	}else{
		wp_send_json_error(array('message' => 'Unauthorized action'));
	}
	
}

// Load policies from the file and database and merge them.
function cookieadmin_load_policy(){
	global $cookieadmin_policies;
	
	$policy = get_option('cookieadmin_consent_settings', array());
	
	if(empty($policy) || !is_array($policy)){
		$policy = array();
	}
	
	if(!file_exists(COOKIEADMIN_DIR.'assets/cookie/policies.php')){
		return $policy;
	}
	
	include_once(COOKIEADMIN_DIR.'assets/cookie/policies.php');
	$j_policy = $cookieadmin_policies;
	// print_r($j_policy);
	
	if(empty($j_policy) || !is_array($j_policy)){
		return $policy;
	}

	return array_replace_recursive($j_policy, $policy);
}

function cookieadmin_load_strings($policy){
	
	$cookieadmin_powered_by_html = '<div class="cookieadmin-poweredby"><a href="https://cookieadmin.net/?utm_source=wpplugin&utm_medium=footer" target="_blank"><span>[[powered_by]]</span> [[logo_svg]]</a></div>';
	
	$cookieadmin_powered_by_html = apply_filters('cookieadmin_powered_by_html', $cookieadmin_powered_by_html);
	$privacy_policy_links = apply_filters('cookieadmin_privacy_policy_links', array(), $policy);
	$reconsent_icon_url = apply_filters('cookieadmin_reconsent_icon_url', '', $policy);
	
	$strings = [
		'override_gpc' => apply_filters('cookieadmin_override_gpc_html', ''),
		'powered_by_html' => $cookieadmin_powered_by_html,
		'banner_policy_links' => !empty($privacy_policy_links['banner']) ? $privacy_policy_links['banner'] : '',
		'modal_policy_links' => !empty($privacy_policy_links['modal']) ? $privacy_policy_links['modal'] : '',
		'reconsent_icon_url' => esc_url($reconsent_icon_url),
		'logo_svg' => cookieadmin_logo_svg(),
		'plugin_url' => esc_url(COOKIEADMIN_PLUGIN_URL),
		'powered_by' => __('Powered by', 'cookieadmin'),
		'reconsent' => __('Re-consent', 'cookieadmin'),
		'cookie_preferences' => __('Cookie Preferences', 'cookieadmin'),
		'remark_standard' => __('Always Active', 'cookieadmin'),
		'remark' => __('Remark', 'cookieadmin'),
		'none' => __('None', 'cookieadmin'),
		'necessary_cookies' => __('Necessary Cookies', 'cookieadmin'),
		'necessary_cookies_desc' => __('Necessary cookies enable essential site features like secure log-ins and consent preference adjustments. They do not store personal data.', 'cookieadmin'),
		'functional_cookies' => __('Functional Cookies', 'cookieadmin'),
		'functional_cookies_desc' => __('Functional cookies support features like content sharing on social media, collecting feedback, and enabling third-party tools.', 'cookieadmin'),
		'analytical_cookies' => __('Analytical Cookies', 'cookieadmin'),
		'analytical_cookies_desc' => __('Analytical cookies track visitor interactions, providing insights on metrics like visitor count, bounce rate, and traffic sources.', 'cookieadmin'),
		'advertisement_cookies' => __('Advertisement Cookies', 'cookieadmin'),
		'advertisement_cookies_desc' => __('Advertisement cookies deliver personalized ads based on your previous visits and analyze the effectiveness of ad campaigns.', 'cookieadmin'),
		'unclassified_cookies' => __('Unclassified Cookies', 'cookieadmin'),
		'unclassified_cookies_desc' => __('Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.', 'cookieadmin'),
	];
	
	return apply_filters('cookieadmin_default_strings', $strings);
}

//Loads consent data from file
function cookieadmin_load_consent_template($policy, $view){
	
	$template = array();
	
	if(!file_exists(COOKIEADMIN_DIR.'assets/cookie/template.php')){
		if(defined('WP_DEBUG') && WP_DEBUG){
			error_log('CookieAdmin: template file missing');
		}
		return $template;
	}
	
	include_once(COOKIEADMIN_DIR.'assets/cookie/template.php');
	
	if(empty($content)){
		if(defined('WP_DEBUG') && WP_DEBUG){
			error_log('CookieAdmin: Could not load template file');
		}
		return $template;
	}
	
	$template[$view] = ($policy['cookieadmin_layout'] != 'popup') ? $content['cookieadmin_layout'][$policy['cookieadmin_layout']] : '';
	$template[$view] .= $content['cookieadmin_modal'][$policy['cookieadmin_modal']];
	
	global $cookieadmin_settings;
	
	// Show consent only if hide reconsent is not enabled
	if(defined('COOKIEADMIN_PRO_VERSION') && empty($cookieadmin_settings['hide_reconsent'])){
		$template[$view] .= $content['cookieadmin_reconsent'];
	}

	$cookieadmin_strings = cookieadmin_load_strings($policy);
	
	foreach($cookieadmin_strings as $ck => $cv){
		$template[$view] = str_replace('[['.$ck.']]', $cv, $template[$view]);
	}
	
	$template[$view] = apply_filters('cookieadmin_consent_banner_template', $template[$view]);

	return $template;
	
}

// Still in progress| No use for now.
function cookieadmin_compare_consent_id($consent_id) {
	
	if (strlen($consent_id) !== 32) {
        return false;
    }
	
	// Split into random part and signature
    $random_part = substr($consent_id, 0, 16);
    $provided_signature = substr($consent_id, 16, 16);
    
    // Recompute the HMAC
    $expected_hmac = hash_hmac('sha256', $random_part . $domain, $secret_key);
    $expected_signature = substr($expected_hmac, 0, 16);
	
    return hash_equals($provided_signature, $expected_signature);
}

function cookieadmin_r_print($array){
	echo '<pre>';
	print_r($array);
	echo '</pre>';
}

function cookieadmin_load_cookies_csv($cookie_names = array(), $like = 0) {
    global $wpdb;
		
	$cookies_list = [];
	
    $csv_file = COOKIEADMIN_DIR . 'assets/open-cookie-database/list.csv';
	
    // Check if file exists
    if ( ! file_exists( $csv_file ) ) {
		return new WP_Error( 'csv_missing', 'The cookie CSV file is missing: '.$csv_file );
    }
    
    if ( ( $handle = fopen( $csv_file, 'r' ) ) !== FALSE ) {
		
		$cookies_list = [];

        $headers = fgetcsv( $handle, 10000, ",", "\"", "\\" );

        while ( ( $data = fgetcsv( $handle, 10000, ",", "\"", "\\" ) ) !== FALSE ) {
            // 0: cookie_id, 1: Platform, 2: Category, 3: Cookie / Data Key name,
            // 4: Domain, 5: Description, 6: Retention period, 7: Data Controller,
            // 8: User Privacy & GDPR Rights Portals, 9: Wildcard match

            $cookie_id    = isset( $data[0] ) ? trim( $data[0] ) : '';
            $cookie_name  = isset( $data[3] ) ? trim( $data[3] ) : '';
            $platform     = isset( $data[1] ) ? trim( $data[1] ) : '';
            $category     = isset( $data[2] ) ? trim( $data[2] ) : '';
            $domain       = isset( $data[4] ) ? trim( $data[4] ) : '';
            $description  = isset( $data[5] ) ? trim( $data[5] ) : '';
            $retention    = isset( $data[6] ) ? trim( $data[6] ) : '';
            $wildcard     = isset( $data[9] ) ? (int) $data[9] : 0;
            $patterns     = isset( $data[10] ) ? trim($data[10]) : '';

            if ( empty( $cookie_id ) || empty( $cookie_name ) ) {
                continue;
            }
			
			if(!empty($cookie_names)){
				
				if(!empty($like)){
					
					$matched = 0;
					foreach($cookie_names as $prefix){
						if (substr($cookie_name, 0, strlen($prefix)) === $prefix) {
							$matched = 1;
							break;
						}
					}
					
					if(empty($matched)){
						continue;
					}
					
				}else{
					if(!in_array($cookie_name, $cookie_names)){
						continue;
					}
				}
			}

			// Add the row to the current batch
			$cookies_list[] = [
				'cookie_id' => $cookie_id,
				'cookie_name' => $cookie_name,
				'platform' => $platform,
				'category' => $category,
				'domain' => $domain,
				'description' => $description,
				'retention' => $retention,
				'wildcard' => $wildcard,
				'patterns' => $patterns
			];
        }

        fclose( $handle );
		
    } else {
		return new WP_Error( 'csv_open_fail', 'Failed to open Cookies CSV file: '.$csv_file );
    }
	
    return $cookies_list;
}

function cookieadmin_categorize_cookies($cookies = []){
	
	global $cookieadmin_lang, $cookieadmin_error, $cookieadmin_msg, $wpdb;
	
	if(!empty($_REQUEST['cookieadmin_cookies'])){
		
		$raw_cookies = json_decode( wp_unslash( $_REQUEST['cookieadmin_cookies'] ), true );

		if ( is_array( $raw_cookies ) ) {
			$sanitized_cookies = [];

			array_walk( $raw_cookies, function( $value, $key ) use ( &$sanitized_cookies ) {
				$sanitized_key = sanitize_key( $key );
				$sanitized_cookies[ $sanitized_key ] = sanitize_text_field($value);
			} );
			
			unset($raw_cookies);
		}
	}else{
		$sanitized_cookies = $cookies;
	}

	
	if(empty($sanitized_cookies)){
		return [
            'success' => false,
            'data'    => null,
            'error'   => 'Please provide valid cookie names.',
        ];
	}
	
	$cookies_info = cookieadmin_load_cookies_csv(array_keys($sanitized_cookies));
	
	if(empty($cookies_info) || is_wp_error($cookies_info)){
		return [
	            'success' => false,
	            'data'    => null,
	            'error'   => 'Failed to load Cookies list',
	        ];
	}
	
	foreach($cookies_info as $info){
		$sanitized_cookies[$info['cookie_name']]['source'] = !empty($info['domain']) ? $info['domain'] : "unknown";
		$sanitized_cookies[$info['cookie_name']]['category'] = !empty($info['category']) ? strtolower($info['category']) : "un_c";
		$sanitized_cookies[$info['cookie_name']]['description'] = !empty($info['description']) ? $info['description'] : "unknown";
		$sanitized_cookies[$info['cookie_name']]['duration'] = !empty($info['retention']) ? $info['retention'] : "unknown";
		$sanitized_cookies[$info['cookie_name']]['platform'] = !empty($info['platform']) ? $info['platform'] : "unknown";;
	}
	
	if(wp_doing_ajax()){
		wp_send_json_success($sanitized_cookies);
	}
	
	return $sanitized_cookies;
}

function cookieadmin_is_pro(){
	return defined('COOKIEADMIN_PREMIUM');
}

function cookieadmin_kses_allowed_html(){
	
	$allowed_tags = wp_kses_allowed_html( 'post' );

	// Add input tag for cookie consent form
	$allowed_tags['input'] = array(
		'type'    => true,
		'name'    => true,
		'value'   => true,
		'class'   => true,
		'id'      => true,
		'checked' => true,
		'disabled' => true,
		'placeholder' => true,
	);

	$allowed_tags['defs'] = array();
	
	$allowed_tags['a'] = array(
		'href' => true,
		'target' => true,
	);
	
	$allowed_tags['br'] = array();
	
	$allowed_tags['image'] = array(
		'href' => true,
		'id' => true,
		'width' => true,
		'height' => true,
	);

	$allowed_tags['use'] = array(
		'href' => true,
		'transform' => true,
		'x' => true,
		'y' => true,
	);

	$allowed_tags['path'] = array(
		'class' => true,
		'd'     => true,
	);

	$allowed_tags['style'] = array(
		'fill' => true,
	);

	$allowed_tags['svg'] = array(
		'class' => true,
		'xmlns' => true,
		'viewbox' => true,
		'width' => true,
		'height' => true,
	);
	
	return $allowed_tags;
}

function cookieadmin_kses_allowed_protocols($protocols){
	
	global $cookieadmin_settings;
	
	if(empty($cookieadmin_settings['hide_powered_by'])){
		$protocols[] = 'data';
	}

	return $protocols;
}

function cookieadmin_logo_svg(){
	
	return '<svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 829 137" width="90" height="15"><defs><image width="512" height="512" id="img1" href="data:image/png;base64,[encoded data, 10612 characters]"/><image  width="84" height="82" id="img2" href="data:image/png;base64,[encoded data, 12504 characters]"/></defs><style>.a{fill:#001d39}.b{fill:#985e23}</style><use  href="#img1" transform="matrix(.269,0,0,.269,.483,.483)"/><path class="a" d="m174.9 108.6q-10 0-18.2-4.7-8.1-4.8-12.9-13-4.7-8.3-4.7-18.3 0-10.2 4.6-18.4 4.6-8.2 12.6-12.8 8-4.7 18-4.7 5.4 0 10.6 1.3 5.2 1.3 8.9 3.7l-2.7 15.5q-7.2-2.7-13-2.7-8 0-12.3 4.7-4.3 4.6-4.3 13.3 0 8.5 4.5 13.3 4.6 4.7 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