Browse Source

Major update

- New page: privacy policy.
- New layout on the about page.
- Added visibility and precipitation for current weather.
- Updated the default language (English).
- Removed the Swedish language for later re-translation.
- Added cookie support on the settings page.
- Added the ability to search for a place (cities only).
- Added better support for weather icons.
- Added a version file for future update checks.
- Using CDN for files that will not be updated so often.
- Using better config method, PHP instead of JSON.
- Bug fixes and improvements.
branch
Airikr 2 weeks ago
parent
commit
2fe9d3a35c
  1. 45
      .htaccess
  2. 1
      VERSION
  3. 27
      ajax/search-place.php
  4. 65
      configs/default-language.php
  5. 82
      configs/website-settings.php
  6. 18
      index.php
  7. 2
      javascripts/js.cookie.min.js
  8. 126
      javascripts/main.js
  9. 1545
      javascripts/moment-timezone-with-data.js
  10. 1
      javascripts/moment-timezone-with-data.min.js
  11. 59
      page-about.php
  12. 24
      page-privacy.php
  13. 99
      page-settings.php
  14. 16
      shortcut.php
  15. 41
      site-config.php
  16. 4
      site-footer.php
  17. 161
      site-functions.php
  18. 41
      site-header.php
  19. 107
      site-settings.php
  20. 148
      stylesheets/desktop.css
  21. 87
      stylesheets/die-content.css
  22. 1280
      stylesheets/leaflet.css
  23. 207
      stylesheets/pe-icon-7-weather.css
  24. 13
      stylesheets/portable.css
  25. 12
      stylesheets/pretty-checkbox.min.css
  26. 53
      weather-data.php

45
.htaccess

@ -8,10 +8,9 @@ IndexIgnore *
LimitRequestBody 10240000
<Files .htaccess>
order allow,deny
deny from all
</Files>
<FilesMatch "\.(htaccess)$">
Require all denied
</FilesMatch>
<IfModule mod_expires.c>
@ -45,34 +44,40 @@ LimitRequestBody 10240000
RewriteRule ^faq$ page-faq.php
RewriteRule ^settings$ page-settings.php
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)$ index.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/about$ page-about.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
# RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/api$ page-api.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/contact-us$ page-contact.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/faq$ page-faq.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/settings$ page-settings.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)$ index.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/about$ page-about.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
# RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/api$ page-api.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/contact-us$ page-contact.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/faq$ page-faq.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/settings$ page-settings.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/privacy$ page-privacy.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})$ index.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/about$ page-about.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
# RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/api$ page-api.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/contact-us$ page-contact.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/faq$ page-faq.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/settings$ page-settings.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})$ index.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/about$ page-about.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
# RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/api$ page-api.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/contact-us$ page-contact.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/faq$ page-faq.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/settings$ page-settings.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h),(light|dark)/apikey:([a-z0-9]{32})/privacy$ page-privacy.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^form:settings$ form-settings.php
RewriteRule ^([a-z]{2})$ shortcut.php?lan=$1
RewriteRule ^([a-z]{2})/([0-9-.]{5,19}),([0-9-.]{5,19})/s:(0|1)(0|1)(0|1)(0|1)$ shortcut.php?lan=$1&lat=$2&lng=$3&uni=$4&dec=$5&tim=$6&the=$7
RewriteRule ^([a-z]{2})/([0-9-.]{5,19}),([0-9-.]{5,19})/s:(0|1)(0|1)(0|1)(0|1)/a:([a-z0-9]{32})$ shortcut.php?lan=$1&lat=$2&lng=$3&uni=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^([a-z]{2})/([0-9-.]{4,19}),([0-9-.]{4,19})/s:(0|1)(0|1)(0|1)(0|1)$ shortcut.php?lan=$1&lat=$2&lng=$3&uni=$4&dec=$5&tim=$6&the=$7
RewriteRule ^([a-z]{2})/([0-9-.]{4,19}),([0-9-.]{4,19})/s:(0|1)(0|1)(0|1)(0|1)/a:([a-z0-9]{32})$ shortcut.php?lan=$1&lat=$2&lng=$3&uni=$4&dec=$5&tim=$6&the=$7&api=$8
RewriteRule ^weather-data/lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h)$ weather-data.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6
RewriteRule ^weather-data/lat:([0-9-.]{5,19}),lng:([0-9-.]{5,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h)/apikey:([a-z0-9]{32})$ weather-data.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&api=$7
RewriteRule ^weather-data/lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h)$ weather-data.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6
RewriteRule ^weather-data/lat:([0-9-.]{4,19}),lng:([0-9-.]{4,19})/settings:(metric|imperial),([a-z]{2}),(comma|dot),(24h|12h)/apikey:([a-z0-9]{32})$ weather-data.php?lat=$1&lng=$2&uni=$3&lan=$4&dec=$5&tim=$6&api=$7
RewriteRule ^update-language$ configs/default-language.php
RewriteRule ^update-settings$ configs/website-settings.php
RewriteRule ^update-settings/go$ configs/website-settings.php?go=
RewriteRule ^search-place:(.*)$ ajax/search-place.php?val=$1
</IfModule>

1
VERSION

@ -0,0 +1 @@
0.6

27
ajax/search-place.php

@ -0,0 +1,27 @@
<?php
$place = strip_tags(htmlspecialchars($_GET['val']));
$useragent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36';
$url = 'https://nominatim.openstreetmap.org/search?city='.$place.'&format=json&extratags=0';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, 'https://example.com');
$result = json_decode(curl_exec($ch));
curl_close($ch);
foreach($result AS $place) {
echo '<a href="javascript:void(0)" data-coordinates="'.(float)number_format($place->lat, 3).','.(float)number_format($place->lon, 3).'">';
echo $place->display_name;
echo '</a>';
}
?>

65
configs/default-language.php

