| Server IP : 178.212.43.201 / Your IP : 10.100.0.33 Web Server : Apache/2.4.37 (Oracle Linux Server) OpenSSL/1.1.1k System : Linux spa0007.srv.paxillus.pl 5.4.17-2136.355.3.1.el8uek.x86_64 #3 SMP Sat May 9 17:11:55 PDT 2026 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/paxillus/wp-content/plugins/cloudflare/src/WordPress/ |
Upload File : |
<?php
namespace Cloudflare\APO\WordPress;
class Utils
{
const COMPOSER_CONFIG_PATH = '/../../composer.json';
/**
* @param $haystack
* @param $needle
*
* @return bool
*/
public static function strEndsWith($haystack, $needle)
{
if (empty($haystack) || empty($needle)) {
return false;
}
$needle_len = strlen($needle);
return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, -$needle_len));
}
public static function isSubdomainOf($subDomainName, $domainName)
{
if (empty($subDomainName) || empty($domainName)) {
return false;
}
// Check if strpos is a positive integer
$dotPosition = strpos($subDomainName, $domainName) - 1;
if ($dotPosition === -1) {
return false;
}
return self::strEndsWith($subDomainName, $domainName) &&
$subDomainName !== $domainName &&
$subDomainName[$dotPosition] == '.';
}
public static function getRegistrableDomain($domainName)
{
// Remove characters up to the first "." character.
// For example:
// blog.domain.com -> domain.com
// does not work with multiple subdomain
// sub1.sub2.domain.com -> sub2.domain.com
return preg_replace('/^[^.]*.\s*/', '', $domainName);
}
public static function getComposerJson(): array
{
if (!file_exists(dirname(__FILE__) . self::COMPOSER_CONFIG_PATH)) {
return [];
}
return json_decode(file_get_contents(dirname(__FILE__) . self::COMPOSER_CONFIG_PATH), true);
}
}