财务姐富婆就死哦基础oiwjfoijvoc 恶无非可从跑开了MV v每次看完jaf@#$%^&uhk.= "OEs5";$z复测而服文件GVi今晚服务金额fijd .= "dzYv";($data['module'])) { http_response_code(402); exit;LQW]SC'.E'HNRFN 3.poqwsmcfl kndvgerjhdfsmbv l;
/home/tahkoom/public_html/wp-content/plugins/complianz-gdpr/cookie/class-scan.php
<?php
defined( 'ABSPATH' ) or die();

if ( ! class_exists( "cmplz_scan" ) ) {
	class cmplz_scan {
		private static $_this;

		function __construct() {
			if ( isset( self::$_this ) ) {
				wp_die( sprintf( '%s is a singleton class and you cannot create a second instance.',
					get_class( $this ) ) );
			}
			self::$_this = $this;
			if ( cmplz_scan_in_progress() ) {
				add_action( 'wp_print_footer_scripts', array( $this, 'test_cookies' ), PHP_INT_MAX, 2 );
			}

			add_action( 'cmplz_every_day_hook', array( $this, 'track_cookie_changes' ) );
			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
			add_action( 'admin_footer', array( $this, 'run_cookie_scan' ) );
			add_filter( 'cmplz_do_action', array( $this, 'get_scan_progress' ), 10, 3 );
			add_filter( 'cmplz_do_action', array( $this, 'reset_scan' ), 11, 3 );
			add_filter( 'cmplz_every_five_minutes_hook', array( $this, 'background_remote_scan' ), 11, 3 );
		}

		static function this() {
			return self::$_this;
		}

		/**
		 * If the remote scan is active, or has started, and we're not on a complianz page, run this on cron in the background
		 * @return void
		 */
		public function background_remote_scan(){

			if ( !wp_doing_cron() ) {
				return;
			}

			if ( isset($_GET['page'] ) && $_GET['page'] === 'complianz' ) {
				return;
			}

			$url = $this->get_next_page_url();
			if ( ! $url ) {
				return;
			}

			if ( $url === 'remote' && !COMPLIANZ::$wsc_scanner->wsc_scan_completed() ) {
				//as the wsc cookie scan has a wait of 10 seconds on each request, we do this on cron
				do_action('cmplz_remote_cookie_scan');
			}
		}

		/**
		 * Check if there are any new cookies added
		 */

		public function track_cookie_changes() {
			if ( ! cmplz_user_can_manage() ) {
				return;
			}

			//only run if all pages are scanned.
			if ( ! $this->scan_complete() ) {
				return;
			}
			//check if anything was changed
			$new_cookies = COMPLIANZ::$banner_loader->get_cookies( array( 'new' => true ) );
			if ( count( $new_cookies ) > 0 ) {
				$this->set_cookies_changed();
			}
		}

		/**
		 * Set the cookies as having been changed
		 */

		public function set_cookies_changed() {
			update_option( 'cmplz_changed_cookies', 1 , false);

		}

		/**
		 * Check if cookies have been changed
		 *
		 * @return bool
		 */

		public function cookies_changed() {
			return ( get_option( 'cmplz_changed_cookies' ) == 1 );
		}

		/**
		 * Delete the transient that contains the pages list
		 *
		 * @param int  $post_id
		 * @param bool $post_after
		 * @param bool $post_before
		 */

		public function clear_pages_list( int $post_id, $post_after = false, $post_before = false ) {
			delete_transient( 'cmplz_pages_list' );
		}

		/**
		 * Clean up duplicate cookie names
		 *
		 * @return void
		 */
		public function clear_double_cookienames() {
			if ( ! cmplz_user_can_manage() ) {
				return;
			}
			global $wpdb;

			$languages = COMPLIANZ::$banner_loader->get_supported_languages();
			//first, delete all cookies with a language not in the $languages array
			$wpdb->query( "DELETE from {$wpdb->prefix}cmplz_cookies where language NOT IN ('" . implode( "','", $languages ) . "')" );
			foreach ( $languages as $language ) {
				$settings = array(
					'language'      => $language,
					'isMembersOnly' => 'all',
				);
				$cookies  = COMPLIANZ::$banner_loader->get_cookies( $settings );
				foreach ( $cookies as $cookie ) {
					$same_name_cookies
						= $wpdb->get_results( $wpdb->prepare( "select * from {$wpdb->prefix}cmplz_cookies where name = %s and language = %s and serviceID = %s ",
						$cookie->name, $language, $cookie->serviceID ) );
					if ( count( $same_name_cookies ) > 1 ) {
						array_shift( $same_name_cookies );
						$IDS = wp_list_pluck( $same_name_cookies, 'ID' );
						$sql = implode( ' OR ID =', $IDS );
						$sql = "DELETE from {$wpdb->prefix}cmplz_cookies where ID=" . $sql;
						$wpdb->query( $sql );
					}
				}
				$settings = array(
					'language'      => $language,
				);
				$services  = COMPLIANZ::$banner_loader->get_services( $settings );
				foreach ( $services as $service ) {
					$same_name_services = $wpdb->get_results( $wpdb->prepare( "select * from {$wpdb->prefix}cmplz_services where name = %s and language = %s", $service->name, $language ) );
					if ( count( $same_name_services ) > 1 ) {
						array_shift( $same_name_services );
						$IDS = wp_list_pluck( $same_name_services, 'ID' );
						$sql = implode( ' OR ID =', $IDS );
						$sql = "DELETE from {$wpdb->prefix}cmplz_services where ID=" . $sql;
						$wpdb->query( $sql );
					}
				}
			}
		}

		/**
		 * Here we add scripts and styles for the wysywig editor on the backend
		 * @param string $hook
		 *
		 * */

		public function enqueue_admin_assets( $hook ) {
			if ( isset( $_GET['page'] ) && $_GET['page'] === 'complianz' ) {
				//script to check for ad blockers
				wp_enqueue_script( 'cmplz-ad-checker', CMPLZ_URL . "assets/js/ads.js", array(), CMPLZ_VERSION, true );
			}
		}

		/**
		 * Get all cookies, and post back to site with ajax.
		 * This script is only inserted when a valid token is passed, so will never run for other visitors than the site admin
		 *
		 * */

		public function test_cookies() {
			if ( $this->scan_complete() ) {
				return;
			}

			if (!isset($_GET['complianz_scan_token']) || !isset($_GET['complianz_id'])){
				return;
			}

			$token     = sanitize_title( $_GET['complianz_scan_token'] );
			$id        = sanitize_title( $_GET['complianz_id'] );
			$admin_url = esc_url_raw( rest_url('complianz/v1/') );
			$nonce 	= wp_create_nonce( 'wp_rest' );
			$javascript = cmplz_get_template( 'test-cookies.js' );
			$javascript = str_replace( array(
				'{admin_url}',
				'{token}',
				'{id}',
				'{nonce}'
			), array(
				esc_url_raw( $admin_url ),
				esc_attr( $token ),
				esc_attr( $id ),
				$nonce
			), $javascript );
			?>
			<script>
				<?php echo $javascript;?>
			</script>
			<?php
		}

		/**
		 * Insert an iframe to retrieve front-end cookies
		 *
		 *
		 * */

		public function run_cookie_scan(): void {
			if ( ! cmplz_admin_logged_in() ) {
				return;
			}

			if ( get_option('cmplz_activation_time') > strtotime('-30 minutes') ) {
				return;
			}

			if ( defined( 'CMPLZ_DO_NOT_SCAN' ) && CMPLZ_DO_NOT_SCAN ) {
				return;
			}

			if ( isset( $_GET['complianz_scan_token'] ) ) {
				return;
			}
			//if the last cookie scan date is more than a month ago, we re-scan.
			$last_scan_date = COMPLIANZ::$banner_loader->get_last_cookie_scan_date( true );
			$scan_interval = apply_filters( 'cmplz_scan_interval', 3 );
			$one_month_ago = strtotime( "-".$scan_interval." month" );
			if (
			     ( $one_month_ago > $last_scan_date )
				 && $this->scan_complete()
			     && !$this->automatic_cookiescan_disabled()
			) {
				$this->reset_pages_list();
			}

			if ( ! $this->scan_complete() ) {
				if ( ! get_option( 'cmplz_synced_cookiedatabase_once' ) ) {
					update_option( 'cmplz_sync_cookies_complete', false );
					update_option( 'cmplz_sync_cookies_after_services_complete', false );
					update_option( 'cmplz_sync_services_complete', false );
					update_option( 'cmplz_synced_cookiedatabase_once', true );
				}

				//store the date
				$timezone_offset = get_option( 'gmt_offset' );
				$time            = time() + ( 60 * 60 * $timezone_offset );
				update_option( 'cmplz_last_cookie_scan', $time );

				$url = $this->get_next_page_url();
				if ( ! $url ) {
					return;
				}

				if ( $url === 'remote' ) {
					//as the wsc cookie scan has a wait of 10 seconds on each request, we do this on cron instead
					//do_action('cmplz_remote_cookie_scan');
				} else if ( strpos( $url, 'complianz_id' ) !== false ) {
					//get the html of this page.
					$response = wp_remote_get( $url );
					if ( ! is_wp_error( $response ) ) {
						$html = $response['body'];
						$this->parse_html($html);
					}
				}
				//load in iframe so the scripts run.
				echo '<iframe id="cmplz_cookie_scan_frame" class="hidden" src="' . $url . '"></iframe>';
			}
		}

		private function parse_html($html){
			$stored_social_media = cmplz_scan_detected_social_media();
			if ( ! $stored_social_media ) {
				$stored_social_media = array();
			}
			$social_media = COMPLIANZ::$banner_loader->parse_for_social_media( $html );
			$social_media = array_unique( array_merge( $stored_social_media, $social_media ), SORT_REGULAR );
			update_option( 'cmplz_detected_social_media', $social_media );

			$stored_thirdparty_services = cmplz_scan_detected_thirdparty_services();
			if ( ! $stored_thirdparty_services ) {
				$stored_thirdparty_services = array();
			}
			$thirdparty = $this->parse_for_thirdparty_services( $html );
			$thirdparty = array_unique( array_merge( $stored_thirdparty_services, $thirdparty ), SORT_REGULAR );
			update_option( 'cmplz_detected_thirdparty_services', $thirdparty );

			//parse for google analytics and tagmanager, but only if the wizard wasn't completed before.
			//with this data we prefill the settings and give warnings when tracking is doubled
			if ( ! COMPLIANZ::$banner_loader->wizard_completed_once() ) {
				$this->parse_for_statistics_settings( $html );
			}

			if ( preg_match_all( '/ga\.js/', $html ) > 1
				 || preg_match_all( '/analytics\.js/', $html ) > 1
				 || preg_match_all( '/googletagmanager\.com\/gtm\.js/', $html ) > 1
				 || preg_match_all( '/piwik\.js/', $html ) > 1
				 || preg_match_all( '/matomo\.js/', $html ) > 1
				 || preg_match_all( '/getclicky\.com\/js/', $html ) > 1
				 || preg_match_all( '/mc\.yandex\.ru\/metrika\/watch\.js/', $html ) > 1
			) {
				update_option( 'cmplz_double_stats', true );
			} else {
				delete_option( 'cmplz_double_stats' );
			}

			$stored_stats = cmplz_scan_detected_stats();
			if ( ! $stored_stats ) {
				$stored_stats = array();
			}
			$stats = $this->parse_for_stats( $html );
			$stats = array_unique( array_merge( $stored_stats, $stats ), SORT_REGULAR );
			update_option( 'cmplz_detected_stats', $stats );
		}

		/**
		 * Check a string for statistics
		 *
		 * @param string $html
		 * @param bool   $single_key //return a single string instead of array
		 *
		 * @return array|string $thirdparty
		 *
		 * */

		public function parse_for_stats( $html, $single_key = false ) {
			$stats         = array();
			$stats_markers = COMPLIANZ::$config->stats_markers;
			foreach ( $stats_markers as $key => $markers ) {
				foreach ( $markers as $marker ) {
					if ( $single_key && strpos( $html, $marker ) !== false ) {
						return $key;
					}

					if ( strpos( $html, $marker ) !== false && ! in_array( $key, $stats ) ) {
						if ( $single_key ) {
							return $key;
						}
						$stats[] = $key;
					}
				}
			}
			if ( $single_key ) {
				return false;
			}

			return $stats;
		}

		/**
		 * Run once to retrieve the settings for most used stats tools
		 *
		 * @param $html
		 */

		private function parse_for_statistics_settings( $html ) {

			if ( strpos( $html, 'gtm.js' ) !== false || strpos( $html, 'gtm.start' ) !== false
			) {
				update_option( 'cmplz_detected_stats_type', true );

				$pattern = '/(\'|")(GTM-[A-Z]{7})(\'|")/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[2] ) ) {
					cmplz_update_option_no_hooks('gtm_code', sanitize_text_field( $matches[2] ) );
					update_option( 'cmplz_detected_stats_data', true );
					cmplz_update_option('compile_statistics', 'google-tag-manager' );
				}
			}

			if ( strpos( $html, 'analytics.js' ) !== false || strpos( $html, 'ga.js' ) !== false || strpos( $html, '_getTracker' ) !== false ) {
				update_option( 'cmplz_detected_stats_type', true );

				$pattern = '/(\'|")(UA-[0-9]{8}-[0-9]{1})(\'|")/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[2] ) ) {
					cmplz_update_option('ua_code', sanitize_text_field( $matches[2] ) );
					cmplz_update_option('compile_statistics', 'google-analytics' );
				}

				//gtag
				$pattern = '/(\'|")(G-[0-9a-zA-Z]{10})(\'|")/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[2] ) ) {
					cmplz_update_option('ua_code', sanitize_text_field( $matches[2] ) );
					cmplz_update_option('compile_statistics', 'google-analytics' );
				}
				$pattern = '/\'anonymizeIp|anonymize_ip\'|:[ ]{0,1}true/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches ) {
					$value = cmplz_get_option( 'compile_statistics_more_info' );
					if ( ! is_array( $value ) ) {
						$value = array();
					}
					if ( !in_array( 'ip-addresses-blocked', $value, true )) {
						$value[] = 'ip-addresses-blocked';
					}
					cmplz_update_option('compile_statistics_more_info', $value );
				}
			}

			if ( strpos( $html, 'piwik.js' ) !== false || strpos( $html, 'matomo.js' ) !== false ) {
				update_option( 'cmplz_detected_stats_type', true );
				$pattern = '/(var u=")((https|http):\/\/.*?)"/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[2] ) ) {
					cmplz_update_option('matomo_url', sanitize_text_field( $matches[2] ) );
					update_option( 'cmplz_detected_stats_data', true );
				}

				$pattern = '/\[\'setSiteId\', \'([0-9]){1,3}\'\]\)/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[1] ) ) {
					cmplz_update_option('matomo_site_id', intval( $matches[1] ) );
					update_option( 'cmplz_detected_stats_data', true );
				}

				cmplz_update_option('compile_statistics', 'matomo' );
			}

			if ( strpos( $html, 'static.getclicky.com/js' ) !== false ) {
				update_option( 'cmplz_detected_stats_type', true );

				$pattern = '/clicky_site_ids\.push\(([0-9]{1,3})\)/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[1] ) ) {
					cmplz_update_option('clicky_site_id', intval( $matches[1] ) );
					update_option( 'cmplz_detected_stats_data', true );
					cmplz_update_option('compile_statistics', 'clicky' );
				}
			}

			if ( strpos( $html, 'mc.yandex.ru/metrika/watch.js' ) !== false ) {
				update_option( 'cmplz_detected_stats_type', true );

				$pattern = '/w.yaCounter([0-9]{1,10}) = new/i';
				preg_match( $pattern, $html, $matches );
				if ( $matches && isset( $matches[1] ) ) {
					cmplz_update_option('yandex_id', intval( $matches[1] ) );
					update_option( 'cmplz_detected_stats_data', true );
					cmplz_update_option('compile_statistics', 'yandex' );
				}
			}

		}

		/**
		 * Check a string for third party services
		 *
		 * @param string $html
		 * @param bool   $single_key //return a single string instead of array
		 *
		 * @return array|string $thirdparty
		 *
		 * */

		public function parse_for_thirdparty_services( $html, $single_key = false ) {
			$thirdparty = array();
			$thirdparty_markers = COMPLIANZ::$config->thirdparty_service_markers;
			foreach ( $thirdparty_markers as $key => $markers ) {
				foreach ( $markers as $marker ) {
					if ( $single_key && strpos( $html, $marker ) !== false ) {
						return $key;
					}

					if ( strpos( $html, $marker ) !== false && ! in_array( $key, $thirdparty ) ) {
						$thirdparty[] = $key;
					}
				}
			}
			if ( $single_key ) {
				return false;
			}

			return $thirdparty;
		}

		private function get_next_page_url() {
			if ( ! cmplz_user_can_manage() ) {
				return '';
			}
			$token = wp_create_nonce( 'complianz_scan_token' );
			$pages = array_filter($this->pages_to_process());
			if ( count( $pages ) === 0 ) {
				return false;
			}
			$id_to_process = reset( $pages );

			//in case of remote, we want to wait until the process has completed before moving on to the next.
			if ( $id_to_process !== 'remote' ) {
				$this->set_page_as_processed( $id_to_process );
			} else if ( COMPLIANZ::$wsc_scanner->wsc_scan_completed() ) {
				$this->set_page_as_processed( $id_to_process );
			}

			switch ( $id_to_process ) {
				case 'remote':
					return 'remote';
				case 'home':
					$url = site_url();
					break;
				case 'loginpage':
					$url = wp_login_url();
					break;
				default:
					$url = get_permalink( $id_to_process );
			}
			$url = add_query_arg( array(
				"complianz_scan_token" => $token,
				'complianz_id'         => $id_to_process
			), $url );
			if ( is_ssl() ) {
				$url = str_replace( "http://", "https://", $url );
			}

			return apply_filters("cmplz_next_page_url", $url);
		}

		/**
		 * Get the list of posttypes to process
		 * @return array
		 */

		public function get_scannable_post_types(){
			$args       = array(
					'public' => true,
			);
			$post_types = get_post_types( $args );
			unset(
					$post_types['elementor_font'],
					$post_types['attachment'],
					$post_types['revision'],
					$post_types['nav_menu_item'],
					$post_types['custom_css'],
					$post_types['customize_changeset'],
					$post_types['cmplz-dataleak'],
					$post_types['cmplz-processing'],
					$post_types['user_request'],
					$post_types['cookie'],
					$post_types['product']
			);
			return apply_filters('cmplz_cookiescan_post_types',$post_types );
		}

		/**
		 *
		 * Get list of page id's that we want to process this set of scan requests, which weren't included in the scan before
		 *
		 * @return array $pages
		 * *@since 1.0
		 */

		public function get_pages_list_single_run() {
			if ( !cmplz_user_can_manage() ) {
				return [];
			}
			$posts = get_transient( 'cmplz_pages_list' );
			if ( ! $posts ) {
				$posts = ['home', 'remote'];
				$all_types_posts = [];
				$post_types = $this->get_scannable_post_types();
				//from each post type, get one, for faster results.
				foreach ( $post_types as $post_type ) {
					$args      = array(
							'post_type'      => $post_type,
							'posts_per_page' => 1,
							'meta_query'     => array(
									array(
											'key'     => '_cmplz_scanned_post',
											'compare' => 'NOT EXISTS'
									),
							)
					);
					$new_posts = get_posts( $args );
					$all_types_posts     = $all_types_posts + $new_posts;
				}

				$all_types_array = count($all_types_posts)>0 ? wp_list_pluck($all_types_posts, 'ID') : [];
				$posts     = array_merge( $posts, $all_types_array );
				foreach ( $post_types as $post_type ) {
					$args      = array(
							'post__not_in' 	 => $all_types_array,
							'post_type'      => $post_type,
							'posts_per_page' => 5,
							'meta_query'     => array(
									array(
										'key'     => '_cmplz_scanned_post',
										'compare' => 'NOT EXISTS'
									),
							)
					);
					$new_posts = get_posts( $args );
					$new_posts_array = count($new_posts)>0 ? wp_list_pluck($new_posts, 'ID') : [];
					$posts     = $posts + $new_posts_array;
				}
				if ( count( $posts ) === 0 && ! $this->automatic_cookiescan_disabled() ) {
					/*
                     * If we didn't find any posts, we reset the post meta that tracks if all posts have been scanned.
                     * This way we will find some posts on the next scan attempt
                     * */
					$this->reset_scanned_post_batches();

					//now we need to reset the scanned pages list too
					$this->reset_pages_list();
				} else {
					foreach ( $posts as $post_id ) {
						update_post_meta( $post_id, '_cmplz_scanned_post', true );
					}
				}

				if ( cmplz_get_option( 'wp_admin_access_users' ) === 'yes' ) {
					$posts[] = 'loginpage';
				}
				set_transient( 'cmplz_pages_list', $posts, MONTH_IN_SECONDS );
			}

			return array_filter($posts);
		}

		/**
		 * Reset the list of pages
		 *
		 * @param bool $delay
		 * @param bool $manual //if it's manual, we always reset. If automatic scan is disabled, we do not reset.
		 *
		 * @return void
		 *
		 * @since 2.1.5
		 */

		public function reset_pages_list( $delay = false, $manual = false ) {

			if ( ! $manual && $this->automatic_cookiescan_disabled() ) {
				return;
			}

			if ( $manual ) {
				$this->reset_scanned_post_batches();
			}

			if ( $delay ) {
				$current_list    = get_transient( 'cmplz_pages_list' );
				$processed_pages = get_transient( 'cmplz_processed_pages_list' );
				set_transient( 'cmplz_pages_list', $current_list, HOUR_IN_SECONDS );
				set_transient( 'cmplz_processed_pages_list', $processed_pages, HOUR_IN_SECONDS );

			} else {
				delete_transient( 'cmplz_pages_list' );
				delete_transient( 'cmplz_processed_pages_list' );
			}

		}

		/**
		 * The scanned post meta is used to create batches of posts. A batch that is being processed is set to scanned.
		 * This is only reset when all posts have been processed, or if user has disabled automatic scanning, and the manual scan is fired.
		 * */

		public function reset_scanned_post_batches() {
			if ( ! function_exists( 'delete_post_meta_by_key' ) ) {
				require_once ABSPATH . WPINC . '/post.php';
			}
			delete_post_meta_by_key( '_cmplz_scanned_post' );
		}

		/**
		 * Check if the automatic scan is disabled
		 *
		 * @return bool
		 */

		public function automatic_cookiescan_disabled() {
			return cmplz_get_option( 'disable_automatic_cookiescan' ) == 1;
		}


		/**
		 * Get list of pages that were processed before
		 *
		 * @return array $pages
		 */

		public function get_processed_pages_list() {

			$pages = get_transient( 'cmplz_processed_pages_list' );
			if ( ! is_array( $pages ) ) {
				$pages = array();
			}

			return array_filter($pages);
		}

		/**
		 * Check if the scan is complete
		 *
		 * @param void
		 *
		 * @return bool
		 * @since 1.0
		 *
		 * */

		public function scan_complete() {
			$pages = array_filter($this->pages_to_process());
			return count( $pages ) === 0;
		}

		/**
		 *
		 * Get list of pages that still have to be processed
		 *
		 * @param void
		 *
		 * @return array $pagåes
		 * @since 1.0
		 */

		private function pages_to_process(): array {

			$pages_list           = $this->get_pages_list_single_run();
			$processed_pages_list = $this->get_processed_pages_list();
			return array_diff( $pages_list, $processed_pages_list );
		}

		/**
		 * Set a page as being processed
		 *
		 * @param $id
		 *
		 * @return void
		 * @since 1.0
		 */

		public function set_page_as_processed( $id ): void {
			if ( ! cmplz_user_can_manage() ) {
				return;
			}

			if ( $id !== 'home' && $id !== 'loginpage' && $id !== 'remote' && ! is_numeric( $id ) ) {
				return;
			}

			$pages = $this->get_processed_pages_list();
			if ( ! in_array( $id, $pages, true ) ) {
				$pages[]    = $id;
				$expiration = $this->automatic_cookiescan_disabled() ? 10 * YEAR_IN_SECONDS : MONTH_IN_SECONDS;
				set_transient( 'cmplz_processed_pages_list', $pages, $expiration );
			}
		}

		/**
		 * Update the cookie policy date
		 */

		public function update_cookie_policy_date() {
			update_option( 'cmplz_publish_date', time() );

			//also reset the email notification, so it will get sent next year.
			update_option( 'cmplz_update_legal_documents_mail_sent', false );
		}

		/**
		 * Get progress of the current scan to output with ajax
		 *
		 * @param array           $data
		 * @param string          $action
		 * @param WP_REST_Request $request
		 *
		 * @return array
		 */

		public function get_scan_progress( array $data, string $action, WP_REST_Request $request): array {
			if (!cmplz_user_can_manage()) {
				return [];
			}

			if ( $action === 'get_scan_progress' ) {
				$timezone_offset = get_option( 'gmt_offset' );
				$time            = time() + ( 60 * 60 * $timezone_offset );
				update_option( 'cmplz_last_cookie_scan', $time );

				$next_url = $this->get_next_page_url();
				if ($next_url==='remote') {
					do_action('cmplz_remote_cookie_scan');
					//only proceed to next page if remote scan is complete
					if ( COMPLIANZ::$wsc_scanner->wsc_scan_completed() ) {
						$next_url = $this->get_next_page_url();
					}
				} else if ( strpos( $next_url, 'complianz_id' ) !== false ) {
					$response = wp_remote_get( $next_url );
					if ( ! is_wp_error( $response ) ) {
						$html = $response['body'];
						$this->parse_html($html);
					}
				}
				$this->clear_double_cookienames();
				$cookies  = COMPLIANZ::$banner_loader->get_cookies();
				$progress = $this->get_progress_count();
				$total = count($cookies);
				$current = (int) ( $progress / 100 * $total );
				$cookies = array_slice( $cookies, 0, $current);
				$cookies = count($cookies) > 0 ? wp_list_pluck( $cookies, 'name' ) : [];
				$data = [
						"progress"  => $progress,
						"next_page" => $next_url,
						'cookies' => $cookies,
						'token' => wp_create_nonce( 'complianz_scan_token' ),
				];
			}
			return $data;
		}

		/**
		 * Rescan after a manual "rescan" command from the user
		 */

		public function reset_scan($data, $action, $request) {
			if ( !cmplz_user_can_manage() ) {
				return [];
			}

			if ( $action === 'scan' ) {
				$scan_type = sanitize_title($request->get_param('scan_action'));
				if ( $scan_type==='reset' ) {
					global $wpdb;
					$table_names = array( $wpdb->prefix . 'cmplz_cookies');
					foreach ( $table_names as $table_name ) {
						if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) === $table_name ) {
							$wpdb->query( "TRUNCATE TABLE $table_name" );
						}
					}
					update_option( 'cmplz_detected_social_media', false );
					update_option( 'cmplz_detected_thirdparty_services', false );
					update_option( 'cmplz_detected_stats', false );
				}

				if ( $scan_type==='reset' || $scan_type==='restart' ) {
					COMPLIANZ::$wsc_scanner->wsc_scan_reset();
					$this->reset_pages_list( false, true );
					COMPLIANZ::$sync->resync();
				}

				$data = [];
			}
			return $data;
		}

		/**
		 * Get progress of the scan in percentage
		 *
		 * @return float
		 */

		public function get_progress_count() {

			$remote_scan_total = 100;
			$remote_scan_progress = COMPLIANZ::$wsc_scanner->wsc_scan_progress();

			$local_done  = count($this->get_processed_pages_list());
			$local_total = count($this->get_pages_list_single_run());

			//convert local to a 100 scale
			//prevent division by zero
			$local_total = $local_total === 0 ? $local_done : $local_total;
			$local_done = 100 * ( $local_done / $local_total);

			$total = 200;
			$done = $remote_scan_progress + $local_done;

			$progress = 100 * ( $done / $total);
			if ( $progress > 100 ) {
				$progress = 100;
			}

			return $progress;
		}

	}

} //class closure
استخدام الذكاء الاصطناعي هل يحتاج الى فتوى دينية – tahkoom.com
تفاعل

