diff --git a/app/index.php b/app/index.php index e232c34..f2dcc55 100644 --- a/app/index.php +++ b/app/index.php @@ -60,15 +60,20 @@ $cache_folder = $cache->getCacheFileCount(); - + <?php echo SITE_NAME; ?> - + - - - + + + + + + + + diff --git a/app/manifest.php b/app/manifest.php index 4206598..dfc768d 100644 --- a/app/manifest.php +++ b/app/manifest.php @@ -10,6 +10,7 @@ */ require_once 'config.php'; +require_once 'inc/Language.php'; header('Content-Type: application/json'); @@ -18,11 +19,14 @@ $manifest = [ 'short_name' => SITE_NAME, 'description' => SITE_DESCRIPTION, 'start_url' => SITE_URL, + 'id' => SITE_URL, + 'scope' => '/', 'display' => 'browser', - 'display_override' => ['window-controls-overlay'], + 'display_override' => ['window-controls-overlay', 'minimal-ui'], 'background_color' => '#ffffff', 'theme_color' => '#2563eb', 'orientation' => 'any', + 'categories' => ['utilities', 'productivity'], 'icons' => [ [ 'src' => 'assets/pwa/192x192.png', @@ -35,17 +39,27 @@ $manifest = [ 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'any maskable' + ], + [ + 'src' => 'assets/pwa/apple-touch-icon.png', + 'sizes' => '180x180', + 'type' => 'image/png', + 'purpose' => 'any' ] ], 'share_target' => [ 'action' => 'pwa.php', 'method' => 'GET', + 'enctype' => 'application/x-www-form-urlencoded', 'params' => [ 'title' => 'title', 'text' => 'text', - 'url' => 'url' + 'url' => 'url', ] - ] + ], + 'prefer_related_applications' => false, + 'lang' => Language::getCurrentLanguage(), + 'dir' => 'ltr' ]; echo json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); diff --git a/app/pwa.php b/app/pwa.php index 9deebf0..e310ece 100644 --- a/app/pwa.php +++ b/app/pwa.php @@ -23,18 +23,52 @@ require_once 'config.php'; +// Get URL and text parameters from GET request +// Obtém os parâmetros URL e text da requisição GET $url = $_GET['url'] ?? ''; +$text = $_GET['text'] ?? ''; -if (!empty($url)) { +/** + * Validates if a given URL is valid + * Valida se uma URL fornecida é válida + * + * @param string $url URL to validate / URL para validar + * @return bool Returns true if URL is valid, false otherwise / Retorna true se a URL for válida, false caso contrário + */ +function isValidUrl($url) { + // First sanitize the URL + // Primeiro sanitiza a URL + $sanitized_url = filter_var($url, FILTER_SANITIZE_URL); + + // Then validate it + // Então valida + return filter_var($sanitized_url, FILTER_VALIDATE_URL) !== false; +} + +// Check URL parameter first +// Verifica primeiro o parâmetro URL +if (!empty($url) && isValidUrl($url)) { + $redirect_url = $url; +} +// If URL is not valid, check text parameter +// Se a URL não é válida, verifica o parâmetro text +elseif (!empty($text) && isValidUrl($text)) { + $redirect_url = $text; +} + +// If we have a valid URL, redirect to it +// Se temos uma URL válida, redireciona para ela +if (isset($redirect_url)) { // Sanitize URL to prevent XSS - $url = filter_var($url, FILTER_SANITIZE_URL); - $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8'); + // Sanitiza a URL para prevenir XSS + $redirect_url = htmlspecialchars($redirect_url, ENT_QUOTES, 'UTF-8'); header('HTTP/1.1 301 Moved Permanently'); - header('Location: /p/' . urlencode($url)); + header('Location: /p/' . urlencode($redirect_url)); exit; } -// If no URL provided, redirect to homepage +// If no valid URL found in either parameter, redirect to homepage +// Se nenhuma URL válida foi encontrada em nenhum dos parâmetros, redireciona para a página inicial header('Location: /'); exit; \ No newline at end of file