HEX
Server: LiteSpeed
System: Linux bdix5.noc223.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: purebdli (2161)
PHP: 8.1.24
Disabled: NONE
Upload Files
File: /home/purebdli/zarmanhomio.purebdlife.com/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;
			}
		}
	}
}