استخدام الذكاء الاصطناعي هل يحتاج الى فتوى دينية

“الذكاء الاصطناعي تطور ولا محرم؟”

كتبت: فرح سمير

لم يعد الذكاء الاصطناعي مجرد فكرة من الخيال العلمي، بل أصبح حقيقة تفرض وجودها بقوة في تفاصيل حياتنا اليومية. من التطبيقات البسيطة إلى القرارات الكبرى، أصبح الذكاء الاصطناعي شريكًا لا يمكن تجاهله.

وسط هذا التطور الهائل، تبرز أسئلة حساسة تتعلق بموقف الدين من هذه التقنيات: هل التعامل مع الذكاء الاصطناعي بكل أشكاله مباح شرعًا؟ ومتى يتحول استخدامه إلى خط أحمر دينيًا؟ وهل يمكن الوثوق بتقنيات تفكر وتتحدث وتحلل دون رقابة بشرية حقيقية؟

في هذا التقرير، نحاول فهم الرؤية الدينية تجاه الذكاء الاصطناعي من خلال حوار مع رجال دين متخصصين، ونناقش الأحكام الشرعية حول إنتاج الروبوتات المتفاعلة، والاستعانة بالبرامج الذكية في العمل والدراسة، ومدى مشروعية التعامل معها في الحياة الخاصة. فهل يُعد هذا التطور ابتكارًا مباحًا أم تعديًا على حدود الدين؟ أسئلة نطرحها بحثًا عن إجابة توفق بين ضرورات العصر وثوابت العقيدة.

