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.
97 lines
3.0 KiB
97 lines
3.0 KiB
<?php
|
|
|
|
require_once 'site-settings.php';
|
|
|
|
|
|
|
|
$coordinates = $_POST['field-search-coordinates'];
|
|
list($latitude, $longitude) = explode(',', $coordinates);
|
|
|
|
$latitude = trim(number_format($latitude, 3));
|
|
$longitude = trim(number_format($longitude, 3));
|
|
$unit = $_POST['field-option-unit'];
|
|
$language = $_POST['field-option-language'];
|
|
$decimal = $_POST['field-option-decimal'];
|
|
$time = $_POST['field-option-time'];
|
|
$theme = $_POST['field-option-theme'];
|
|
$apikey = $_POST['field-api-key'];
|
|
|
|
|
|
header("Location: ".url('lat:'.$latitude.',lng:'.$longitude.'/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;
|
|
|
|
|
|
|
|
/*
|
|
$latitude_pure = (isset($_GET['lat']) ? strip_tags(htmlspecialchars($_GET['lat'])) : null);
|
|
$latitude_shorten = (float)number_format($latitude_pure, 3);
|
|
$longitude_pure = (isset($_GET['lng']) ? strip_tags(htmlspecialchars($_GET['lng'])) : null);
|
|
$longitude_shorten = (float)number_format($longitude_pure, 3);
|
|
$unit = (isset($_GET['uni']) ? strip_tags(htmlspecialchars($_GET['uni'])) : null);
|
|
$language = (isset($_GET['lan']) ? strip_tags(htmlspecialchars($_GET['lan'])) : null);
|
|
$decimal = (isset($_GET['dec']) ? strip_tags(htmlspecialchars($_GET['dec'])) : null);
|
|
$time = (isset($_GET['tim']) ? strip_tags(htmlspecialchars($_GET['tim'])) : null);
|
|
$theme = (isset($_GET['the']) ? strip_tags(htmlspecialchars($_GET['the'])) : null);
|
|
$apikey = (isset($_GET['api']) ? strip_tags(htmlspecialchars($_GET['api'])) : null);
|
|
|
|
|
|
|
|
if(strlen($latitude_pure) > 8 OR strlen($longitude_pure) > 8) {
|
|
|
|
header("Location: ".url('lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$unit.','.$language.','.$decimal.','.$time.','.$theme.'/form:settings', true));
|
|
exit;
|
|
|
|
|
|
} else {
|
|
|
|
header('Content-Type: application/json;charset=utf-8');
|
|
|
|
|
|
|
|
$array_unit = [
|
|
'metric' => 0,
|
|
'imperial' => 1
|
|
];
|
|
|
|
$array_decimal = [
|
|
'comma' => 0,
|
|
'dot' => 1
|
|
];
|
|
|
|
$array_time = [
|
|
'24h' => 0,
|
|
'12h' => 1
|
|
];
|
|
|
|
$array_theme = [
|
|
'light' => 0,
|
|
'dark' => 1
|
|
];
|
|
|
|
$settings_unit = ($unit == null ? $settings_unit : $array_unit[$unit]);
|
|
$settings_decimal = ($decimal == null ? $settings_decimal : $array_decimal[$decimal]);
|
|
$settings_time = ($time == null ? $settings_time : $array_time[$time]);
|
|
$settings_theme = ($theme == null ? $settings_theme : $array_theme[$theme]);
|
|
$settings = $settings_unit . $settings_decimal . $settings_time . $settings_theme;
|
|
|
|
|
|
|
|
$json = [
|
|
'latitude' => $latitude_shorten,
|
|
'longitude' => $longitude_shorten,
|
|
'unit' => $unit,
|
|
'language' => $language,
|
|
'decimal' => $decimal,
|
|
'time' => $time,
|
|
'theme' => $theme,
|
|
'apikey' => $apikey,
|
|
'shortcut' => 'https://'.$config->domain.'/'.$language.'/'.$latitude.','.$longitude.'/s:'.$settings . ($apikey == null ? '' : '/a:'.$apikey),
|
|
'only_language' => 'https://'.$config->domain.'/'.$language
|
|
];
|
|
|
|
echo json_encode($json);
|
|
|
|
}
|
|
*/
|
|
|
|
?>
|