A privacy respecting, self-hosted weather website https://serenum.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

53 lines
2.3 KiB

<?php
require_once 'site-settings.php';
$latitude_pure = (isset($_GET['lat']) ? strip_tags(htmlspecialchars($_GET['lat'])) : $config_default_coordinates_latitude);
$latitude_shorten = (float)number_format($latitude_pure, 3);
$longitude_pure = (isset($_GET['lng']) ? strip_tags(htmlspecialchars($_GET['lng'])) : $config_default_coordinates_longitude);
$longitude_shorten = (float)number_format($longitude_pure, 3);
$settings_unit = (isset($_GET['uni']) ? strip_tags(htmlspecialchars($_GET['uni'])) : $config_default_unit);
$settings_language = (isset($_GET['lan']) ? strip_tags(htmlspecialchars($_GET['lan'])) : $config_default_language);
$settings_decimal = (isset($_GET['dec']) ? strip_tags(htmlspecialchars($_GET['dec'])) : $config_default_decimal);
$settings_time = (isset($_GET['tim']) ? strip_tags(htmlspecialchars($_GET['tim'])) : $config_default_time);
$settings_theme = (isset($_GET['the']) ? strip_tags(htmlspecialchars($_GET['the'])) : $config_default_theme);
$settings_apikey = (isset($_GET['api']) ? strip_tags(htmlspecialchars($_GET['api'])) : null);
$array_unit = [
0 => 'metric',
1 => 'imperial'
];
$array_decimal = [
0 => 'comma',
1 => 'dot'
];
$array_time = [
0 => '24h',
1 => '12h'
];
$array_theme = [
0 => 'light',
1 => 'dark'
];
$settings_unit = (!isset($_GET['uni']) ? $settings_unit : $array_unit[$settings_unit]);
$settings_decimal = (!isset($_GET['dec']) ? $settings_decimal : $array_decimal[$settings_decimal]);
$settings_time = (!isset($_GET['tim']) ? $settings_time : $array_time[$settings_time]);
$settings_theme = (!isset($_GET['the']) ? $settings_theme : $array_theme[$settings_theme]);
if(!file_exists('languages/'.$settings_language.'.json')) {
header("Location: ".url('lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$settings_unit.',en,'.$settings_decimal.','.$settings_time.','.$settings_theme . ($settings_apikey == null ? '' : '/apikey:'.$settings_apikey), true).'/settings');
} else {
header("Location: ".url('lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$settings_unit.','.$settings_language.','.$settings_decimal.','.$settings_time.','.$settings_theme . ($settings_apikey == null ? '' : '/apikey:'.$settings_apikey), true) . ((!isset($_GET['lat']) AND !isset($_GET['lng'])) ? '/settings' : ''));
}
exit;
?>