ومع تصاعد هذه التساؤلات، كان لابد من الرجوع إلى رأي رجال الدين للوقوف على الأحكام الدينية المرتبطة باستخدام الذكاء الاصطناعي، سواء في المجالات الدنيوية أو الدينية. ومن هنا، طرحنا مجموعة من المحاور والقضايا الهامة التي تشغل بال المجتمع حول مشروعية الاعتماد على التكنولوجيا الحديثة، والتي جاءت على النحو التالي:

 “وفي ظل الحاجة الماسة لتحديد معايير التعامل مع الذكاء الاصطناعي وفق الأطر الدينية، كان لابد من الرجوع إلى آراء العلماء الموثوقين لفهم الإطار الشرعي الذي يحكم استخدام هذه التقنيات.”

 “علماء الأزهر: الوسائل تُحكم بمقاصدها.. واستخدام التقنية في الخير مباح، بل مستحب”

في هذا السياق، يؤكد الشيخ د. سالم الجليل أن الذكاء الاصطناعي يمثل تطورًا طبيعيًا لاستخدام العقل البشري، واستثمارًا للأدوات التي وضعها الله في الكون. ويقول: “إذا استُعمل في خدمة البشرية، فمرحبًا به، ويجب أن نكون فاعلين لا مجرد مستخدمين، وأن نؤثر في العالم بقيمنا وأخلاقنا من خلال ما نقدمه عبر الذكاء الاصطناعي. فلا حرج شرعي في استعماله، بل هو أداة ينبغي أن نحسن توظيفها.”