@ -1,8 +1,8 @@
<?php
require_once '../site-functions.php';
require_once '../site-config.php';
$settings = json_decode(file_get_contents('../settings.json'));
$protocol = (stripos($_SERVER['SERVER_PROTOCOL'], 'http') !== false ? 'https' : 'http');
$host = $_SERVER['HTTP_HOST'];
@ -11,7 +11,7 @@
# You can use variables from {config.json} to print out for an example website's title.
# Here's what variables has been used and from what file:
# $settings->title shows the set title (line 6 in config.php)
# $config_title shows the set title (line 6 in config.php)
# link_(string, url) is a functions and creates a link that opens in a new tab (line 20 in site-functions.php).
$data = [
@ -28,8 +28,9 @@
'link_settings' => 'Settings',
'link_about' => 'About',
'link_faq' => 'FAQ',
'link_privacy' => 'Privacy',
'link_api' => 'API',
'data_from' => $settings->title.' uses'
'data_from' => $config_title.' uses'
],
@ -46,12 +47,12 @@
'subtitle_options' => 'Options',
'subtitle_apikey' => 'API key',
'subtitle_save' => 'Save your settings',
'desc_gps' => '<p>Let '.$settings->title.' use your device\'s GPS to get your current position.</p>',
'desc_manualplace_jsenabled' => '<p>We are working on adding places. Until then, you can enter coordinates or use the map above and choose a place that way.</p>',
'desc_gps' => '<p>Let '.$config_title.' use your device\'s GPS to get your current position.</p>',
'desc_manualplace_jsenabled' => '<p>Search for a place (city) or enter the coordinates.</p>',
'desc_manualplace_jsdisabled' => '<p>At the moment, you can only enter the coordinates.</p>',
'desc_options' => '<p>Customize '.$settings->title.' after your liking.</p>',
'desc_apikey' => '<p>'.$settings->title.' use its own API key, but you can also use your own. Go to '.link_('openweathermap.com', 'https://openweathermap.org/').' and create an account there (if you don\'t already have one) to get your own API key.</p>',
'desc_save' => '<p>If you want to use your settings right away, you can use the URL below. Nothing are saved in the database and the link does not expire.</p>',
'desc_options' => '<p>Customize '.$config_title.' after your liking.</p>',
'desc_apikey' => '<p>'.$config_title.' uses its own API key, but you are able to use your own. Go to '.link_('openweathermap.com', 'https://openweathermap.org/').' and create an account (if you don\'t already have one) to get your own API key.</p>',
'desc_save' => '<p>If you want to get access to your settings in a easy way, you can choose to either use a link or save a cookie on your device. The link will not be stored anywhere and will never expire while the cookie will be automatically deleted from your device 7 days after you pressed the Continue button.</p>',
'error_coordinates_empty' => 'You must enter coordinates in order to continue',
'error_coordinates_invalid' => 'The coordinates are not valid',
'error_apikey_not32' => 'The API key must be 32 characters long',
@ -62,6 +63,7 @@
'info_gps_unavailable' => 'Couldn\'t locate your position. Try again',
'info_gps_timeout' => 'The localization timed out. Try again',
'info_urlcopied' => 'The shortcut address has been copied',
'info_searching' => 'Searching, please wait...',
'gps_fetch' => 'Fetch my current position',
'gps_fetching' => 'Trying to find you, please wait...',
'field_place' => 'Place',
@ -79,6 +81,8 @@
'theme_light' => 'Light',
'theme_dark' => 'Dark',
'link_copy' => 'Copy the shortcut address',
'cookie_store' => 'Save a cookie on my device',
'cookie_delete' => 'Delete the cookie',
'button_continue' => 'Continue'
],
@ -87,7 +91,8 @@
'loading' => 'Fetching weather data - please wait...',
'error_401' => '<p>The given API key can\'t be used. Please go to settings and enter an API key that you have got from OpenWeatherMap by logging in to your OpenWeather account.</p>',
'error_404' => '<p>An error occured. Please check so the given API key can be used for '.link_('One Call API', 'https://openweathermap.org/api/one-call-api').'. The issue can also be that the name of the place are wrong.</p>',
'error_429' => '<p>We can\'t use the given API key because it has been used 60 times under a minute (which is '.link_('the limit for free plans', 'https://openweathermap.org/price').'). Please wait for a while and then try again.</p><p>In the meantime, you can use our API key by remove your key from the settings page here on '.$settings->title.'.</p>',
'error_429' => '<p>We can\'t use the given API key because it has been used 60 times under a minute (which is '.link_('the limit for free plans', 'https://openweathermap.org/price').'). Please wait for a while and then try again.</p><p>In the meantime, you can use our API key by remove your key from the settings page here on '.$config_title.'.</p>',
'error_failed' => '<p>Something went wrong. Try again by reloading the page. If the error persist, please contact us and explain the error.</p>',
'details_wind' => 'Wind',
'details_feelslike' => 'Feels like',
'details_dewpoint' => 'Dew point',
@ -95,6 +100,8 @@
'details_humidity' => 'Humidity',
'details_pressure' => 'Pressure',
'details_uvindex' => 'UV index',
'details_visibility' => 'Visibility',
'details_precipitation' => 'Precipitation',
'subtitle_forecast_48h' => '48 hours forecast',
'subtitle_forecast_7d' => '7 hours forecast at 11:00',
'message_moredatalateron' => 'More data will be added eventually'
@ -102,15 +109,23 @@
'page_about' => [
'intro' => '<p>'.$settings->title.' are a weather service that are keen to your privacy. It displays the current weather report, the forecast for the next 48 hours and 7 days for the location you choose.</p>',
'intro' => '<p>'.$config_title.' are a weather service that strongly respects your privacy. It displays the current weather report, the forecast for the next 48 hours and 7 days for the location you choose.</p>',
'subtitle_opensource' => 'Open source',
'subtitle_install' => 'Install',
'subtitle_privacy' => 'Privacy',
'subtitle_contactus' => 'Contact us',
'subtitle_using' => 'Uses',
'opensource' => '<p>'.$settings->title.' are free, licensed under <b>GNU GPLv3</b>. See more at '.link_('git.airikr.me/serenum', 'https://git.airikr.me/serenum').'.</p>',
'privacy' => '<p>We have strict privacy rules. '.$settings->title.' does not log anything about your visit - period.</p>',
'contactus' => '<p>You can contact us either through email (hi@serenum.org) or through '.link_('Telegram', 'https://telegram.org').'. You can join our group with the following link: '.link_('t.me/'.strtolower($settings->title).'foss', 'https://t.me/'.strtolower($settings->title).'foss').'</p>',
'using' => '<p>We are using the following to let '.$settings->title.' work as it should.</p>'
'opensource' => '<p>'.$config_title.' are free, licensed under <b>GNU GPLv3</b>. Go to '.link_('git.airikr.me/serenum', 'https://git.airikr.me/serenum').' to see the source code.</p>',
'privacy' => '<p>We have strict privacy rules. '.$config_title.' does not log anything about your visit - period.</p><p>For more info, choose "Privacy" in the footer.</p>',
'install' => '<p>You can install '.$config_title.' on your own server. The installation are very basic and do not require much experience. Read '.link_('INSTALL.md', 'https://git.airikr.me/serenum/website/src/branch/master/INSTALL.md').' to get started.</p>',
'contactus' => '<p>You can contact us via email (<b>hi@serenum.org</b>) and via '.link_('Telegram', 'https://telegram.org').' by joining our group with the following link: '.link_('t.me/'.strtolower($config_title).'foss', 'https://t.me/'.strtolower($config_title).'foss').'</p>',
'using' => '<p>Below you can see what we are using to make '.$config_title.' work.</p>'
],
'page_privacy' => [
'title' => 'Privacy policy',
'content' => '<p>'.$config_title.' does not collect any personal or non-personal information about you, the visitor, or any visitors for that matter. We do not want to log anything and will probably never will be. With "probably" we mean that we are not sure if we will log at least your device\'s IP address. But if that happens, we will update our privacy policy and also let you know next time you visit '.$config_title.'.</p><p>As of today, we do not care about how many people are visiting our website. To build and manage a good and stable weather service are our priority.</p>'
],
@ -118,16 +133,16 @@
'title' => 'FAQ',
'items' => [
[
'question' => 'Are '.$settings->title.'\'s source code open for all?',
'answer' => 'Yes. The source code of '.$settings->title.' can be downloaded by anyone under the GNU GPLv3 license. You can get the source code at '.link_('git.airikr.me/serenum', 'https://git.airikr.me/serenum').'.'
'question' => 'Are '.$config_title.'\'s source code open for all?',
'answer' => 'Yes. The source code of '.$config_title.' can be downloaded by anyone under the GNU GPLv3 license. You can get the source code at '.link_('git.airikr.me/serenum', 'https://git.airikr.me/serenum').'.'
],
[
'question' => 'Can I install '.$settings->title.' on my own server?',
'answer' => 'Yes. Go to '.link_('the installation guide', 'https://git.airikr.me/'.$settings->title.'/website/src/branch/master/INSTALL.md').' to get started.'
'question' => 'Can I install '.$config_title.' on my own server?',
'answer' => 'Yes. Go to '.link_('the installation guide', 'https://git.airikr.me/'.$config_title.'/website/src/branch/master/INSTALL.md').' to get started.'
],
[
'question' => $settings->title.' can\'t fetch my current position. Why?',
'answer' => '<p>There can be several reasons to this.</p><ol><li>You are inside a building. Be close to a window or an open door to allow the satellites to find you easier. But for best result, be sure to be outside with the sky above you.</li><li>The system settings for GPS are set to only use GPS and not WiFi and/or mobile data. If you allow your device to use both WiFi and mobile data when using GPS, your device will be easier to be found.</li><li>The GPS does not work as it should. See if your device can be found in an application for an example '.link_('OsmAnd', 'https://osmand.net/').', '.link_('Apple Maps', 'https://apple.com/maps/').' or '.link_('OpenStreetMap', 'https://openstreetmap.org/').'. If some of these apps can find your location, try again with '.$settings->title.'. If the issue persist, try another device.</li></ol>'
'question' => $config_title.' can\'t fetch my current position. Why?',
'answer' => '<p>There can be several reasons to this.</p><ol><li>You are inside a building. Be close to a window or an open door to allow the satellites to find you easier. But for best result, be sure to be outside with the sky above you.</li><li>The system settings for GPS are set to only use GPS and not WiFi and/or mobile data. If you allow your device to use both WiFi and mobile data when using GPS, your device will be easier to be found.</li><li>The GPS does not work as it should. See if your device can be found in an application for an example '.link_('OsmAnd', 'https://osmand.net/').', '.link_('Apple Maps', 'https://apple.com/maps/').' or '.link_('OpenStreetMap', 'https://openstreetmap.org/').'. If some of these apps can find your location, try again with '.$config_title.'. If the issue persist, try another device.</li></ol>'
],
[
'question' => 'How often do the weather data update?',
@ -236,12 +251,12 @@
$language = $data['language_name']['short'];
$file = 'languages/'.$language.'.json';
# if(is_writable('../'.$file)) {
if(is_writable('../'.$file)) {
file_put_contents('../'.$file, json_encode($data, JSON_UNESCAPED_UNICODE));
die_content($settings->title.' - Update language', $language.'.json has been updated. Go to <a href="'.$protocol.'://'.$host.'/serenum">Go to '.$settings->title.'</a>.');
die_content($config_title.' - Update language', '<h2>Success</h2><p>'.$language.'.json has been updated. Go to <a href="'.$protocol.'://'.$host.'/serenum">Go to '.$config_title.'</a>.</p>');
# } else {
# die_content($settings->title, 'Can\'t write to <code>'.$file.'</code> due to the lack of permissions.');
# }
} else {
die_content($config_title, '<h2>Permission denied</h2><p>Please set proper permissions for <code>'.$file.'</code>.</p><p>See '.link_('the guide', '').' for more information.</p>');
}
?>

82
configs/website-settings.php

@ -1,82 +0,0 @@
<?php
require_once '../site-functions.php';
$filename_path = explode('/', $_SERVER['PHP_SELF']);
$filename = $filename_path[count($filename_path) - 1];
$protocol = (stripos($_SERVER['SERVER_PROTOCOL'], 'http') !== false ? 'https' : 'http');
$host = $_SERVER['HTTP_HOST'];
$data = [
# Defines what the website will be called, what the description it will,
# have and what image the website will use for an example the metadata.
'title' => 'Serenum', # STRING
'description' => 'A privacy respecting, self-hosted weather website', # STRING
'image' => null, # STRING
'image_alternative' => null, # STRING
# Show the description below the title on the website.
'show_description_onpage' => false, # BOOLEAN
# Defines what domain the website are on.
'domain' => 'serenum.org', # STRING
# If set to false, the website will not use any cache.
'development' => true, # BOOLEAN
# These are for the settings page, what will shown or not.
'allow_own_apikey' => true, # BOOLEAN
'allow_search' => true, # BOOLEAN
'allow_gps' => true, # BOOLEAN
# Defines default values for the settings page.
'defaults' => [
'map' => [
'layers' => [
'light' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', # STRING (default: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png)
'light_text' => '&copy; '.link_('OpenStreetMap', 'https://www.openstreetmap.org/copyright').' contributors', # STRING
'dark' => 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', # STRING (default: https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x})
'dark_text' => 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' # STRING
],
'zoom' => 8, # INT (default: 8)
'zoom_min' => 3, # INT (default: 3)
'zoom_max' => 15 # INT (default: 15)
],
'coordinates' => [
'latitude' => 59.381, # DECIMAL(2,3) (default: 59.381)
'longitude' => 13.503 # DECIMAL(2,3) (default: 13.503)
],
'language' => 'en', # STRING (default: en)
'unit' => 'metric', # STRING (default: metric)
'time' => '24h', # STRING (default: 24h)
'decimal' => 'comma', # STRING (default: comma)
'theme' => 'light' # STRING (default: light)
]
];
$private = [
# Enter the API key from OpenWeatherMap that the website will use as default.
'apikey' => null # STRING (MD5)
];
file_put_contents('../settings.json', json_encode($data, JSON_UNESCAPED_UNICODE));
file_put_contents('/var/www/files/file.json', json_encode($private, JSON_UNESCAPED_UNICODE));
if(!file_exists('../languages')) {
$message = 'Now add the default language by going to <a href="'.url('update-language', true).'">/update-language</a>';
} else {
$message = '<a href="'.$protocol.'://'.$host.'/serenum">Go to '.$data['title'].'</a>';
}
die_content($data['title'], 'Done. '.$message.'.');
?>

18
index.php

@ -111,6 +111,24 @@
echo '<div class="value"></div>';
echo '</div>';
echo '<div class="item visibility">';
echo '<div class="label">';
echo $lang->page_weather->details_visibility;
echo '</div>';
echo '<div class="value"></div>';
echo '</div>';
echo '<div class="item precipitation">';
echo '<div class="label">';
echo $lang->page_weather->details_precipitation;
echo '</div>';
echo '<div class="value"></div>';
echo '</div>';
echo '</div>';
echo '</div>';

2
javascripts/js.cookie.min.js

@ -0,0 +1,2 @@
/*! js-cookie v3.0.0-rc.1 | MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,r=e.Cookies=t();r.noConflict=function(){return e.Cookies=n,r}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var t={read:function(e){return e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};return function n(r,o){function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),n=r.write(n,t);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+c}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var c=n[i].split("="),u=c.slice(1).join("=");'"'===u[0]&&(u=u.slice(1,-1));try{var f=t.read(c[0]);if(o[f]=r.read(u,f),e===f)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}(t,{path:"/"})});

126
javascripts/main.js

@ -7,21 +7,16 @@ $(document).ready(function () {
using_light_theme = (settings_theme == 'light' ? true : false);
var scrollbar_light = '#dedfe1';
var scrollbar_dark = '#2e3338';
$.ajax({
url: folder_name + 'settings.json',
async: false,
success: function(d) {
default_maplayer_light = d.defaults.map.layers.light;
default_maplayer_light_text = d.defaults.map.layers.light_text;
default_maplayer_dark = d.defaults.map.layers.dark;
default_maplayer_dark_text = d.defaults.map.layers.dark_text;
default_zoom = d.defaults.map.zoom;
default_maxzoom = d.defaults.map.zoom_max;
default_minzoom = d.defaults.map.zoom_min;
}
});
domain = $('section#website').data('domain');
default_maplayer_light = $('section#website').data('default-maplayer-light');
default_maplayer_light_text = $('section#website').attr('data-default-maplayer-light-text');
default_maplayer_dark = $('section#website').attr('data-default-maplayer-dark');
default_maplayer_dark_text = $('section#website').attr('data-default-maplayer-dark-text');
default_zoom = $('section#website').attr('data-default-map-zoom');
default_minzoom = $('section#website').attr('data-default-map-zoom-min');
default_maxzoom = $('section#website').attr('data-default-map-zoom-max');
cookie_options_set = { expires: 7, path: '', domain: 'localhost' };
cookie_options_remove = { path: '', domain: 'localhost' };
$.ajax({
url: folder_name + 'languages/' + settings_language + '.json',
@ -39,6 +34,7 @@ $(document).ready(function () {
message_error_api_401 = l.page_weather.error_401;
message_error_api_404 = l.page_weather.error_404;
message_error_api_429 = l.page_weather.error_429;
message_error_failed = l.page_weather.error_failed;
dayname_today = l.various.days.today;
dayname_tomorrow = l.various.days.tomorrow;
@ -250,6 +246,75 @@ $(document).ready(function () {
get_location();
});
if(typeof Cookies.get('weather-settings') !== 'undefined') {
$('.delete-cookie').show();
$('body').on('click', 'a#delete-cookie', function() {
Cookies.remove('weather-settings', cookie_options_remove);
$('.delete-cookie').hide();
$('input#check-1').attr({ 'checked': false });
});
}
if(typeof Cookies.get('weather-settings') !== 'undefined') {
$('.delete-cookie').show();
}
$('body').on('change', 'input#check-1', function() {
if($(this).is(':checked')) {
$('.will-be-deleted').hide();
$('a#delete-cookie').show();
} else {
if(typeof Cookies.get('weather-settings') !== 'undefined') {
$('.will-be-deleted').show();
$('a#delete-cookie').hide();
}
}
});
var typing_timer;
var input_search = $('input[name="field-search-place"]');
input_search.on('keyup', function () {
if(input_search.val().length > 2) {
clearTimeout(typing_timer);
typing_timer = setTimeout(get_results, 1000);
$('.searching').show();
$('.result').hide();
}
});
input_search.on('keydown', function () {
clearTimeout(typing_timer);
});
function get_results() {
$.ajax({
url: folder_name + 'search-place:' + input_search.val(),
method: 'GET',
success: function(s) {
if(s != '') {
$('.searching').hide();
$('.result').show().html(s);
}
}
});
}
$('body').on('click', '.result > a', function() {
var coordinates = $(this).attr('data-coordinates').split(',');
var latlng = new L.LatLng(coordinates[0], coordinates[1]);
marker.setLatLng(latlng);
map.setView(latlng);
$('input[name="field-search-coordinates"]').val(coordinates[0] + ',' + coordinates[1]);
});
$('body').on('click', '[type="submit"]', function() {
var coordinates = ($('input[name="field-search-coordinates"]').is(':visible') ? $('input[name="field-search-coordinates"]').val() : $('div#map').attr('data-coordinates'));
var coordinates_splitted = coordinates.replace(/\s/g, '').split(',');
@ -263,6 +328,7 @@ $(document).ready(function () {
var time = $('select[name="field-option-time"]').val();
var theme = $('select[name="field-option-theme"]').val();
var apikey = ($('input[name="field-api-key"]').is(':visible') ? $('input[name="field-api-key"]').val() : null);
var use_cookie = ($('input#check-1').is(':checked') ? true : false);
hide_message();
@ -279,6 +345,12 @@ $(document).ready(function () {
display_message('input[name="field-api-key"]', message_error_apikey_invalid, 'error');
} else {
if(use_cookie == true) {
Cookies.set('weather-settings', latitude + ',' + longitude + '/' + unit + '/' + language + '/' + decimal + '/' + time + '/' + theme + ((apikey != '' && apikey != null) ? '/' + apikey : ''), cookie_options_set);
} else {
Cookies.remove('weather-settings', cookie_options_remove);
}
window.location = folder_name + 'lat:' + latitude + ',lng:' + longitude + '/settings:' + unit + ',' + language + ',' + decimal + ',' + time + ',' + theme + ((apikey != '' && apikey != null) ? '/apikey:' + apikey : '');
}
});
@ -297,7 +369,7 @@ $(document).ready(function () {
var settings_time = $('div#settings').attr('data-time');
var apikey = $('div#settings').attr('data-apikey');
$.getJSON(folder_name + 'weather-data/lat:' + latitude + ',lng:' + longitude + '/settings:' + settings_unit + ',' + settings_language + ',' + settings_decimal + ',' + settings_time + (apikey != '' ? '/apikey:' + apikey : ''), function(d) {
var json_call = $.getJSON(folder_name + 'weather-data/lat:' + latitude + ',lng:' + longitude + '/settings:' + settings_unit + ',' + settings_language + ',' + settings_decimal + ',' + settings_time + (apikey != '' ? '/apikey:' + apikey : ''), function(d) {
if(typeof d.error === 'undefined') {
$('.loading').hide();
$('.weather').show();
@ -316,20 +388,22 @@ $(document).ready(function () {
$('.weather > .report > .details > .item.uvindex > .value').text(format('0', d.uv));
$('.weather > .report > .details > .item.dewpoint > .value').text(temperature(d.tp_dp, settings_unit, settings_decimal));
$('.weather > .report > .details > .item.clouds > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '#', d.cl) + '%');
$('.weather > .report > .details > .item.visibility > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '#', d.vi) + ' ' + (settings_unit == 'metric' ? 'km' : 'mi'));
$('.weather > .report > .details > .item.precipitation > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '##', d.pr_1h) + ' mm');
$.each(d.hr.da, function(k, v) {
var get_today = moment(v.ts_str.dt).tz(v.tz).format('X');
var today = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(v.tz).format('YYYY-MM-DD'));
var tomorrow = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(v.tz).add(1, 'd').format('YYYY-MM-DD'));
var get_today = moment(v.ts_str.dt).tz(d.tz).format('X');
var today = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(d.tz).format('YYYY-MM-DD'));
var tomorrow = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(d.tz).add(1, 'd').format('YYYY-MM-DD'));
var dayname = (today == true ? dayname_today : (tomorrow == true ? dayname_tomorrow : v.ts_str.dy));
$('.hourly').append('<div class="item"><div class="day">' + dayname + '</div><div class="time">' + moment(v.ts_str.dt + ' ' + v.ts_str.tm).format((settings_time == '24h' ? 'HH:mm' : 'h:mm a')) + '</div><div class="temperature">' + temperature(v.tp, settings_unit, settings_decimal, true) + '</div><div class="icon"><i class="' + v.wt_ic_icon + '"></i></div><div class="weather">' + weather_name[v.wt_ic.slice(0, -1) + '-' + v.wt_id] + '</div>');
});
$.each(d.dy.da, function(k, v) {
var get_today = moment(v.ts_str.dt).format('X');
var today = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(v.tz).format('YYYY-MM-DD'));
var tomorrow = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(v.tz).add(1, 'd').format('YYYY-MM-DD'));
var get_today = moment(v.ts_str.dt).tz(d.tz).format('X');
var today = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(d.tz).format('YYYY-MM-DD'));
var tomorrow = moment(moment.unix(get_today).format('YYYY-MM-DD')).isSame(moment().tz(d.tz).add(1, 'd').format('YYYY-MM-DD'));
var dayname = (today == true ? dayname_today : (tomorrow == true ? dayname_tomorrow : v.ts_str.dy));
$('.forecast > .daily').append('<div class="item"><div class="day">' + dayname + '</div><div class="temperature">' + temperature(v.tp.dy, settings_unit, settings_decimal, true) + '</div><div class="icon"><i class="' + v.wt_ic_icon + '"></i></div><div class="weather">' + weather_name[v.wt_ic.slice(0, -1) + '-' + v.wt_id] + '</div>');
@ -349,6 +423,14 @@ $(document).ready(function () {
$('.error > div > .message').html(errmsgs[d.error]);
$('.error > div > .code').text(d.error + ': ' + d.message);
}
}).fail(function() {
$('.loading').hide();
$('.error').show();
$('.error > div > .message').show();
$('.error > div > .message').html(message_error_failed);
});
}

1545
javascripts/moment-timezone-with-data.js
File diff suppressed because it is too large
View File

1
javascripts/moment-timezone-with-data.min.js
File diff suppressed because it is too large
View File

59
page-about.php

@ -22,6 +22,15 @@
echo $lang->page_about->opensource;
echo '</div>';
echo '<div class="item">';
echo '<h4>';
echo svgicon('install');
echo $lang->page_about->subtitle_install;
echo '</h4>';
echo $lang->page_about->install;
echo '</div>';
echo '<div class="item">';
echo '<h4>';
echo svgicon('shield');
@ -34,35 +43,37 @@
echo '<div class="contact-us">';
echo '<h4>';
echo svgicon('contact');
echo $lang->page_about->subtitle_contactus;
echo '</h4>';
echo $lang->page_about->contactus;
echo '</div>';
echo '<div class="side-by-side">';
echo '<div class="contact-us">';
echo '<h4>';
echo svgicon('contact');
echo $lang->page_about->subtitle_contactus;
echo '</h4>';
echo $lang->page_about->contactus;
echo '</div>';
echo '<div class="using">';
echo '<h4>';
echo svgicon('using');
echo $lang->page_about->subtitle_using;
echo '</h4>';
echo $lang->page_about->using;
echo '<div class="using">';
echo '<h4>';
echo svgicon('using');
echo $lang->page_about->subtitle_using;
echo '</h4>';
echo '<ul>';
echo '<li>'.link_('jquery/jquery', 'https://github.com/jquery/jquery').'</li>';
echo '<li>'.link_('Mottie/javascript-number-formatter', 'https://github.com/Mottie/javascript-number-formatter').'</li>';
# echo '<li>'.link_('inuyaksa/jquery.nicescroll', 'https://github.com/inuyaksa/jquery.nicescroll').'</li>';
echo '<li>'.link_('Leaflet/Leaflet', 'https://github.com/Leaflet/Leaflet').'</li>';
echo '<li>'.link_('Leaflet/Leaflet.fullscreen', 'https://github.com/Leaflet/Leaflet.fullscreen').'</li>';
echo '<li>'.link_('validatorjs/validator.js', 'https://github.com/validatorjs/validator.js').'</li>';
echo '<li>'.link_('moment/moment', 'https://github.com/moment/moment').'</li>';
echo '<li>'.link_('moment/moment-timezone', 'https://github.com/moment/moment-timezone').'</li>';
echo '</ul>';
echo $lang->page_about->using;
echo '<ul>';
echo '<li>'.link_('jquery/jquery', 'https://github.com/jquery/jquery').'</li>';
echo '<li>'.link_('Mottie/javascript-number-formatter', 'https://github.com/Mottie/javascript-number-formatter').'</li>';
# echo '<li>'.link_('inuyaksa/jquery.nicescroll', 'https://github.com/inuyaksa/jquery.nicescroll').'</li>';
echo '<li>'.link_('Leaflet/Leaflet', 'https://github.com/Leaflet/Leaflet').'</li>';
echo '<li>'.link_('Leaflet/Leaflet.fullscreen', 'https://github.com/Leaflet/Leaflet.fullscreen').'</li>';
echo '<li>'.link_('validatorjs/validator.js', 'https://github.com/validatorjs/validator.js').'</li>';
echo '<li>'.link_('moment/moment', 'https://github.com/moment/moment').'</li>';
echo '<li>'.link_('moment/moment-timezone', 'https://github.com/moment/moment-timezone').'</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</section>';

24
page-privacy.php

@ -0,0 +1,24 @@
<?php
require_once 'site-header.php';
echo '<section id="privacy">';
echo '<h2>'.$lang->page_privacy->title.'</h2>';
echo $lang->page_privacy->content;
echo '</section>';
require_once 'site-footer.php';
?>

99
page-settings.php

@ -4,13 +4,6 @@
/* $array_themes = [
'dark' => $lang->page_settings->theme_dark,
'light' => $lang->page_settings->theme_light
]; */
@ -20,7 +13,11 @@
echo '<h2>'.$lang->page_settings->title.'</h2>';
echo '<div id="map" data-coordinates="';
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $settings->defaults->coordinates->latitude.','.$settings->defaults->coordinates->longitude : $latitude_shorten.','.$longitude_shorten);
if($cookie_exists == true) {
echo $cs_coordinates;
} else {
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $settings->defaults->coordinates->latitude.','.$settings->defaults->coordinates->longitude : $latitude_shorten.','.$longitude_shorten);
}
echo '"></div>';
echo '<div class="message"><div>';
@ -34,10 +31,10 @@
# echo '<form action="'.url('form:settings').'" method="POST" autocomplete="off" novalidate>';
echo '<form action="javascript:void(0)" method="GET" autocomplete="off" novalidate>';
if($settings->allow_search == true) {
if($config_allow_search == true) {
echo '<div class="side-by-side">';
if($settings->allow_gps == true) {
if($config_allow_gps == true) {
echo '<div class="gps">';
echo '<h4>';
echo svgicon('gps');
@ -67,7 +64,7 @@
echo '<div class="search'.($settings->allow_gps == true ? ' gps-enabled' : '').'">';
echo '<div class="search'.($config_allow_gps == true ? ' gps-enabled' : '').'">';
echo '<h4>';
echo svgicon('search');
echo $lang->page_settings->subtitle_manualplace;
@ -84,25 +81,38 @@
echo '</div>';
echo '<div class="items '.($settings->allow_gps == true ? 'column' : 'row').'">';
echo '<div class="items '.($config_allow_gps == true ? 'column' : 'row').'">';
echo '<div class="item">';
echo '<div class="label disabled">';
echo '<div class="label">';
echo $lang->page_settings->field_place;
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-search-place" disabled>';
echo '<input type="text" name="field-search-place">';
echo '</div>';
echo '</div>';
echo '<div class="searching color-blue"><div>';
echo svgicon('loading');
echo $lang->page_settings->info_searching;
echo '</div></div>';
echo '<div class="result"></div>';
echo '<div class="item coordinates">';
echo '<div class="label">';
echo $lang->page_settings->field_coordinates;
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-search-coordinates" placeholder="'.$settings->defaults->coordinates->latitude.','.$settings->defaults->coordinates->longitude.'" value="';
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $settings->defaults->coordinates->latitude.','.$settings->defaults->coordinates->longitude : $latitude_shorten.','.$longitude_shorten);
echo '<input type="text" name="field-search-coordinates" placeholder="'.$config_default_coordinates_latitude.','.$config_default_coordinates_longitude.'" value="';
if($cookie_exists == true) {
echo $cs_coordinates;
} else {
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $config_default_coordinates_latitude.','.$config_default_coordinates_longitude : $latitude_shorten.','.$longitude_shorten);
}
echo '">';
echo '</div>';
echo '</div>';
@ -129,8 +139,8 @@
echo '<div class="field">';
echo '<select name="field-option-unit" class="select-css">';
echo '<option value="metric"'.($settings_unit == 'metric' ? ' selected' : '').'>'.$lang->page_settings->unit_metric.' (km/h, kilometer)</option>';
echo '<option value="imperial"'.($settings_unit == 'imperial' ? ' selected' : '').'>'.$lang->page_settings->unit_imperial.' (mph, miles)</option>';
echo '<option value="metric"'.(($cs_unit == 'metric' OR $settings_unit == 'metric') ? ' selected' : '').'>'.$lang->page_settings->unit_metric.' (km/h, kilometer)</option>';
echo '<option value="imperial"'.(($cs_unit == 'imperial' OR $settings_unit == 'imperial') ? ' selected' : '').'>'.$lang->page_settings->unit_imperial.' (mph, miles)</option>';
echo '</select>';
echo '</div>';
echo '</div>';
@ -144,7 +154,7 @@
echo '<select name="field-option-language" class="select-css">';
foreach(glob('languages/*.json') AS $langfile) {
$langscoop = json_decode(file_get_contents($langfile));
echo '<option value="'.$langscoop->language_name->short.'"'.($settings_language == $langscoop->language_name->short ? ' selected' : '').'>'.$langscoop->language_name->full.'</option>';
echo '<option value="'.$langscoop->language_name->short.'"'.(($cs_language == $langscoop->language_name->short OR $settings_language == $langscoop->language_name->short) ? ' selected' : '').'>'.$langscoop->language_name->full.'</option>';
}
echo '</select>';
echo '</div>';
@ -157,8 +167,8 @@
echo '<div class="field">';
echo '<select name="field-option-decimal" class="select-css">';
echo '<option value="comma"'.($settings_decimal == 'comma' ? ' selected' : '').'>'.$lang->page_settings->decimal_comma.' (14,7)</option>';
echo '<option value="dot"'.($settings_decimal == 'dot' ? ' selected' : '').'>'.$lang->page_settings->decimal_dot.' (14.7)</option>';
echo '<option value="comma"'.(($cs_decimal == 'comma' OR $settings_decimal == 'comma') ? ' selected' : '').'>'.$lang->page_settings->decimal_comma.' (14,7)</option>';
echo '<option value="dot"'.(($cs_decimal == 'dot' OR $settings_decimal == 'dot') ? ' selected' : '').'>'.$lang->page_settings->decimal_dot.' (14.7)</option>';
echo '</select>';
echo '</div>';
echo '</div>';
@ -170,8 +180,8 @@
echo '<div class="field">';
echo '<select name="field-option-time" class="select-css">';
echo '<option value="24h"'.($settings_time == '24h' ? ' selected' : '').'>24h</option>';
echo '<option value="12h"'.($settings_time == '12h' ? ' selected' : '').'>12h</option>';
echo '<option value="24h"'.(($cs_time == '24h' OR $settings_time == '24h') ? ' selected' : '').'>24h</option>';
echo '<option value="12h"'.(($cs_time == '12h' OR $settings_time == '12h') ? ' selected' : '').'>12h</option>';
echo '</select>';
echo '</div>';
echo '</div>';
@ -183,15 +193,8 @@
echo '<div class="field">';
echo '<select name="field-option-theme" class="select-css">';
echo '<option value="light"'.($settings_theme == 'light' ? ' selected' : '').'>'.$lang->page_settings->theme_light.'</option>';
echo '<option value="dark"'.($settings_theme == 'dark' ? ' selected' : '').'>'.$lang->page_settings->theme_dark.'</option>';
/* foreach(glob('stylesheets/theme-*.css') AS $theme) {
$fileinfo = pathinfo($theme);
$name_theme = str_replace('theme-', '', $fileinfo['filename']);
echo '<option value="'.$name_theme.'"'.($settings_theme == $name_theme ? ' selected' : '').'>'.$array_themes[$name_theme].'</option>';
} */
echo '<option value="light"'.(($cs_theme == 'light' OR $settings_theme == 'light') ? ' selected' : '').'>'.$lang->page_settings->theme_light.'</option>';
echo '<option value="dark"'.(($cs_theme == 'dark' OR $settings_theme == 'dark') ? ' selected' : '').'>'.$lang->page_settings->theme_dark.'</option>';
echo '</select>';
echo '</div>';
echo '</div>';
@ -200,7 +203,7 @@
if($settings->allow_own_apikey == true) {
if($config_allow_own_apikey == true) {
echo '<div class="apikey">';
echo '<h4>';
echo svgicon('key');
@ -220,7 +223,11 @@
echo '<div class="field">';
echo '<input type="text" name="field-api-key"';
echo ($settings_apikey == null ? null : ' value="'.$settings_apikey.'"');
if($cs_apikey == null) {
echo ($settings_apikey == null ? null : ' value="'.$settings_apikey.'"');
} else {
echo ' value="'.$cs_apikey.'"';
}
echo '>';
echo '<div class="icon"><div>'.svgicon('clear').'</div></div>';
@ -243,7 +250,7 @@
echo '</div>';
echo '<p><code>';
echo 'https://'.$settings->domain.'/beta/';
echo 'https://'.$config_domain.'/beta/';
echo '<span class="language">'.$settings_language.'</span>/';
echo '<span class="coordinates">'.$latitude_shorten.','.$longitude_shorten.'</span>/';
echo 's:';
@ -271,6 +278,28 @@
echo $lang->page_settings->error_failedtocopyurl;
echo '</span>';
echo '</p>';
echo '<div class="checkbox pretty p-default p-round p-fill">';
echo '<input type="checkbox" name="check-1" id="check-1"';
echo ($cookie_exists == true ? ' checked' : '');
echo '>';
echo '<div class="state p-primary">';
echo '<label for="check-1">';
echo $lang->page_settings->cookie_store;
echo '</label>';
echo '</div>';
echo '</div>';
echo '<div class="delete-cookie">';
echo '<a href="javascript:void(0)" id="delete-cookie">';
echo $lang->page_settings->cookie_delete;
echo '</a>';
echo '<div class="will-be-deleted color-blue">';
echo 'The cookie will be deleted if you continue';
echo '</div>';
echo '</div>';
echo '</div>';

16
shortcut.php

@ -4,15 +4,15 @@
$latitude_pure = (isset($_GET['lat']) ? strip_tags(htmlspecialchars($_GET['lat'])) : $config->defaults->coordinates->latitude);
$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->defaults->coordinates->longitude);
$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->defaults->unit);
$settings_language = (isset($_GET['lan']) ? strip_tags(htmlspecialchars($_GET['lan'])) : $config->defaults->language);
$settings_decimal = (isset($_GET['dec']) ? strip_tags(htmlspecialchars($_GET['dec'])) : $config->defaults->decimal);
$settings_time = (isset($_GET['tim']) ? strip_tags(htmlspecialchars($_GET['tim'])) : $config->defaults->time);
$settings_theme = (isset($_GET['the']) ? strip_tags(htmlspecialchars($_GET['the'])) : $config->defaults->theme);
$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 = [
@ -43,7 +43,7 @@
if(!file_exists('languages/'.$settings_language.'.json')) {
header("Location: ".url('lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$settings_unit.',sv,'.$settings_decimal.','.$settings_time.','.$settings_theme . ($settings_apikey == null ? '' : '/apikey:'.$settings_apikey), true).'/settings');
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' : ''));
}

41
site-config.php

@ -0,0 +1,41 @@
<?php
# Defines what the website will be called, what the description it will,
# have and what image the website will use for an example the metadata.
$config_title = 'Serenum'; # STRING
$config_description = 'A privacy respecting, self-hosted weather website'; # STRING
$config_image = null; # STRING
$config_image_alternative = null; # STRING
# Defines what domain the website are on.
$config_domain = 'serenum.org'; # STRING
# If set to true, the website will not use any cache.
$config_development = true; # BOOLEAN
# These are for the settings page, what will shown or not.
$config_allow_own_apikey = true; # BOOLEAN
$config_allow_search = true; # BOOLEAN
$config_allow_gps = true; # BOOLEAN
# Defines default values for the settings page.
$config_map_layer_light = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; # STRING (default: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png)
$config_map_layer_light_text = '&copy; '.link_('OpenStreetMap', 'https://www.openstreetmap.org/copyright').' contributors'; # STRING
$config_map_layer_dark = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'; # STRING (default: https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x})
$config_map_layer_dark_text = 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'; # STRING
$config_map_zoom = 8; # INT (default: 8)
$config_map_zoom_min = 3; # INT (default: 3)
$config_map_zoom_max = 15; # INT (default: 15)
$config_default_coordinates_latitude = 59.381; # DECIMAL(2,3) (default: 59.381)
$config_default_coordinates_longitude = 13.503; # DECIMAL(2,3) (default: 13.503)
$config_default_language = 'en'; # STRING (default: en)
$config_default_unit = 'metric'; # STRING (default: metric)
$config_default_time = '24h'; # STRING (default: 24h)
$config_default_decimal = 'comma'; # STRING (default: comma)
$config_default_theme = 'light'; # STRING (default: light)
# Enter the API key from OpenWeatherMap that the website will use as default.
$config_apikey = null; # STRING (MD5)
?>

4
site-footer.php

@ -22,6 +22,10 @@
echo $lang->footer->link_faq;
echo '</a>';
echo '<a href="'.url('privacy').'">';
echo $lang->footer->link_privacy;
echo '</a>';
/* echo '<a href="'.url('api').'">';
echo $lang->footer->link_api;
echo '</a>'; */

161
site-functions.php

@ -6,11 +6,10 @@
function url($string, $pure = false) {
global $is_locally, $latitude_shorten, $longitude_shorten, $settings_gps, $settings_unit, $settings_language, $settings_decimal, $settings_time, $settings_theme, $settings_apikey;
global $latitude_shorten, $longitude_shorten, $settings_gps, $settings_unit, $settings_language, $settings_decimal, $settings_time, $settings_theme, $settings_apikey;
# ($settings_gps == null ? null : ',gps'.($settings_gps == '' ? '' : ':follow'))
$basename_dir = basename(__DIR__) . (($pure == false AND $string == '') ? '/' : '/');
$is_locally = ($_SERVER['HTTP_HOST'] == 'localhost' ? true : false);
$basename_dir = basename(__DIR__) . (($pure == false AND $string == '') ? '' : '/');
$is_locally = '/'.($is_locally == true ? $basename_dir : null);
$settings = ($pure == true ? null : 'lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$settings_unit.','.$settings_language.','.$settings_decimal.','.$settings_time.','.$settings_theme . ($settings_apikey == null ? null : '/apikey:'.$settings_apikey));
@ -21,6 +20,10 @@
return '<a href="'.$link.'" target="_blank" rel="noreferrer">'.$string.'</a>';
}
function check_permissions($string) {
return substr(sprintf('%o', fileperms($string)), -4);
}
function create_folder($string) {
if(!file_exists($string)) {
$oldmask = umask(0);
@ -33,7 +36,9 @@
$content = '<head>';
$content .= '<title>'.$title.'</title>';
$content .= '<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon">';
$content .= '<style>body {background-color: #ffffff; font-family: "Arial", sans-serif; font-size: 0.980rem; margin: 0; padding: 15px;} code {background-color: #eaeaea; font-size: 0.880rem;}</style>';
$content .= '<link rel="stylesheet" href="//brick.freetls.fastly.net/Roboto:300,400,700/Roboto+Mono:400">';
$content .= '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/theme-light.css?'.time(), true).'">';
$content .= '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/die-content.css?'.time(), true).'">';
$content .= '</head>';
$content .= '<body>';
$content .= $string;
@ -100,36 +105,140 @@
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm9.06 8.683L5.648 6.238 4.353 7.762l7.72 6.555 7.581-6.56-1.308-1.513-6.285 5.439z"/></svg>' => 'contact',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></svg>' => 'clear',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M7 11.5a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm0 10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm10-10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm0 10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z"/></svg>' => 'using',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M4 3h14l2.707 2.707a1 1 0 0 1 .293.707V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm3 1v5h9V4H7zm-1 8v7h12v-7H6zm7-7h2v3h-2V5z"/></svg>' => 'save'
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M4 3h14l2.707 2.707a1 1 0 0 1 .293.707V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm3 1v5h9V4H7zm-1 8v7h12v-7H6zm7-7h2v3h-2V5z"/></svg>' => 'save',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M11 2v5H8l4 4 4-4h-3V2h7a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h7zm8 14H5v4h14v-4zm-2 1v2h-2v-2h2z"/></svg>' => 'install'
);
return array_search($string, $array_icons, true);
}
# Open up configs/default-language.php to see the names of the weather codes.
function weathericon($string) {
$icon_prefix = 'pe-7w-';
$array = Array(
'01d' => 'pe-7w-sun',
'02d' => 'pe-7w-cloud-sun',
'03d' => 'pe-7w-cloud-sun',
'04d' => 'pe-7w-cloud',
'09d' => 'pe-7w-rain-alt',
'10d' => 'pe-7w-rain',
'11d' => 'pe-7w-lightning-rain',
'13d' => 'pe-7w-snow',
'50d' => 'pe-7w-mist',
'01n' => 'pe-7w-moon',
'02n' => 'pe-7w-cloud-moon',
'03n' => 'pe-7w-cloud',
'04n' => 'pe-7w-cloud',
'09n' => 'pe-7w-rain-alt',
'10n' => 'pe-7w-rain',
'11n' => 'pe-7w-lightning-rain',
'13n' => 'pe-7w-snow',
'50n' => 'pe-7w-mist'
'01d800' => 'sun',
'01n800' => 'moon',
'02d801' => 'cloud-sun',
'02n801' => 'cloud-moon',
'03d802' => 'cloud-sun',
'03n802' => 'cloud-moon',
'04d803' => 'cloud',
'04d804' => 'cloud',
'04n803' => 'cloud',
'04n804' => 'cloud',
'09d300' => 'drizzle-alt',
'09d301' => 'drizzle',
'09d302' => 'drizzle',
'09d310' => 'drizzle-alt',
'09d311' => 'drizzle',
'09d312' => 'drizzle',
'09d313' => 'drizzle',
'09d314' => 'drizzle',
'09d321' => 'drizzle',
'09d520' => 'rain-alt',
'09d521' => 'rain-alt',
'09d522' => 'rain-alt',
'09d531' => 'rain-alt',
'09n300' => 'drizzle-alt',
'09n301' => 'drizzle',
'09n302' => 'drizzle',
'09n310' => 'drizzle-alt',
'09n311' => 'drizzle',
'09n312' => 'drizzle',
'09n313' => 'drizzle',
'09n314' => 'drizzle',
'09n321' => 'drizzle',
'09n520' => 'rain-alt',
'09n521' => 'rain-alt',
'09n522' => 'rain-alt',
'09n531' => 'rain-alt',
'10d500' => 'rain',
'10d501' => 'rain',
'10d502' => 'rain',
'10d503' => 'rain-alt',
'10d504' => 'rain-alt',
'10n500' => 'rain',
'10n501' => 'rain',
'10n502' => 'rain',
'10n503' => 'rain-alt',
'10n504' => 'rain-alt',
'11d200' => 'lightning-rain',
'11d201' => 'lightning-rain',
'11d202' => 'lightning-rain',
'11d210' => 'lightning',
'11d211' => 'lightning',
'11d212' => 'lightning',
'11d221' => 'lightning',
'11d230' => 'lightning-rain',
'11d231' => 'lightning-rain',
'11d232' => 'lightning-rain',
'11n200' => 'lightning-rain',
'11n201' => 'lightning-rain',
'11n202' => 'lightning-rain',
'11n210' => 'lightning',
'11n211' => 'lightning',
'11n212' => 'lightning',
'11n221' => 'lightning',
'11n230' => 'lightning-rain',
'11n231' => 'lightning-rain',
'11n232' => 'lightning-rain',
'13d511' => 'rain',
'13d600' => 'snow-alt',
'13d601' => 'snow-alt',
'13d602' => 'snow-alt',
'13d611' => 'snow',
'13d612' => 'snow',
'13d613' => 'snow',
'13d615' => 'snow',
'13d616' => 'snow',
'13d620' => 'snow',
'13d621' => 'snow',
'13d622' => 'snow',
'13n511' => 'rain',
'13n600' => 'snow-alt',
'13n601' => 'snow-alt',
'13n602' => 'snow-alt',
'13n611' => 'snow',
'13n612' => 'snow',
'13n613' => 'snow',
'13n615' => 'snow',
'13n616' => 'snow',
'13n620' => 'snow',
'13n621' => 'snow',
'13n622' => 'snow',
'50d701' => 'fog',
'50d711' => 'fog',
'50d721' => 'fog',
'50d731' => 'fog',
'50d741' => 'fog',
'50d751' => 'fog',
'50d761' => 'fog',
'50d762' => 'fog',
'50d771' => 'fog',
'50d781' => 'hurricane',
'50n701' => 'fog',
'50n711' => 'fog',
'50n721' => 'fog',
'50n731' => 'fog',
'50n741' => 'fog',
'50n751' => 'fog',
'50n761' => 'fog',
'50n762' => 'fog',
'50n771' => 'fog',
'50n781' => 'hurricane'
);
return (!isset($array[$string]) ? '-' : $array[$string]);
return $icon_prefix . (!isset($array[$string]) ? '-' : $array[$string]);
}
?>

41
site-header.php

@ -43,24 +43,26 @@
echo '<link type="text/css" rel="stylesheet preload" href="https://cdn.airikr.me/all.min.css">';
} else {
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/theme-'.$settings_theme.'.css?'.time(), true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/theme-'.$settings_theme.'.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/desktop.css?'.time(), true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/portable.css?'.time(), true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/pe-icon-7-weather.css', true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/leaflet.css', true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/pe-icon-7-weather.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/leaflet.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/pretty-checkbox.min.css">';
}
echo '<script src="'.url('javascripts/jquery.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/jquery.min.js" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/main.js?'.time(), true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/validator.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/moment.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/moment-timezone-with-data.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/format.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/leaflet.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/leaflet-fullscreen.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/jquery.nicescroll.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/clipboard.min.js', true).'" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/validator.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/moment.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/moment-timezone-with-data.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/format.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/leaflet.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/leaflet-fullscreen.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/jquery.nicescroll.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/clipboard.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/js.cookie.min.js" type="text/javascript"></script>';
echo '</head>';
echo '<body>';
@ -102,13 +104,20 @@
echo '<section id="website"';
echo ' data-settings-language="'.$settings_language.'"';
echo ' data-settings-theme="'.$settings_theme.'"';
echo ' data-domain="'.$config_domain.'"';
echo " data-default-maplayer-light='".$config_map_layer_light."'";
echo " data-default-maplayer-light-text='".$config_map_layer_light_text."'";
echo " data-default-maplayer-dark='".$config_map_layer_dark."'";
echo " data-default-maplayer-dark-text='".$config_map_layer_dark_text."'";
echo ' data-default-map-zoom="'.$config_map_zoom.'"';
echo ' data-default-map-zoom-min="'.$config_map_zoom_min.'"';
echo ' data-default-map-zoom-max="'.$config_map_zoom_max.'"';
echo ' data-settings-language="'.($cookie_exists == false ? $settings_language : $cs_language).'"';
echo ' data-settings-theme="'.($cookie_exists == false ? $settings_theme : $cs_theme).'"';
echo '>';
echo '<header>';
echo '<div class="name">'.$settings->title.'</div>';
echo ($settings->show_description_onpage == false ? '' : '<div class="description">'.$settings->description.'</div>');
echo '<div class="name">'.$config_title.'</div>';
echo '</header>';
echo '<main>';

107
site-settings.php

@ -1,16 +1,15 @@
<?php
require_once 'site-functions.php';
require_once 'site-config.php';
$debug = true;
$useragent = $_SERVER['HTTP_USER_AGENT'];
$host = $_SERVER['HTTP_HOST'];
$is_locally = ($_SERVER['HTTP_HOST'] == 'localhost' ? true : false);
$protocol = (stripos($_SERVER['SERVER_PROTOCOL'], 'http') !== false ? 'https' : 'http');
$website_settings = 'settings.json';
$website_settings_private = '/var/www/files/file.json';
$cdnurl = 'https://cdn.serenum.org';
$filename_path = explode('/', $_SERVER['PHP_SELF']);
$filename = $filename_path[count($filename_path) - 1];
@ -19,54 +18,68 @@
if(!file_exists($website_settings)) {
die_content('Please edit the settings file', 'Please edit <code>configs/website-settings.php</code> after your liking and then go to <a href="'.url('update-settings', true).'">/update-settings</a>.');
} else {
$settings = json_decode(file_get_contents($website_settings));
$settings_private = json_decode(file_get_contents($website_settings_private));
$og_title = $settings->title;
$og_url = $protocol.'://'.$settings->domain;
$og_image = $settings->image;
$og_image_alternative = $settings->image_alternative;
$og_description = $settings->description;
if($filename != 'shortcut.php') {
$latitude_pure = (isset($_GET['lat']) ? strip_tags(htmlspecialchars($_GET['lat'])) : $settings->defaults->coordinates->latitude);
$latitude_shorten = (float)number_format($latitude_pure, 3);
$longitude_pure = (isset($_GET['lng']) ? strip_tags(htmlspecialchars($_GET['lng'])) : $settings->defaults->coordinates->longitude);
$longitude_shorten = (float)number_format($longitude_pure, 3);
$settings_unit = (isset($_GET['uni']) ? strip_tags(htmlspecialchars($_GET['uni'])) : $settings->defaults->unit);
$settings_language = (isset($_GET['lan']) ? strip_tags(htmlspecialchars($_GET['lan'])) : $settings->defaults->language);
$settings_decimal = (isset($_GET['dec']) ? strip_tags(htmlspecialchars($_GET['dec'])) : $settings->defaults->decimal);
$settings_time = (isset($_GET['tim']) ? strip_tags(htmlspecialchars($_GET['tim'])) : $settings->defaults->time);
$settings_theme = (isset($_GET['the']) ? strip_tags(htmlspecialchars($_GET['the'])) : $settings->defaults->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'
];
$og_title = $config_title;