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.
 
 
 

86 lines
3.0 KiB

<?php
require_once 'site-functions.php';
require_once 'site-config.php';
$debug = true;
$useragent = $_SERVER['HTTP_USER_AGENT'];
$host = $_SERVER['HTTP_HOST'];
$protocol = (stripos($_SERVER['SERVER_PROTOCOL'], 'http') !== false ? 'https' : 'http');
$cdnurl = 'https://cdn.serenum.org';
$filename_path = explode('/', $_SERVER['PHP_SELF']);
$filename = $filename_path[count($filename_path) - 1];
$filename_query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$filename_get = !empty($filename_query) ? $filename_query : '-';
$og_title = $config_title;
$og_url = $protocol.'://'.$config_domain;
$og_image = $config_image;
$og_image_alternative = $config_image_alternative;
$og_description = $config_description;
if($filename != 'shortcut.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);
$settings_exists = false;
if(isset($_GET['lat']) AND isset($_GET['lng']) AND isset($_GET['uni']) AND isset($_GET['lan']) AND isset($_GET['dec']) AND isset($_GET['tim']) AND isset($_GET['the'])) {
$settings_exists = true;
}
$array_pages = [
'page-about.php',
'page-api.php',
'page-contact.php',
'page-faq.php',
'page-settings.php',
'errors.php',
'weather-data.php'
];
$lang = json_decode(file_get_contents('languages/'.$settings_language.'.json'));
$cookie_exists = (isset($_COOKIE['weather-settings']) ? true : false);
$cs_coordinates = null;
$cs_unit = null;
$cs_language = null;
$cs_decimal = null;
$cs_time = null;
$cs_theme = null;
$cs_apikey = null;
if($cookie_exists == true) {
$settings = explode('/', $_COOKIE['weather-settings']);
list($cs_latitude, $cs_longitude) = explode(',', $settings[0]);
$cs_coordinates = $settings[0];
$cs_unit = $settings[1];
$cs_language = $settings[2];
$cs_decimal = $settings[3];
$cs_time = $settings[4];
$cs_theme = $settings[5];
$cs_apikey = (isset($settings[6]) ? $settings[6] : null);
$settings_theme = $cs_theme;
}
if(!in_array($filename, $array_pages) AND $settings_exists == false) {
header("Location: ".url('settings'));
exit;
}
}
?>