ulogger-server/index.php

167 lines
7.5 KiB
PHP
Raw Permalink Normal View History

2013-06-19 13:27:14 +02:00
<?php
2017-01-30 21:36:44 +01:00
/* μlogger
2013-06-19 13:27:14 +02:00
*
2017-01-30 21:36:44 +01:00
* Copyright(C) 2017 Bartek Fabiszewski (www.fabiszewski.net)
2013-06-19 13:27:14 +02:00
*
* This is free software; you can redistribute it and/or modify it under
2017-04-07 00:05:28 +02:00
* the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2013-06-19 13:27:14 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
2017-04-07 00:05:28 +02:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
2017-04-09 23:35:55 +02:00
2022-03-19 17:48:44 +01:00
require_once(__DIR__ . '/helpers/auth.php');
require_once(ROOT_DIR . '/helpers/config.php');
require_once(ROOT_DIR . '/helpers/position.php');
require_once(ROOT_DIR . '/helpers/track.php');
require_once(ROOT_DIR . '/helpers/utils.php');
require_once(ROOT_DIR . '/helpers/lang.php');
2017-08-25 13:59:19 +02:00
2022-03-19 17:48:44 +01:00
$login = uUtils::postString('user');
$pass = uUtils::postPass('pass');
$action = uUtils::postString('action');
2019-01-24 19:07:41 +01:00
2022-03-19 17:48:44 +01:00
$config = uConfig::getInstance();
$lang = (new uLang($config))->getStrings();
$langsArr = uLang::getLanguages();
2019-02-25 10:04:09 +01:00
2022-03-19 17:48:44 +01:00
$auth = new uAuth();
if ($action === 'auth') {
$auth->checkLogin($login, $pass);
}
2017-08-25 13:59:19 +02:00
2022-03-19 17:48:44 +01:00
if ($action === 'auth' && !$auth->isAuthenticated()) {
$auth->exitWithRedirect('login.php?auth_error=1');
}
if ($config->requireAuthentication && !$auth->isAuthenticated()) {
$auth->exitWithRedirect('login.php');
}
2017-04-10 22:46:56 +02:00
?>
<!DOCTYPE html>
2020-02-20 17:08:47 +01:00
<html lang="<?= $config->lang ?>">
2013-06-19 13:27:14 +02:00
<head>
2019-12-22 19:34:56 +01:00
<title><?= $lang['title'] ?></title>
<?php include('meta.php'); ?>
<script src="js/dist/bundle.js"></script>
2013-06-19 13:27:14 +02:00
</head>
2017-04-10 22:46:56 +02:00
<body>
2019-12-22 19:34:56 +01:00
<div id="container">
<div id="menu">
<div id="menu-content">
<?php if ($auth->isAuthenticated()): ?>
<div>
<a data-bind="onShowUserMenu"><img class="icon" alt="<?= $lang['user'] ?>" src="images/user.svg"> <?= htmlspecialchars($auth->user->login) ?></a>
<div id="user-menu" class="menu-hidden">
<a id="user-pass" data-bind="onPasswordChange"><img class="icon" alt="<?= $lang['changepass'] ?>" src="images/lock.svg"> <?= $lang['changepass'] ?></a>
2020-06-10 12:40:28 +02:00
<a class="menu-link" data-bind="onLogout"><img class="icon" alt="<?= $lang['logout'] ?>" src="images/poweroff.svg"> <?= $lang['logout'] ?></a>
2019-12-22 19:34:56 +01:00
</div>
2017-04-10 22:46:56 +02:00
</div>
2019-12-22 19:34:56 +01:00
<?php else: ?>
2020-06-10 12:40:28 +02:00
<a class="menu-link" data-bind="onLogin"><img class="icon" alt="<?= $lang['login'] ?>" src="images/key.svg"> <?= $lang['login'] ?></a>
2017-04-10 22:46:56 +02:00
<?php endif; ?>
2019-12-22 19:34:56 +01:00
<div class="section">
<label for="user"><?= $lang['user'] ?></label>
<select id="user" data-bind="currentUserId" name="user"></select>
</div>
2017-04-10 22:46:56 +02:00
2019-12-22 19:34:56 +01:00
<div class="section">
<label for="track"><?= $lang['track'] ?></label>
<select id="track" data-bind="currentTrackId" name="track"></select>
<input id="latest" type="checkbox" data-bind="showLatest"> <label for="latest"><?= $lang['latest'] ?></label><br>
2020-02-20 17:08:47 +01:00
<input id="auto-reload" type="checkbox" data-bind="autoReload"> <label for="auto-reload"><?= $lang['autoreload'] ?></label> (<a id="set-interval" data-bind="onSetInterval"><span id="interval" data-bind="interval"><?= $config->interval ?></span></a> s)<br>
2019-12-22 19:34:56 +01:00
<a id="force-reload" data-bind="onReload"> <?= $lang['reload'] ?></a><br>
</div>
2017-04-10 22:46:56 +02:00
2019-12-22 19:34:56 +01:00
<div id="summary" class="section" data-bind="summary"></div>
2017-04-10 22:46:56 +02:00
<div class="section" data-bind="trackColor">
<div class="menu-title"><?= $lang['trackcolor'] ?></div>
<input id="color-speed" type="checkbox" data-bind="speedVisible"> <label for="color-speed"><?= $lang['speed'] ?></label><br>
<input id="color-altitude" type="checkbox" data-bind="altitudeVisible"> <label for="color-altitude"><?= $lang['altitude'] ?></label><br>
</div>
2019-12-22 19:34:56 +01:00
<div id="other" class="section">
<a id="altitudes" class="menu-link menu-hidden" data-bind="onChartToggle"><?= $lang['chart'] ?></a>
2019-12-22 19:34:56 +01:00
</div>
2017-04-10 22:46:56 +02:00
2019-12-22 19:34:56 +01:00
<div>
<label for="api"><?= $lang['api'] ?></label>
<select id="api" name="api" data-bind="mapApi">
2020-02-20 17:08:47 +01:00
<option value="gmaps"<?= ($config->mapApi === 'gmaps') ? ' selected' : '' ?>>Google Maps</option>
<option value="openlayers"<?= ($config->mapApi === 'openlayers') ? ' selected' : '' ?>>OpenLayers</option>
2019-12-22 19:34:56 +01:00
</select>
</div>
2017-04-10 22:46:56 +02:00
2019-12-22 19:34:56 +01:00
<div>
<label for="lang"><?= $lang['language'] ?></label>
<select id="lang" name="lang" data-bind="lang">
<?php foreach ($langsArr as $langCode => $langName): ?>
2020-02-20 17:08:47 +01:00
<option value="<?= $langCode ?>"<?= ($config->lang === $langCode) ? ' selected' : '' ?>><?= $langName ?></option>
2019-12-22 19:34:56 +01:00
<?php endforeach; ?>
</select>
</div>
2017-04-10 22:46:56 +02:00
2019-06-29 12:54:32 +02:00
<div class="section">
2019-12-22 19:34:56 +01:00
<label for="units"><?= $lang['units'] ?></label>
<select id="units" name="units" data-bind="units">
2020-02-20 17:08:47 +01:00
<option value="metric"<?= ($config->units === 'metric') ? ' selected' : '' ?>><?= $lang['metric'] ?></option>
<option value="imperial"<?= ($config->units === 'imperial') ? ' selected' : '' ?>><?= $lang['imperial'] ?></option>
<option value="nautical"<?= ($config->units === 'nautical') ? ' selected' : '' ?>><?= $lang['nautical'] ?></option>
2019-12-22 19:34:56 +01:00
</select>
2017-05-09 09:06:23 +02:00
</div>
2019-12-22 19:34:56 +01:00
<div class="section">
<div class="menu-title"><?= $lang['export'] ?></div>
<a id="export-kml" class="menu-link" data-bind="onExportKml">kml</a>
<a id="export-gpx" class="menu-link" data-bind="onExportGpx">gpx</a>
2017-04-10 22:46:56 +02:00
</div>
2019-12-22 19:34:56 +01:00
<?php if ($auth->isAuthenticated()): ?>
<div class="section">
<div id="import" class="menu-title"><?= $lang['import'] ?></div>
<form id="import-form" enctype="multipart/form-data" method="post">
2020-06-02 22:25:06 +02:00
<input type="hidden" name="MAX_FILE_SIZE" value="<?= $config->uploadMaxSize ?>" />
2019-12-22 19:34:56 +01:00
<input type="file" id="input-file" name="gpx" data-bind="inputFile"/>
</form>
<a id="import-gpx" class="menu-link" data-bind="onImportGpx">gpx</a>
</div>
<div id="admin-menu">
<div class="menu-title"><?= $lang['adminmenu'] ?></div>
<?php if ($auth->isAdmin()): ?>
2020-02-23 22:21:17 +01:00
<a id="adduser" class="menu-link" data-bind="onConfigEdit"><?= $lang['config'] ?></a>
<a id="adduser" class="menu-link" data-bind="onUserAdd"><?= $lang['adduser'] ?></a>
<a id="edituser" class="menu-link" data-bind="onUserEdit"><?= $lang['edituser'] ?></a>
2019-12-22 19:34:56 +01:00
<?php endif; ?>
2020-06-14 19:48:03 +02:00
<a id="edittrack" class="menu-link menu-hidden" data-bind="onTrackEdit"><?= $lang['edittrack'] ?></a>
2019-12-22 19:34:56 +01:00
</div>
<?php endif; ?>
</div>
<div id="menu-button"><a data-bind="onMenuToggle"></a></div>
2020-02-20 17:08:47 +01:00
<div id="footer"><a target="_blank" href="https://github.com/bfabiszewski/ulogger-server"><span class="mi">μ</span>logger</a> <?= $config->version ?></div>
2013-06-19 13:27:14 +02:00
</div>
2017-04-10 22:46:56 +02:00
2019-12-22 19:34:56 +01:00
<div id="main">
<div id="map-canvas"></div>
<div id="bottom">
<div id="chart"></div>
2020-04-14 20:50:12 +02:00
<a id="chart-close" data-bind="onChartToggle"><img src="images/close_blue.svg" alt="<?= $lang['close'] ?>"></a>
2019-12-22 19:34:56 +01:00
</div>
</div>
2019-12-22 19:34:56 +01:00
</div>
2017-04-10 22:46:56 +02:00
</body>
</html>