SignUp/index.php
2019-08-08 16:40:15 +03:00

195 lines
7.7 KiB
PHP

<?php
/**
* /index.php
* @version 1.0
* @desc Kind a main index file for stuffs like login form
* @author Fándly Gergő Zoltán
* @copy 2017 Fándly Gergő Zoltán
*/
require_once("config/config.php");
$view="";
if(!$lm->validateLogin()){
if(isset($_POST['uname']) && isset($_POST['passwd'])){
$lm->login($_POST['uname'], $_POST['passwd']);
}
}
else{
if(isset($_GET['logout'])){
$lm->logout();
}
if(isset($_GET['view'])){
$view=$_GET['view'];
if($view!="programs" && $view!="timetable" && $view!="timetable_programs" && $view!="users" && $view!="admin"){
header("Location: ./");
}
if($view=="timetable_programs" && $_SESSION['accesslevel']<1){
$view="";
}
else if($view=="users" && $_SESSION['accesslevel']<2){
$view="";
}
else if($view=="admin" && $_SESSION['accesslevel']<3){
$view="";
}
}
else{
$view="";
}
//include sub
include("subs/".$view.".backend.php");
//if just the backend was requested, stop here
if(isset($_GET['backend'])){
//echo messages
echo "<center>";
if(functions::isMessage()){
foreach(functions::getMessageArray() as $m){
echo "<div class=\"message\">";
echo "<p>".$lang['message'][$m]."</p>";
echo "</div>";
}
echo "<hr class=\"placeholder\">";
}
if(functions::isError()){
foreach(functions::getErrorArray() as $m){
echo "<div class=\"message error\">";
echo "<p>".$lang['error'][$m]."</p>";
echo "</div>";
}
echo "<hr class=\"placeholder\">";
}
echo "</center>";
//clear messages
functions::clearError();
functions::clearMessage();
//stop execution
die();
}
}
$oid=0;
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo ($view==""?$lang['index']:$lang[$view])." :: ".$config['general']['title']." - ".$config['general']['org'] ?></title>
<meta charset="UTF-8">
<!-- styleseets, icons -->
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" media="screen and (max-width: 1024px)" href="./style_mobile.css">
<link rel="icon" href="./res/icon.png">
<!-- 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 for fancy table -->
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="./script/footable/footable.min.js"></script>
<link rel="stylesheet" href="./script/footable/footable.standalone.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- personal script -->
<script src="./script/script.js"></script>
</head>
<body>
<div id="loadingOverlay" class="overlay loading" style="display: none">
<img src="./res/loading.gif" alt="loading...">
</div>
<div id="messageOverlay" class="overlay messages" style="display: none" onclick="disposeMessageOverlay()"></div>
<h1 class="title"><?php echo $config['general']['title']." - ".$config['general']['org'] ?></h1>
<hr class="placeholder">
<center>
<div id="message_container">
<?php
if(functions::isMessage()){
foreach(functions::getMessageArray() as $m){
echo "<div class=\"message\">";
echo "<p>".$lang['message'][$m]."</p>";
echo "</div>";
}
echo "<hr class=\"placeholder\">";
}
if(functions::isError()){
foreach(functions::getErrorArray() as $m){
echo "<div class=\"message error\">";
echo "<p>".$lang['error'][$m]."</p>";
echo "</div>";
}
echo "<hr class=\"placeholder\">";
}
?>
</div>
<?php if(!$lm->validateLogin()): ?>
<div id="login_area">
<center>
<form method="POST" action="" id="login">
<fieldset>
<legend><?php echo $lang['login'] ?></legend>
<center>
<table>
<tr>
<td><?php echo $lang['id'].": " ?></td>
<td><input type="text" name="uname" placeholder="<?php echo $lang['id']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['password'].": " ?></td>
<td><input type="password" name="passwd" placeholder="<?php echo $lang['password']."..." ?>" required></td>
</tr>
</table>
<br>
<?php $lm->loginPrepare(); $lm->printCaptcha() ?>
<br>
<button type="submit" form="login"><?php echo $lang['ok'] ?></button>
</center>
</fieldset>
</form>
</center>
</div>
<?php else: ?>
<div id="users_area">
<div id="profile">
<p><?php echo $lang['id'].": ".$_SESSION['id']." | ".$lang['name'].": ".$_SESSION['name']." | ".$lang['class'].": ".$_SESSION['class'] ?></p>
</div>
<div id="menu">
<ul class="menu">
<a href="./"><li><?php echo $lang['index'] ?></li></a>
<a href="./programs"><li><?php echo $lang['programs'] ?></li></a>
<a href="./timetable"><li><?php echo $lang['timetable'] ?></li></a>
<?php if($_SESSION['accesslevel']>=1): ?><a href="./timetable_programs"><li><?php echo $lang['timetable_programs'] ?></li></a><?php endif ?>
<a href="./timetable?studentcard"><li><?php echo $lang['studentcard'] ?></li></a>
<?php if($_SESSION['accesslevel']>=2): ?><a href="./users"><li><?php echo $lang['users'] ?></li></a><?php endif ?>
<?php if($_SESSION['accesslevel']>=3): ?><a href="./admin"><li><?php echo $lang['admin'] ?></li></a><?php endif ?>
<a href="./?logout"><li><?php echo $lang['logout'] ?></li></a>
</ul>
</div>
<hr class="placeholder">
<!-- include -->
<?php include("subs/".$view.".php") ?>
<!-- end -->
</div>
<?php endif ?>
</center>
<hr class="placeholder" style="height: 500px">
</body>
<footer>
<p><?php echo "&copy; ".$config['general']['org']." ".date("Y") ?></p>
<p>Powered by: SignUP<br>version: <?php echo VERSION ?><br>Created by: Fándly Gergő<br><a href="//systemtest.tk">systemtest.tk</a></p>
</footer>
</html>