mirror of
https://github.com/manualdousuario/marreta.git
synced 2025-09-01 10:10:14 +00:00
melhorias de suporte ao android e ios
This commit is contained in:
parent
2de8c4ea45
commit
8389a2110b
3 changed files with 66 additions and 13 deletions
|
@ -60,15 +60,20 @@ $cache_folder = $cache->getCacheFileCount();
|
|||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title><?php echo SITE_NAME; ?></title>
|
||||
<link rel="icon" href="<?php echo SITE_URL; ?>/assets/svg/marreta.svg" type="image/svg+xml">
|
||||
<link rel="manifest" href="<?php echo SITE_URL; ?>/manifest.json">
|
||||
<meta name="theme-color" content="#2563eb">
|
||||
<link rel="manifest" href="<?php echo SITE_URL; ?>/manifest.json">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-title" content="<?php echo SITE_NAME; ?>">
|
||||
<link rel="apple-touch-icon" href="<?php echo SITE_URL; ?>/assets/pwa/apple-touch-icon.png">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="<?php echo SITE_URL; ?>">
|
||||
<link rel="apple-touch-icon" href="assets/pwa/apple-touch-icon.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="assets/pwa/apple-touch-icon.png">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="application-name" content="<?php echo SITE_URL; ?>">
|
||||
<meta name="msapplication-TileColor" content="#2563eb">
|
||||
<meta name="msapplication-tap-highlight" content="no">
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="<?php echo SITE_URL; ?>" />
|
||||
<meta property="og:title" content="<?php echo SITE_NAME; ?>" />
|
||||
|
|
|
@ -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);
|
||||
|
|
44
app/pwa.php
44
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;
|
Loading…
Add table
Reference in a new issue