Compare commits

...

39 Commits

Author SHA1 Message Date
Vojtěch Sajdl b2baa5051b
Merge pull request #169 from kim3-sudo/master
Updated sorting, version number in README ( Fixes #168 )
2022-12-20 16:57:07 +01:00
Sejin Kim 9951c22d07
Update minimum version to PHP5.5
This version is not compatible with PHP 5.4 due to a constants handling issue. See [GH issue #168](https://github.com/server-status-project/server-status/issues/168)
2022-12-20 10:30:25 -05:00
Sejin Kim 2d65d0f9df
Add sort for services for group then service 2022-12-20 10:26:39 -05:00
Vojtěch Sajdl c9bcbc241b
Merge pull request #148 from Steffen-MLR/master
Fix for status api by correcting sql queries
2021-10-03 01:31:50 +02:00
Vojtěch Sajdl 184f803d6e
Create SECURITY.md 2021-09-07 14:53:34 +02:00
Steffen Mueller 002bb13e10 Fix for status api by correcting sql queries 2021-04-22 09:16:30 +02:00
Yigit Kerem Oktay 9d3d14f67c
Update README.md 2021-04-19 20:11:07 +03:00
Steffen Mueller 58b375161d Big fix for status api with parameter ID 2021-03-15 08:57:14 +01:00
Yigit Kerem Oktay f33bf996c6
Merge pull request #136 from server-status-project/dev
Release Developer branch to stable
2021-02-01 13:59:29 +03:00
Yigit Kerem Oktay 3e706233a4 Only make changes to files when not in development mode 2020-12-15 15:25:00 +03:00
Yigit Kerem Oktay 1408d0ad91 Bug fix for not allowing access to admin because of a file not found error 'head.txt' 2020-12-15 15:08:17 +03:00
Yiğit Kerem Oktay 8007097d2f
Fix a graphical glitch 2020-11-24 16:07:23 +03:00
Yiğit Kerem Oktay 85dfce55c8
Remove old version server checks 2020-11-12 22:06:55 +03:00
Yiğit Kerem Oktay 75bdde26b3
Update main.css 2020-11-12 11:20:35 +03:00
Yiğit Kerem Oktay 3939fca1f7
Update main.css 2020-11-12 11:16:16 +03:00
Yigit Kerem Oktay 96f79ee725 Revert "Merge pull request #135 from server-status-project/master"
This reverts commit 8d571547f5, reversing
changes made to e96df7015e.
2020-11-05 16:54:04 +03:00
Yiğit Kerem Oktay 8d571547f5
Merge pull request #135 from server-status-project/master
Merge new updates
2020-11-05 16:52:24 +03:00
Yigit Kerem Oktay 46c0b55779 Revert "Merge branch 'dev' into master"
This reverts commit 18b89e8c35, reversing
changes made to 81132e9ccf.
2020-11-05 16:51:43 +03:00
Yiğit Kerem Oktay 18b89e8c35
Merge branch 'dev' into master 2020-11-05 16:50:05 +03:00
Yiğit Kerem Oktay e96df7015e
Merge pull request #131 from thnilsen/dev
Initial code for front-end categorization status view
2020-10-14 23:06:53 +03:00
Thomas Nilsen 505d802c2e
Merge pull request #4 from yigitkeremoktay/patch-1
Fix a UI bug
2020-10-14 21:40:14 +02:00
Yiğit Kerem Oktay 3edfd9dbe2
Fix a UI bug 2020-10-14 22:30:12 +03:00
thnilsen 887a197033 Initial code for front-end categorization status view 2020-10-14 19:54:32 +02:00
Vojtěch Sajdl 81132e9ccf
Merge pull request #129 from kim3-sudo/patch-1
Fix PHP syntax error
2020-10-05 23:55:36 +02:00
Sejin Kim af62f9f49d
Fix PHP syntax error
Added a semicolon that allows fresh installations on *NIX to work properly with PHP 7.2+
2020-10-05 17:34:27 -04:00
Yiğit Kerem Oktay e2b331a039
Fixback 2020-10-02 08:58:07 +03:00
Yiğit Kerem Oktay 671004579c
Update incident.php 2020-10-01 16:35:32 +03:00
thnilsen 93d1491aac Add functionality to services in backend.
- Add functionallity to categorize a one or more services under one
  service group. Partial fix for #7 and #90. (Frontend code to be done)
- Add description field to service to be displayed as a help text
  on front page. Partial fix for #51 (Frontend code to be done)
2020-09-27 14:01:54 +02:00
Yiğit Kerem Oktay 38fcabdbb4
Update stale.yml 2020-09-12 16:41:36 +03:00
Vojtěch Sajdl f7ad9ac6b1
Create stale.yml 2020-09-09 13:20:05 +02:00
Vojtěch Sajdl 9963e1f834
Merge pull request #126 from Nothing4You/fix-head.php
fix head.php: comment wasn't part of of a php block
2020-09-01 09:39:18 +02:00
Richard Schwab ff06a320b0 fix head.php: comment wasn't part of of a php block 2020-09-01 08:28:31 +02:00
Yiğit Kerem Oktay 3c540496d4
Update template.php 2020-08-30 22:03:42 +03:00
Yiğit Kerem Oktay e09d02cf2e
Update and rename head.txt to head.php 2020-08-30 22:03:09 +03:00
Vojtěch Sajdl 14015d4666
Update README.md 2020-08-30 09:19:46 +02:00
Yiğit Kerem Oktay 48b9cbbc82
Update README.md 2020-08-27 16:43:41 +03:00
Yiğit Kerem Oktay b3a1bfeb0e Update issue templates 2020-08-24 23:04:14 +03:00
Yiğit Kerem Oktay 1573b062b5
Update README.md 2020-08-24 22:46:31 +03:00
Yiğit Kerem Oktay 86a36e3832
Update versionfile for beta 8 2020-08-24 22:43:09 +03:00
17 changed files with 674 additions and 100 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
config.php
.idea/
.vscode/
.code/

View File

@ -1,19 +1,19 @@
# Server Status Beta (Official)
## This is the official beta fork of Server Status by the contributors.
# Server Status (Official)
## This is the official Server Status Project.
![License](https://img.shields.io/github/license/Pryx/server-status.svg) ![Current release](https://img.shields.io/badge/version-2-blue)
![Beta-Build](https://img.shields.io/badge/latest_beta-Developmet_Beta_6-black)
![Beta-Stability](https://img.shields.io/badge/Beta_Stability-Unusable-red)
![Stability](https://img.shields.io/badge/master_stability-Unstable-red)
![Beta-Build](https://img.shields.io/badge/latest_beta-Developmet_Beta_7-black)
![Stability](https://img.shields.io/badge/master_stability-Stable-red)
![Build](https://img.shields.io/badge/build-success-green)
<!--
## What does **contributor beta** mean?
It means the beta that is heavily unstable that is meant for contributors to make changes and use as a recovery point.
### Other Beta Type
### Other Beta Types
#### Development Beta
##### This beta has some bugs that are noticeable and is sometimes unstable. Best for new contributors
#### Public Beta
##### This beta has some bugs that are not really noticeable and mostly exist as bugs. Best for trying the new features before updating!
Very simple server status page written in PHP that can run on **PHP 5.4+** - even on **shared webhosting** even without shell access. Because why waste your money on another server (or host on a server that you might want to do maintenance on), when you can use cheap webhosting? And as a cherry on top - it works even without javascript!
-->
Very simple server status page written in PHP that can run on **PHP 5.5+** - even on **shared webhosting** even without shell access. Because why waste your money on another server (or host on a server that you might want to do maintenance on), when you can use cheap webhosting? And as a cherry on top - it works even without javascript!
## How do I install this thing?
Simply put the files on your server and access it from your browser. There will be a simple install dialog waiting for you.

15
SECURITY.md Normal file
View File

@ -0,0 +1,15 @@
# Security Policy
## Supported Versions
Only the latest version of server-status is being supported. Older versions won't recieve security updates.
## Reporting a Vulnerability
If you believe that you have have discovered a vulnerability you can report it by emailing the [lead maintainer](https://github.com/Pryx) at vojtech@sajdl.com.
Please include the keyword VULNERABILITY and the repository name in the subject of the email.
In the email, please describe your findings, the project versions you tested and were affected by the vulnerability and also include the full steps to reproduce it.
We appreciate your efforts to make server-status more secure and will try to do everytihing in our power to get the issues resolved as fast as possible. We will
keep you informed of the progress towards a fix.

View File

@ -36,7 +36,7 @@ else{
define("PHP_MAILER_USER", $db->getSetting($mysqli, "php_mailer_user"));
define("PHP_MAILER_PASS", $db->getSetting($mysqli, "php_mailer_pass"));
define("CRON_SERVER_IP", $db->getSetting($mysqli, "cron_server_ip"));
// Process the subscriber notification queue
// If CRON_SERVER_IP is not set, call notification once incident has been saved
if ( empty(CRON_SERVER_IP) )
@ -110,6 +110,16 @@ else{
require_once("new-user.php");
break;
case 'new-service':
case 'edit-service':
require_once('service.php');
break;
case 'new-service-group':
case 'edit-service-group':
require_once('service-group.php');
break;
case 'options':
require_once("options.php");
break;

99
admin/service-group.php Normal file
View File

@ -0,0 +1,99 @@
<?php
if (isset($_GET['new']))
{
ServiceGroup::add();
}
if (isset($_GET['edit']))
{
ServiceGroup::edit();
}
if (isset($_GET['delete']))
{
ServiceGroup::delete();
}
$boolEdit = false;
$group_value = isset($_POST['group']) ? $_POST['group'] : '';
$description_value = isset($_POST['description']) ? $_POST['description'] : '';
$visibility_id_value = isset($_POST['visibility_id']) ? $_POST['visibility_id'] : '';
if ( isset($_GET['id']) && !isset($_POST['id']) ) {
$group_id = (int) $_GET['id'];
$boolEdit = true;
$stmt = $mysqli->prepare("SELECT * FROM services_groups WHERE id LIKE ?");
$stmt->bind_param("i", $group_id);
$stmt->execute();
$query = $stmt->get_result();
$data = $query->fetch_assoc();
$group_value = $data['name'];
$description_value = $data['description'];
$visibility_id_value = $data['visibility'];
}
if (!$boolEdit) {
Template::render_header(_("New service group"), true); ?>
<div class="text-center">
<h2><?php echo _("Add new service group");?></h2>
</div>
<?php
$form_url = WEB_URL .'/admin/?do=new-service-group&amp;new=group';
} else {
Template::render_header(_("Edit service group"), true); ?>
<div class="text-center">
<h2><?php echo _("Edit service group");?></h2>
</div>
<?php
$form_url = WEB_URL .'/admin/?do=edit-service-group&amp;edit&amp;id='.$group_id;
}
?>
<form action="<?php echo $form_url;?>" method="POST" class="form-horizontal">
<?php if (isset($message))
{?>
<p class="alert alert-danger"><?php echo $message?></p>
<?php
} ?>
<div class="form-group">
<div class="col-sm-6"><label for="group"><?php echo _("Service Group Name");?>: </label><input type="text" maxlength="50" name="group" value="<?php echo ((isset($_POST['group']))?htmlspecialchars($_POST['group'],ENT_QUOTES):$group_value);?>" id="group" placeholder="<?php echo _("service group name");?>" class="form-control" required></div>
<div class="col-sm-6"><label for="description"><?php echo _("Description");?>: </label><input type="text" maxlength="100" name="description" value="<?php echo ((isset($_POST['description']))?htmlspecialchars($description_value,ENT_QUOTES):$description_value);?>" id="description" placeholder="<?php echo _("Description");?>" class="form-control"></div>
</div>
<div class="form-group">
<div class="col-sm-6">
<label for="visibility_id"><?php echo _("Visibility");?>: </label>
<select name="visibility_id" id="visibility_id" class="form-control">
<?php
if (!empty($visibility_id_value))
{
$visibility_id = $visibility_id_value;
}
else
{
$visibility_id = null;
}
//$visibilitys = Service::get_groups();
foreach ($visibility as $key => $value) {
if ($visibility_id == $key)
{
echo '<option value="'.$key.'" selected>'.$value.'</option>';
}
else{
echo '<option value="'.$key.'">'.$value.'</option>';
}
}
?>
</select>
</div>
</div>
<?php
if ( $boolEdit ) {
echo '<input type="hidden" id="id" name="id" value="'.$group_id.'">';
}
?>
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button>
</form>

97
admin/service.php Normal file
View File

@ -0,0 +1,97 @@
<?php
if (isset($_GET['new']))
{
Service::add();
}
if (isset($_GET['edit']))
{
Service::edit();
}
/*if (isset($_GET['delete']))
{
Service::delete();
}*/
$boolEdit = false;
$service_value = isset($_POST['service']) ? $_POST['service'] : '';
$description_value = isset($_POST['description']) ? $_POST['description'] : '';
$group_id_value = isset($_POST['group_id']) ? $_POST['group_id'] : '';
if ( isset($_GET['id']) && !isset($_POST['id']) ) {
$service_id = (int) $_GET['id'];
$boolEdit = true;
$stmt = $mysqli->prepare("SELECT * FROM services WHERE id LIKE ?");
$stmt->bind_param("i", $service_id);
$stmt->execute();
$query = $stmt->get_result();
$data = $query->fetch_assoc();
//print_r($data);
$service_value = $data['name'];
$description_value = $data['description'];
$group_id_value = $data['group_id'];
}
if (!$boolEdit) {
Template::render_header(_("New service"), true); ?>
<div class="text-center">
<h2><?php echo _("Add new service");?></h2>
</div>
<?php
$form_url = WEB_URL . '/admin/?do=new-service&amp;new=service';
} else {
Template::render_header(_("New service"), true); ?>
<div class="text-center">
<h2><?php echo _("Add new service");?></h2>
</div>
<?php
$form_url = WEB_URL . '/admin/?do=edit-service&amp;edit&amp;id='.$service_id;
}
?>
<form action="<?php echo $form_url;?>" method="POST" class="form-horizontal">
<?php if (isset($message))
{?>
<p class="alert alert-danger"><?php echo $message?></p>
<?php
} ?>
<div class="form-group">
<div class="col-sm-6"><label for="service"><?php echo _("Service");?>: </label><input type="text" maxlength="50" name="service" value="<?php echo ((isset($_POST['service']))?htmlspecialchars($_POST['service'],ENT_QUOTES):$service_value);?>" id="service" placeholder="<?php echo _("service");?>" class="form-control" required></div>
<div class="col-sm-6"><label for="description"><?php echo _("Description");?>: </label><input type="text" maxlength="200" name="description" value="<?php echo ((isset($_POST['description']))?htmlspecialchars($_POST['description'],ENT_QUOTES):$description_value);?>" id="description" placeholder="<?php echo _("Description");?>" class="form-control"></div>
</div>
<div class="form-group">
<div class="col-sm-6">
<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))
{
$group_id = $group_id_value;
}
else
{
$group_id = null;
}
$groups = ServiceGroup::get_groups();
foreach ($groups as $key => $value) {
if ($group_id == $key)
{
echo '<option value="'.$key.'" selected>'.$value.'</option>';
}
else{
echo '<option value="'.$key.'">'.$value.'</option>';
}
}
?>
</select>
</div>
</div>
<?php
if ( $boolEdit ) {
echo '<input type="hidden" id="id" name="id" value="'.$service_id.'">';
}
?>
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button>
</form>

View File

@ -1,12 +1,12 @@
<?php
if (isset($_GET['new']))
if (isset($_GET['delete']) && isset($_GET['type']))
{
Service::add();
}
if (isset($_GET['delete']))
{
Service::delete();
if ( $_GET['type'] == 'service') {
Service::delete();
}
elseif ( $_GET['type'] == 'groups') {
ServiceGroup::delete();
}
}
Template::render_header(_("Settings"), true);
@ -14,7 +14,7 @@ Template::render_header(_("Settings"), true);
<div class="text-center">
<h2>Settings</h2>
</div>
<?php
<?php
if (isset($message)){
?>
<p class="alert alert-danger"><?php echo $message; ?></p>
@ -24,19 +24,18 @@ if (isset($message)){
<?php if ($user->get_rank() <= 1){?>
<form action="?do=settings&new=service" method="post">
<div class="input-group pull-right new-service">
<input class="form-control" name="service" placeholder="Name" type="text" value="<?php echo ((isset($_POST['service']))?htmlspecialchars($_POST['service']):''); ?>" maxlength="50" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-success pull-right"><?php echo _("Add service");?></button>
</span>
<a href="<?php echo WEB_URL;?>/admin/?do=new-service" class="btn btn-success pull-right"><?php echo _("Add new service");?></a>
</div>
</form>
<?php }?>
<div class="table-responsive">
<table class="table">
<thead><tr>
<th scope="col"><?php echo _("ID");?></th>
<!--<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)
{?>
<th scope="col"><?php echo _("Delete");?></th>
@ -44,16 +43,66 @@ if (isset($message)){
</tr>
</thead>
<tbody>
<?php
$query = $mysqli->query("SELECT * FROM services");
<?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())
{
echo "<tr>";
echo "<td>".$result['id']."</td>";
echo "<td>".$result['name']."</td>";
//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)
{
echo '<td><a href="'.WEB_URL.'/admin/?do=settings&delete='.$result['id'].'" class="pull-right delete-service"><i class="fa fa-trash"></i></a></td>';
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>";
}?>
</tbody>
</table>
</div>
</section>
<section>
<h3 class="pull-left"><?php echo _("Services Groups");?></h3>
<?php if ($user->get_rank() <= 1){?>
<form action="?do=settings&new=service-group" method="post">
<div class="input-group pull-right new-service">
<a href="<?php echo WEB_URL;?>/admin/?do=new-service-group" class="btn btn-success pull-right"><?php echo _("Add new service group");?></a>
</div>
</form>
<?php }?>
<div class="table-responsive">
<table class="table">
<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)
{?>
<th scope="col"><?php echo _("Delete");?></th>
<?php } ?>
</tr>
</thead>
<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())
{
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>';
echo '<td> <span class="badge badge-danger ml-2">'.$result['counter'].'</span>';
echo "<td>".$result['description']."</td>";
echo "<td>".$visibility[$result['visibility']]."</td>";
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>";
}?>
@ -68,10 +117,10 @@ if (isset($message)){
<?php if ($user->get_rank() == 0){?> <a href="<?php echo WEB_URL;?>/admin/?do=new-user" class="btn btn-success pull-right"><?php echo _("Add new user");?></a><?php }?>
<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>
<tbody>
<?php
<?php
$query = $mysqli->query("SELECT * FROM users");
while($result = $query->fetch_assoc())
{
@ -89,4 +138,4 @@ if (isset($message)){
</tbody>
</table>
</div>
</section>
</section>

View File

@ -15,26 +15,25 @@ else{
$array = $constellation->render_status(true, false);
echo json_encode($array);
}else{
$query = $mysqli->prepare("SELECT name FROM services WHERE id=?");
$query->bind_param("i", $_GET['id']);
$query->execute();
$result = $query->get_result()->fetch_assoc();
// get id of service, check if service exists
$queryId = $mysqli->prepare("SELECT id from services where id = ?;");
$queryId->bind_param("i", $_GET['id']);
$queryId->execute();
$result = $queryId->get_result()->fetch_assoc();
if (!count($result))
{
die(json_encode(["error" => _("Service does not exist!")]));
}
$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)
{
$service = new Service($_GET['id'], $result['name'], $tmp->fetch_assoc()['type']);
}
else{
$service = new Service($_GET['id'], $result['name']);
// get name, description and status.type (status of service) by id
$query = $mysqli->prepare("select services.id, name, description, status.type from services inner join status on status.id = services.id where services.id = ?;");
$query->bind_param("i", $_GET['id']);
$query->execute();
$result = $query->get_result()->fetch_assoc();
// if type is a number then return it, else just return the service name/desc
if (is_numeric($result["type"])) {
$service = new Service($_GET["id"], $result["name"], $result["description"], '', $result["type"]);
} else {
$service = new Service($_GET["id"], $result["name"], $result["description"]);
}
echo json_encode($service);

View File

@ -2,6 +2,7 @@
//DIR Because of include problems
require_once(__DIR__ . "/incident.php");
require_once(__DIR__ . "/service.php");
require_once(__DIR__ . "/service-group.php");
require_once(__DIR__ . "/user.php");
require_once(__DIR__ . "/token.php");
/**
@ -20,7 +21,7 @@ class Constellation
public function render_incidents($future=false, $offset=0, $limit = 5, $admin = 0){
if ($offset<0)
{
$offset = 0;
$offset = 0;
}
$limit = (isset($_GET['limit'])?$_GET['limit']:5);
@ -37,7 +38,7 @@ class Constellation
}
else if (count($incidents["incidents"]) &&!$ajax)
{
if ($offset)
if ($offset)
{
echo '<noscript><div class="centered"><a href="'.WEB_URL.'/?offset='.($offset-$limit).'&timestamp='.$timestamp.'" class="btn btn-default">'._("Back").'</a></div></noscript>';
}
@ -66,12 +67,13 @@ class Constellation
/**
* Renders service status - in admin page it returns array so it can be processed further.
* @param boolean $admin
* @return array of services
* @return array of services
*/
public function render_status($admin = false, $heading = true){
global $mysqli;
$query = $mysqli->query("SELECT id, name FROM services");
//$query = $mysqli->query("SELECT id, name, description FROM services");
$query = $mysqli->query("SELECT services.id, services.name, services.description, services_groups.name as group_name FROM services LEFT JOIN services_groups ON services.group_id=services_groups.id ORDER BY services_groups.name ASC, services.name;");
$array = array();
if ($query->num_rows){
$timestamp = time();
@ -86,12 +88,12 @@ class Constellation
$tmp = $sql->get_result();
if ($tmp->num_rows)
{
$array[] = new Service($result['id'], $result['name'], $tmp->fetch_assoc()['type']);
$array[] = new Service($result['id'], $result['name'], $result['description'], $result['group_name'], $tmp->fetch_assoc()['type']);
}
else{
$array[] = new Service($result['id'], $result['name']);
$array[] = new Service($result['id'], $result['name'], $result['description'], $result['group_name']);
}
}
}
if ($heading)
{
echo Service::current_status($array);
@ -102,11 +104,27 @@ class Constellation
}
if (!$admin)
{
echo '<div id="status-container" class="clearfix">';
?>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<?php
//echo '<div id="status-container" class="clearfix">';
//$arrCompletedGroups = array();
foreach($array as $service){
//print_r($service);
//if ( !empty($service->group_name) && !in_array($service->group_name, $arrCompletedGroups)) {
//print $service->name;
// $arrCompletedGroups[] = $service['group_name'];
// $service->render(true);
//} else {
$service->render();
//}
}
echo '</div>';
echo '</ul>';
//echo '</div>';
}
else{
return $array;
@ -131,14 +149,14 @@ class Constellation
$limit--;
$more = false;
if ($query->num_rows>$limit){
$more = true;
$more = true;
}
if ($query->num_rows){
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
$stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services
INNER JOIN services_status ON services.id = services_status.service_id
WHERE services_status.status_id = ?");
$stmt_service->bind_param("i", $result['status_id']);
$stmt_service->execute();
@ -156,17 +174,17 @@ class Constellation
"incidents" => $array
];
}
function render_warning($header, $message, $show_link = false, $url = null, $link_text = null)
{
$this->render_alert('alert-warning', $header, $message, $show_link, $url, $link_text);
$this->render_alert('alert-warning', $header, $message, $show_link, $url, $link_text);
}
function render_success($header, $message, $show_link = false, $url = null, $link_text = null)
{
$this->render_alert('alert-success', $header, $message, $show_link, $url, $link_text);
}
/**
* Renders an alert on screen with an optional button to return to a given URL
* @param string alert_type - Type of warning to render alert-danger, alert-warning, alert-success etc
@ -188,8 +206,8 @@ class Constellation
if ( $show_link ) {
echo '<div class="clearfix"><a href="'.$url.'" class="btn btn-success" role="button">'.$link_text.'</a></div>';
}
}
}
$constellation = new Constellation();
$constellation = new Constellation();

167
classes/service-group.php Normal file
View File

@ -0,0 +1,167 @@
<?php
/**
* Class for managing services
*/
class ServiceGroup
{
private $id;
private $name;
private $description;
private $visibility_id;
/**
* Constructs servicegroup from its data.
* @param int $id service ID
* @param String $name service name
* @param String $description tooltip text
* @param int $visibility_id how to display group items
*/
function __construct($id, $name, $description, $visibility_id)
{
//TODO: Maybe get data from ID?
$this->id = $id;
$this->name = $name;
$this->description = $description;
$this->visibility_id = $visibility_id;
$this->status = $status;
}
/**
* Returns id of this servicegroup
* @return int id
*/
public function get_id()
{
return $this->id;
}
/**
* Returns name of this servicegroup
* @return String name
*/
public function get_name()
{
return $this->name;
}
/**
* Returns description of this servicegroup
* @return String description
*/
public function get_description()
{
return $this->description;
}
/**
* Processes submitted form and adds service unless problem is encountered,
* calling this is possible only for admin or higher rank. Also checks requirements
* for char limits.
* @return void
*/
public static function add()
{
global $user, $message;
if (strlen($_POST['group'])>50)
{
$message = _("Service group name is too long! Character limit is 50");
return;
}else if (strlen(trim($_POST['group']))==0){
$message = _("Please enter name!");
return;
}
if ($user->get_rank()<=1)
{
global $mysqli;
$name = $_POST["group"];
$description = $_POST["description"];
$visibility_id = $_POST["visibility_id"];
$stmt = $mysqli->prepare("INSERT INTO services_groups VALUES(NULL,?,?,?)");
$stmt->bind_param("ssi", $name, $description, $visibility_id);
$stmt->execute();
$stmt->get_result();
header("Location: ".WEB_URL."/admin/?do=settings");
}else
{
$message = _("You don't have the permission to do that!");
}
}
public static function edit()
{
global $user, $message;
if (strlen($_POST['group'])>50)
{
$message = _("Service group name is too long! Character limit is 50");
return;
}else if (strlen(trim($_POST['group']))==0){
$message = _("Please enter name!");
return;
}
if ($user->get_rank()<=1)
{
global $mysqli;
$name = $_POST["group"];
$description = $_POST["description"];
$visibility_id = $_POST["visibility_id"];
$group_id = $_POST["id"];
$stmt = $mysqli->prepare("UPDATE services_groups SET name=?, description=?,visibility=? WHERE id LIKE ?");
$stmt->bind_param("ssii", $name, $description, $visibility_id, $group_id);
$stmt->execute();
$stmt->get_result();
header("Location: ".WEB_URL."/admin/?do=settings");
}else
{
$message = _("You don't have the permission to do that!");
}
}
/**
* Deletes this service - first checks if user has permission to do that.
* @return void
*/
public static function delete()
{
global $user, $message;
if ($user->get_rank()<=1)
{
global $mysqli;
$id = $_GET['delete'];
$stmt = $mysqli->prepare("DELETE FROM services_groups WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$query = $stmt->get_result();
$stmt = $mysqli->prepare("UPDATE services SET group_id = NULL WHERE group_id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$query = $stmt->get_result();
header("Location: ".WEB_URL."/admin/?do=settings");
}
else
{
$message = _("You don't have the permission to do that!");
}
}
/**
* Get list of services groups.
* @return array $groups
*/
public function get_groups() {
global $mysqli;
$stmt = $mysqli->query("SELECT id, name FROM services_groups ORDER by name ASC");
$groups = array();
$groups[0] = '';
while ($res = $stmt->fetch_assoc()) {
$groups[$res['id']] = $res['name'];
}
return $groups;
}
}

View File

@ -6,19 +6,24 @@ class Service implements JsonSerializable
{
private $id;
private $name;
private $description;
private $group_name;
private $status;
/**
* Constructs service from its data.
* @param int $id service ID
* @param String $name service name
* @param String $descriotion service description for tooltip
* @param int $status current service status
*/
function __construct($id, $name, $status=3)
function __construct($id, $name, $description=null, $group_name='', $status=3)
{
//TODO: Maybe get data from ID?
$this->id = $id;
$this->name = $name;
$this->description = $description;
$this->group_name = $group_name;
$this->status = $status;
}
@ -49,6 +54,15 @@ class Service implements JsonSerializable
return $this->name;
}
/**
* Returns description of this service
* @return String description
*/
public function get_description()
{
return $this->description;
}
/**
* Processes submitted form and adds service unless problem is encountered,
* calling this is possible only for admin or higher rank. Also checks requirements
@ -70,9 +84,11 @@ class Service implements JsonSerializable
if ($user->get_rank()<=1)
{
global $mysqli;
$name = $_POST['service'];
$stmt = $mysqli->prepare("INSERT INTO services ( name ) VALUES ( ? )");
$stmt->bind_param("s", $name);
$name = htmlspecialchars($_POST['service']);
$description = htmlspecialchars($_POST['description']);
$group_id = $_POST['group_id'];
$stmt = $mysqli->prepare("INSERT INTO services ( name, description, group_id ) VALUES ( ?, ?, ? )");
$stmt->bind_param("ssi", $name, $description, $group_id);
$stmt->execute();
$stmt->get_result();
header("Location: ".WEB_URL."/admin/?do=settings");
@ -81,6 +97,41 @@ class Service implements JsonSerializable
$message = _("You don't have the permission to do that!");
}
}
/**
* Processes submitted form and adds service unless problem is encountered,
* calling this is possible only for admin or higher rank. Also checks requirements
* for char limits.
* @return void
*/
public static function edit()
{
global $user, $message;
if (strlen($_POST['service'])>50)
{
$message = _("Service name is too long! Character limit is 50");
return;
}else if (strlen(trim($_POST['service']))==0){
$message = _("Please enter name!");
return;
}
if ($user->get_rank()<=1)
{
global $mysqli;
$service_id = $_POST["id"];
$name = htmlspecialchars($_POST['service']);
$description = htmlspecialchars($_POST["description"]);
$group_id = $_POST["group_id"];
$stmt = $mysqli->prepare("UPDATE services SET name=?, description=?, group_id=? WHERE id = ?");
$stmt->bind_param("ssii", $name, $description, $group_id, $service_id);
$stmt->execute();
$stmt->get_result();
header("Location: ".WEB_URL."/admin/?do=settings");
}else
{
$message = _("You don't have the permission to do that!");
}
}
/**
* Deletes this service - first checks if user has permission to do that.
@ -139,7 +190,7 @@ class Service implements JsonSerializable
{
$worst = $service->get_status();
}
$statuses[$service->get_status()]++;
$statuses[$service->get_status()]++;
}
echo '<div id="status-big" class="status '.$classes[$worst].'">';
@ -155,17 +206,56 @@ class Service implements JsonSerializable
/**
* Renders this service.
* @param $boolGroup set to true if the groups name is to be rendered
* @return void
*/
public function render(){
global $statuses;
global $classes;
?>
<div class="item clearfix">
<div class="service"><?php echo $this->name; ?></div>
<?php if ($this->status!=-1){?><div class="status <?php echo $classes[$this->status];?>"><?php echo _($statuses[$this->status]);?></div><?php }?>
</div>
<?php
static $arrCompletedGroups = array();
//static $boolClosed;
static $boolOpened;
// Check if previous ul has been opened, and if a empty/new group is being
// render_header, close the UL first.
if ( $boolOpened ) {
if ( empty($this->group_name) || !in_array($this->group_name, $arrCompletedGroups) ) {
echo '</ul>';
$boolOpened = false;
}
}
// If no group exist or group is new, start a new UL
if ( !empty($this->group_name) && !in_array($this->group_name, $arrCompletedGroups)) {
echo '<ul class="list-group components">';
//echo '<ul class="platforms list-group mb-2">';
// Render the group status if it exists
echo '<li class="list-group-item list-group-item-success group-name"><span><i class="glyphicon glyphicon-plus"></i></span>&nbsp;' . $this->group_name .'<div class="status '. $classes[$this->status] .'">'. _($statuses[$this->status]).'</div></li>';
//echo '<li class="cist-group-item d-flex flex-row justify-content-between platform list-group-item-action py-0 expanded" role="button">' . $this->group_name .'<div class="status '. $classes[$this->status] .'"'. _($statuses[$this->status]).'</div></li>';
$arrCompletedGroups[] = $this->group_name;
$boolOpened = true;
}
if ( empty($this->group_name)) {
echo '<ul class="list-group components">';
// echo '<ul class="platforms list-group mb-2">';
$boolFinish = true;
}
// Render the service status
echo '<li class="list-group-item sub-component"><strong>' . $this->name .'</strong>';
//echo '<li class="list-group-item d-flex flex-columns justify-content-between><span>+</span><h3 class="py-2 my-0 flex-fill expanded">' . $this->name . '</h3>';
if(!empty($this->description)) {
echo '<a class="desc-tool-tip" data-toggle="tooltip" data-placement="top" title="'.$this->description.'"> <span><i class="glyphicon glyphicon-question-sign"></i></span></a>';
}
if ($this->status!=-1){?><div class="status pull-right <?php echo $classes[$this->status];?>"><?php echo _($statuses[$this->status]);?></div>
<?php
}
echo '</li>';
if ( isset($boolFinish) && $boolFinish) {
echo '</ul>';
}
}
public function jsonSerialize() {
@ -173,6 +263,7 @@ class Service implements JsonSerializable
return [
"id" => $this->id,
"name" => $this->name,
"description" => $this->description,
"status" => $this->status,
"status_string" => $statuses[$this->status]
];

View File

@ -27,6 +27,10 @@ a:focus {
color:#f5f4f4;
}
a.desc-tool-tip, a.desc-tool-tip:hover, a.desc-tool-tip:visited {
color: grey;
}
.centered {
text-align: center
}
@ -60,22 +64,15 @@ a:focus {
background: gray;
}
.navbar-default {
z-index: 200;
background-color: gray;
border-color: transparent;
z-index: 200;
background-color: gray;
border-color: transparent;
border-radius: 0px 0px 30px 30px;
height: 77px;
position: fixed;
top: 0;
width: 100%;
}
body {
min-height: 100vh;
height: 100vh;
}
.admins_color h4 {
color: #3a72bd;
font-weight: bold;
@ -136,7 +133,7 @@ body a h1{
.status{
float: right;
box-sizing: border-box;
padding: 15px 35px;
padding: 0px 35px;
text-align: right;
font-size: 1.05em;
font-family: 'Fira Sans', sans-serif;
@ -686,4 +683,3 @@ input:checked + .slider:before {
.slider.round:before {
border-radius: 50%;
}

View File

@ -68,6 +68,7 @@ if (isset($_GET['subscriber_logout'])){
unset($_SESSION['subscriber_id']);
header('Location: index.php');
}
/*
$versionfile = fopen("versionfile", "r") or die("Unable to open version file!");
$appversion = fread($versionfile,filesize("versionfile"));
fclose($versionfile);
@ -90,6 +91,7 @@ if($db->getSetting($mysqli,"notifyUpdates") == "yes"){
die("Your installation is not upp to date! Download the new update from: '".$remotedl."' Your version is:'".$appversion."' Remote Authority Version is:'".$remoteversion."' Your Update Seed is:'".$useed."' Remote Package Authority is Skyfallen. <br>If you cannot access Remote Authority, please check status.theskyfallen.com and skyfallenhosted.ml manually.");
}
}
*/
Template::render_header("Status");
?>
<div class="text-center">

View File

@ -9,6 +9,14 @@ define("COPYRIGHT_TEXT","");
require_once("classes/locale-negotiator.php");
require_once("classes/db-class.php");
$isDeveleoperEnvironement = false;
if(isset($_GET["isDev"])){
if($_GET["isDev"] == "devMode"){
$isDeveleoperEnvironement = true;
}
}
$negotiator = new LocaleNegotiator("en_GB");
$message = "";
$db = new SSDB();
@ -161,11 +169,12 @@ if(isset($_POST['server']) && empty($message))
$db->setSetting($mysqli,"google_recaptcha_secret","");
$db->setSetting($mysqli,"google_recaptcha_sitekey","");
$db->setSetting($mysqli,"cron_server_ip","");
unlink("create-server-config.php");
unlink("config.php.template");
unlink("install.sql");
unlink(__FILE__);
if(!$isDeveleoperEnvironement) {
unlink("create-server-config.php");
unlink("config.php.template");
unlink("install.sql");
unlink(__FILE__);
}
header("Location: ".WEB_URL);
}
}

View File

@ -57,6 +57,14 @@ CREATE TABLE queue_notify (
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,
description varchar(50) DEFAULT NULL,
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,
@ -128,3 +136,7 @@ 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;
COMMIT;

View File

@ -1,12 +1,11 @@
<?php
//This should later be translatable, maybe find a better solution?
//This is here for better generation of POT files :)
$statuses = array(_("Major outage"), _("Minor outage"), _("Planned maintenance"), _("Operational") );
$classes = array("danger", "warning", "primary", "success" );
$icons = array("fa fa-times", "fa fa-exclamation", "fa fa-info", "fa fa-check" );
$some = array(_("Some systems are experiencing major outages"), _("Some systems are experiencing minor outages"), _("Some systems are under maintenance"));
$all = array(_("Our systems are experiencing major outages."), _("Our systems are experiencing minor outages"), _("Our systems are under maintenance"), _("All systems operational"));
$permissions = array(_("Super admin"), _("Admin"), _("Editor"));
$visibility = array(_("Collapsed"), _("Expanded"), _("Expand on events"));
/**
* Class that encapsulates methods to render header and footer
@ -56,10 +55,14 @@ class Template{
<!doctype html>
<html lang="en">
<head>
<?php
<?php
if(!admin){
$headfile = fopen("head.txt", "r") or die("Unable to open head.txt!");
$head_additionalcode = fread($versionfile,filesize("head.txt"));
fclose($headfile); ?>
fclose($headfile);
echo $head_additionalcode;
}
?>
<meta charset="utf-8">
<title><?php echo $page_name." - ".NAME ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
@ -173,6 +176,9 @@ class Template{
/**
* Renders a toggle switch
* Created by Yigit Kerem Oktay
* @param String $toggletext will decide what the description text next to the toggle will be
* @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){
?>
@ -198,7 +204,7 @@ class Template{
<div id="footerwrap">
<div class="container">
<div class="row centered">
<div class="col-md-4 text-left"><a href="https://github.com/Pryx/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 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="btn-group dropup">
<button type="button" class="btn btn-primary"><?php echo '<img src="'.WEB_URL.'/locale/'.$_SESSION['locale'].'/flag.png" alt="'.$lang_names[$_SESSION['locale']].'">'.$lang_names[$_SESSION['locale']];?></button>

View File

@ -1 +1 @@
Version2Beta7
Version2Beta8