HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/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;
			}
		}
	}
}