mirror of
https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
synced 2026-06-04 23:24:53 -04:00
Initial commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
$offset = 0;
|
||||
if (isset($_GET['ajax']))
|
||||
{
|
||||
$constellation->render_incidents(false,$_GET['offset'],5);
|
||||
exit();
|
||||
}else if (isset($_GET['offset']))
|
||||
{
|
||||
$offset = $_GET['offset'];
|
||||
}
|
||||
|
||||
if ($_GET['new']=="incident")
|
||||
{
|
||||
Incident::add();
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']))
|
||||
{
|
||||
Incident::delete($_GET['delete']);
|
||||
}
|
||||
|
||||
//TODO: Pamatovat si data
|
||||
|
||||
render_header("Dashboard", true);
|
||||
?>
|
||||
|
||||
<div class="text-center">
|
||||
<h1>Dashboard</h1>
|
||||
<h3>Welcome <?php echo $user->get_name();?></h3>
|
||||
</div>
|
||||
|
||||
<div id="current">
|
||||
<?php
|
||||
$services = $constellation->render_status(true);
|
||||
?>
|
||||
</div>
|
||||
<div id="timeline">
|
||||
<div class="item">
|
||||
<div class="timeline">
|
||||
<div class="line text-muted"></div>
|
||||
<h3>New incident</h3>
|
||||
<form id="new-incident" action="/admin/?new=incident" method="POST" class="clearfix">
|
||||
<article class="panel">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<?php
|
||||
} ?>
|
||||
<div id="status-container" class="clearfix">
|
||||
<?php
|
||||
if (!is_array($_POST['services']))
|
||||
{
|
||||
$_POST['services'] = array($_POST['services']);
|
||||
}
|
||||
foreach($services as $service){
|
||||
?>
|
||||
<div class="item clearfix">
|
||||
<div class="service"><?php if ($service->get_status()!=-1){?><input type="checkbox" name="services[]" value="<?php echo $service->get_id(); ?>" <?php echo (in_array($service->get_id(), $_POST['services']))?"checked":'';?> id="service-<?php echo $service->get_id(); ?>"><?php } ?><label for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label></div>
|
||||
<div class="status <?php echo $classes[$service->get_status()];?>"><?php echo $statuses[$service->get_status()];?></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</article>
|
||||
<article class="panel new panel-primary">
|
||||
<div class="panel-heading icon">
|
||||
<i class="glyphicon glyphicon-info-sign"></i>
|
||||
</div>
|
||||
<div class="panel-heading clearfix">
|
||||
<input type="text" name="title" id="title" placeholder="Title" value="<?php echo htmlspecialchars($_POST['title']); ?>" required> <input type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" id="time" name="time" value="<?php echo htmlspecialchars($_POST['time']); ?>" class="pull-right" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" placeholder="Time">
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea name="text" placeholder="Here goes your text..." required><?php echo htmlspecialchars($_POST['text']); ?></textarea>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<small>Posted by: <?php echo $user->get_username();?> <span class="pull-right" id="end_time_wrapper">Ending: <input id="end_time" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="end_time" class="pull-right" placeholder="End time" value="<?php echo htmlspecialchars($_POST['end_time']); ?>"></span></small>
|
||||
</div>
|
||||
</article>
|
||||
<select class="form-control pull-left" id="type" name="type">
|
||||
<?php
|
||||
if (isset($_POST['type']))
|
||||
{
|
||||
$selected_status = $_POST['type'];
|
||||
}else
|
||||
{
|
||||
$selected_status = 2;
|
||||
}
|
||||
|
||||
foreach ($statuses as $key => $value) {
|
||||
echo '<option value="'.$key.'"'.(($key==$selected_status)?' selected':'').'>'.$value.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary pull-right">Submit</button>
|
||||
</form>
|
||||
<?php
|
||||
$constellation->render_incidents(true,$offset,5,true);
|
||||
$constellation->render_incidents(false,$offset,5,true);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
session_start();
|
||||
require("../config.php");
|
||||
require("../classes/constellation.php");
|
||||
require("../header.php");
|
||||
require("../footer.php");
|
||||
|
||||
if(isset($_COOKIE['user'])&&!isset($_SESSION['user']))
|
||||
{
|
||||
User::restore_session();
|
||||
}
|
||||
|
||||
//TODO: CHeck if user deactivated
|
||||
|
||||
if (!isset($_SESSION['user']))
|
||||
{
|
||||
if (isset($_GET['do']) && $_GET['do']=="lost-password")
|
||||
{
|
||||
require("lost-password.php");
|
||||
}else if (isset($_GET['do']) && $_GET['do']=="change-email"){
|
||||
$user_pwd = new User($_GET['id']);
|
||||
$user_pwd->change_email();
|
||||
require("login-form.php");
|
||||
}
|
||||
else{
|
||||
User::login();
|
||||
require("login-form.php");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = new User($_SESSION['user']);
|
||||
switch ($_GET["do"]) {
|
||||
case 'change-email':
|
||||
$user = new User($_GET['id']);
|
||||
$user->change_email();
|
||||
case 'user':
|
||||
require("user.php");
|
||||
break;
|
||||
|
||||
case 'settings':
|
||||
require("settings.php");
|
||||
break;
|
||||
|
||||
case 'new-user':
|
||||
require("new-user.php");
|
||||
break;
|
||||
|
||||
case 'logout':
|
||||
User::logout();
|
||||
break;
|
||||
|
||||
default:
|
||||
require("dashboard.php");
|
||||
break;
|
||||
}
|
||||
|
||||
render_footer(true);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
render_header("Login");
|
||||
?>
|
||||
<div class="text-center">
|
||||
<h1>Login</h1>
|
||||
</div>
|
||||
<div id="login-form" class="center">
|
||||
<?php if (isset($message)){?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<?php }else{?>
|
||||
<p class="alert alert-info">Please login to continue.</p>
|
||||
<?php }?>
|
||||
<form action="/admin/" method="post">
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input placeholder="Email" class="form-control" name="email" id="email" type="email" tabindex="1" value="<?php echo htmlspecialchars((isset($_POST['email'])?$_POST['email']:''),ENT_QUOTES);?>" required>
|
||||
</div>
|
||||
<div class="form-group" style="margin-bottom: 8px">
|
||||
<label for="pass">Password</label>
|
||||
<input placeholder="Password" class="form-control" name="pass" id="pass" type="password" tabindex="2" required>
|
||||
<div style="padding-top: 8px; position: relative;">
|
||||
<a href="?do=lost-password" class="pull-right noselect" tabindex="5">Forgotten password?</a>
|
||||
<input name="remember" id="remember" type="checkbox" tabindex="3"> <label class="lbl-login noselect" style="color: black;" for="remember">Remember me</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group clearfix">
|
||||
<button type="submit" class="btn btn-success pull-right" tabindex="4">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
render_footer();
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
render_header("Lost password");
|
||||
?>
|
||||
<div class="text-center">
|
||||
<h1>Lost password</h1>
|
||||
</div>
|
||||
<div id="login-form" class="center">
|
||||
|
||||
<?php
|
||||
if (isset($_POST['id']))
|
||||
{
|
||||
$user = new User($_POST['id']);
|
||||
$user->change_password($_POST['token']);
|
||||
if (isset($message)){?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<a href="/admin/?do=lost-password<?php echo "&id=".$_POST['id']."&token=".$_POST['token'];?>">Go back</a>
|
||||
<?php
|
||||
}
|
||||
else{?>
|
||||
<p class="alert alert-success">Password changed successfully!</p>
|
||||
<a href="/admin/">Go back to login page</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else if (isset($_POST['email']))
|
||||
{
|
||||
User::password_link();
|
||||
if (isset($message)){?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<a href="/admin/?do=lost-password">Go back to start</a>
|
||||
<?php
|
||||
}
|
||||
else{?>
|
||||
<p class="alert alert-success">Email with password reset link has been sent!</p>
|
||||
<a href="/admin/">Go back to login page</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if (isset($message)){?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<?php }?>
|
||||
<form action="/admin/?do=lost-password" method="post">
|
||||
<?php if (!isset($_GET['id'])||!isset($_GET['token'])){?>
|
||||
<label for="email">Email:</label>
|
||||
<div class="input-group pull-right">
|
||||
<input class="form-control" name="email" id="email" placeholder="Email" type="email" required>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-success pull-right">Submit request</button>
|
||||
</span>
|
||||
</div>
|
||||
<?php }
|
||||
else{
|
||||
$user = new User($_GET['id']);
|
||||
?>
|
||||
<p class="alert alert-info">Reset password for <?php echo $user->get_name()." (".$user->get_username().")";?></p>
|
||||
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>" >
|
||||
<input type="hidden" name="token" value="<?php echo $_GET['token'];?>" >
|
||||
<label for="new_password">New password</label>
|
||||
<input id="new_password" placeholder="New password" type="password" class="form-control" name="password">
|
||||
<label for="new_password_check">Repeat password</label>
|
||||
<input id="new_password_check" placeholder="Repeat password" type="password" class="form-control" name="password_repeat">
|
||||
<button type="submit" class="btn btn-primary pull-right margin-top">Change password</button>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<?php }?>
|
||||
</div>
|
||||
<?php
|
||||
render_footer();
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
User::add();
|
||||
}
|
||||
|
||||
render_header("New user", true); ?>
|
||||
<div class="text-center">
|
||||
<h2>Add new user</h2>
|
||||
</div>
|
||||
|
||||
<form action="/admin/?do=new-user&new=user" method="POST" class="form-horizontal">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<?php
|
||||
} ?>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6"><label for="name">Name: </label><input type="text" maxlength="50" name="name" value="<?php echo htmlspecialchars($_POST['name'],ENT_QUOTES);?>" id="name" placeholder="Name" class="form-control" required></div>
|
||||
<div class="col-sm-6"><label for="surname">Surname: </label><input type="text" maxlength="50" name="surname" value="<?php echo htmlspecialchars($_POST['surname'],ENT_QUOTES);?>" id="surname" placeholder="Surname" class="form-control" required></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6"><label for="username">Username:</label><input type="text" maxlength="50" name="username" value="<?php echo htmlspecialchars($_POST['username'],ENT_QUOTES);?>" id="username" placeholder="Username" class="form-control" required></div>
|
||||
<div class="col-sm-6"><label for="email">Email:</label><input type="email" maxlength="60" name="email" value="<?php echo htmlspecialchars($_POST['email'],ENT_QUOTES);?>" id="email" placeholder="Email" class="form-control" required></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6"><label for="password">Password:</label><input type="password" name="password" value="<?php echo htmlspecialchars($_POST['password'],ENT_QUOTES);?>" id="password" placeholder="Password" class="form-control" required></div>
|
||||
<div class="col-sm-6">
|
||||
<label for="permission">Permission: </label>
|
||||
<select name="permission" id="permission" class="form-control">
|
||||
<?php
|
||||
if (!empty($_POST['permission']))
|
||||
{
|
||||
$permission = $_POST['permission'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$permission = 2;
|
||||
}
|
||||
foreach ($permissions as $key => $value) {
|
||||
if ($permission == $key)
|
||||
{
|
||||
echo '<option value="'.$key.'" selected>'.$value.'</option>';
|
||||
}
|
||||
else{
|
||||
echo '<option value="'.$key.'">'.$value.'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary pull-right">Submit</button>
|
||||
</form>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
Service::add();
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']))
|
||||
{
|
||||
Service::delete();
|
||||
}
|
||||
|
||||
render_header("Settings", true);
|
||||
?>
|
||||
<div class="text-center">
|
||||
<h2>Settings</h2>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($message)){
|
||||
?>
|
||||
<p class="alert alert-danger"><?php echo $message; ?></p>
|
||||
<?php }?>
|
||||
<section>
|
||||
<h3 class="pull-left">Services</h3>
|
||||
<?php if ($user->get_rank() <= 1){?>
|
||||
<form action="?do=settings&new=service" method="post">
|
||||
<div class="input-group pull-right new-service">
|
||||
<input class="form-control" name="service" placeholder="Name" type="text" value="<?php echo htmlspecialchars($_POST['service']); ?>" maxlength="50" required>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-success pull-right">Add service</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<?php }?>
|
||||
<table class="table">
|
||||
|
||||
<thead><tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Name</th>
|
||||
<?php if ($user->get_rank()<=1)
|
||||
{?>
|
||||
<th scope="col">Delete</th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$query = $mysqli->query("SELECT * FROM services");
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td>".$result['id']."</td>";
|
||||
echo "<td>".$result['name']."</td>";
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
echo '<td><a href="?do=settings&delete='.$result['id'].'" class="pull-right delete-service"><i class="fa fa-trash"></i></a></td>';
|
||||
}
|
||||
echo "</tr>";
|
||||
}?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h3 class="pull-left">Users</h3>
|
||||
<?php if ($user->get_rank() == 0){?> <a href="?do=new-user" class="btn btn-success pull-right">Add new user</a><?php }?>
|
||||
<table class="table">
|
||||
|
||||
<thead><tr><th scope="col">ID</th><th scope="col">Username</th><th scope="col">Name</th><th scope="col">Surname</th><th scope="col">Email</th><th scope="col">Role</th><th scope="col">Active</th></tr></thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$query = $mysqli->query("SELECT * FROM users");
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td>".$result['id']."</td>";
|
||||
echo "<td><a href='/admin/?do=user&id=".$result['id']."'>".$result['username']."</a></td>";
|
||||
echo "<td>".$result['name']."</td>";
|
||||
echo "<td>".$result['surname']."</td>";
|
||||
echo "<td><a href=\"mailto:".$result['email']."\">".$result['email']."</a></td>";
|
||||
echo "<td>".$permissions[$result['permission']]."</td><td>";
|
||||
echo "<i class='fa fa-".($result['active']?"check success":"times danger")."'></i>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
$id = $_SESSION['user'];
|
||||
if (isset($_GET['id']))
|
||||
{
|
||||
$id = $_GET['id'];
|
||||
}
|
||||
try {
|
||||
$displayed_user = new User($id);
|
||||
} catch (Exception $e) {
|
||||
header("Location: /admin/?do=user");
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['password']))
|
||||
{
|
||||
$displayed_user->change_password();
|
||||
}
|
||||
|
||||
if (isset($_POST['email']))
|
||||
{
|
||||
$displayed_user->email_link();
|
||||
}
|
||||
|
||||
if (isset($_POST['permission']))
|
||||
{
|
||||
$displayed_user->change_permission();
|
||||
}
|
||||
|
||||
|
||||
if ($_GET['what']=='toggle')
|
||||
{
|
||||
$displayed_user->toggle();
|
||||
}
|
||||
|
||||
render_header("User", true);
|
||||
|
||||
?>
|
||||
<div class="text-center">
|
||||
<h1>User settings</h1>
|
||||
</div>
|
||||
<?php if (isset($message)){?>
|
||||
<p class="alert alert-danger"><?php echo $message?></p>
|
||||
<?php }
|
||||
|
||||
$displayed_user->render_user_settings();
|
||||
Reference in New Issue
Block a user