ResultManager/index.php

196 lines
9.2 KiB
PHP
Raw Permalink Normal View History

2019-08-08 13:58:29 +00:00
<?php
/**
* /index.php
* @version 1.0
* @desc Main index file
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
require_once("config/config.php");
require_once("subs/loader.php");
if(!$lm->validateLogin()){
$lm->loginPrepare();
if(isset($_POST['uname']) && isset($_POST['passwd'])){
$remember=isset($_POST['remember']);
$lm->login($_POST['uname'], $_POST['passwd'], $remember);
}
if(isset($_GET['login_auto'])){
$lm->login("", "");
}
if(isset($_GET['forget_user'])){
$lm->forgetUser();
}
}
else{
if(isset($_GET['logout'])){
$lm->logout();
}
}
//select page we want to see
$view="";
if(isset($_GET['view'])){
$view=$_GET['view'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $config['general']['title']." - ".$config['general']['org'] ?></title>
<meta charset="UTF-8">
<!-- stylesheet, icon -->
<link rel="stylesheet" href="./style/style.css">
<link rel="stylesheet" media="screen and (max-width: 1024px)" href="./style/mobile.css">
<link rel="icon" href="./res/icon.png">
<!-- jquery -->
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- cookieconsent -->
<script>
window.cookieconsent_options={
message: '<?php echo $lang['cookie_message'] ?>',
dismiss: '<?php echo $lang['cookie_dismiss'] ?>',
};
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>
<!-- reCaptcha -->
<script src="//www.google.com/recaptcha/api.js"></script>
<!-- footable -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-footable/3.1.6/footable.core.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery-footable/3.1.6/footable.core.standalone.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- main script -->
<script src="./script/js.php?load=main"></script>
<script src="./script/js.php?load=<?php echo $view ?>"></script>
</head>
<body>
<!-- overlays -->
<div id="messageOverlay" class="overlay messages" style="display: none" onclick="disposeMessageOverlay()"></div>
<div id="loadingOverlay" class="overlay loading" style="display: none">
<img src="./res/loading.gif" alt="loading">
<span><?php echo $lang['loading']."..." ?></span>
</div>
<div class="center">
<div id="message_container">
<?php
//load messages manually
include("subs/msg.php");
?>
</div>
</div>
<?php if(!$lm->validateLogin()): ?>
<!-- Not logged in -->
<div class="center">
<div id="login_area">
<div class="center">
<?php if($lm->isRememberingUser()): ?>
<fieldset class="center">
<legend><?php echo $lang['login']?></legend>
<?php
$sql=$db->prepare("SELECT fullname FROM users WHERE id=:id");
$sql->execute(array(":id"=>$lm->isRememberingUser()));
$res=$sql->fetch(PDO::FETCH_ASSOC);
?>
<h3><?php echo $lang['remember_as']." ".$res['fullname'] ?></h3>
<button type="button" onclick="window.location='./?login_auto'"><?php echo $lang['login'] ?></button>
<br>
<br>
<button type="button" onclick="window.location='./?forget_user'"><?php echo $lang['forget_user'] ?></button>
</fieldset>
<?php else: ?>
<form method="POST" action="./" id="login">
<fieldset class="center">
<legend><?php echo $lang['login'] ?></legend>
<div class="center">
<table class="center">
<tr>
<td><?php echo $lang['username'].": " ?></td>
<td><input type="text" name="uname" placeholder="<?php echo $lang['username']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['password'].": " ?></td>
<td><input type="password" name="passwd" placeholder="<?php echo $lang['password']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['remember'].": " ?></td>
<td>
<div class="checkbox">
<input id="remember" type="checkbox" name="remember" hidden>
<label for="remember"></label>
</div>
</td>
</tr>
</table>
<br>
<?php $lm->printCaptcha() ?>
<br>
<br>
<button type="submit" form="login"><?php echo $lang['ok'] ?></button>
</div>
</fieldset>
</form>
<?php endif ?>
</div>
</div>
</div>
<?php else: ?>
<!-- Logged in -->
<div id="menu">
<ul class="menu">
<a onclick="goTo('')"><li><img src="./res/index.png" class="icon" alt="icon"><?php echo $lang['index'] ?></li></a>
<?php if($_SESSION['accesslevel']>=3): ?>
<a onclick="goTo('users')"><li><img src="./res/users.png" class="icon" alt="icon"><?php echo $lang['users'] ?></li></a>
<?php endif ?>
<?php if($_SESSION['accesslevel']>=1): ?>
<a onclick="goTo('classes')"><li><img src="./res/classes.png" class="icon" alt="icon"><?php echo $lang['classes'] ?></li></a>
<a onclick="goTo('subjects')"><li><img src="./res/subjects.png" class="icon" alt="icon"><?php echo $lang['subjects'] ?></li></a>
<a onclick="goTo('contests')"><li><img src="./res/contests.png" class="icon" alt="icon"><?php echo $lang['contests'] ?></li></a>
<a onclick="goTo('phases')"><li><img src="./res/phases.png" class="icon" alt="icon"><?php echo $lang['phases'] ?></li></a>
<a onclick="goTo('register')"><li><img src="./res/register.png" class="icon" alt="icon"><?php echo $lang['register'] ?></li></a>
<a onclick="goTo('wizard')"><li><img src="./res/wizard.png" class="icon" alt="icon"><?php echo $lang['wizard'] ?></li></a>
<?php endif ?>
<a onclick="goTo('profile')"><li><img src="./res/profile.png" class="icon" alt="icon"><?php echo $lang['profile'] ?></li></a>
<?php if($_SESSION['accesslevel']>=4): ?>
<a onclick="goTo('admin')"><li><img src="./res/admin.png" class="icon" alt="icon"><?php echo $lang['admin'] ?></li></a>
<?php endif ?>
<a href="./?logout"><li><img src="./res/logout.png" class="icon" alt="icon"><?php echo $lang['logout'] ?></li></a>
</ul>
</div>
<hr class="placeholder">
<div class="content" id="content">
<!-- part -->
<?php
//load first part manually
loadPart($view);
?>
<!-- part end -->
</div>
<?php endif ?>
<hr class="placeholder" style="height: 500px">
<footer>
<p><?php echo "&copy; ".$config['general']['org']." ".date("Y") ?></p>
<p>Powered by: ResultManager<br>version: <?php echo VERSION ?><br>Copyright (c) 2017-<?php echo date("Y") ?> Fándly Gergő (<a href="//systemtest.tk">systemtest.tk</a>, <a href="mailto:contact@systemtest.tk">contact@systemtest.tk</a>)</p>
<p><a href="./license.txt">License</a></p>
</footer>
</body>
</html>