FreeSTAR-Status-Engine/admin/settings.php

88 lines
2.6 KiB
PHP
Raw Normal View History

2017-11-23 18:09:36 -05:00
<?php
if (isset($_GET['new']))
{
Service::add();
}
if (isset($_GET['delete']))
{
Service::delete();
}
2017-12-30 18:41:58 -05:00
render_header(_("Settings"), true);
2017-11-23 18:09:36 -05:00
?>
<div class="text-center">
<h2>Settings</h2>
</div>
<?php
if (isset($message)){
?>
<p class="alert alert-danger"><?php echo $message; ?></p>
<?php }?>
<section>
2017-12-30 18:41:58 -05:00
<h3 class="pull-left"><?php echo _("Services");?></h3>
2017-11-23 18:09:36 -05:00
<?php if ($user->get_rank() <= 1){?>
<form action="?do=settings&new=service" method="post">
<div class="input-group pull-right new-service">
2018-01-03 08:15:45 -05:00
<input class="form-control" name="service" placeholder="Name" type="text" value="<?php echo ((isset($_POST['service']))?htmlspecialchars($_POST['service']):''); ?>" maxlength="50" required>
2017-11-23 18:09:36 -05:00
<span class="input-group-btn">
2017-12-30 18:41:58 -05:00
<button type="submit" class="btn btn-success pull-right"><?php echo _("Add service");?></button>
2017-11-23 18:09:36 -05:00
</span>
</div>
</form>
<?php }?>
<table class="table">
<thead><tr>
2017-12-30 18:41:58 -05:00
<th scope="col"><?php echo _("ID");?></th>
<th scope="col"><?php echo _("Name");?></th>
2017-11-23 18:09:36 -05:00
<?php if ($user->get_rank()<=1)
{?>
2017-12-30 18:41:58 -05:00
<th scope="col"><?php echo _("Delete");?></th>
2017-11-23 18:09:36 -05:00
<?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>
2017-12-30 18:41:58 -05:00
<h3 class="pull-left"><?php echo _("Users");?></h3>
<?php if ($user->get_rank() == 0){?> <a href="?do=new-user" class="btn btn-success pull-right"><?php echo _("Add new user");?></a><?php }?>
2017-11-23 18:09:36 -05:00
<table class="table">
2017-12-30 18:41:58 -05:00
<thead><tr><th scope="col"><?php echo _("ID");?></th><th scope="col"><?php echo _("Username");?></th><th scope="col"><?php echo _("Name");?></th><th scope="col"><?php echo _("Surname");?></th><th scope="col"><?php echo _("Email");?></th><th scope="col"><?php echo _("Role");?></th><th scope="col">Active</th></tr></thead>
2017-11-23 18:09:36 -05:00
<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>