HEX
Server: LiteSpeed
System: Linux cluster02.load-balancer.x2.network 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: kbdhpghp (1098)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /home/kbdhpghp/vivenciarteatelie.com.br/wp-content/plugins/internal-links/helper/cloudflare.php
<?php

namespace ILJ\Helper;

class Cloudflare {

	/**
	 * Max time limit for any request routed through CF (100 seconds)
	 */
	const MAX_TIME_LIMIT = 95;

	/**
	 * Check for a standard Cloudflare header and return the minimum between safe limit and pre configured
	 *
	 * @return int
	 */
	public static function check_header_for_timelimit_adjust() {
		if (function_exists('ini_get')) {
			$current_limit = ini_get('max_execution_time');
		} else {
			$current_limit = 30;
		}

		// sometimes this function fails, we cannot do anything then
		$headers = getallheaders();
		if (!is_array($headers)) {
			return $current_limit;
		}

		$headers = array_change_key_case($headers, CASE_LOWER);
		
		if (0 === (int) $current_limit) {
			return self::MAX_TIME_LIMIT;
		} else {
			if (isset($headers['cf-connecting-ip']) && ('' != $headers['cf-connecting-ip'])) {
				return min($current_limit, self::MAX_TIME_LIMIT);
			} else {
				return $current_limit;
			}
		}
	}
}