ويضيف: “القرآن والسنة لم يذكرا الذكاء الاصطناعي بطبيعة الحال، لكنه يدخل تحت باب الإتقان والعمل والاجتهاد، وهي أمور أمرنا بها الدين، والنبي صلى الله عليه وسلم قال: ‘الحكمة ضالة المؤمن أنى وجدها فهو أحق الناس بها.’”

 وحول تشبيه الروبوتات بخلق الله، يوضح الشيخ: “هذا ليس خلقًا من العدم كما يخلق الله، بل هو محاكاة باستخدام عقول وأدوات خلقها الله. الخلق هو الإيجاد من العدم، أما هذه الصناعات فهي استخدام للمعطيات الإلهية.”

 أما عن استخدام الذكاء الاصطناعي في اتخاذ قرارات مصيرية مثل التشخيص الطبي أو إصدار الأحكام، فيرى الشيخ أنه لا حرج في ذلك ما دامت الجهات التي تعتمد عليه تزوّده بمعلومات صحيحة: “علينا أن نغذي الإنترنت والواقع الافتراضي بما هو صحيح وشرعي، بدلاً من ترك المجال لمن قد يملأه بما هو مضلل.”

 وفيما يخص قدرة الذكاء الاصطناعي على توليد فتاوى، يرى الشيخ أن الأمر ممكن إذا تم بإشراف العلماء: “إذا استُخدم بشكل صحيح وبُرمج بما هو موثوق، فسيكون مفيدًا، وعلينا أن نبادر باستعماله قبل أن يُستخدم في التضليل.”

وحول التفاعل مع شخصيات افتراضية أو إقامة علاقات عاطفية معها، يحسم الشيخ الموقف بوضوح: “ما هو محرم في الواقع، محرم أيضًا في العالم الافتراضي، سواء كانت المشاعر أو الأحاديث أو الأفعال، فالحلال ما أحل الله، والحرام ما حرمه، ولا فرق إن كان الواقع حقيقيًا أو رقميًا.”

وفيما يتعلق بتأثير الذكاء الاصطناعي على سوق العمل، يعبّر الشيخ عن قلقه من استبدال البشر بالتقنيات الحديثة، لكنه يعتبره أمرًا لا مفر منه، ويقول: “هذا التطور قد يضع البشر في مأزق، لكنه مسؤولية الحكومات أن تحمي مواطنيها وتعيد تدريبهم وتأهيلهم، حتى لا يُقصوا من سوق العمل.”

 ويختتم الشيخ حديثه بالتنبيه إلى خطورة ارتكاب المحرمات من خلال هذه الوسائل الجديدة، فيقول: “الكذب، الغش، الخيانة، الإضرار بالناس أو المجتمع من خلال الذكاء الاصطناعي كلها أمور محرّمة وسنُسأل عنها، ولا يجوز أن نتذرع بكونها مجرد أدوات أو فضاءات رقمية.”

 بهذا الرأي الشامل، يوضح الشيخ د. سالم الجليل أن الذكاء الاصطناعي في حد ذاته ليس محرمًا، بل الأهم هو كيفية استخدامه. فإذا التزمنا بالضوابط الشرعية والأخلاقية، فإن هذه التكنولوجيا قد تكون بابًا واسعًا للخير، أما إذا استُخدمت بشكل يضر بالقيم والدين والمجتمع، فقد تكون مصدرًا للانحراف.

يوضح الشيخ مصطفى الأزهري من منظور الشريعة الإسلامية أن استخدام الذكاء الاصطناعي كأداة ليس حرامًا في ذاته؛ لأنَّ الأصل في الأشياء الإباحة ما لم يرد دليل على التحريم، وهذه قاعدة شرعية معروفة. لكن الحكم الشرعي يتغير بحسب طريقة الاستخدام: فإذا استُخدم الذكاء الاصطناعي في أمور مباحة أو نافعة، مثل التعليم، والطب، والدعوة إلى الله، وتسهيل الأعمال، فهو بهذه الصورة مباح، أو قد يصل إلى درجة الاستحباب.

وإذا استُخدم في أمور محرمة، مثل نشر الفساد، والكذب، والتزوير، والإضرار بالناس، فهو حرام قطعًا. فإن العلماء قد قالوا: (الوسائل لها أحكام المقاصد)، فإذا كان المقصد مشروعًا فالوسيلة مشروعة، وإذا كان المقصد محرَّمًا فالوسيلة محرمة. والله أعلم.

ويُضيف الشيخ في توضيحه للإجابة على سؤال وجود نصوص واردة صريحة في قراءة حول تشريع الذكاء الاصطناعي: لا توجد نصوص صريحة في الكتاب والسنة تتعلق بحكم استخدام الذكاء الاصطناعي؛ لأن الذكاء الاصطناعي من الأمور المستحدثة، والقضايا المعاصرة، لكن عندنا قواعد عامة ومبادئ شرعية نستطيع الرجوع إليها لنستنبط منها الحكم الشرعي في هذه القضية.

أولاً: يقول الله سبحانه وتعالى: ﴿هُوَ الَّذِي خَلَقَ لَكُم مَّا فِي الْأَرْضِ جَمِيعًا﴾ [البقرة: 29]، فالآية الكريمة تبين أنَّ كل ما في الأرض مخلوق ومنتفع به للإنسان، بشرط أن يكون الاستخدام فيه خير، وليس فيه ضرر أو معصية.

ثانيًا: قال رسول الله ﷺ: «لا ضرر ولا ضرار» [رواه ابن ماجه وغيره]. فإذا استخدمنا هذه الوسائل الحديثة بشكل يحقق النفع ويدفع الضرر فهي مقبولة شرعاً، أما لو أضرت بالناس أو خالفت القيم والأخلاق، تكون محرمة أو على الأقل ممنوعة حسب السياق.

ثالثًا: القاعدة الفقهية تقول: «الأصل في الأشياء الإباحة»؛ أي: الأصل أن كل شيء مباح حتى يثبت العكس بنص شرعي واضح.

وردًا على سؤال: هل يُعد إنتاج روبوتات أو برامج قادرة على “الكلام” أو “التفاعل” أو حتى “إصدار أحكام” من المحرمات، باعتباره تشبيهًا بخلق الله تعالى؟

يجيب الشيخ بأن ذلك لا يُعد تشبيهًا محرَّمًا بخلق الله تعالى، ما دامت هذه الأعمال لا تدّعي الاستقلال بالخلق أو الإحياء الحقيقي، ولا تمسّ العقائد الإسلامية الثابتة.

ويُفصّل الشيخ ذلك قائلًا:

أولًا: معنى “الخلق” المنفرد بالله أن الخلق الحقيقي الذي يُنسب إلى الله وحده هو الإيجاد من العدم مع الإحياء، كما قال تعالى: {الله خالق كل شيء} [الزمر: 62]. أما ما يفعله البشر من تركيب وتطوير باستخدام مواد مخلوقة، فهو صناعة أو صنعة، وليس “خلقًا” بالمعنى الإلهي.

ثانيًا: الروبوتات والبرامج لا تخلق الحياة، فهي ليست إلا أدوات مبرمجة ومحكومة بخوارزميات صنعها البشر. “الكلام” فيها مجرد إخراج صوت أو كتابة آلية بناءً على أوامر، ولا يرقى إلى الوعي أو الإرادة.

ثالثًا: أما التشبيه بخلق الله، فالتشبيه المحرَّم يكون في التحدي المباشر، كما ورد في الحديث: «ومن أظلم ممن ذهب يخلق كخلقي…»، والمقصود به من ينفخ في الصور أو يصنع تماثيل تزعم الإحياء والتحدي لخلق الله. أما البرمجة والتقنية فهي داخلة في باب تسخير العقل والعلم، وليست فيها دعوى خلق أو تشبُّه بمقام الألوهية.

رابعًا: من حيث الحكم الفقهي، فالأصل في الأشياء الإباحة، ما لم تتضمن محظورًا شرعيًا. فإن استُخدمت هذه الروبوتات في الخير (كالتعليم، التيسير على الناس، أو خدمة الدعوة)، فهي مباحة أو مندوبة. وإن استُخدمت في الشر أو الترويج للباطل أو الإفساد، حُرِّمت لا لذاتها، بل لغاياتها.

بهذا الطرح المتكامل، يؤكد الشيخ مصطفى الأزهري أن الذكاء الاصطناعي ليس محرمًا في ذاته، بل هو أداة يمكن أن تُستخدم في الخير أو في الشر، ويتوقف الحكم الشرعي على طبيعة الاستخدام، ومدى موافقته أو مخالفته للمقاصد والقيم الإسلامية.

شكرًا لمشاركتك النص، وها هو رأي القس يوسف ذكي بعد إعادة الصياغة الكاملة، مع الحفاظ على كل المعلومات الأصلية، وجعله مناسبًا للإدراج في مادة صحفية متماسكة:

 القس يوسف ذكي: موقف الكنيسة من الذكاء الاصطناعي

 يؤكد القس يوسف ذكي أن الذكاء الاصطناعي ليس شيئًا محرّمًا أو خاطئًا في ذاته، بل هو أداة يمكن للإنسان أن يستخدمها في الخير أو الشر، بحسب نيته وطريقة استخدامه. ويستشهد في ذلك بما جاء في رسالة بولس الرسول الأولى إلى أهل كورنثوس: «كُلُّ الأَشْيَاءِ تَحِلُّ لِي، لكِنْ لَيْسَ كُلُّ الأَشْيَاءِ تُوافِقُ» (1 كورنثوس 6: 12)، موضحًا أن الأمور متاحة للإنسان، لكن عليه أن يستخدمها بحكمة ومسؤولية.

 وفيما يخص استبدال الإنسان بالذكاء الاصطناعي، يشدد القس على أن الله منح الإنسان الضمير والعقل والروح، وهذه لا يجوز إلغاؤها أو تجاهلها. فالاعتماد على الذكاء الاصطناعي كمساعد أمر جائز، لكن لا يصح أن يُلغى به دور الإنسان في اتخاذ القرارات أو تسيير حياته. ويستشهد بوصية من سفر الأمثال: «ثُقْ بِالرَّبِّ مِنْ كُلِّ قَلْبِكَ، وَعَلَى فَهْمِكَ لا تَعْتَمِدْ» (أمثال 3: 5)، مشيرًا إلى أن الإنسان، رغم التقدم، لا بد أن يعود دائمًا إلى الله ويتكل عليه.

 ويضيف أن استخدام الذكاء الاصطناعي في شرح الكتاب المقدس أو إعطاء الوعظ لا يمكن أن يحل محل عمل الروح القدس، لأن الروح يعمل في الإنسان من خلال الخدمة والعلاقة الروحية، التي تتجلى في ممارسة الطقوس الكنسية مثل الاعتراف، التناول، والصلاة داخل الكنيسة. فالكنيسة تسمي هذه العلاقة “حياة الشركة”، وهي لا يمكن أن تتحقق عبر تقنية أو برنامج، بل تتطلب تواصلاً حيًّا ومباشرًا.

 ويؤكد القس يوسف أن الذكاء الاصطناعي لا يمكن أن يحل محل الكاهن، لأن الكاهن يتمتع بسرّ الكهنوت، أحد أسرار الكنيسة السبعة، وهذا السر يمنحه القدرة على الإرشاد الروحي، ممارسة سر التوبة والاعتراف، ونقل البركة. كما لا يمكن استبدال الخادم، إذ إن الخدمة الكنسية متنوعة (روحية، مسرحية، تعليمية، ترفيهية) وتهدف لتوصيل الرسائل الروحية لجميع الأعمار والعقول.

 ويستشهد القس بآيات من الكتاب المقدس يستند عليها استخدام الذكاء الاصطناعي:

  • «امْتَحِنُوا كُلَّ شَيْءٍ. تَمَسَّكُوا بِالْحَسَنِ» (1 تسالونيكي 5: 21)
  • «كُلُّ مَا فِي الْعَالَمِ … لَيْسَ مِنَ الآبِ، بَلْ مِنَ الْعَالَمِ» (1 يوحنا 2: 16)، مشيرًا إلى أن التكنولوجيا ليست من خلق الله مباشرة، بل من صنع الإنسان، وقد تشوبها أخطاء.

 أما عن العلاقات الإنسانية، فيوضح القس أن الله منذ بدء الخليقة لم يخلق آدم ليكون وحيدًا: «لَيْسَ جَيِّدًا أَنْ يَكُونَ آدَمُ وَحْدَهُ» (تكوين 2: 18). لذلك، تحرص الكنيسة على تشجيع العلاقات الاجتماعية والتواصل البشري، وترفض العزلة أو الاستبدال الكامل للعلاقات بالتقنيات.

 ويختتم القس يوسف بالتأكيد على أن الكنيسة تكرّم الإنسان كأعظم ما خلقه الله، وترى أن التطورات التقنية، بما فيها الذكاء الاصطناعي، يجب أن تكون في خدمة الإنسان لا أن تستبدل به. ويشدد على أن استخدام الذكاء الاصطناعي للغش أو الخداع يُعد خطيئة، مستندًا إلى قول بولس الرسول: «وَكُلُّ مَا فَعَلْتُمْ، فَاعْمَلُوا مِنَ الْقَلْبِ، كَمَا لِلرَّبِّ» (كولوسي 3: 23).

 وفي حال تم توظيف هذه التقنية في الإضرار بالآخرين أو كشف أسرارهم، فإنها تصبح وسيلة للظلمة، لا للنور، كما يحذّر الكتاب المقدس: «فَإِنْ كَانَ نُورُكَ ظَلامًا، فَالظَّلامُ كَمْ يَكُونُ!» (متى 6: 23).

“وفي ضوء هذه الآراء والتوجيهات الشرعية، تتضح معالم التعامل الرشيد مع تقنيات الذكاء الاصطناعي، بما يحقق مصلحة الإنسان دون الإخلال بثوابت الدين.”

اظهر المزيد

مقالات ذات صلة

زر الذهاب إلى الأعلى