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
|
|
|
|
2017-08-25 13:59:19 +02:00
|
|
|
require_once(__DIR__ . "/helpers/auth.php");
|
|
|
|
require_once(ROOT_DIR . "/helpers/config.php");
|
2017-04-11 17:00:40 +02:00
|
|
|
require_once(ROOT_DIR . "/helpers/position.php");
|
|
|
|
require_once(ROOT_DIR . "/helpers/track.php");
|
2017-05-09 15:25:16 +02:00
|
|
|
require_once(ROOT_DIR . "/helpers/utils.php");
|
2019-02-25 10:04:09 +01:00
|
|
|
require_once(ROOT_DIR . "/helpers/lang.php");
|
2017-08-25 13:59:19 +02:00
|
|
|
|
2019-01-24 19:07:41 +01:00
|
|
|
$login = uUtils::postString('user');
|
|
|
|
$pass = uUtils::postPass('pass');
|
|
|
|
$action = uUtils::postString('action');
|
|
|
|
|
2019-02-25 10:04:09 +01:00
|
|
|
$lang = (new uLang(uConfig::$lang))->getStrings();
|
|
|
|
$langsArr = uLang::getLanguages();
|
|
|
|
|
2017-08-25 13:59:19 +02:00
|
|
|
$auth = new uAuth();
|
2019-01-24 19:07:41 +01:00
|
|
|
if ($action == "auth") {
|
|
|
|
$auth->checkLogin($login, $pass);
|
|
|
|
}
|
2017-08-25 13:59:19 +02:00
|
|
|
|
2019-01-24 19:07:41 +01:00
|
|
|
if (!$auth->isAuthenticated() && $action == "auth") {
|
2018-01-31 10:11:56 +01:00
|
|
|
$auth->exitWithRedirect("login.php?auth_error=1");
|
2017-08-25 13:59:19 +02:00
|
|
|
}
|
|
|
|
if (!$auth->isAuthenticated() && uConfig::$require_authentication) {
|
2018-01-31 10:11:56 +01:00
|
|
|
$auth->exitWithRedirect("login.php");
|
2017-08-25 13:59:19 +02:00
|
|
|
}
|
|
|
|
|
2017-04-10 22:46:56 +02:00
|
|
|
$displayUserId = NULL;
|
|
|
|
$usersArr = [];
|
2017-08-25 13:59:19 +02:00
|
|
|
if ($auth->isAdmin() || uConfig::$public_tracks) {
|
2017-04-10 22:46:56 +02:00
|
|
|
// public access or admin user
|
|
|
|
// get last position user
|
2017-08-17 15:38:58 +02:00
|
|
|
$lastPosition = uPosition::getLast();
|
2017-04-10 22:46:56 +02:00
|
|
|
if ($lastPosition->isValid) {
|
|
|
|
// display track of last position user
|
|
|
|
$displayUserId = $lastPosition->userId;
|
2017-04-06 18:07:15 +02:00
|
|
|
}
|
2017-04-10 22:46:56 +02:00
|
|
|
// populate users array (for <select>)
|
2017-08-17 15:38:58 +02:00
|
|
|
$usersArr = uUser::getAll();
|
2017-08-25 13:59:19 +02:00
|
|
|
} else if ($auth->isAuthenticated()) {
|
2017-04-10 22:46:56 +02:00
|
|
|
// display track of authenticated user
|
2017-08-25 13:59:19 +02:00
|
|
|
$displayUserId = $auth->user->id;
|
2013-06-19 13:27:14 +02:00
|
|
|
}
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2017-08-17 15:38:58 +02:00
|
|
|
$tracksArr = uTrack::getAll($displayUserId);
|
2017-04-10 22:46:56 +02:00
|
|
|
if (!empty($tracksArr)) {
|
|
|
|
// get id of the latest track
|
|
|
|
$displayTrackId = $tracksArr[0]->id;
|
|
|
|
} else {
|
|
|
|
$tracksArr = [];
|
|
|
|
$displayTrackId = NULL;
|
2017-04-07 16:04:59 +02:00
|
|
|
}
|
2017-04-10 22:46:56 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
2019-04-13 19:45:51 +02:00
|
|
|
<html lang="<?= uConfig::$lang ?>">
|
2013-06-19 13:27:14 +02:00
|
|
|
<head>
|
2017-04-10 22:46:56 +02:00
|
|
|
<title><?= $lang["title"] ?></title>
|
2017-08-25 13:59:19 +02:00
|
|
|
<?php include("meta.php"); ?>
|
2019-05-15 11:32:36 +02:00
|
|
|
<script type="module" src="js/ulogger.js"></script>
|
|
|
|
<!-- <script src="dist/ulogger.js"></script>-->
|
2013-06-19 13:27:14 +02:00
|
|
|
</head>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<body>
|
2013-06-19 13:27:14 +02:00
|
|
|
<div id="menu">
|
|
|
|
<div id="menu-content">
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2017-08-25 13:59:19 +02:00
|
|
|
<?php if ($auth->isAuthenticated()): ?>
|
2019-06-29 12:54:32 +02:00
|
|
|
<div>
|
|
|
|
<a id="user-menu"><img class="icon" alt="<?= $lang["user"] ?>" src="images/user.svg"> <?= htmlspecialchars($auth->user->login) ?></a>
|
|
|
|
<div id="user-dropdown">
|
|
|
|
<a id="user-pass"><img class="icon" alt="<?= $lang["changepass"] ?>" src="images/lock.svg"> <?= $lang["changepass"] ?></a>
|
2017-04-11 17:00:40 +02:00
|
|
|
<a href="utils/logout.php"><img class="icon" alt="<?= $lang["logout"] ?>" src="images/poweroff.svg"> <?= $lang["logout"] ?></a>
|
2017-04-10 22:46:56 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php else: ?>
|
2017-08-25 13:59:19 +02:00
|
|
|
<a href="login.php"><img class="icon" alt="<?= $lang["login"] ?>" src="images/key.svg"> <?= $lang["login"] ?></a>
|
2017-04-10 22:46:56 +02:00
|
|
|
<?php endif; ?>
|
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div class="section">
|
2017-04-10 22:46:56 +02:00
|
|
|
<?php if (!empty($usersArr)): ?>
|
2019-06-29 12:54:32 +02:00
|
|
|
<label for="user"><?= $lang["user"] ?></label>
|
|
|
|
<select id="user" name="user">
|
|
|
|
<option value="0" disabled><?= $lang["suser"] ?></option>
|
|
|
|
<?php foreach ($usersArr as $aUser): ?>
|
|
|
|
<option <?= ($aUser->id == $displayUserId) ? "selected " : "" ?>value="<?= $aUser->id ?>"><?= htmlspecialchars($aUser->login) ?></option>
|
|
|
|
<?php endforeach; ?>
|
2017-04-10 22:46:56 +02:00
|
|
|
</select>
|
|
|
|
<?php endif; ?>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div class="section">
|
2019-06-29 12:54:32 +02:00
|
|
|
<label for="track"><?= $lang["track"] ?></label>
|
|
|
|
<select id="track" name="track">
|
|
|
|
<?php foreach ($tracksArr as $aTrack): ?>
|
|
|
|
<option value="<?= $aTrack->id ?>"><?= htmlspecialchars($aTrack->name) ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
<input id="latest" type="checkbox"> <label for="latest"><?= $lang["latest"] ?></label><br>
|
|
|
|
<input id="auto-reload" type="checkbox"> <label for="auto-reload"><?= $lang["autoreload"] ?></label> (<a id="set-interval"><span id="interval"><?= uConfig::$interval ?></span></a> s)<br>
|
|
|
|
<a id="force-reload"> <?= $lang["reload"] ?></a><br>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div id="summary" class="section"></div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div id="other" class="section">
|
|
|
|
<a id="altitudes"><?= $lang["chart"] ?></a>
|
2013-06-21 11:15:09 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div>
|
2019-06-29 12:54:32 +02:00
|
|
|
<label for="api"><?= $lang["api"] ?></label>
|
|
|
|
<select id="api" name="api">
|
|
|
|
<option value="gmaps"<?= (uConfig::$mapapi == "gmaps") ? " selected" : "" ?>>Google Maps</option>
|
|
|
|
<option value="openlayers"<?= (uConfig::$mapapi == "openlayers") ? " selected" : "" ?>>OpenLayers</option>
|
|
|
|
</select>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div>
|
2019-06-29 12:54:32 +02:00
|
|
|
<label for="lang"><?= $lang["language"] ?></label>
|
|
|
|
<select id="lang" name="lang">
|
|
|
|
<?php foreach ($langsArr as $langCode => $langName): ?>
|
|
|
|
<option value="<?= $langCode ?>"<?= (uConfig::$lang == $langCode) ? " selected" : "" ?>><?= $langName ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
2013-06-23 23:43:09 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-04-13 19:45:51 +02:00
|
|
|
<div class="section">
|
2019-06-29 12:54:32 +02:00
|
|
|
<label for="units"><?= $lang["units"] ?></label>
|
|
|
|
<select id="units" name="units">
|
|
|
|
<option value="metric"<?= (uConfig::$units == "metric") ? " selected" : "" ?>><?= $lang["metric"] ?></option>
|
|
|
|
<option value="imperial"<?= (uConfig::$units == "imperial") ? " selected" : "" ?>><?= $lang["imperial"] ?></option>
|
|
|
|
<option value="nautical"<?= (uConfig::$units == "nautical") ? " selected" : "" ?>><?= $lang["nautical"] ?></option>
|
|
|
|
</select>
|
2013-06-23 23:43:09 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2019-06-29 12:54:32 +02:00
|
|
|
<div class="section">
|
|
|
|
<div class="menu-title"><?= $lang["export"] ?></div>
|
|
|
|
<a id="export-kml" class="menu-link">kml</a>
|
|
|
|
<a id="export-gpx" class="menu-link">gpx</a>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2017-08-25 13:59:19 +02:00
|
|
|
<?php if ($auth->isAuthenticated()): ?>
|
2019-06-29 12:54:32 +02:00
|
|
|
<div class="section">
|
|
|
|
<div id="import" class="menu-title"><?= $lang["import"] ?></div>
|
|
|
|
<form id="import-form" enctype="multipart/form-data" method="post">
|
2017-05-09 15:25:16 +02:00
|
|
|
<input type="hidden" name="MAX_FILE_SIZE" value="<?= uUtils::getUploadMaxSize() ?>" />
|
2019-06-29 12:54:32 +02:00
|
|
|
<input type="file" id="input-file" name="gpx" />
|
2017-05-09 09:06:23 +02:00
|
|
|
</form>
|
2019-06-29 12:54:32 +02:00
|
|
|
<a id="import-gpx" class="menu-link">gpx</a>
|
2017-05-09 09:06:23 +02:00
|
|
|
</div>
|
|
|
|
|
2019-06-29 12:54:32 +02:00
|
|
|
<div id="admin-menu">
|
|
|
|
<div class="menu-title"><?= $lang["adminmenu"] ?></div>
|
2017-08-25 13:59:19 +02:00
|
|
|
<?php if ($auth->isAdmin()): ?>
|
2019-06-29 12:54:32 +02:00
|
|
|
<a id="adduser" class="menu-link"><?= $lang["adduser"] ?></a>
|
|
|
|
<a id="edituser" class="menu-link"><?= $lang["edituser"] ?></a>
|
2017-04-14 17:24:09 +02:00
|
|
|
<?php endif; ?>
|
2019-06-29 12:54:32 +02:00
|
|
|
<a id="edittrack" class="menu-link"><?= $lang["edittrack"] ?></a>
|
2017-04-10 22:46:56 +02:00
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2019-04-13 19:45:51 +02:00
|
|
|
<div id="menu-close">»</div>
|
2017-04-18 09:25:21 +02:00
|
|
|
<div id="footer"><a target="_blank" href="https://github.com/bfabiszewski/ulogger-server"><span class="mi">μ</span>logger</a> <?= uConfig::$version ?></div>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-10 22:46:56 +02:00
|
|
|
|
2013-06-19 13:27:14 +02:00
|
|
|
<div id="main">
|
|
|
|
<div id="map-canvas"></div>
|
|
|
|
<div id="bottom">
|
|
|
|
<div id="chart"></div>
|
2019-06-29 12:54:32 +02:00
|
|
|
<div id="chart-close"><?= $lang["close"] ?></div>
|
2016-10-29 14:05:13 +02:00
|
|
|
</div>
|
2013-06-19 13:27:14 +02:00
|
|
|
</div>
|
2017-04-07 16:04:59 +02:00
|
|
|
|
2017-04-10 22:46:56 +02:00
|
|
|
</body>
|
2018-06-22 19:38:45 +01:00
|
|
|
</html>
|