Revert "Merge pull request #135 from server-status-project/master"

This reverts commit 8d571547f5, reversing
changes made to e96df7015e.
This commit is contained in:
Yigit Kerem Oktay
2020-11-05 16:54:04 +03:00
parent 8d571547f5
commit 96f79ee725
44 changed files with 5689 additions and 267 deletions
+28 -11
View File
@@ -1,4 +1,6 @@
<?php
require_once(__DIR__ . "/notification.php");
/**
* Class for creating and rendering an incident
*/
@@ -73,7 +75,7 @@ class Incident implements JsonSerializable
}
/**
* Processes submitted form and adds incident unless problem is encountered,
* Processes submitted form and adds incident unless problem is encountered,
* calling this is possible only for admin or higher rank. Also checks requirements
* for char limits.
* @return void
@@ -81,6 +83,9 @@ class Incident implements JsonSerializable
public static function add()
{
global $mysqli, $message;
//Sould be a better way to get this array...
$statuses = array(_("Major outage"), _("Minor outage"), _("Planned maintenance"), _("Operational") );
$user_id = $_SESSION['user'];
$type = $_POST['type'];
$title = strip_tags($_POST['title']);
@@ -124,7 +129,7 @@ class Incident implements JsonSerializable
if (!empty($_POST['time']) && $type == 2){
$input_time = (!empty($_POST['time_js'])?$_POST['time_js']: $_POST['time']);
$input_end_time = (!empty($_POST['end_time_js'])?$_POST['end_time_js']: $_POST['end_time']);
$time = strtotime($input_time);
$time = strtotime($input_time);
$end_time = strtotime($input_end_time);
if (!$time)
{
@@ -147,7 +152,7 @@ class Incident implements JsonSerializable
$time = time();
$end_time = '';
}
$stmt = $mysqli->prepare("INSERT INTO status VALUES (NULL,?, ?, ?, ?, ?, ?)");
$stmt->bind_param("issiii", $type, $title, $text, $time ,$end_time ,$user_id);
$stmt->execute();
@@ -155,16 +160,28 @@ class Incident implements JsonSerializable
$status_id = $mysqli->insert_id;
foreach ($services as $service) {
$stmt = $mysqli->prepare("INSERT INTO services_status VALUES (NULL,?, ?)");
$stmt = $mysqli->prepare("INSERT INTO services_status VALUES (NULL,?, ?)");
$stmt->bind_param("ii", $service, $status_id);
$stmt->execute();
$query = $stmt->get_result();
}
header("Location: ".WEB_URL."/admin");
// Perform notification to subscribers
$notify = new Notification();
$notify->populate_impacted_services($status_id);
$notify->type = $type;
$notify->time = $time;
$notify->title = $title;
$notify->text = $text;
$notify->status = $statuses[$type];
$notify->notify_subscribers();
header("Location: ".WEB_URL."/admin?sent=true");
}
}
/**
* Renders incident
* @param Boolean $admin - decides whether admin controls should be rendered
@@ -174,7 +191,7 @@ class Incident implements JsonSerializable
global $icons;
global $classes, $user;
$admin = $admin && (($user->get_rank()<=1) || ($user->get_username() == $this->username));
$Parsedown = new Parsedown();
?>
<article class="panel panel-<?php echo $classes[$this->type];?>">
<div class="panel-heading icon">
@@ -188,16 +205,16 @@ class Incident implements JsonSerializable
<time class="pull-right timeago" datetime="<?php echo $this->date; ?>"><?php echo $this->date; ?></time>
</div>
<div class="panel-body">
<?php echo $this->text; ?>
<?php echo $Parsedown->setBreaksEnabled(true)->text($this->text); ?>
</div>
<div class="panel-footer clearfix">
<small>
<?php echo _("Impacted service(s): ");
foreach ( $this->service_name as $key => $value ) {
foreach ( $this->service_name as $value ) {
echo '<span class="label label-default">'.$value . '</span>&nbsp;';
}
if (isset($this->end_date)){?>
if (isset($this->end_date)){?>
<span class="pull-right"><?php echo strtotime($this->end_date)>time()?_("Ending"):_("Ended");?>:&nbsp;<time class="pull-right timeago" datetime="<?php echo $this->end_date; ?>"><?php echo $this->end_date; ?></time></span>
<?php } ?>
</small>
@@ -217,4 +234,4 @@ class Incident implements JsonSerializable
"username" => $this->username
];
}
}
}