0) { $baseUrl = substr(ACYM_LIVE, 0, strrpos(ACYM_LIVE, $urls['path'])).'/'; $otherArguments = trim(str_replace($baseUrl, '', ACYM_LIVE), '/'); if (strlen($otherArguments) > 0) { $otherArguments .= '/'; } } else { $baseUrl = ACYM_LIVE; } } if ($otherArguments && strpos($link, $otherArguments) === false) { $link = $otherArguments.$link; } return $baseUrl; } function acym_currentURL(): string { $protocol = isset($_SERVER['HTTPS']) || !empty($_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']) ? 'https' : 'http'; $httpHost = acym_getVar('string', 'HTTP_HOST', '', 'SERVER'); $serverName = acym_getVar('string', 'SERVER_NAME', '', 'SERVER'); $host = empty($httpHost) ? ( empty($serverName) ? getenv('HTTP_HOST') : $serverName ) : $httpHost; $requestUri = acym_getVar('string', 'REQUEST_URI', '', 'SERVER'); return $protocol.'://'.$host.$requestUri; } function acym_cleanUrl(string $url, array $parametersToRemove): string { $parts = acym_parseUrl($url); if (empty($parts['query'])) { return $url; } $queryParams = []; parse_str($parts['query'], $queryParams); foreach ($parametersToRemove as $parameter) { unset($queryParams[$parameter]); } return $parts['scheme'].'://'.$parts['host'].$parts['path'].'?'.http_build_query($queryParams); } function acym_isLocalWebsite(): bool { return strpos(ACYM_LIVE, 'localhost') !== false || strpos(ACYM_LIVE, '127.0.0.1') !== false; } function acym_internalUrlToPath(string $url): string { $base = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', ACYM_LIVE); $replacements = ['https://www.'.$base, 'http://www.'.$base, 'https://'.$base, 'http://'.$base]; foreach ($replacements as $oneReplacement) { if (strpos($url, $oneReplacement) === false) { continue; } return str_replace([$oneReplacement, '/'], [ACYM_ROOT, DS], urldecode($url)); } return $url; } function acym_isValidUrl(string $url): bool { // If this option is not activated in the php.ini file, we return true because the function get_headers will not work if (empty(ini_get('allow_url_fopen'))) { return true; } // If we detect youtu.be url, we don't check the headers because it's a redirection to a valid Url if (strpos($url, 'youtu.be') !== false) { return true; } $headers = @get_headers($url); return !empty($headers) && strpos($headers[0], '200'); } function acym_isImageUrl(string $url): bool { $extension = strtolower(pathinfo($url, PATHINFO_EXTENSION)); return in_array($extension, acym_getImageFileExtensions(true)); }