File manager - Edit - /var/www/html/portal/app/Support/GoogleMapsEmbed.php
Back
<?php namespace App\Support; /** * Valida URLs de mapa do Google para uso em iframe (embed). */ class GoogleMapsEmbed { private const ALLOWED_HOST_SUFFIXES = [ 'google.com', 'google.com.br', ]; /** * Retorna a URL sanitizada para src do iframe, ou null se não for permitida. */ public static function embedSrc(?string $raw): ?string { if ($raw === null) { return null; } $trimmed = trim($raw); if ($trimmed === '') { return null; } if (! filter_var($trimmed, FILTER_VALIDATE_URL)) { return null; } $parts = parse_url($trimmed); if (($parts['scheme'] ?? '') !== 'https' || empty($parts['host'])) { return null; } $host = strtolower($parts['host']); foreach (self::ALLOWED_HOST_SUFFIXES as $suffix) { if ($host === $suffix || str_ends_with($host, '.'.$suffix)) { return $trimmed; } } return null; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.09 |
proxy
|
phpinfo
|
Settings