parent
e2e4a9620b
commit
bf3048baf8
3
404.php
3
404.php
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
require_once("template.php");
|
||||
if (!file_exists("config.php"))
|
||||
{
|
||||
if (!file_exists("config.php")) {
|
||||
require_once("install.php");
|
||||
} else {
|
||||
require_once("config.php");
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
<?php
|
||||
$offset = 0;
|
||||
if (isset($_GET['ajax']))
|
||||
{
|
||||
if (isset($_GET['ajax'])) {
|
||||
$constellation->render_incidents(false, $_GET['offset'], 5);
|
||||
exit();
|
||||
}else if (isset($_GET['offset']))
|
||||
{
|
||||
} else if (isset($_GET['offset'])) {
|
||||
$offset = $_GET['offset'];
|
||||
}
|
||||
|
||||
if (isset($_GET['new']) && $_GET['new']=="incident")
|
||||
{
|
||||
if (isset($_GET['new']) && $_GET['new'] == "incident") {
|
||||
Incident::add();
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']))
|
||||
{
|
||||
if (isset($_GET['delete'])) {
|
||||
Incident::delete($_GET['delete']);
|
||||
}
|
||||
if (isset($_GET['tasks'])) {
|
||||
|
@ -42,15 +38,13 @@ Template::render_header(_("Dashboard"), true);
|
|||
<h3><?php echo _("New incident"); ?></h3>
|
||||
<form id="new-incident" action="<?php echo WEB_URL; ?>/admin/?new=incident" method="POST" class="">
|
||||
<div class="card">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<?php if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
<?php
|
||||
} ?>
|
||||
<div id="status-container" class="">
|
||||
<?php
|
||||
if (isset($_POST['services']) && !is_array($_POST['services']))
|
||||
{
|
||||
if (isset($_POST['services']) && !is_array($_POST['services'])) {
|
||||
$post_services = array($_POST['services']);
|
||||
} else {
|
||||
$post_services = array();
|
||||
|
@ -64,7 +58,9 @@ Template::render_header(_("Dashboard"), true);
|
|||
<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(); ?>">
|
||||
</div>
|
||||
<label id="name" class="input-group-text form-control" for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label>
|
||||
<label id="status" class="input-group-text btn-<?php if ($service->get_status()!=-1){echo $classes[$service->get_status()];}?>" for="service-<?php echo $service->get_id(); ?>"><?php echo $statuses[$service->get_status()];?></label >
|
||||
<label id="status" class="input-group-text btn-<?php if ($service->get_status() != -1) {
|
||||
echo $classes[$service->get_status()];
|
||||
} ?>" for="service-<?php echo $service->get_id(); ?>"><?php echo $statuses[$service->get_status()]; ?></label>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -95,11 +91,9 @@ Template::render_header(_("Dashboard"), true);
|
|||
<div class="input-group">
|
||||
<select class="form-select" id="type" name="type">
|
||||
<?php
|
||||
if (isset($_POST['type']))
|
||||
{
|
||||
if (isset($_POST['type'])) {
|
||||
$selected_status = $_POST['type'];
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
$selected_status = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!file_exists("../config.php"))
|
||||
{
|
||||
if (!file_exists("../config.php")) {
|
||||
header("Location: ../");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
require_once("../config.php");
|
||||
require_once("../classes/constellation.php");
|
||||
require_once("../classes/mailer.php");
|
||||
|
@ -39,52 +37,39 @@ else{
|
|||
|
||||
// Process the subscriber notification queue
|
||||
// If CRON_SERVER_IP is not set, call notification once incident has been saved
|
||||
if ( empty(CRON_SERVER_IP) )
|
||||
{
|
||||
if ( isset($_GET['sent']) && $_GET['sent'] == true )
|
||||
{
|
||||
if (empty(CRON_SERVER_IP)) {
|
||||
if (isset($_GET['sent']) && $_GET['sent'] == true) {
|
||||
Queue::process_queue();
|
||||
}
|
||||
}
|
||||
else if ( isset($_GET['task']) && $_GET['task'] == 'cron' )
|
||||
{
|
||||
} else if (isset($_GET['task']) && $_GET['task'] == 'cron') {
|
||||
// Else, base it on call to /admin?task=cron being called from IP defined by CRON_SERVER_IP
|
||||
if (! empty(CRON_SERVER_IP) && $_SERVER['REMOTE_ADDR'] == CRON_SERVER_IP )
|
||||
{
|
||||
if (!empty(CRON_SERVER_IP) && $_SERVER['REMOTE_ADDR'] == CRON_SERVER_IP) {
|
||||
Queue::process_queue();
|
||||
syslog(1, "CRON server processed");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
syslog(1, "CRON called from unauthorised server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($_COOKIE['user'])&&!isset($_SESSION['user']))
|
||||
{
|
||||
if (isset($_COOKIE['user']) && !isset($_SESSION['user'])) {
|
||||
User::restore_session();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user']))
|
||||
{
|
||||
if (isset($_GET['do']) && $_GET['do']=="lost-password")
|
||||
{
|
||||
if (!isset($_SESSION['user'])) {
|
||||
if (isset($_GET['do']) && $_GET['do'] == "lost-password") {
|
||||
require_once("lost-password.php");
|
||||
} else if (isset($_GET['do']) && $_GET['do'] == "change-email") {
|
||||
$user_pwd = new User($_GET['id']);
|
||||
$user_pwd->change_email();
|
||||
require_once("login-form.php");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
User::login();
|
||||
require_once("login-form.php");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$user = new User($_SESSION['user']);
|
||||
if (!$user->is_active())
|
||||
{
|
||||
if (!$user->is_active()) {
|
||||
User::logout();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,36 +7,30 @@ Template::render_header(_("Lost password"));
|
|||
<div id="login-form" class="center">
|
||||
|
||||
<?php
|
||||
if (isset($_POST['id']))
|
||||
{
|
||||
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="<?php echo WEB_URL; ?>/admin/?do=lost-password<?php echo "&id=" . $_POST['id'] . "&token=" . $_POST['token']; ?>"><?php echo _("Go back"); ?> </a>
|
||||
<?php
|
||||
}
|
||||
else{?>
|
||||
} else { ?>
|
||||
<p class="alert alert-success"><?php echo _("Password changed successfully!"); ?></p>
|
||||
<a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else if (isset($_POST['email']))
|
||||
{
|
||||
} else if (isset($_POST['email'])) {
|
||||
User::password_link();
|
||||
if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
<a href="<?php echo WEB_URL; ?>/admin/?do=lost-password"><?php echo _("Go back to start"); ?></a>
|
||||
<?php
|
||||
}
|
||||
else{?>
|
||||
} else { ?>
|
||||
<p class="alert alert-success"><?php echo _("Email with password reset link has been sent!"); ?></p>
|
||||
<a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
|
@ -50,8 +44,7 @@ Template::render_header(_("Lost password"));
|
|||
<button type="submit" class="btn btn-success pull-right"><?php echo _("Submit request"); ?></button>
|
||||
</span>
|
||||
</div>
|
||||
<?php }
|
||||
else{
|
||||
<?php } else {
|
||||
$user = new User($_GET['id']);
|
||||
?>
|
||||
<p class="alert alert-info"><?php printf(_("Reset password for %s (%s)"), $user->get_name(), $user->get_username()); ?></p>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
if (isset($_GET['new'])) {
|
||||
User::add();
|
||||
}
|
||||
|
||||
|
@ -10,8 +9,7 @@ Template::render_header(_("New user"), true); ?>
|
|||
</div>
|
||||
|
||||
<form action="<?php echo WEB_URL; ?>/admin/?do=new-user&new=user" method="POST" class="form-horizontal">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<?php if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
<?php
|
||||
} ?>
|
||||
|
@ -29,20 +27,15 @@ Template::render_header(_("New user"), true); ?>
|
|||
<label for="permission"><?php echo _("Permission"); ?>: </label>
|
||||
<select name="permission" id="permission" class="form-control">
|
||||
<?php
|
||||
if (!empty($_POST['permission']))
|
||||
{
|
||||
if (!empty($_POST['permission'])) {
|
||||
$permission = $_POST['permission'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$permission = 2;
|
||||
}
|
||||
foreach ($permissions as $key => $value) {
|
||||
if ($permission == $key)
|
||||
{
|
||||
if ($permission == $key) {
|
||||
echo '<option value="' . $key . '" selected>' . $value . '</option>';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
function getToggle($variable){
|
||||
function getToggle($variable)
|
||||
{
|
||||
$res = ((isset($variable) && ($variable == "on")) ? "yes" : "no");
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
if (!file_exists("../config.php"))
|
||||
{
|
||||
if (!file_exists("../config.php")) {
|
||||
header("Location: ../");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
require_once("../config.php");
|
||||
require_once("../classes/constellation.php");
|
||||
require_once("../classes/mailer.php");
|
||||
|
@ -96,7 +95,11 @@ else{
|
|||
Template::render_header(_("Options"), true);
|
||||
?>
|
||||
<div class="text-center">
|
||||
<h2><?php if($set_post){ echo "Settings Saved"; } else { echo "Server Status Options"; } ?></h2>
|
||||
<h2><?php if ($set_post) {
|
||||
echo "Settings Saved";
|
||||
} else {
|
||||
echo "Server Status Options";
|
||||
} ?></h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<?php Template::render_toggle("Notify Updates", "nu_toggle", $notifyUpdates_status); ?>
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
<?php
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
if (isset($_GET['new'])) {
|
||||
ServiceGroup::add();
|
||||
}
|
||||
|
||||
if (isset($_GET['edit']))
|
||||
{
|
||||
if (isset($_GET['edit'])) {
|
||||
ServiceGroup::edit();
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']))
|
||||
{
|
||||
if (isset($_GET['delete'])) {
|
||||
ServiceGroup::delete();
|
||||
}
|
||||
|
||||
|
@ -41,7 +38,6 @@ Template::render_header(_("New service group"), true); ?>
|
|||
</div>
|
||||
<?php
|
||||
$form_url = WEB_URL . '/admin/?do=new-service-group&new=group';
|
||||
|
||||
} else {
|
||||
Template::render_header(_("Edit service group"), true); ?>
|
||||
<div class="text-center">
|
||||
|
@ -49,13 +45,11 @@ $form_url = WEB_URL .'/admin/?do=new-service-group&new=group';
|
|||
</div>
|
||||
<?php
|
||||
$form_url = WEB_URL . '/admin/?do=edit-service-group&edit&id=' . $group_id;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="<?php echo $form_url; ?>" method="POST" class="form-horizontal">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<?php if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
<?php
|
||||
} ?>
|
||||
|
@ -68,21 +62,16 @@ $form_url = WEB_URL .'/admin/?do=new-service-group&new=group';
|
|||
<label for="visibility_id"><?php echo _("Visibility"); ?>: </label>
|
||||
<select name="visibility_id" id="visibility_id" class="form-control">
|
||||
<?php
|
||||
if (!empty($visibility_id_value))
|
||||
{
|
||||
if (!empty($visibility_id_value)) {
|
||||
$visibility_id = $visibility_id_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$visibility_id = null;
|
||||
}
|
||||
//$visibilitys = Service::get_groups();
|
||||
foreach ($visibility as $key => $value) {
|
||||
if ($visibility_id == $key)
|
||||
{
|
||||
if ($visibility_id == $key) {
|
||||
echo '<option value="' . $key . '" selected>' . $value . '</option>';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
if (isset($_GET['new'])) {
|
||||
Service::add();
|
||||
}
|
||||
|
||||
if (isset($_GET['edit']))
|
||||
{
|
||||
if (isset($_GET['edit'])) {
|
||||
Service::edit();
|
||||
}
|
||||
|
||||
|
@ -52,8 +50,7 @@ $form_url = WEB_URL . '/admin/?do=new-service&new=service';
|
|||
}
|
||||
?>
|
||||
<form action="<?php echo $form_url; ?>" method="POST" class="form-horizontal">
|
||||
<?php if (isset($message))
|
||||
{?>
|
||||
<?php if (isset($message)) { ?>
|
||||
<p class="alert alert-danger"><?php echo $message ?></p>
|
||||
<?php
|
||||
} ?>
|
||||
|
@ -66,21 +63,16 @@ $form_url = WEB_URL . '/admin/?do=new-service&new=service';
|
|||
<label for="group_id"><?php echo _("Service Group"); ?>: </label>
|
||||
<select name="group_id" id="group_id" class="form-control">
|
||||
<?php
|
||||
if (!empty($group_id_value))
|
||||
{
|
||||
if (!empty($group_id_value)) {
|
||||
$group_id = $group_id_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$group_id = null;
|
||||
}
|
||||
$groups = ServiceGroup::get_groups();
|
||||
foreach ($groups as $key => $value) {
|
||||
if ($group_id == $key)
|
||||
{
|
||||
if ($group_id == $key) {
|
||||
echo '<option value="' . $key . '" selected>' . $value . '</option>';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
echo '<option value="' . $key . '">' . $value . '</option>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
if (isset($_GET['delete']) && isset($_GET['type']))
|
||||
{
|
||||
if (isset($_GET['delete']) && isset($_GET['type'])) {
|
||||
if ($_GET['type'] == 'service') {
|
||||
Service::delete();
|
||||
}
|
||||
elseif ( $_GET['type'] == 'groups') {
|
||||
} elseif ($_GET['type'] == 'groups') {
|
||||
ServiceGroup::delete();
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +29,13 @@ if (isset($message)){
|
|||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
|
||||
<thead><tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<!--<th scope="col"><?php echo _("ID"); ?></th>-->
|
||||
<th scope="col"><?php echo _("Name"); ?></th>
|
||||
<th scope="col"><?php echo _("Description"); ?></th>
|
||||
<th scope="col"><?php echo _("Group"); ?></th>
|
||||
<?php if ($user->get_rank()<=1)
|
||||
{?>
|
||||
<?php if ($user->get_rank() <= 1) { ?>
|
||||
<th scope="col"><?php echo _("Delete"); ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
@ -45,16 +43,14 @@ if (isset($message)){
|
|||
<tbody>
|
||||
<?php
|
||||
$query = $mysqli->query("SELECT services.*, services_groups.name AS group_name FROM `services` LEFT JOIN services_groups ON services.group_id = services_groups.id ORDER BY services.name ASC");
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
while ($result = $query->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
//echo "<td>".$result['id']."</td>";
|
||||
echo '<td><a href="' . WEB_URL . '/admin?do=edit-service&id=' . $result['id'] . '">' . $result['name'] . '</a></th>';
|
||||
echo "<td>" . $result['description'] . "</td>";
|
||||
echo "<td>" . $result['group_name'] . "</td>";
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
echo '<td><a href="' . WEB_URL . '/admin/?do=settings&type=service&delete=' . $result['id'] . '" class="pull-right delete-service"><i class="fa fa-trash"></i></a></td>';
|
||||
}
|
||||
echo "</tr>";
|
||||
|
@ -76,14 +72,14 @@ if (isset($message)){
|
|||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
|
||||
<thead><tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<!--<th scope="col"><?php echo _("ID"); ?></th>-->
|
||||
<th scope="col"><?php echo _("Group Name"); ?></th>
|
||||
<th scope="col"><?php echo _("In use by"); ?></th>
|
||||
<th scope="col"><?php echo _("Description"); ?></th>
|
||||
<th scope="col"><?php echo _("Visibility"); ?></th>
|
||||
<?php if ($user->get_rank()<=1)
|
||||
{?>
|
||||
<?php if ($user->get_rank() <= 1) { ?>
|
||||
<th scope="col"><?php echo _("Delete"); ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
@ -91,8 +87,7 @@ if (isset($message)){
|
|||
<tbody>
|
||||
<?php
|
||||
$query = $mysqli->query("SELECT sg.* , (SELECT COUNT(*) FROM services WHERE services.group_id = sg.id) AS counter FROM services_groups AS sg ORDER BY sg.id ASC");
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
while ($result = $query->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
//echo "<td>".$result['id']."</td>";
|
||||
echo '<td><a href="' . WEB_URL . '/admin?do=edit-service-group&id=' . $result['id'] . '">' . $result['name'] . '</a></th>';
|
||||
|
@ -100,8 +95,7 @@ if (isset($message)){
|
|||
echo "<td>" . $result['description'] . "</td>";
|
||||
echo "<td>" . $visibility[$result['visibility']] . "</td>";
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
echo '<td><a href="' . WEB_URL . '/admin/?do=settings&type=groups&delete=' . $result['id'] . '" class="pull-right delete-service"><i class="fa fa-trash"></i></a></td>';
|
||||
}
|
||||
echo "</tr>";
|
||||
|
@ -118,12 +112,21 @@ if (isset($message)){
|
|||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<tbody>
|
||||
<?php
|
||||
$query = $mysqli->query("SELECT * FROM users");
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
while ($result = $query->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $result['id'] . "</td>";
|
||||
echo "<td><a href='" . WEB_URL . "/admin/?do=user&id=" . $result['id'] . "'>" . $result['username'] . "</a></td>";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
$id = $_SESSION['user'];
|
||||
if (isset($_GET['id']))
|
||||
{
|
||||
if (isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
}
|
||||
try {
|
||||
|
@ -11,34 +10,28 @@ try {
|
|||
}
|
||||
|
||||
|
||||
if (isset($_POST['password']))
|
||||
{
|
||||
if (isset($_POST['password'])) {
|
||||
$displayed_user->change_password();
|
||||
}
|
||||
|
||||
if (isset($_POST['username']))
|
||||
{
|
||||
if (isset($_POST['username'])) {
|
||||
$displayed_user->change_username();
|
||||
}
|
||||
|
||||
if (isset($_POST['name']))
|
||||
{
|
||||
if (isset($_POST['name'])) {
|
||||
$displayed_user->change_name();
|
||||
}
|
||||
|
||||
if (isset($_POST['email']))
|
||||
{
|
||||
if (isset($_POST['email'])) {
|
||||
$success = $displayed_user->email_link();
|
||||
}
|
||||
|
||||
if (isset($_POST['permission']))
|
||||
{
|
||||
if (isset($_POST['permission'])) {
|
||||
$displayed_user->change_permission();
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['what']) && $_GET['what']=='toggle')
|
||||
{
|
||||
if (isset($_GET['what']) && $_GET['what'] == 'toggle') {
|
||||
$displayed_user->toggle();
|
||||
}
|
||||
|
||||
|
@ -47,8 +40,7 @@ Template::render_header(_("User"), true);
|
|||
?>
|
||||
<div class="text-center">
|
||||
<h1><?php
|
||||
if ($_SESSION['user'] == $_GET['id'])
|
||||
{
|
||||
if ($_SESSION['user'] == $_GET['id']) {
|
||||
echo _("User settings");
|
||||
} else {
|
||||
echo _("User");
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (!file_exists("../config.php"))
|
||||
{
|
||||
if (!file_exists("../config.php")) {
|
||||
header("Location: ../");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
require_once("../config.php");
|
||||
require_once("../classes/constellation.php");
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
<?php
|
||||
|
||||
if (!file_exists("../config.php"))
|
||||
{
|
||||
if (!file_exists("../config.php")) {
|
||||
header("Location: ../");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
require_once("../config.php");
|
||||
require_once("../classes/constellation.php");
|
||||
header('Cache-Control: no-cache');
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!isset($_GET['id']))
|
||||
{
|
||||
if (!isset($_GET['id'])) {
|
||||
$array = $constellation->render_status(true, false);
|
||||
echo json_encode($array);
|
||||
} else {
|
||||
|
@ -19,8 +16,7 @@ else{
|
|||
$query->bind_param("i", $_GET['id']);
|
||||
$query->execute();
|
||||
$result = $query->get_result()->fetch_assoc();
|
||||
if (!count($result))
|
||||
{
|
||||
if (!count($result)) {
|
||||
die(json_encode(["error" => _("Service does not exist!")]));
|
||||
}
|
||||
|
||||
|
@ -29,11 +25,9 @@ else{
|
|||
$sql->bind_param("iii", $id, $timestamp, $timestamp);
|
||||
$sql->execute();
|
||||
$tmp = $sql->get_result();
|
||||
if ($tmp->num_rows)
|
||||
{
|
||||
if ($tmp->num_rows) {
|
||||
$service = new Service($_GET['id'], $result['name'], $tmp->fetch_assoc()['type']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$service = new Service($_GET['id'], $result['name']);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ class Constellation
|
|||
* @param int $limit - limits the number of incidents rendered
|
||||
* @param Boolean $admin - specifies whether to render admin controls
|
||||
*/
|
||||
public function render_incidents($future=false, $offset=0, $limit = 5, $admin = 0){
|
||||
if ($offset<0)
|
||||
public function render_incidents($future = false, $offset = 0, $limit = 5, $admin = 0)
|
||||
{
|
||||
if ($offset < 0) {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
|
@ -32,20 +32,14 @@ class Constellation
|
|||
|
||||
$ajax = isset($_GET['ajax']);
|
||||
|
||||
if ($future && count($incidents["incidents"]) && !$ajax)
|
||||
{
|
||||
if ($future && count($incidents["incidents"]) && !$ajax) {
|
||||
echo "<h3>" . _("Planned maintenance") . "</h3>";
|
||||
}
|
||||
else if (count($incidents["incidents"]) &&!$ajax)
|
||||
{
|
||||
if ($offset)
|
||||
{
|
||||
} else if (count($incidents["incidents"]) && !$ajax) {
|
||||
if ($offset) {
|
||||
echo '<noscript><div class="centered"><a href="' . WEB_URL . '/?offset=' . ($offset - $limit) . '×tamp=' . $timestamp . '" class="btn btn-default">' . _("Back") . '</a></div></noscript>';
|
||||
}
|
||||
echo "<h3>" . _("Past incidents") . "</h3>";
|
||||
}
|
||||
else if (!$future &&!$ajax)
|
||||
{
|
||||
} else if (!$future && !$ajax) {
|
||||
echo "<h3>" . _("No incidents") . "</h3>";
|
||||
}
|
||||
$show = !$future && $incidents["more"];
|
||||
|
@ -57,8 +51,7 @@ class Constellation
|
|||
$incident->render($admin);
|
||||
}
|
||||
|
||||
if ($show)
|
||||
{
|
||||
if ($show) {
|
||||
echo '<div class="centered"><a href="' . WEB_URL . '/?offset=' . ($offset) . '×tamp=' . $timestamp . '" id="loadmore" class="btn btn-default">' . _("Load more") . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +62,8 @@ class Constellation
|
|||
* @param boolean $admin
|
||||
* @return array of services
|
||||
*/
|
||||
public function render_status($admin = false, $heading = true){
|
||||
public function render_status($admin = false, $heading = true)
|
||||
{
|
||||
global $mysqli;
|
||||
|
||||
//$query = $mysqli->query("SELECT id, name, description FROM services");
|
||||
|
@ -78,32 +72,26 @@ class Constellation
|
|||
if ($query->num_rows) {
|
||||
$timestamp = time();
|
||||
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
while ($result = $query->fetch_assoc()) {
|
||||
$id = $result['id'];
|
||||
$sql = $mysqli->prepare("SELECT type FROM services_status INNER JOIN status ON services_status.status_id = status.id WHERE service_id = ? AND `time` <= ? AND (`end_time` >= ? OR `end_time`=0) ORDER BY `time` DESC LIMIT 1");
|
||||
|
||||
$sql->bind_param("iii", $id, $timestamp, $timestamp);
|
||||
$sql->execute();
|
||||
$tmp = $sql->get_result();
|
||||
if ($tmp->num_rows)
|
||||
{
|
||||
if ($tmp->num_rows) {
|
||||
$array[] = new Service($result['id'], $result['name'], $result['description'], $result['group_name'], $tmp->fetch_assoc()['type']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$array[] = new Service($result['id'], $result['name'], $result['description'], $result['group_name']);
|
||||
}
|
||||
}
|
||||
if ($heading)
|
||||
{
|
||||
if ($heading) {
|
||||
echo Service::current_status($array);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$array[] = new Service(0, _("No services"), -1);
|
||||
}
|
||||
if (!$admin)
|
||||
{
|
||||
if (!$admin) {
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
@ -125,17 +113,16 @@ class Constellation
|
|||
}
|
||||
echo '</ul>';
|
||||
//echo '</div>';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_incidents($future = false, $offset = 0, $limit = 5, $timestamp = 0){
|
||||
global $mysqli;
|
||||
if ($timestamp == 0)
|
||||
function get_incidents($future = false, $offset = 0, $limit = 5, $timestamp = 0)
|
||||
{
|
||||
global $mysqli;
|
||||
if ($timestamp == 0) {
|
||||
$timestamp = time();
|
||||
}
|
||||
|
||||
|
@ -152,8 +139,7 @@ class Constellation
|
|||
$more = true;
|
||||
}
|
||||
if ($query->num_rows) {
|
||||
while(($result = $query->fetch_assoc()) && $limit-- > 0)
|
||||
{
|
||||
while (($result = $query->fetch_assoc()) && $limit-- > 0) {
|
||||
// Add service id and service names to an array in the Incident class
|
||||
$stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services
|
||||
INNER JOIN services_status ON services.id = services_status.service_id
|
||||
|
@ -206,7 +192,6 @@ class Constellation
|
|||
if ($show_link) {
|
||||
echo '<div class="clearfix"><a href="' . $url . '" class="btn btn-success" role="button">' . $link_text . '</a></div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
|
||||
class SSDB
|
||||
{
|
||||
function execute($conn,$sql){
|
||||
function execute($conn, $sql)
|
||||
{
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
return true;
|
||||
} else {
|
||||
return $conn->error;
|
||||
}
|
||||
}
|
||||
function getSetting($conn,$setting){
|
||||
function getSetting($conn, $setting)
|
||||
{
|
||||
$sql = "SELECT value FROM settings WHERE setting='" . $setting . "'";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
|
@ -22,31 +24,33 @@ class SSDB
|
|||
return "null";
|
||||
}
|
||||
}
|
||||
function setSetting($conn,$settingname,$settingvalue){
|
||||
function setSetting($conn, $settingname, $settingvalue)
|
||||
{
|
||||
$sql = "INSERT INTO settings (setting,value) VALUES ('" . $settingname . "','" . $settingvalue . "');";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
return true;
|
||||
} else {
|
||||
return $conn->error;
|
||||
}
|
||||
|
||||
}
|
||||
function deleteSetting($conn,$settingname){
|
||||
function deleteSetting($conn, $settingname)
|
||||
{
|
||||
$sql = "DELETE FROM settings WHERE setting=\"" . $settingname . "\";";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
return true;
|
||||
} else {
|
||||
return $conn->error;
|
||||
}
|
||||
|
||||
}
|
||||
function updateSetting($conn, $settingname, $settingvalue){
|
||||
function updateSetting($conn, $settingname, $settingvalue)
|
||||
{
|
||||
$this->deleteSetting($conn, $settingname);
|
||||
$this->setSetting($conn, $settingname, $settingvalue);
|
||||
return true;
|
||||
}
|
||||
|
||||
function getBooleanSetting($conn, $setting) {
|
||||
function getBooleanSetting($conn, $setting)
|
||||
{
|
||||
if (trim($this->getSetting($conn, $setting)) == "yes") {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -46,17 +46,16 @@ class Incident implements JsonSerializable
|
|||
* Deletes incident by ID.
|
||||
* @param int ID
|
||||
*/
|
||||
public static function delete($id){
|
||||
public static function delete($id)
|
||||
{
|
||||
global $mysqli, $message, $user;
|
||||
|
||||
if ($user->get_rank() > 1)
|
||||
{
|
||||
if ($user->get_rank() > 1) {
|
||||
$stmt = $mysqli->prepare("SELECT count(*) as count FROM status WHERE id= ? AND user_id = ?");
|
||||
$stmt->bind_param("ii", $id, $_SESSION['user']);
|
||||
$stmt->execute();
|
||||
$query = $stmt->get_result();
|
||||
if (!$query->fetch_assoc()['count'])
|
||||
{
|
||||
if (!$query->fetch_assoc()['count']) {
|
||||
$message = _("You don't have permission to do that!");
|
||||
return;
|
||||
}
|
||||
|
@ -91,8 +90,7 @@ class Incident implements JsonSerializable
|
|||
$title = strip_tags($_POST['title']);
|
||||
$text = strip_tags($_POST['text'], '<br>');
|
||||
|
||||
if (strlen($title)==0)
|
||||
{
|
||||
if (strlen($title) == 0) {
|
||||
$message = _("Please enter title");
|
||||
return;
|
||||
} else if (strlen($title) > 50) {
|
||||
|
@ -100,29 +98,22 @@ class Incident implements JsonSerializable
|
|||
return;
|
||||
}
|
||||
|
||||
if (strlen($title)==0)
|
||||
{
|
||||
if (strlen($title) == 0) {
|
||||
$message = _("Please enter text");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type == 2 && (!strlen(trim($_POST['time'])) || !strlen(trim($_POST['end_time']))))
|
||||
{
|
||||
if ($type == 2 && (!strlen(trim($_POST['time'])) || !strlen(trim($_POST['end_time'])))) {
|
||||
$message = _("Please set start and end time! Use ISO 8601 format.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($_POST['services'])) {
|
||||
$message = _("Please select at least one service");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!is_array($_POST['services']))
|
||||
{
|
||||
} else {
|
||||
if (!is_array($_POST['services'])) {
|
||||
$services = array($_POST['services']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$services = $_POST['services'];
|
||||
}
|
||||
|
||||
|
@ -131,20 +122,17 @@ class Incident implements JsonSerializable
|
|||
$input_end_time = (!empty($_POST['end_time_js']) ? $_POST['end_time_js'] : $_POST['end_time']);
|
||||
$time = strtotime($input_time);
|
||||
$end_time = strtotime($input_end_time);
|
||||
if (!$time)
|
||||
{
|
||||
if (!$time) {
|
||||
$message = _("Start date format is not recognized. Please use ISO 8601 format.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$end_time)
|
||||
{
|
||||
if (!$end_time) {
|
||||
$message = _("End date format is not recognized. Please use ISO 8601 format.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($time >= $end_time)
|
||||
{
|
||||
if ($time >= $end_time) {
|
||||
$message = _("End time is either the same or earlier than start time!");
|
||||
return;
|
||||
}
|
||||
|
@ -187,7 +175,8 @@ class Incident implements JsonSerializable
|
|||
* @param Boolean $admin - decides whether admin controls should be rendered
|
||||
* @return void
|
||||
*/
|
||||
public function render($admin=0){
|
||||
public function render($admin = 0)
|
||||
{
|
||||
global $icons;
|
||||
global $classes, $user;
|
||||
$admin = $admin && (($user->get_rank() <= 1) || ($user->get_username() == $this->username));
|
||||
|
@ -220,7 +209,8 @@ class Incident implements JsonSerializable
|
|||
<?php
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
"date" => $this->timestamp,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This class is used to negotiate language displayed to user.
|
||||
* Reads browser preferences and chooses the best language from list
|
||||
|
@ -241,7 +242,8 @@ class LocaleNegotiator
|
|||
/**
|
||||
* Returns list of accepted langs so it can be reused for rendering language list for switching...
|
||||
*/
|
||||
public function get_accepted_langs(){
|
||||
public function get_accepted_langs()
|
||||
{
|
||||
return $this->accepted_langs;
|
||||
}
|
||||
|
||||
|
@ -251,7 +253,8 @@ class LocaleNegotiator
|
|||
* @param String $override adds language to list of preffered languages with highest priority
|
||||
* @return String language code that matched best with browser preferences
|
||||
*/
|
||||
public function negotiate($override = null){
|
||||
public function negotiate($override = null)
|
||||
{
|
||||
$langs = [];
|
||||
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
|
@ -266,8 +269,7 @@ class LocaleNegotiator
|
|||
if ($val === '') $langs[$lang] = 1;
|
||||
}
|
||||
|
||||
if (isset($override))
|
||||
{
|
||||
if (isset($override)) {
|
||||
//More important than the best lang of browser
|
||||
$langs[$override] = 2;
|
||||
}
|
||||
|
@ -312,4 +314,3 @@ class LocaleNegotiator
|
|||
return $best_match;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@ if (file_exists("libs/php_idn/idna.php")) {
|
|||
require_once("../libs/php_idn/idna.php");
|
||||
}
|
||||
|
||||
class Mailer {
|
||||
|
||||
public function __construct(){
|
||||
class Mailer
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +29,8 @@ class Mailer {
|
|||
* @param boolean $html Set to true if we are sending HTML Mailer
|
||||
* @return boolean True if success
|
||||
*/
|
||||
public function send_mail($to, $subject, $message, $html = true) {
|
||||
public function send_mail($to, $subject, $message, $html = true)
|
||||
{
|
||||
// TODO -Handle $to as an array in order to send to muliple recipients without having
|
||||
// to call the entire send_mail function over and over..
|
||||
|
||||
|
@ -90,7 +92,6 @@ class Mailer {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// Use standard PHP mail() function
|
||||
$headers = "Content-Type: $content_type; \"charset=utf-8\" " . PHP_EOL;
|
||||
|
@ -102,7 +103,6 @@ class Mailer {
|
|||
// TODO log error message if mail fails
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Tries to verify the domain using dns request against an MX record of the domain part
|
||||
|
@ -112,7 +112,8 @@ class Mailer {
|
|||
* @param String $email Email address to check
|
||||
* @return boolean True if MX record exits, false if otherwise
|
||||
*/
|
||||
public function verify_domain($email){
|
||||
public function verify_domain($email)
|
||||
{
|
||||
// TODO - Handle idn/punycode domain names without being dependent on PHP native libs.
|
||||
$domain = explode('@', $email);
|
||||
$domain = EncodePunycodeIDN(array_pop($domain) . '.'); // Add dot at end of domain to avoid local domain lookups
|
||||
|
@ -145,13 +146,15 @@ class Mailer {
|
|||
* @param boolean $remove_links Set to true if links should be removed from email
|
||||
* @return String pain text version
|
||||
*/
|
||||
public function convert_html_to_plain_txt($content, $remove_links=false){
|
||||
public function convert_html_to_plain_txt($content, $remove_links = false)
|
||||
{
|
||||
// TODO does not handle unsubscribe/manage subscription text very well.
|
||||
// Replace HTML line breaks with text line breaks
|
||||
$plain_text = str_ireplace(array("<br>", "<br />"), "\n\r", $content);
|
||||
|
||||
// Remove the content between the tags that wouldn't normally get removed with the strip_tags function
|
||||
$plain_text = preg_replace(array('@<head[^>]*?>.*?</head>@siu',
|
||||
$plain_text = preg_replace(array(
|
||||
'@<head[^>]*?>.*?</head>@siu',
|
||||
'@<style[^>]*?>.*?</style>@siu',
|
||||
'@<script[^>]*?.*?</script>@siu',
|
||||
'@<noscript[^>]*?.*?</noscript>@siu',
|
||||
|
@ -170,5 +173,4 @@ class Mailer {
|
|||
|
||||
return $plain_text;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -103,9 +103,7 @@ class Notification
|
|||
if ($typeID == 2 && SUBSCRIBE_EMAIL) {
|
||||
$arr_email[] = $subscriber['subscriberIDFK'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (SUBSCRIBE_TELEGRAM) {
|
||||
|
@ -138,7 +136,6 @@ class Notification
|
|||
|
||||
if (!is_array($response) || !array_key_exists("ok", $response) || $response['ok'] != 1) {
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -160,7 +157,8 @@ class Notification
|
|||
return true;
|
||||
}
|
||||
|
||||
public function prepare_email(){
|
||||
public function prepare_email()
|
||||
{
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
$str_mail = file_get_contents("../libs/templates/email_status_update.html");
|
||||
|
@ -189,7 +187,8 @@ class Notification
|
|||
return $val;
|
||||
}
|
||||
|
||||
public function prepare_telegram(){
|
||||
public function prepare_telegram()
|
||||
{
|
||||
$msg = _("Hi #s!\nThere is a status update for service(s): %s\nThe new status is: %s\nTitle: %s\n\n%s\n\n<a href='%s'>View online</a>");
|
||||
$val['body'] = sprintf($msg, $this->servicenames, $this->status, $this->title, $this->text, WEB_URL);
|
||||
return $val;
|
||||
|
|
|
@ -14,22 +14,26 @@ class Queue
|
|||
public $completed_time;
|
||||
public $num_errors;
|
||||
public $user_id;
|
||||
public $all_type_id = array('notify_telegram' => 1,
|
||||
'notify_email' => 2);
|
||||
public $all_type_id = array(
|
||||
'notify_telegram' => 1,
|
||||
'notify_email' => 2
|
||||
);
|
||||
|
||||
public $all_status = array('populating' => 1,
|
||||
public $all_status = array(
|
||||
'populating' => 1,
|
||||
'ready' => 2,
|
||||
'processing' => 3,
|
||||
'completed' => 4,
|
||||
'failed' => 5);
|
||||
'failed' => 5
|
||||
);
|
||||
|
||||
public function add_task() {
|
||||
public function add_task()
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("INSERT INTO queue_task (type_id, status, template_data1, template_data2, created_time, user_id) VALUES (?,?,?,?,?,?)");
|
||||
if (false === $stmt) {
|
||||
//die('prepare() failed: ' . htmlspecialchars($mysqli->error));
|
||||
echo $mysqli->errno();
|
||||
|
||||
}
|
||||
#if ( false === $stmt ) { syslog(1, "Error :". $mysqli->error); }
|
||||
$now = time();
|
||||
|
@ -49,7 +53,8 @@ class Queue
|
|||
* Remove task from the queue
|
||||
* @return void
|
||||
*/
|
||||
public function delete_task($task_id){
|
||||
public function delete_task($task_id)
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("DELETE FROM queue_task WHERE id = ?");
|
||||
$stmt->bind_param("i", $task_id);
|
||||
|
@ -61,7 +66,8 @@ class Queue
|
|||
* @param int $new_status The new current status of the task. Must be selected from the $all_status array.
|
||||
* @return void
|
||||
*/
|
||||
public function set_task_status($new_status) {
|
||||
public function set_task_status($new_status)
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("UPDATE queue_task SET status = ? WHERE id = ?");
|
||||
$stmt->bind_param("ii", $new_status, $this->task_id);
|
||||
|
@ -74,7 +80,8 @@ class Queue
|
|||
* @param array $arr_data Array filled with subscriber_id
|
||||
* @return void
|
||||
*/
|
||||
public function add_notification($arr_data) {
|
||||
public function add_notification($arr_data)
|
||||
{
|
||||
global $mysqli;
|
||||
|
||||
//Default status = 1, retres = 0, task_id = $this->task_id
|
||||
|
@ -88,7 +95,9 @@ class Queue
|
|||
|
||||
foreach ($arr_data as $value) {
|
||||
$counter++;
|
||||
if ($counter == $count) { $seperator = ''; } // Make sure last character for SQL query is correct
|
||||
if ($counter == $count) {
|
||||
$seperator = '';
|
||||
} // Make sure last character for SQL query is correct
|
||||
$query .= sprintf($sub_query, $this->task_id, 1, $value, 0, $seperator);
|
||||
}
|
||||
$sql = "INSERT INTO queue_notify (task_id, status, subscriber_id, retries) VALUES " . $query;
|
||||
|
@ -98,23 +107,25 @@ class Queue
|
|||
$this->set_task_status($this->all_status['ready']); // Make task available for release
|
||||
}
|
||||
|
||||
public function update_notification_retries($task_id, $subscriber_id) {
|
||||
public function update_notification_retries($task_id, $subscriber_id)
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("UPDATE queue_notify SET retries = retries+1 WHERE task_id = ? AND subscriber_id = ?");
|
||||
$stmt->bind_param("ii", $task_id, $subscriber_id);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
public function delete_notification($task_id, $subscriber_id) {
|
||||
public function delete_notification($task_id, $subscriber_id)
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("DELETE FROM queue_notify WHERE task_id = ? AND subscriber_id = ?");
|
||||
$stmt->bind_param("ii", $task_id, $subscriber_id);
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
|
||||
// TODO: Fix max attempts for notifications
|
||||
public function process_queue(){
|
||||
public function process_queue()
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->query("SELECT qn.id, qn.task_id, qn.status, qn.subscriber_id, qn.retries, sub.firstname, sub.userID, sub.token FROM queue_notify AS qn INNER JOIN subscribers AS sub ON qn.subscriber_id = sub.subscriberID WHERE qn.status NOT LIKE 2 AND sub.active=1");
|
||||
while ($result = $stmt->fetch_assoc()) {
|
||||
|
@ -156,6 +167,5 @@ class Queue
|
|||
Queue::delete_task($result['id']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class for managing services
|
||||
*/
|
||||
|
@ -63,8 +64,7 @@ class ServiceGroup
|
|||
public static function add()
|
||||
{
|
||||
global $user, $message;
|
||||
if (strlen($_POST['group'])>50)
|
||||
{
|
||||
if (strlen($_POST['group']) > 50) {
|
||||
$message = _("Service group name is too long! Character limit is 50");
|
||||
return;
|
||||
} else if (strlen(trim($_POST['group'])) == 0) {
|
||||
|
@ -72,8 +72,7 @@ class ServiceGroup
|
|||
return;
|
||||
}
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$name = $_POST["group"];
|
||||
$description = $_POST["description"];
|
||||
|
@ -83,8 +82,7 @@ class ServiceGroup
|
|||
$stmt->execute();
|
||||
$stmt->get_result();
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +90,7 @@ class ServiceGroup
|
|||
public static function edit()
|
||||
{
|
||||
global $user, $message;
|
||||
if (strlen($_POST['group'])>50)
|
||||
{
|
||||
if (strlen($_POST['group']) > 50) {
|
||||
$message = _("Service group name is too long! Character limit is 50");
|
||||
return;
|
||||
} else if (strlen(trim($_POST['group'])) == 0) {
|
||||
|
@ -101,8 +98,7 @@ class ServiceGroup
|
|||
return;
|
||||
}
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$name = $_POST["group"];
|
||||
$description = $_POST["description"];
|
||||
|
@ -113,8 +109,7 @@ class ServiceGroup
|
|||
$stmt->execute();
|
||||
$stmt->get_result();
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +120,7 @@ class ServiceGroup
|
|||
public static function delete()
|
||||
{
|
||||
global $user, $message;
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$id = $_GET['delete'];
|
||||
|
||||
|
@ -141,9 +135,7 @@ class ServiceGroup
|
|||
$query = $stmt->get_result();
|
||||
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +145,8 @@ class ServiceGroup
|
|||
* Get list of services groups.
|
||||
* @return array $groups
|
||||
*/
|
||||
public function get_groups() {
|
||||
public function get_groups()
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->query("SELECT id, name FROM services_groups ORDER by name ASC");
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class for managing services
|
||||
*/
|
||||
|
@ -72,8 +73,7 @@ class Service implements JsonSerializable
|
|||
public static function add()
|
||||
{
|
||||
global $user, $message;
|
||||
if (strlen($_POST['service'])>50)
|
||||
{
|
||||
if (strlen($_POST['service']) > 50) {
|
||||
$message = _("Service name is too long! Character limit is 50");
|
||||
return;
|
||||
} else if (strlen(trim($_POST['service'])) == 0) {
|
||||
|
@ -81,8 +81,7 @@ class Service implements JsonSerializable
|
|||
return;
|
||||
}
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$name = htmlspecialchars($_POST['service']);
|
||||
$description = htmlspecialchars($_POST['description']);
|
||||
|
@ -92,8 +91,7 @@ class Service implements JsonSerializable
|
|||
$stmt->execute();
|
||||
$stmt->get_result();
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +104,7 @@ class Service implements JsonSerializable
|
|||
public static function edit()
|
||||
{
|
||||
global $user, $message;
|
||||
if (strlen($_POST['service'])>50)
|
||||
{
|
||||
if (strlen($_POST['service']) > 50) {
|
||||
$message = _("Service name is too long! Character limit is 50");
|
||||
return;
|
||||
} else if (strlen(trim($_POST['service'])) == 0) {
|
||||
|
@ -115,8 +112,7 @@ class Service implements JsonSerializable
|
|||
return;
|
||||
}
|
||||
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$service_id = $_POST["id"];
|
||||
$name = htmlspecialchars($_POST['service']);
|
||||
|
@ -127,8 +123,7 @@ class Service implements JsonSerializable
|
|||
$stmt->execute();
|
||||
$stmt->get_result();
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +135,7 @@ class Service implements JsonSerializable
|
|||
public static function delete()
|
||||
{
|
||||
global $user, $message;
|
||||
if ($user->get_rank()<=1)
|
||||
{
|
||||
if ($user->get_rank() <= 1) {
|
||||
global $mysqli;
|
||||
$id = $_GET['delete'];
|
||||
|
||||
|
@ -151,8 +145,7 @@ class Service implements JsonSerializable
|
|||
$query = $stmt->get_result();
|
||||
|
||||
while ($res = $query->fetch_assoc()) {
|
||||
if ($res['count']==1)
|
||||
{
|
||||
if ($res['count'] == 1) {
|
||||
Incident::delete($res['status']);
|
||||
}
|
||||
}
|
||||
|
@ -168,9 +161,7 @@ class Service implements JsonSerializable
|
|||
$query = $stmt->get_result();
|
||||
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -180,14 +171,14 @@ class Service implements JsonSerializable
|
|||
* @param Service[] $array array of services
|
||||
* @return void
|
||||
*/
|
||||
public static function current_status($array){
|
||||
public static function current_status($array)
|
||||
{
|
||||
global $all, $some, $classes;
|
||||
$statuses = array(0, 0, 0, 0);
|
||||
$worst = 5;
|
||||
|
||||
foreach ($array as $service) {
|
||||
if ($service->status<$worst)
|
||||
{
|
||||
if ($service->status < $worst) {
|
||||
$worst = $service->get_status();
|
||||
}
|
||||
$statuses[$service->get_status()]++;
|
||||
|
@ -195,8 +186,7 @@ class Service implements JsonSerializable
|
|||
|
||||
echo '<div id="status-big" class="alert-' . $classes[$worst] . '">';
|
||||
|
||||
if ($statuses[$worst] == count($array))
|
||||
{
|
||||
if ($statuses[$worst] == count($array)) {
|
||||
echo $all[$worst];
|
||||
} else {
|
||||
echo $some[$worst];
|
||||
|
@ -209,7 +199,8 @@ class Service implements JsonSerializable
|
|||
* @param $boolGroup set to true if the groups name is to be rendered
|
||||
* @return void
|
||||
*/
|
||||
public function render(){
|
||||
public function render()
|
||||
{
|
||||
global $statuses;
|
||||
global $classes;
|
||||
static $arrCompletedGroups = array();
|
||||
|
@ -260,7 +251,8 @@ class Service implements JsonSerializable
|
|||
echo '</div>';
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize()
|
||||
{
|
||||
global $statuses;
|
||||
return [
|
||||
"id" => $this->id,
|
||||
|
@ -270,5 +262,4 @@ class Service implements JsonSerializable
|
|||
"status_string" => $statuses[$this->status]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Subscriber class
|
||||
*
|
||||
*/
|
||||
Class Subscriber
|
||||
class Subscriber
|
||||
{
|
||||
public $id = null;
|
||||
public $firstname = null;
|
||||
|
@ -15,7 +15,8 @@ Class Subscriber
|
|||
public $typeID = null; // Holds subscription type ID
|
||||
|
||||
|
||||
function __construct() {
|
||||
function __construct()
|
||||
{
|
||||
$this->firstname = null;
|
||||
$this->lastname = null;
|
||||
$this->userID = "";
|
||||
|
@ -44,7 +45,6 @@ Class Subscriber
|
|||
return $row['token'];
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
public function get_subscriber_by_token($token)
|
||||
{
|
||||
|
@ -135,7 +135,6 @@ Class Subscriber
|
|||
$stmt->bind_param("ii", $updateTime, $subscriberID);
|
||||
$stmt->execute();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function activate($subscriberID)
|
||||
|
@ -164,7 +163,6 @@ Class Subscriber
|
|||
$stmt->execute();
|
||||
//$query = $stmt->get_result();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function check_userid_exist()
|
||||
|
@ -223,7 +221,6 @@ Class Subscriber
|
|||
$this->userID = $row['userID'];
|
||||
$this->token = $row['token'];
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// Timeframe outside of given scope -> delete account
|
||||
$stmt2 = $mysqli->prepare("DELETE FROM subscribers WHERE subscriberID = ?");
|
||||
|
@ -325,5 +322,4 @@ Class Subscriber
|
|||
unset($_SESSION['subscriber_id']);
|
||||
unset($_SESSION['subscriber_token']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Subscriptions class
|
||||
*
|
||||
*/
|
||||
Class Subscriptions
|
||||
class Subscriptions
|
||||
{
|
||||
public function add($userID, $service)
|
||||
{
|
||||
|
@ -41,14 +41,17 @@ Class Subscriptions
|
|||
$query = $stmt->get_result();
|
||||
|
||||
$strNotifyType = _('E-mail Notification subscription');
|
||||
if ( $typeID == 1 ) { $strNotifyType = _('Telegram Notification subscription'); }
|
||||
if ($typeID == 1) {
|
||||
$strNotifyType = _('Telegram Notification subscription');
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-lg-offset-2 col-lg-8">
|
||||
<div class="text-center">
|
||||
<h3><?php echo $strNotifyType; ?></h3>
|
||||
<p><?php echo _("Manage notification subscription for"); echo " ". $userID; ?></p>
|
||||
<p><?php echo _("Manage notification subscription for");
|
||||
echo " " . $userID; ?></p>
|
||||
<a onclick="if (confirm('<?php echo _("Are you sure you want to cancel you subscription?"); ?>')){return true;}else{event.stopPropagation(); event.preventDefault();};" class="confirmation" href="index.php?do=unsubscribe&type=<?php echo $typeID; ?>&token=<?php echo $token; ?>"><button class="btn btn-danger"><?php echo _("Cancel Subscription"); ?></button></a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,12 +63,10 @@ Class Subscriptions
|
|||
$subs = array(); // Will be used to hold IDs of services already selected
|
||||
|
||||
if ($query->num_rows) {
|
||||
while($result = $query->fetch_assoc())
|
||||
{
|
||||
while ($result = $query->fetch_assoc()) {
|
||||
echo '<a href="' . WEB_URL . '/subscriptions.php?remove=' . $result['id'] . '" class="list-group-item"><span class="glyphicon glyphicon-remove text-danger"></span> ' . $result['name'] . '</a>';
|
||||
$subs[] = $result['id'];
|
||||
}
|
||||
|
||||
} else {
|
||||
echo '<div class="container"><summary>' . _("You do not currently subscribe to any services. Please add services from the list below.") . '</summary></div>';
|
||||
}
|
||||
|
@ -90,5 +91,4 @@ Class Subscriptions
|
|||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
Class Telegram
|
||||
class Telegram
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,8 @@ Class Telegram
|
|||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function getTelegramUserData() {
|
||||
function getTelegramUserData()
|
||||
{
|
||||
if (isset($_COOKIE['tg_user'])) {
|
||||
$auth_data_json = urldecode($_COOKIE['tg_user']);
|
||||
$auth_data = json_decode($auth_data_json, true);
|
||||
|
@ -32,7 +33,8 @@ Class Telegram
|
|||
* @return $auth_data
|
||||
*
|
||||
*/
|
||||
function checkTelegramAuthorization($auth_data) {
|
||||
function checkTelegramAuthorization($auth_data)
|
||||
{
|
||||
$check_hash = $auth_data['hash'];
|
||||
unset($auth_data['hash']);
|
||||
$data_check_arr = [];
|
||||
|
@ -60,7 +62,8 @@ Class Telegram
|
|||
* Save the telegram user data in a cookie
|
||||
* @return void
|
||||
*/
|
||||
function saveTelegramUserData($auth_data) {
|
||||
function saveTelegramUserData($auth_data)
|
||||
{
|
||||
$auth_data_json = json_encode($auth_data);
|
||||
setcookie('tg_user', $auth_data_json);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class for creating and deleting tokens
|
||||
*/
|
||||
|
|
141
classes/user.php
141
classes/user.php
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class that encapsulates everything that can be done with a user
|
||||
*/
|
||||
|
@ -24,8 +25,7 @@ class User
|
|||
$stmt->execute();
|
||||
$query = $stmt->get_result();
|
||||
|
||||
if (!$query->num_rows)
|
||||
{
|
||||
if (!$query->num_rows) {
|
||||
throw new Exception("User doesn't exist.");
|
||||
return;
|
||||
}
|
||||
|
@ -86,8 +86,7 @@ class User
|
|||
global $mysqli, $message, $user;
|
||||
|
||||
$id = $_GET['id'];
|
||||
if ($this->id!=$_SESSION['user'] && $user->get_rank()<=1 && ($user->get_rank()<$this->rank))
|
||||
{
|
||||
if ($this->id != $_SESSION['user'] && $user->get_rank() <= 1 && ($user->get_rank() < $this->rank)) {
|
||||
$stmt = $mysqli->prepare("UPDATE users SET active = !active WHERE id=?");
|
||||
$stmt->bind_param("i", $this->id);
|
||||
$stmt->execute();
|
||||
|
@ -108,8 +107,7 @@ class User
|
|||
public static function add()
|
||||
{
|
||||
global $user, $message, $mysqli;
|
||||
if (INSTALL_OVERRIDE || $user->get_rank()==0)
|
||||
{
|
||||
if (INSTALL_OVERRIDE || $user->get_rank() == 0) {
|
||||
if (strlen(trim($_POST['name'])) == 0) {
|
||||
$messages[] = _("Name");
|
||||
}
|
||||
|
@ -122,8 +120,7 @@ class User
|
|||
if (strlen(trim($_POST['password'])) == 0) {
|
||||
$messages[] = _("Password");
|
||||
}
|
||||
if(!isset($_POST['permission']))
|
||||
{
|
||||
if (!isset($_POST['permission'])) {
|
||||
$messages[] = _("Rank");
|
||||
}
|
||||
|
||||
|
@ -138,8 +135,7 @@ class User
|
|||
$email = $_POST['email'];
|
||||
$pass = $_POST['password'];
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$message = "Invalid email!";
|
||||
return;
|
||||
}
|
||||
|
@ -159,8 +155,7 @@ class User
|
|||
}
|
||||
|
||||
|
||||
if (!empty($variables))
|
||||
{
|
||||
if (!empty($variables)) {
|
||||
$message = _("Please mind the following character limits: ");
|
||||
$message .= implode(", ", $variables);
|
||||
return;
|
||||
|
@ -175,8 +170,7 @@ class User
|
|||
$stmt->bind_param("ssssssi", $email, $username, $name, $surname, $hash, $salt, $permission);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->affected_rows==0)
|
||||
{
|
||||
if ($stmt->affected_rows == 0) {
|
||||
$message = _("Username or email already used");
|
||||
return;
|
||||
}
|
||||
|
@ -190,12 +184,10 @@ class User
|
|||
$headers .= "Reply-To: " . MAILER_NAME . ' <' . MAILER_ADDRESS . '>' . PHP_EOL;
|
||||
|
||||
mail($to, $subject, $msg, $headers);
|
||||
if (!INSTALL_OVERRIDE)
|
||||
{
|
||||
if (!INSTALL_OVERRIDE) {
|
||||
header("Location: " . WEB_URL . "/admin/?do=settings");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$message = _("You don't have the permission to do that!");
|
||||
}
|
||||
}
|
||||
|
@ -210,13 +202,11 @@ class User
|
|||
public static function login()
|
||||
{
|
||||
global $message, $mysqli;
|
||||
if (!isset($_POST['email']) && !isset($_POST['email']))
|
||||
{
|
||||
if (!isset($_POST['email']) && !isset($_POST['email'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!isset($_POST['email']) || !isset($_POST['email'])))
|
||||
{
|
||||
if ((!isset($_POST['email']) || !isset($_POST['email']))) {
|
||||
$message = _("Please fill in your email and password!");
|
||||
return;
|
||||
}
|
||||
|
@ -228,8 +218,7 @@ class User
|
|||
$stmt->execute();
|
||||
$query = $stmt->get_result();
|
||||
|
||||
if ($query->num_rows<1)
|
||||
{
|
||||
if ($query->num_rows < 1) {
|
||||
$message = _("Wrong email or password");
|
||||
return;
|
||||
}
|
||||
|
@ -239,8 +228,7 @@ class User
|
|||
$id = $result["id"];
|
||||
$active = $result["active"];
|
||||
|
||||
if (!$active)
|
||||
{
|
||||
if (!$active) {
|
||||
$message = _("Your account has been disabled. Please contact administrator.");
|
||||
return;
|
||||
}
|
||||
|
@ -251,14 +239,12 @@ class User
|
|||
$stmt->execute();
|
||||
$query = $stmt->get_result();
|
||||
|
||||
if (!$query->fetch_assoc()['count'])
|
||||
{
|
||||
if (!$query->fetch_assoc()['count']) {
|
||||
$message = _("Wrong email or password");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_POST['remember'])&&$_POST['remember'])
|
||||
{
|
||||
if (isset($_POST['remember']) && $_POST['remember']) {
|
||||
$year = strtotime('+356 days', time());
|
||||
$token = Token::add($id, 'remember', $year);
|
||||
setcookie('token', $token, $year, "/");
|
||||
|
@ -281,17 +267,14 @@ class User
|
|||
$id = $_COOKIE['user'];
|
||||
$token = $_COOKIE['token'];
|
||||
|
||||
if (Token::validate($token, $id, "remember"))
|
||||
{
|
||||
if (Token::validate($token, $id, "remember")) {
|
||||
$year = strtotime('+356 days', time());
|
||||
unset($_COOKIE['token']);
|
||||
$_SESSION['user'] = $id;
|
||||
$new_token = Token::add($id, 'remember', $year);
|
||||
setcookie('token', $new_token, $year, "/");
|
||||
setcookie('user', $id, $year, "/");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
unset($_COOKIE['user']);
|
||||
unset($_COOKIE['token']);
|
||||
setcookie('user', null, -1, '/');
|
||||
|
@ -310,8 +293,7 @@ class User
|
|||
global $permissions, $user;
|
||||
?>
|
||||
<div class="row user">
|
||||
<div class="col-md-2 col-md-offset-2"><img src="https://www.gravatar.com/avatar/<?php echo md5( strtolower( trim( $this->email ) ) );?>?s=160"
|
||||
alt="<?php echo _("Profile picture");?>"></div>
|
||||
<div class="col-md-2 col-md-offset-2"><img src="https://www.gravatar.com/avatar/<?php echo md5(strtolower(trim($this->email))); ?>?s=160" alt="<?php echo _("Profile picture"); ?>"></div>
|
||||
<div class="col-md-6">
|
||||
<?php if ($this->id == $_SESSION['user'] || $user->get_rank() < 1) {
|
||||
?>
|
||||
|
@ -323,12 +305,8 @@ class User
|
|||
<label class="form-name" for="surname"><?php echo _("Surname"); ?></label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="text" name="name" placeholder="<?php echo _("Name"); ?>"
|
||||
title="<?php echo _("Name"); ?>" class="form-control form-name"
|
||||
value=<?php echo htmlspecialchars($this->name, ENT_QUOTES);?>>
|
||||
<input type="text" name="surname" placeholder="<?php echo _("Surname"); ?>"
|
||||
title="<?php echo _("Surname"); ?>" class="form-control form-name"
|
||||
value=<?php echo htmlspecialchars($this->surname, ENT_QUOTES);?>>
|
||||
<input type="text" name="name" placeholder="<?php echo _("Name"); ?>" title="<?php echo _("Name"); ?>" class="form-control form-name" value=<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>>
|
||||
<input type="text" name="surname" placeholder="<?php echo _("Surname"); ?>" title="<?php echo _("Surname"); ?>" class="form-control form-name" value=<?php echo htmlspecialchars($this->surname, ENT_QUOTES); ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -378,12 +356,14 @@ class User
|
|||
</select><span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Change role"); ?></button>
|
||||
</span>
|
||||
</div><?php }else{ echo $permissions[$this->rank];}?></div>
|
||||
</div><?php } else {
|
||||
echo $permissions[$this->rank];
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if($this->id==$_SESSION['user']||$user->get_rank()<1)
|
||||
{?>
|
||||
<?php if ($this->id == $_SESSION['user'] || $user->get_rank() < 1) { ?>
|
||||
<form action="<?php echo WEB_URL; ?>/admin/?do=user&id=<?php echo $this->id; ?>" method="POST">
|
||||
<div class="row user">
|
||||
<div class="col-md-2 col-md-offset-2"><strong>Email</strong></div>
|
||||
|
@ -397,8 +377,7 @@ class User
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php }else
|
||||
{
|
||||
<?php } else {
|
||||
?>
|
||||
<div class="row user">
|
||||
<div class="col-md-2 col-md-offset-2"><strong><?php echo _("Email"); ?></strong></div>
|
||||
|
@ -429,8 +408,7 @@ class User
|
|||
<?php
|
||||
}
|
||||
|
||||
if ($this->id!=$_SESSION['user'] && $user->get_rank()<=1 && ($user->get_rank()<$this->rank))
|
||||
{?>
|
||||
if ($this->id != $_SESSION['user'] && $user->get_rank() <= 1 && ($user->get_rank() < $this->rank)) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-2 col-md-offset-2"></div>
|
||||
<div class="col-md-6">
|
||||
|
@ -458,15 +436,13 @@ class User
|
|||
$stmt = $mysqli->prepare("SELECT count(*) FROM users WHERE username LIKE ?");
|
||||
$stmt->bind_param("s", $_POST["username"]);
|
||||
$stmt->execute();
|
||||
if ($stmt->num_rows > 0)
|
||||
{
|
||||
if ($stmt->num_rows > 0) {
|
||||
$message = _("This username is already taken.");
|
||||
return;
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
if ($_SESSION['user'] != $id && $user->get_rank()>0)
|
||||
{
|
||||
if ($_SESSION['user'] != $id && $user->get_rank() > 0) {
|
||||
$message = _("Cannot change username of other users!");
|
||||
} else {
|
||||
$stmt = $mysqli->prepare("UPDATE users SET username = ? WHERE id=?");
|
||||
|
@ -491,16 +467,14 @@ class User
|
|||
$messages[] = _("Surname");
|
||||
}
|
||||
|
||||
if (!empty($messages))
|
||||
{
|
||||
if (!empty($messages)) {
|
||||
$message = "Please enter " . implode(", ", $messages);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $this->id;
|
||||
|
||||
if ($_SESSION['user'] != $id && $user->get_rank()>0)
|
||||
{
|
||||
if ($_SESSION['user'] != $id && $user->get_rank() > 0) {
|
||||
$message = _("Cannot change names of other users!");
|
||||
} else {
|
||||
$stmt = $mysqli->prepare("UPDATE users SET `name` = ?, `surname` = ? WHERE id=?");
|
||||
|
@ -521,16 +495,13 @@ class User
|
|||
{
|
||||
global $mysqli, $message;
|
||||
$id = $this->id;
|
||||
if ($_POST['password']!=$_POST['password_repeat'])
|
||||
{
|
||||
if ($_POST['password'] != $_POST['password_repeat']) {
|
||||
$message = _("Passwords do not match!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$token)
|
||||
{
|
||||
if ($_SESSION['user']!=$id)
|
||||
{
|
||||
if (!$token) {
|
||||
if ($_SESSION['user'] != $id) {
|
||||
$message = _("Cannot change password of other users!");
|
||||
} else {
|
||||
$stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?");
|
||||
|
@ -547,8 +518,7 @@ class User
|
|||
$stmt->bind_param("is", $id, $hash);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->get_result()->fetch_assoc()['count'])
|
||||
{
|
||||
if ($stmt->get_result()->fetch_assoc()['count']) {
|
||||
$pass = $_POST['password'];
|
||||
$hash = hash('sha256', $pass . $salt);
|
||||
$stmt = $mysqli->prepare("UPDATE users SET password_hash = ? WHERE id=?");
|
||||
|
@ -562,14 +532,12 @@ class User
|
|||
$stmt->get_result();
|
||||
|
||||
User::logout();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$message = _("Wrong password!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Token::validate($token, $id, "passwd"))
|
||||
{
|
||||
if (Token::validate($token, $id, "passwd")) {
|
||||
$stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
|
@ -589,9 +557,7 @@ class User
|
|||
$stmt->bind_param("d", $id);
|
||||
$stmt->execute();
|
||||
$stmt->get_result();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = _("Invalid token detected, please retry your request from start!");
|
||||
}
|
||||
Token::delete($token);
|
||||
|
@ -634,14 +600,14 @@ class User
|
|||
* Sends email with link for email change confirmation (security reasons), link is token protected and valid only once.
|
||||
* @return void
|
||||
*/
|
||||
public function email_link(){
|
||||
public function email_link()
|
||||
{
|
||||
global $user, $mysqli;
|
||||
|
||||
$email = $_POST['email'];
|
||||
$id = $this->id;
|
||||
|
||||
if ($user->get_rank()<1 && $id!=$_SESSION['user'])
|
||||
{
|
||||
if ($user->get_rank() < 1 && $id != $_SESSION['user']) {
|
||||
$stmt = $mysqli->prepare("UPDATE users SET email = ? WHERE id=?");
|
||||
$stmt->bind_param("sd", $email, $id);
|
||||
$stmt->execute();
|
||||
|
@ -677,8 +643,7 @@ class User
|
|||
$token = $_GET['token'];
|
||||
$id = $_GET['id'];
|
||||
|
||||
if (Token::validate($token, $id, "email;%"))
|
||||
{
|
||||
if (Token::validate($token, $id, "email;%")) {
|
||||
$data = explode(";", Token::get_data($token, $id));
|
||||
|
||||
$email = $data[1];
|
||||
|
@ -689,24 +654,21 @@ class User
|
|||
$stmt->get_result();
|
||||
Token::delete($token);
|
||||
header("Location: " . WEB_URL . "/admin/");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = _("Invalid token detected, please retry your request from start!");
|
||||
}
|
||||
|
||||
Token::delete($token);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs current user out.
|
||||
* @return void
|
||||
*/
|
||||
public static function logout(){
|
||||
session_unset();
|
||||
if (isset($_COOKIE['token']))
|
||||
public static function logout()
|
||||
{
|
||||
session_unset();
|
||||
if (isset($_COOKIE['token'])) {
|
||||
$token = $_COOKIE['token'];
|
||||
Token::delete($token);
|
||||
unset($_COOKIE['user']);
|
||||
|
@ -721,18 +683,17 @@ class User
|
|||
* Changes permissions of current user - only super admin can do this, so it checks permission first.
|
||||
* @return void
|
||||
*/
|
||||
public function change_permission(){
|
||||
global $mysqli, $message, $user;
|
||||
if ($user->get_rank()==0)
|
||||
public function change_permission()
|
||||
{
|
||||
global $mysqli, $message, $user;
|
||||
if ($user->get_rank() == 0) {
|
||||
$permission = $_POST['permission'];
|
||||
$id = $_GET['id'];
|
||||
$stmt = $mysqli->prepare("UPDATE users SET permission=? WHERE id=?");
|
||||
$stmt->bind_param("si", $permission, $id);
|
||||
$stmt->execute();
|
||||
header("Location: " . WEB_URL . "/admin/?do=user&id=" . $id);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$message = _("You don't have permission to do that!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,4 +20,3 @@ fwrite($f, fread($f2, filesize("IISWebConfig")));
|
|||
fclose($f);
|
||||
fclose($f2);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -6,18 +6,16 @@ body {
|
|||
margin: 0;
|
||||
height: 100%;
|
||||
line-height: 24px;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-family: "Open Sans", sans-serif;
|
||||
}
|
||||
|
||||
#status-container
|
||||
{
|
||||
#status-container {
|
||||
border-radius: 0;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
#status-container .item:last-child
|
||||
{
|
||||
#status-container .item:last-child {
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
@ -25,13 +23,12 @@ body {
|
|||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
#status-big
|
||||
{
|
||||
#status-big {
|
||||
float: none;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-family: 'Fira Sans', sans-serif;
|
||||
font-size: 1.5em
|
||||
font-family: "Fira Sans", sans-serif;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
|
@ -47,7 +44,7 @@ body {
|
|||
padding: 15px 35px;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
font-family: 'Fira Sans', sans-serif;
|
||||
font-family: "Fira Sans", sans-serif;
|
||||
}
|
||||
|
||||
.status {
|
||||
|
@ -58,10 +55,9 @@ body {
|
|||
padding: 15px 35px;
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
font-family: 'Fira Sans', sans-serif;
|
||||
font-family: "Fira Sans", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
#status-container .status.success {
|
||||
color: #2fcc66 !important;
|
||||
font-weight: bolder;
|
||||
|
@ -78,7 +74,7 @@ body {
|
|||
}
|
||||
|
||||
#status-container .status.primary {
|
||||
color:#3A72BD!important;
|
||||
color: #3a72bd !important;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
|
@ -86,11 +82,10 @@ body {
|
|||
border-color: #2fcc66;
|
||||
}
|
||||
#footerwrap {
|
||||
display: none
|
||||
display: none;
|
||||
}
|
||||
.btn
|
||||
{
|
||||
display: none
|
||||
.btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h3 {
|
||||
|
@ -107,34 +102,36 @@ h2.panel-title{
|
|||
float: left;
|
||||
}
|
||||
|
||||
.panel,.panel-heading,.panel-footer{
|
||||
border-width: 3px
|
||||
.panel,
|
||||
.panel-heading,
|
||||
.panel-footer {
|
||||
border-width: 3px;
|
||||
}
|
||||
|
||||
body .panel-danger,
|
||||
.panel-danger > .panel-body,
|
||||
.panel-danger > .panel-heading,
|
||||
.panel-danger > .panel-footer {
|
||||
border-color: #a94442
|
||||
border-color: #a94442;
|
||||
}
|
||||
|
||||
body .panel-success,
|
||||
.panel-success > .panel-body,
|
||||
.panel-success > .panel-heading,
|
||||
.panel-success > .panel-footer {
|
||||
border-color: #2fcc66
|
||||
border-color: #2fcc66;
|
||||
}
|
||||
|
||||
body .panel-warning,
|
||||
.panel-warning > .panel-body,
|
||||
.panel-warning > .panel-heading,
|
||||
.panel-warning > .panel-footer {
|
||||
border-color: #edaa16
|
||||
border-color: #edaa16;
|
||||
}
|
||||
|
||||
body .panel-primary,
|
||||
.panel-primary > .panel-body,
|
||||
.panel-primary > .panel-heading,
|
||||
.panel-primary > .panel-footer {
|
||||
border-color: #337ab7
|
||||
border-color: #337ab7;
|
||||
}
|
|
@ -81,11 +81,9 @@ if ( isset($_GET['new']) ) {
|
|||
$message = _("Please check<br>");
|
||||
$message .= implode("<br> ", $messages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['emailaddress']) && empty($message))
|
||||
{
|
||||
if (isset($_POST['emailaddress']) && empty($message)) {
|
||||
|
||||
// Check if email is already registered
|
||||
$boolUserExist = false;
|
||||
|
@ -100,13 +98,11 @@ if ( isset($_GET['new']) ) {
|
|||
$subscriber->add($subscriber->typeID, $_POST['emailaddress']);
|
||||
$url = WEB_URL . "/index.php?do=manage&token=" . $subscriber->token; // Needed again after adding subscriber since token did not exist before add
|
||||
$msg = sprintf(_("Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href=\"%s\">%s</a>. New subscriptions must be confirmed within 2 hours"), $url, NAME . ' - ' . _("Validate subscription"));
|
||||
|
||||
} else {
|
||||
if (!$subscriber->active) {
|
||||
// Subscriber is registered, but has not been activated yet...
|
||||
$msg = sprintf(_("Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href=\"%s\">%s</a>. New subscriptions must be confirmed within 2 hours"), $url, NAME . ' - ' . _("Validate subscription"));
|
||||
$subscriber->activate($subscriber->id);
|
||||
|
||||
} else {
|
||||
// subscriber is registered and active
|
||||
$msg = sprintf(_("Click on the following link to update your existing subscription: <a href=\"%s\">%s</a>"), $url, NAME . ' - ' . _("Manage subscription"));
|
||||
|
@ -182,8 +178,6 @@ if ( isset($_GET['new']) ) {
|
|||
$message = _("If you have recently subscribed, please make sure you activate the account within two hours of doing so. You are welcome to try and re-subscribe.");
|
||||
$constellation->render_warning($header, $message, true, WEB_URL, _('Go back'));
|
||||
}
|
||||
|
||||
|
||||
} else if (isset($_GET['do']) && $_GET['do'] == 'unsubscribe') {
|
||||
// Handle unsubscriptions
|
||||
// TODO This function is universal and should probably live elsewhere??
|
||||
|
@ -198,7 +192,6 @@ if ( isset($_GET['new']) ) {
|
|||
$header = _("You have been unsubscribed from our system");
|
||||
$message = _("We are sorry to see you go. If you want to subscribe again at a later date please feel free to re-subscribe.");
|
||||
$constellation->render_success($header, $message, true, WEB_URL, _('Go back'));
|
||||
|
||||
} else {
|
||||
// TODO Log token for troubleshooting ?
|
||||
// Cannot find subscriber - show alert
|
||||
|
|
13
index.php
13
index.php
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
require_once("libs/parsedown/Parsedown.php");
|
||||
|
||||
if (!file_exists("config.php"))
|
||||
{
|
||||
if (!file_exists("config.php")) {
|
||||
require_once("template.php");
|
||||
require_once("install.php");
|
||||
|
||||
} elseif (isset($_GET['do'])) { // we can add other actions with $_GET['do'] later.
|
||||
// Fix for translation via _(). We need config.php first...
|
||||
require_once("config.php");
|
||||
|
@ -50,12 +48,10 @@ define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli,"google_recaptcha_sit
|
|||
define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret"));
|
||||
$offset = 0;
|
||||
|
||||
if (isset($_GET['ajax']))
|
||||
{
|
||||
if (isset($_GET['ajax'])) {
|
||||
$constellation->render_incidents(false, $_GET['offset'], 5);
|
||||
exit();
|
||||
}else if (isset($_GET['offset']))
|
||||
{
|
||||
} else if (isset($_GET['offset'])) {
|
||||
$offset = $_GET['offset'];
|
||||
}
|
||||
|
||||
|
@ -101,8 +97,7 @@ Template::render_header("Status");
|
|||
<?php $constellation->render_status(); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($mysqli->query("SELECT count(*) FROM status")->num_rows)
|
||||
{
|
||||
<?php if ($mysqli->query("SELECT count(*) FROM status")->num_rows) {
|
||||
?>
|
||||
<div id="timeline">
|
||||
<div class="item">
|
||||
|
|
45
install.php
45
install.php
|
@ -20,8 +20,7 @@ if(isset($_GET["isDev"])){
|
|||
$negotiator = new LocaleNegotiator("en_GB");
|
||||
$message = "";
|
||||
$db = new SSDB();
|
||||
if (!isset($_SESSION['locale'])||isset($_GET['lang']))
|
||||
{
|
||||
if (!isset($_SESSION['locale']) || isset($_GET['lang'])) {
|
||||
$override = ((isset($_GET['lang'])) ? $_GET['lang'] : null);
|
||||
$best_match = $negotiator->negotiate($override);
|
||||
$_SESSION['locale'] = $best_match;
|
||||
|
@ -32,16 +31,14 @@ if (!isset($_SESSION['locale'])||isset($_GET['lang']))
|
|||
textdomain("server-status");
|
||||
}
|
||||
|
||||
if (isset($_POST['server']))
|
||||
{
|
||||
if (isset($_POST['server'])) {
|
||||
$mysqli = new mysqli($_POST['server'], $_POST['dbuser'], $_POST['dbpassword'], $_POST['database']);
|
||||
|
||||
if ($mysqli->connect_errno) {
|
||||
$message .= sprintf(_("Connection failed: %s\n"), $mysqli->connect_error);
|
||||
}
|
||||
|
||||
if (isset($_POST['url']) && filter_var($_POST['url'], FILTER_VALIDATE_URL) === false)
|
||||
{
|
||||
if (isset($_POST['url']) && filter_var($_POST['url'], FILTER_VALIDATE_URL) === false) {
|
||||
$message .= _("Please set valid url!");
|
||||
}
|
||||
|
||||
|
@ -78,19 +75,16 @@ if (isset($_POST['server']))
|
|||
$messages[] = _("Database user");
|
||||
}
|
||||
|
||||
if (0 == strlen(trim($_POST['dbpassword'])))
|
||||
{
|
||||
if (0 == strlen(trim($_POST['dbpassword']))) {
|
||||
$messages[] = _("Database password");
|
||||
}
|
||||
if (isset($messages))
|
||||
{
|
||||
if (isset($messages)) {
|
||||
$message .= _("Please enter");
|
||||
$message .= implode(", ", $messages);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['server']) && empty($message))
|
||||
{
|
||||
if (isset($_POST['server']) && empty($message)) {
|
||||
define("MAILER_NAME", $_POST['mailer']);
|
||||
define("MAILER_ADDRESS", $_POST['mailer_email']);
|
||||
define("INSTALL_OVERRIDE", true);
|
||||
|
@ -102,27 +96,23 @@ if(isset($_POST['server']) && empty($message))
|
|||
|
||||
foreach ($array as $value) {
|
||||
$val = trim($value);
|
||||
if (empty($val))
|
||||
{
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
$q_res = $mysqli->query($value);
|
||||
if ($q_res === false)
|
||||
{
|
||||
if ($q_res === false) {
|
||||
$message = sprintf(_("Error while creating database. Please check permission for your account or MYSQL version.<br>Error: %s"), $mysqli->error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($message))
|
||||
{
|
||||
if (empty($message)) {
|
||||
require_once("classes/constellation.php");
|
||||
|
||||
User::add();
|
||||
}
|
||||
|
||||
if (empty($message))
|
||||
{
|
||||
if (empty($message)) {
|
||||
//Create config
|
||||
$config = file_get_contents("config.php.template");
|
||||
//$config = str_replace("##name##", htmlspecialchars($_POST['servername'], ENT_QUOTES), $config);
|
||||
|
@ -194,16 +184,22 @@ Template::render_header(_("Install"));
|
|||
$preq_writedir = $preq_fail;
|
||||
|
||||
// Check if PHP version if > MINIMUM_PHP_VERSION
|
||||
if (strnatcmp(phpversion(), MINIMUM_PHP_VERSION) >= 0) { $preq_phpver = $preq_ok; }
|
||||
if (strnatcmp(phpversion(), MINIMUM_PHP_VERSION) >= 0) {
|
||||
$preq_phpver = $preq_ok;
|
||||
}
|
||||
|
||||
// Test for mysqlnd precense. The mysqlnd driver provides some extra functions that is not available
|
||||
// if the plain mysql package is installed, and mysqli_get_client_stats is one of them. This is documented
|
||||
// on the PHP site at http://www.php.net/manual/en/mysqlnd.stats.php
|
||||
// This test is also discussed at https://stackoverflow.com/questions/1475701/how-to-know-if-mysqlnd-is-the-active-driver
|
||||
if ( function_exists('mysqli_get_client_stats') ) { $preq_mysqlnd = $preq_ok; }
|
||||
if (function_exists('mysqli_get_client_stats')) {
|
||||
$preq_mysqlnd = $preq_ok;
|
||||
}
|
||||
|
||||
// Check if we have access to write to location
|
||||
if ( is_writable(__DIR__) ) { $preq_writedir = $preq_ok; }
|
||||
if (is_writable(__DIR__)) {
|
||||
$preq_writedir = $preq_ok;
|
||||
}
|
||||
|
||||
?>
|
||||
<section class="prereq-section clearfix">
|
||||
|
@ -226,8 +222,7 @@ Template::render_header(_("Install"));
|
|||
|
||||
<h1 class="text-center"><?php echo _("Installation"); ?></h1>
|
||||
<?php
|
||||
if (!empty($message))
|
||||
{
|
||||
if (!empty($message)) {
|
||||
?>
|
||||
<p class="alert alert-danger"><?php echo $message; ?></p>
|
||||
<?php
|
||||
|
|
42
install.sql
42
install.sql
|
@ -56,7 +56,6 @@ CREATE TABLE queue_notify (
|
|||
retries tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_czech_ci;
|
||||
|
||||
CREATE TABLE services_groups (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
name varchar(50) NOT NULL,
|
||||
|
@ -64,7 +63,6 @@ CREATE TABLE services_groups (
|
|||
visibility tinyint(4) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE queue_task (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
type_id int(11) NOT NULL,
|
||||
|
@ -123,20 +121,32 @@ ALTER TABLE `services_subscriber`
|
|||
ADD CONSTRAINT `services_subscriber_ibfk_1` FOREIGN KEY (`subscriberIDFK`) REFERENCES `subscribers` (`subscriberID`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `services_subscriber_ibfk_2` FOREIGN KEY (`serviceIDFK`) REFERENCES `services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
ALTER TABLE `subscribers` CHANGE COLUMN lastname lastname varchar(255) DEFAULT NULL; # was varchar(255) NOT NULL
|
||||
ALTER TABLE `subscribers` CHANGE COLUMN firstname firstname varchar(255) DEFAULT NULL; # was varchar(255) NOT NULL
|
||||
ALTER TABLE `subscribers` CHANGE COLUMN lastname lastname varchar(255) DEFAULT NULL;
|
||||
# was varchar(255) NOT NULL
|
||||
ALTER TABLE `subscribers` CHANGE COLUMN firstname firstname varchar(255) DEFAULT NULL;
|
||||
# was varchar(255) NOT NULL
|
||||
ALTER TABLE `subscribers` CHANGE COLUMN telegramID userID varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL;
|
||||
ALTER TABLE `subscribers` ADD COLUMN typeID tinyint(1) NOT NULL AFTER subscriberID;
|
||||
ALTER TABLE `subscribers` ADD COLUMN token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER lastname;
|
||||
ALTER TABLE `subscribers` ADD COLUMN expires int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers` ADD COLUMN active tinyint(1) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers` ADD COLUMN create_time int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers` ADD COLUMN update_time int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers` DROP INDEX telegramID; # was UNIQUE (telegramID)
|
||||
ALTER TABLE `subscribers` ADD UNIQUE userID (userID);
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN typeID tinyint(1) NOT NULL
|
||||
AFTER subscriberID;
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||
AFTER lastname;
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN expires int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN active tinyint(1) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN create_time int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers`
|
||||
ADD COLUMN update_time int(11) DEFAULT NULL;
|
||||
ALTER TABLE `subscribers` DROP INDEX telegramID;
|
||||
# was UNIQUE (telegramID)
|
||||
ALTER TABLE `subscribers`
|
||||
ADD UNIQUE userID (userID);
|
||||
COMMIT;
|
||||
|
||||
ALTER TABLE services ADD COLUMN description varchar(200) COLLATE utf8_czech_ci NOT NULL;
|
||||
ALTER TABLE services ADD COLUMN group_id int(11) DEFAULT NULL;
|
||||
ALTER TABLE services
|
||||
ADD COLUMN description varchar(200) COLLATE utf8_czech_ci NOT NULL;
|
||||
ALTER TABLE services
|
||||
ADD COLUMN group_id int(11) DEFAULT NULL;
|
||||
COMMIT;
|
36
js/admin.js
36
js/admin.js
|
@ -1,11 +1,20 @@
|
|||
(function () {
|
||||
$("#time_input").flatpickr({enableTime:true, minDate: "today",time_24hr:true, onChange: function(date, dateStr, instance) {
|
||||
$("#time_input").flatpickr({
|
||||
enableTime: true,
|
||||
minDate: "today",
|
||||
time_24hr: true,
|
||||
onChange: function (date, dateStr, instance) {
|
||||
$("#time_input_js").val(date[0].toISOString());
|
||||
}});
|
||||
$("#end_time").flatpickr({enableTime:true, minDate: "today",time_24hr:true, onChange: function(date, dateStr, instance) {
|
||||
},
|
||||
});
|
||||
$("#end_time").flatpickr({
|
||||
enableTime: true,
|
||||
minDate: "today",
|
||||
time_24hr: true,
|
||||
onChange: function (date, dateStr, instance) {
|
||||
$("#end_time_js").val(date[0].toISOString()); // iso date str
|
||||
}});
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
var bgcolore = ["bg-danger", "bg-warning", "bg-primary", "bg-success"];
|
||||
var bordercolore = ["border-danger", "border-warning", "border-primary", "border-success"];
|
||||
|
@ -29,35 +38,28 @@
|
|||
var end_time = Date.parse($("#end_time").val());
|
||||
var type = $("#type").val() || 0;
|
||||
|
||||
if (parseInt(type) === 2 &&(isNaN(time) || isNaN(end_time)))
|
||||
{
|
||||
if (isNaN(end_time))
|
||||
{
|
||||
if (parseInt(type) === 2 && (isNaN(time) || isNaN(end_time))) {
|
||||
if (isNaN(end_time)) {
|
||||
$("#time_input").addClass("error");
|
||||
$.growl.error({ message: "Start time is invalid!" });
|
||||
}
|
||||
|
||||
if (isNaN(end_time))
|
||||
{
|
||||
if (isNaN(end_time)) {
|
||||
$("#end_time").addClass("error");
|
||||
$.growl.error({ message: "End time is invalid!" });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (parseInt(type) === 2 && time >= end_time)
|
||||
{
|
||||
} else if (parseInt(type) === 2 && time >= end_time) {
|
||||
$.growl.error({ message: "End time is either the same or earlier than start time!" });
|
||||
$("#time").addClass("error");
|
||||
$("#end_time").addClass("error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if($("#status-container :checkbox:checked").length === 0)
|
||||
{
|
||||
if ($("#status-container :checkbox:checked").length === 0) {
|
||||
$.growl.error({ message: "Please check at least one service!" });
|
||||
$("#status-container").addClass("error");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
function timeago()
|
||||
{
|
||||
function timeago() {
|
||||
$("time.timeago").timeago();
|
||||
$("time.timeago").each(function () {
|
||||
var date = new Date($(this).attr("datetime"));
|
||||
|
@ -16,17 +15,15 @@ function timeago()
|
|||
$($(this).data("target")).toggleClass("collapse");
|
||||
});
|
||||
|
||||
var incidents = $('.timeline');
|
||||
var incidents = $(".timeline");
|
||||
$("body").on("click", "#loadmore", function (e) {
|
||||
e.preventDefault();
|
||||
var url = $("#loadmore").attr("href") + "&ajax=true";
|
||||
$("#loadmore").remove();
|
||||
|
||||
$.get(url,
|
||||
function(data){
|
||||
$.get(url, function (data) {
|
||||
incidents.append(data);
|
||||
timeago();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ if( $_SESSION['subscriber_valid'] ){
|
|||
}
|
||||
|
||||
$subscription->render_subscribed_services($typeID, $subscriberID, $userID, $token);
|
||||
|
||||
} else {
|
||||
|
||||
$header = _("Your session has expired or you tried something we don't suppprt");
|
||||
|
|
|
@ -10,7 +10,6 @@ define("WEB_URL", $db->getSetting($mysqli,"url"));
|
|||
define("MAILER_NAME", $db->getSetting($mysqli, "mailer"));
|
||||
define("MAILER_ADDRESS", $db->getSetting($mysqli, "mailer_email"));
|
||||
define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram"));
|
||||
define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram"));
|
||||
define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token"));
|
||||
define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username"));
|
||||
|
||||
|
|
37
template.php
37
template.php
|
@ -10,15 +10,16 @@ $visibility = array(_("Collapsed"), _("Expanded"), _("Expand on events"));
|
|||
/**
|
||||
* Class that encapsulates methods to render header and footer
|
||||
*/
|
||||
class Template{
|
||||
class Template
|
||||
{
|
||||
/**
|
||||
* Renders header
|
||||
* @param String $page_name name of the page to be displayed as title
|
||||
* @param Boolean $admin decides whether to show admin menu
|
||||
*/
|
||||
public static function render_header($page_name, $admin = false){
|
||||
if (!$admin)
|
||||
public static function render_header($page_name, $admin = false)
|
||||
{
|
||||
if (!$admin) {
|
||||
// Create subscriber menu sections for later inclusion
|
||||
// Check if we are on admin menu, if so do not display
|
||||
$arr_url = explode("/", $_SERVER['PHP_SELF']);
|
||||
|
@ -55,6 +56,7 @@ class Template{
|
|||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo $page_name . " - " . NAME ?></title>
|
||||
|
@ -98,6 +100,7 @@ class Template{
|
|||
}
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar fixed-top navbar-expand-lg navbar-dark">
|
||||
<div class="container">
|
||||
|
@ -105,7 +108,11 @@ class Template{
|
|||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarToggler">
|
||||
<a class="navbar-brand" href="<?php echo WEB_URL;?>/admin"><img src="<?php if(strlen(CUSTOM_LOGO_URL)>1){ echo CUSTOM_LOGO_URL; } else { echo WEB_URL."/img/logo_white.png"; } ?>" alt="logo" class="menu-logo" width="50" height="50"></a>
|
||||
<a class="navbar-brand" href="<?php echo WEB_URL; ?>/admin"><img src="<?php if (strlen(CUSTOM_LOGO_URL) > 1) {
|
||||
echo CUSTOM_LOGO_URL;
|
||||
} else {
|
||||
echo WEB_URL . "/img/logo_white.png";
|
||||
} ?>" alt="logo" class="menu-logo" width="50" height="50"></a>
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
<?php
|
||||
if (!$admin) {
|
||||
|
@ -160,12 +167,15 @@ class Template{
|
|||
* @param String $input_name will decide what the HTML Name attribute of the toggle will be
|
||||
* @param Boolean $checked will decide if the toggle will initially be on or off
|
||||
*/
|
||||
public static function render_toggle($toggletext,$input_name,$checked){
|
||||
public static function render_toggle($toggletext, $input_name, $checked)
|
||||
{
|
||||
?>
|
||||
<div>
|
||||
<h3><?php echo $toggletext; ?></h3>
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="<?php echo $input_name; ?>" <?php if($checked){ echo "checked"; } ?> >
|
||||
<input type="checkbox" name="<?php echo $input_name; ?>" <?php if ($checked) {
|
||||
echo "checked";
|
||||
} ?>>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
@ -184,7 +194,9 @@ class Template{
|
|||
<div id="footerwrap">
|
||||
<div class="container">
|
||||
<div class="row centered">
|
||||
<div class="col-md-4 text-left"><a class="link-light" href="https://github.com/server-status-project/server-status/graphs/contributors" target="_blank">Copyright © <?php echo date("Y");?> Server Status Project Contributors </a><?php if(strlen(COPYRIGHT_TEXT)>1){ echo " and ".COPYRIGHT_TEXT; } ?></div>
|
||||
<div class="col-md-4 text-left"><a class="link-light" href="https://github.com/server-status-project/server-status/graphs/contributors" target="_blank">Copyright © <?php echo date("Y"); ?> Server Status Project Contributors </a><?php if (strlen(COPYRIGHT_TEXT) > 1) {
|
||||
echo " and " . COPYRIGHT_TEXT;
|
||||
} ?></div>
|
||||
<div class="col-md-4 text-center">
|
||||
<div class="input-group dropup mb-3">
|
||||
<button type="button" class="btn btn-primary" disabled><?php echo '<img src="' . $WEB_URL . '/locale/' . $_SESSION['locale'] . '/flag.png" alt="' . $lang_names[$_SESSION['locale']] . '">' . $lang_names[$_SESSION['locale']]; ?></button>
|
||||
|
@ -197,14 +209,18 @@ class Template{
|
|||
echo '<a href="?lang=' . $key . '"><img src="' . $WEB_URL . '/locale/' . $key . '/flag.png" alt="' . $value . '">' . $value . '</a>';
|
||||
}
|
||||
?>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a href="https://poeditor.com/join/project/37SpmJtyOm"><?php echo _("Help with translation!"); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 text-right"><a class="link-light" href="<?php echo POLICY_URL; ?>"><?php echo _("Imprint & Privacy Policy"); ?></a></div>
|
||||
</div><!--/row -->
|
||||
</div><!--/container -->
|
||||
</div>
|
||||
<!--/row -->
|
||||
</div>
|
||||
<!--/container -->
|
||||
</div>
|
||||
<script src="<?php echo WEB_URL; ?>/js/vendor/jquery-3.5.1.min.js"></script>
|
||||
<script src="<?php echo WEB_URL; ?>/js/vendor/jquery.timeago.js"></script>
|
||||
|
@ -218,6 +234,7 @@ class Template{
|
|||
<script src="<?php echo WEB_URL; ?>/js/main.js"></script>
|
||||
<?php if ($GOOGLE_RECAPTCHA) { ?><script src='https://www.google.com/recaptcha/api.js'></script><?php } ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue