files reformatted

for better readability
This commit is contained in:
Tealk 2021-03-18 18:26:03 +01:00
parent e2e4a9620b
commit bf3048baf8
No known key found for this signature in database
GPG Key ID: 5FE349ABC863E7F9
40 changed files with 2079 additions and 2205 deletions

View File

@ -1,7 +1,6 @@
<?php <?php
require_once("template.php"); require_once("template.php");
if (!file_exists("config.php")) if (!file_exists("config.php")) {
{
require_once("install.php"); require_once("install.php");
} else { } else {
require_once("config.php"); require_once("config.php");

View File

@ -1,21 +1,17 @@
<?php <?php
$offset = 0; $offset = 0;
if (isset($_GET['ajax'])) if (isset($_GET['ajax'])) {
{
$constellation->render_incidents(false, $_GET['offset'], 5); $constellation->render_incidents(false, $_GET['offset'], 5);
exit(); exit();
}else if (isset($_GET['offset'])) } else if (isset($_GET['offset'])) {
{
$offset = $_GET['offset']; $offset = $_GET['offset'];
} }
if (isset($_GET['new']) && $_GET['new']=="incident") if (isset($_GET['new']) && $_GET['new'] == "incident") {
{
Incident::add(); Incident::add();
} }
if (isset($_GET['delete'])) if (isset($_GET['delete'])) {
{
Incident::delete($_GET['delete']); Incident::delete($_GET['delete']);
} }
if (isset($_GET['tasks'])) { if (isset($_GET['tasks'])) {
@ -42,15 +38,13 @@ Template::render_header(_("Dashboard"), true);
<h3><?php echo _("New incident"); ?></h3> <h3><?php echo _("New incident"); ?></h3>
<form id="new-incident" action="<?php echo WEB_URL; ?>/admin/?new=incident" method="POST" class=""> <form id="new-incident" action="<?php echo WEB_URL; ?>/admin/?new=incident" method="POST" class="">
<div class="card"> <div class="card">
<?php if (isset($message)) <?php if (isset($message)) { ?>
{?>
<p class="alert alert-danger"><?php echo $message ?></p> <p class="alert alert-danger"><?php echo $message ?></p>
<?php <?php
} ?> } ?>
<div id="status-container" class=""> <div id="status-container" class="">
<?php <?php
if (isset($_POST['services']) && !is_array($_POST['services'])) if (isset($_POST['services']) && !is_array($_POST['services'])) {
{
$post_services = array($_POST['services']); $post_services = array($_POST['services']);
} else { } else {
$post_services = array(); $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(); ?>"> <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> </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="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 } ?> <?php } ?>
</div> </div>
<?php <?php
@ -95,11 +91,9 @@ Template::render_header(_("Dashboard"), true);
<div class="input-group"> <div class="input-group">
<select class="form-select" id="type" name="type"> <select class="form-select" id="type" name="type">
<?php <?php
if (isset($_POST['type'])) if (isset($_POST['type'])) {
{
$selected_status = $_POST['type']; $selected_status = $_POST['type'];
}else } else {
{
$selected_status = 2; $selected_status = 2;
} }

View File

@ -1,10 +1,8 @@
<?php <?php
if (!file_exists("../config.php")) if (!file_exists("../config.php")) {
{
header("Location: ../"); header("Location: ../");
} } else {
else{
require_once("../config.php"); require_once("../config.php");
require_once("../classes/constellation.php"); require_once("../classes/constellation.php");
require_once("../classes/mailer.php"); require_once("../classes/mailer.php");
@ -39,52 +37,39 @@ else{
// Process the subscriber notification queue // Process the subscriber notification queue
// If CRON_SERVER_IP is not set, call notification once incident has been saved // If CRON_SERVER_IP is not set, call notification once incident has been saved
if ( empty(CRON_SERVER_IP) ) if (empty(CRON_SERVER_IP)) {
{ if (isset($_GET['sent']) && $_GET['sent'] == true) {
if ( isset($_GET['sent']) && $_GET['sent'] == true )
{
Queue::process_queue(); 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 // 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(); Queue::process_queue();
syslog(1, "CRON server processed"); syslog(1, "CRON server processed");
} } else {
else {
syslog(1, "CRON called from unauthorised server"); syslog(1, "CRON called from unauthorised server");
} }
} }
if(isset($_COOKIE['user'])&&!isset($_SESSION['user'])) if (isset($_COOKIE['user']) && !isset($_SESSION['user'])) {
{
User::restore_session(); User::restore_session();
} }
if (!isset($_SESSION['user'])) if (!isset($_SESSION['user'])) {
{ if (isset($_GET['do']) && $_GET['do'] == "lost-password") {
if (isset($_GET['do']) && $_GET['do']=="lost-password")
{
require_once("lost-password.php"); require_once("lost-password.php");
} else if (isset($_GET['do']) && $_GET['do'] == "change-email") { } else if (isset($_GET['do']) && $_GET['do'] == "change-email") {
$user_pwd = new User($_GET['id']); $user_pwd = new User($_GET['id']);
$user_pwd->change_email(); $user_pwd->change_email();
require_once("login-form.php"); require_once("login-form.php");
} } else {
else{
User::login(); User::login();
require_once("login-form.php"); require_once("login-form.php");
} }
} } else {
else
{
$user = new User($_SESSION['user']); $user = new User($_SESSION['user']);
if (!$user->is_active()) if (!$user->is_active()) {
{
User::logout(); User::logout();
} }

View File

@ -7,36 +7,30 @@ Template::render_header(_("Lost password"));
<div id="login-form" class="center"> <div id="login-form" class="center">
<?php <?php
if (isset($_POST['id'])) if (isset($_POST['id'])) {
{
$user = new User($_POST['id']); $user = new User($_POST['id']);
$user->change_password($_POST['token']); $user->change_password($_POST['token']);
if (isset($message)) { ?> if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p> <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> <a href="<?php echo WEB_URL; ?>/admin/?do=lost-password<?php echo "&id=" . $_POST['id'] . "&token=" . $_POST['token']; ?>"><?php echo _("Go back"); ?> </a>
<?php <?php
} } else { ?>
else{?>
<p class="alert alert-success"><?php echo _("Password changed successfully!"); ?></p> <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> <a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
<?php <?php
} }
} } else if (isset($_POST['email'])) {
else if (isset($_POST['email']))
{
User::password_link(); User::password_link();
if (isset($message)) { ?> if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p> <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> <a href="<?php echo WEB_URL; ?>/admin/?do=lost-password"><?php echo _("Go back to start"); ?></a>
<?php <?php
} } else { ?>
else{?>
<p class="alert alert-success"><?php echo _("Email with password reset link has been sent!"); ?></p> <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> <a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
<?php <?php
} }
} } else {
else{
if (isset($message)) { ?> if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p> <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> <button type="submit" class="btn btn-success pull-right"><?php echo _("Submit request"); ?></button>
</span> </span>
</div> </div>
<?php } <?php } else {
else{
$user = new User($_GET['id']); $user = new User($_GET['id']);
?> ?>
<p class="alert alert-info"><?php printf(_("Reset password for %s (%s)"), $user->get_name(), $user->get_username()); ?></p> <p class="alert alert-info"><?php printf(_("Reset password for %s (%s)"), $user->get_name(), $user->get_username()); ?></p>

View File

@ -1,6 +1,5 @@
<?php <?php
if (isset($_GET['new'])) if (isset($_GET['new'])) {
{
User::add(); User::add();
} }
@ -10,8 +9,7 @@ Template::render_header(_("New user"), true); ?>
</div> </div>
<form action="<?php echo WEB_URL; ?>/admin/?do=new-user&new=user" method="POST" class="form-horizontal"> <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> <p class="alert alert-danger"><?php echo $message ?></p>
<?php <?php
} ?> } ?>
@ -29,20 +27,15 @@ Template::render_header(_("New user"), true); ?>
<label for="permission"><?php echo _("Permission"); ?>: </label> <label for="permission"><?php echo _("Permission"); ?>: </label>
<select name="permission" id="permission" class="form-control"> <select name="permission" id="permission" class="form-control">
<?php <?php
if (!empty($_POST['permission'])) if (!empty($_POST['permission'])) {
{
$permission = $_POST['permission']; $permission = $_POST['permission'];
} } else {
else
{
$permission = 2; $permission = 2;
} }
foreach ($permissions as $key => $value) { foreach ($permissions as $key => $value) {
if ($permission == $key) if ($permission == $key) {
{
echo '<option value="' . $key . '" selected>' . $value . '</option>'; echo '<option value="' . $key . '" selected>' . $value . '</option>';
} } else {
else{
echo '<option value="' . $key . '">' . $value . '</option>'; echo '<option value="' . $key . '">' . $value . '</option>';
} }
} }

View File

@ -1,15 +1,14 @@
<?php <?php
function getToggle($variable){ function getToggle($variable)
{
$res = ((isset($variable) && ($variable == "on")) ? "yes" : "no"); $res = ((isset($variable) && ($variable == "on")) ? "yes" : "no");
return $res; return $res;
} }
if (!file_exists("../config.php")) if (!file_exists("../config.php")) {
{
header("Location: ../"); header("Location: ../");
} } else {
else{
require_once("../config.php"); require_once("../config.php");
require_once("../classes/constellation.php"); require_once("../classes/constellation.php");
require_once("../classes/mailer.php"); require_once("../classes/mailer.php");
@ -96,7 +95,11 @@ else{
Template::render_header(_("Options"), true); Template::render_header(_("Options"), true);
?> ?>
<div class="text-center"> <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> </div>
<form method="post"> <form method="post">
<?php Template::render_toggle("Notify Updates", "nu_toggle", $notifyUpdates_status); ?> <?php Template::render_toggle("Notify Updates", "nu_toggle", $notifyUpdates_status); ?>

View File

@ -1,16 +1,13 @@
<?php <?php
if (isset($_GET['new'])) if (isset($_GET['new'])) {
{
ServiceGroup::add(); ServiceGroup::add();
} }
if (isset($_GET['edit'])) if (isset($_GET['edit'])) {
{
ServiceGroup::edit(); ServiceGroup::edit();
} }
if (isset($_GET['delete'])) if (isset($_GET['delete'])) {
{
ServiceGroup::delete(); ServiceGroup::delete();
} }
@ -41,7 +38,6 @@ Template::render_header(_("New service group"), true); ?>
</div> </div>
<?php <?php
$form_url = WEB_URL . '/admin/?do=new-service-group&amp;new=group'; $form_url = WEB_URL . '/admin/?do=new-service-group&amp;new=group';
} else { } else {
Template::render_header(_("Edit service group"), true); ?> Template::render_header(_("Edit service group"), true); ?>
<div class="text-center"> <div class="text-center">
@ -49,13 +45,11 @@ $form_url = WEB_URL .'/admin/?do=new-service-group&amp;new=group';
</div> </div>
<?php <?php
$form_url = WEB_URL . '/admin/?do=edit-service-group&amp;edit&amp;id=' . $group_id; $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"> <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> <p class="alert alert-danger"><?php echo $message ?></p>
<?php <?php
} ?> } ?>
@ -68,21 +62,16 @@ $form_url = WEB_URL .'/admin/?do=new-service-group&amp;new=group';
<label for="visibility_id"><?php echo _("Visibility"); ?>: </label> <label for="visibility_id"><?php echo _("Visibility"); ?>: </label>
<select name="visibility_id" id="visibility_id" class="form-control"> <select name="visibility_id" id="visibility_id" class="form-control">
<?php <?php
if (!empty($visibility_id_value)) if (!empty($visibility_id_value)) {
{
$visibility_id = $visibility_id_value; $visibility_id = $visibility_id_value;
} } else {
else
{
$visibility_id = null; $visibility_id = null;
} }
//$visibilitys = Service::get_groups(); //$visibilitys = Service::get_groups();
foreach ($visibility as $key => $value) { foreach ($visibility as $key => $value) {
if ($visibility_id == $key) if ($visibility_id == $key) {
{
echo '<option value="' . $key . '" selected>' . $value . '</option>'; echo '<option value="' . $key . '" selected>' . $value . '</option>';
} } else {
else{
echo '<option value="' . $key . '">' . $value . '</option>'; echo '<option value="' . $key . '">' . $value . '</option>';
} }
} }

View File

@ -1,11 +1,9 @@
<?php <?php
if (isset($_GET['new'])) if (isset($_GET['new'])) {
{
Service::add(); Service::add();
} }
if (isset($_GET['edit'])) if (isset($_GET['edit'])) {
{
Service::edit(); Service::edit();
} }
@ -52,8 +50,7 @@ $form_url = WEB_URL . '/admin/?do=new-service&amp;new=service';
} }
?> ?>
<form action="<?php echo $form_url; ?>" method="POST" class="form-horizontal"> <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> <p class="alert alert-danger"><?php echo $message ?></p>
<?php <?php
} ?> } ?>
@ -66,21 +63,16 @@ $form_url = WEB_URL . '/admin/?do=new-service&amp;new=service';
<label for="group_id"><?php echo _("Service Group"); ?>: </label> <label for="group_id"><?php echo _("Service Group"); ?>: </label>
<select name="group_id" id="group_id" class="form-control"> <select name="group_id" id="group_id" class="form-control">
<?php <?php
if (!empty($group_id_value)) if (!empty($group_id_value)) {
{
$group_id = $group_id_value; $group_id = $group_id_value;
} } else {
else
{
$group_id = null; $group_id = null;
} }
$groups = ServiceGroup::get_groups(); $groups = ServiceGroup::get_groups();
foreach ($groups as $key => $value) { foreach ($groups as $key => $value) {
if ($group_id == $key) if ($group_id == $key) {
{
echo '<option value="' . $key . '" selected>' . $value . '</option>'; echo '<option value="' . $key . '" selected>' . $value . '</option>';
} } else {
else{
echo '<option value="' . $key . '">' . $value . '</option>'; echo '<option value="' . $key . '">' . $value . '</option>';
} }
} }

View File

@ -1,10 +1,8 @@
<?php <?php
if (isset($_GET['delete']) && isset($_GET['type'])) if (isset($_GET['delete']) && isset($_GET['type'])) {
{
if ($_GET['type'] == 'service') { if ($_GET['type'] == 'service') {
Service::delete(); Service::delete();
} } elseif ($_GET['type'] == 'groups') {
elseif ( $_GET['type'] == 'groups') {
ServiceGroup::delete(); ServiceGroup::delete();
} }
} }
@ -31,13 +29,13 @@ if (isset($message)){
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
<thead><tr> <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 _("Name"); ?></th>
<th scope="col"><?php echo _("Description"); ?></th> <th scope="col"><?php echo _("Description"); ?></th>
<th scope="col"><?php echo _("Group"); ?></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> <th scope="col"><?php echo _("Delete"); ?></th>
<?php } ?> <?php } ?>
</tr> </tr>
@ -45,16 +43,14 @@ if (isset($message)){
<tbody> <tbody>
<?php <?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"); $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 "<tr>";
//echo "<td>".$result['id']."</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><a href="' . WEB_URL . '/admin?do=edit-service&id=' . $result['id'] . '">' . $result['name'] . '</a></th>';
echo "<td>" . $result['description'] . "</td>"; echo "<td>" . $result['description'] . "</td>";
echo "<td>" . $result['group_name'] . "</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 '<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>"; echo "</tr>";
@ -76,14 +72,14 @@ if (isset($message)){
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">
<thead><tr> <thead>
<tr>
<!--<th scope="col"><?php echo _("ID"); ?></th>--> <!--<th scope="col"><?php echo _("ID"); ?></th>-->
<th scope="col"><?php echo _("Group Name"); ?></th> <th scope="col"><?php echo _("Group Name"); ?></th>
<th scope="col"><?php echo _("In use by"); ?></th> <th scope="col"><?php echo _("In use by"); ?></th>
<th scope="col"><?php echo _("Description"); ?></th> <th scope="col"><?php echo _("Description"); ?></th>
<th scope="col"><?php echo _("Visibility"); ?></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> <th scope="col"><?php echo _("Delete"); ?></th>
<?php } ?> <?php } ?>
</tr> </tr>
@ -91,8 +87,7 @@ if (isset($message)){
<tbody> <tbody>
<?php <?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"); $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 "<tr>";
//echo "<td>".$result['id']."</td>"; //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><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>" . $result['description'] . "</td>";
echo "<td>" . $visibility[$result['visibility']] . "</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 '<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>"; echo "</tr>";
@ -118,12 +112,21 @@ if (isset($message)){
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <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> <tbody>
<?php <?php
$query = $mysqli->query("SELECT * FROM users"); $query = $mysqli->query("SELECT * FROM users");
while($result = $query->fetch_assoc()) while ($result = $query->fetch_assoc()) {
{
echo "<tr>"; echo "<tr>";
echo "<td>" . $result['id'] . "</td>"; echo "<td>" . $result['id'] . "</td>";
echo "<td><a href='" . WEB_URL . "/admin/?do=user&id=" . $result['id'] . "'>" . $result['username'] . "</a></td>"; echo "<td><a href='" . WEB_URL . "/admin/?do=user&id=" . $result['id'] . "'>" . $result['username'] . "</a></td>";

View File

@ -1,7 +1,6 @@
<?php <?php
$id = $_SESSION['user']; $id = $_SESSION['user'];
if (isset($_GET['id'])) if (isset($_GET['id'])) {
{
$id = $_GET['id']; $id = $_GET['id'];
} }
try { try {
@ -11,34 +10,28 @@ try {
} }
if (isset($_POST['password'])) if (isset($_POST['password'])) {
{
$displayed_user->change_password(); $displayed_user->change_password();
} }
if (isset($_POST['username'])) if (isset($_POST['username'])) {
{
$displayed_user->change_username(); $displayed_user->change_username();
} }
if (isset($_POST['name'])) if (isset($_POST['name'])) {
{
$displayed_user->change_name(); $displayed_user->change_name();
} }
if (isset($_POST['email'])) if (isset($_POST['email'])) {
{
$success = $displayed_user->email_link(); $success = $displayed_user->email_link();
} }
if (isset($_POST['permission'])) if (isset($_POST['permission'])) {
{
$displayed_user->change_permission(); $displayed_user->change_permission();
} }
if (isset($_GET['what']) && $_GET['what']=='toggle') if (isset($_GET['what']) && $_GET['what'] == 'toggle') {
{
$displayed_user->toggle(); $displayed_user->toggle();
} }
@ -47,8 +40,7 @@ Template::render_header(_("User"), true);
?> ?>
<div class="text-center"> <div class="text-center">
<h1><?php <h1><?php
if ($_SESSION['user'] == $_GET['id']) if ($_SESSION['user'] == $_GET['id']) {
{
echo _("User settings"); echo _("User settings");
} else { } else {
echo _("User"); echo _("User");

View File

@ -1,10 +1,8 @@
<?php <?php
if (!file_exists("../config.php")) if (!file_exists("../config.php")) {
{
header("Location: ../"); header("Location: ../");
} } else {
else{
require_once("../config.php"); require_once("../config.php");
require_once("../classes/constellation.php"); require_once("../classes/constellation.php");

View File

@ -1,17 +1,14 @@
<?php <?php
if (!file_exists("../config.php")) if (!file_exists("../config.php")) {
{
header("Location: ../"); header("Location: ../");
} } else {
else{
require_once("../config.php"); require_once("../config.php");
require_once("../classes/constellation.php"); require_once("../classes/constellation.php");
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
header('Content-type: application/json'); header('Content-type: application/json');
if (!isset($_GET['id'])) if (!isset($_GET['id'])) {
{
$array = $constellation->render_status(true, false); $array = $constellation->render_status(true, false);
echo json_encode($array); echo json_encode($array);
} else { } else {
@ -19,8 +16,7 @@ else{
$query->bind_param("i", $_GET['id']); $query->bind_param("i", $_GET['id']);
$query->execute(); $query->execute();
$result = $query->get_result()->fetch_assoc(); $result = $query->get_result()->fetch_assoc();
if (!count($result)) if (!count($result)) {
{
die(json_encode(["error" => _("Service does not exist!")])); die(json_encode(["error" => _("Service does not exist!")]));
} }
@ -29,11 +25,9 @@ else{
$sql->bind_param("iii", $id, $timestamp, $timestamp); $sql->bind_param("iii", $id, $timestamp, $timestamp);
$sql->execute(); $sql->execute();
$tmp = $sql->get_result(); $tmp = $sql->get_result();
if ($tmp->num_rows) if ($tmp->num_rows) {
{
$service = new Service($_GET['id'], $result['name'], $tmp->fetch_assoc()['type']); $service = new Service($_GET['id'], $result['name'], $tmp->fetch_assoc()['type']);
} } else {
else{
$service = new Service($_GET['id'], $result['name']); $service = new Service($_GET['id'], $result['name']);
} }

View File

@ -18,9 +18,9 @@ class Constellation
* @param int $limit - limits the number of incidents rendered * @param int $limit - limits the number of incidents rendered
* @param Boolean $admin - specifies whether to render admin controls * @param Boolean $admin - specifies whether to render admin controls
*/ */
public function render_incidents($future=false, $offset=0, $limit = 5, $admin = 0){ public function render_incidents($future = false, $offset = 0, $limit = 5, $admin = 0)
if ($offset<0)
{ {
if ($offset < 0) {
$offset = 0; $offset = 0;
} }
@ -32,20 +32,14 @@ class Constellation
$ajax = isset($_GET['ajax']); $ajax = isset($_GET['ajax']);
if ($future && count($incidents["incidents"]) && !$ajax) if ($future && count($incidents["incidents"]) && !$ajax) {
{
echo "<h3>" . _("Planned maintenance") . "</h3>"; echo "<h3>" . _("Planned maintenance") . "</h3>";
} } else if (count($incidents["incidents"]) && !$ajax) {
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>'; echo '<noscript><div class="centered"><a href="' . WEB_URL . '/?offset=' . ($offset - $limit) . '&timestamp=' . $timestamp . '" class="btn btn-default">' . _("Back") . '</a></div></noscript>';
} }
echo "<h3>" . _("Past incidents") . "</h3>"; echo "<h3>" . _("Past incidents") . "</h3>";
} } else if (!$future && !$ajax) {
else if (!$future &&!$ajax)
{
echo "<h3>" . _("No incidents") . "</h3>"; echo "<h3>" . _("No incidents") . "</h3>";
} }
$show = !$future && $incidents["more"]; $show = !$future && $incidents["more"];
@ -57,8 +51,7 @@ class Constellation
$incident->render($admin); $incident->render($admin);
} }
if ($show) if ($show) {
{
echo '<div class="centered"><a href="' . WEB_URL . '/?offset=' . ($offset) . '&timestamp=' . $timestamp . '" id="loadmore" class="btn btn-default">' . _("Load more") . '</a></div>'; echo '<div class="centered"><a href="' . WEB_URL . '/?offset=' . ($offset) . '&timestamp=' . $timestamp . '" id="loadmore" class="btn btn-default">' . _("Load more") . '</a></div>';
} }
} }
@ -69,7 +62,8 @@ class Constellation
* @param boolean $admin * @param boolean $admin
* @return array of services * @return array of services
*/ */
public function render_status($admin = false, $heading = true){ public function render_status($admin = false, $heading = true)
{
global $mysqli; global $mysqli;
//$query = $mysqli->query("SELECT id, name, description FROM services"); //$query = $mysqli->query("SELECT id, name, description FROM services");
@ -78,32 +72,26 @@ class Constellation
if ($query->num_rows) { if ($query->num_rows) {
$timestamp = time(); $timestamp = time();
while($result = $query->fetch_assoc()) while ($result = $query->fetch_assoc()) {
{
$id = $result['id']; $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 = $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->bind_param("iii", $id, $timestamp, $timestamp);
$sql->execute(); $sql->execute();
$tmp = $sql->get_result(); $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']); $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']); $array[] = new Service($result['id'], $result['name'], $result['description'], $result['group_name']);
} }
} }
if ($heading) if ($heading) {
{
echo Service::current_status($array); echo Service::current_status($array);
} }
} } else {
else{
$array[] = new Service(0, _("No services"), -1); $array[] = new Service(0, _("No services"), -1);
} }
if (!$admin) if (!$admin) {
{
?> ?>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
@ -125,17 +113,16 @@ class Constellation
} }
echo '</ul>'; echo '</ul>';
//echo '</div>'; //echo '</div>';
} } else {
else{
return $array; return $array;
} }
} }
function get_incidents($future = false, $offset = 0, $limit = 5, $timestamp = 0){ function get_incidents($future = false, $offset = 0, $limit = 5, $timestamp = 0)
global $mysqli;
if ($timestamp == 0)
{ {
global $mysqli;
if ($timestamp == 0) {
$timestamp = time(); $timestamp = time();
} }
@ -152,8 +139,7 @@ class Constellation
$more = true; $more = true;
} }
if ($query->num_rows) { 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 // Add service id and service names to an array in the Incident class
$stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services $stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services
INNER JOIN services_status ON services.id = services_status.service_id INNER JOIN services_status ON services.id = services_status.service_id
@ -206,7 +192,6 @@ class Constellation
if ($show_link) { if ($show_link) {
echo '<div class="clearfix"><a href="' . $url . '" class="btn btn-success" role="button">' . $link_text . '</a></div>'; echo '<div class="clearfix"><a href="' . $url . '" class="btn btn-success" role="button">' . $link_text . '</a></div>';
} }
} }
} }

View File

@ -3,14 +3,16 @@
class SSDB class SSDB
{ {
function execute($conn,$sql){ function execute($conn, $sql)
{
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
return true; return true;
} else { } else {
return $conn->error; return $conn->error;
} }
} }
function getSetting($conn,$setting){ function getSetting($conn, $setting)
{
$sql = "SELECT value FROM settings WHERE setting='" . $setting . "'"; $sql = "SELECT value FROM settings WHERE setting='" . $setting . "'";
$result = $conn->query($sql); $result = $conn->query($sql);
@ -22,31 +24,33 @@ class SSDB
return "null"; return "null";
} }
} }
function setSetting($conn,$settingname,$settingvalue){ function setSetting($conn, $settingname, $settingvalue)
{
$sql = "INSERT INTO settings (setting,value) VALUES ('" . $settingname . "','" . $settingvalue . "');"; $sql = "INSERT INTO settings (setting,value) VALUES ('" . $settingname . "','" . $settingvalue . "');";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
return true; return true;
} else { } else {
return $conn->error; return $conn->error;
} }
} }
function deleteSetting($conn,$settingname){ function deleteSetting($conn, $settingname)
{
$sql = "DELETE FROM settings WHERE setting=\"" . $settingname . "\";"; $sql = "DELETE FROM settings WHERE setting=\"" . $settingname . "\";";
if ($conn->query($sql) === TRUE) { if ($conn->query($sql) === TRUE) {
return true; return true;
} else { } else {
return $conn->error; return $conn->error;
} }
} }
function updateSetting($conn, $settingname, $settingvalue){ function updateSetting($conn, $settingname, $settingvalue)
{
$this->deleteSetting($conn, $settingname); $this->deleteSetting($conn, $settingname);
$this->setSetting($conn, $settingname, $settingvalue); $this->setSetting($conn, $settingname, $settingvalue);
return true; return true;
} }
function getBooleanSetting($conn, $setting) { function getBooleanSetting($conn, $setting)
{
if (trim($this->getSetting($conn, $setting)) == "yes") { if (trim($this->getSetting($conn, $setting)) == "yes") {
return true; return true;
} }

View File

@ -46,17 +46,16 @@ class Incident implements JsonSerializable
* Deletes incident by ID. * Deletes incident by ID.
* @param int ID * @param int ID
*/ */
public static function delete($id){ public static function delete($id)
{
global $mysqli, $message, $user; 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 = $mysqli->prepare("SELECT count(*) as count FROM status WHERE id= ? AND user_id = ?");
$stmt->bind_param("ii", $id, $_SESSION['user']); $stmt->bind_param("ii", $id, $_SESSION['user']);
$stmt->execute(); $stmt->execute();
$query = $stmt->get_result(); $query = $stmt->get_result();
if (!$query->fetch_assoc()['count']) if (!$query->fetch_assoc()['count']) {
{
$message = _("You don't have permission to do that!"); $message = _("You don't have permission to do that!");
return; return;
} }
@ -91,8 +90,7 @@ class Incident implements JsonSerializable
$title = strip_tags($_POST['title']); $title = strip_tags($_POST['title']);
$text = strip_tags($_POST['text'], '<br>'); $text = strip_tags($_POST['text'], '<br>');
if (strlen($title)==0) if (strlen($title) == 0) {
{
$message = _("Please enter title"); $message = _("Please enter title");
return; return;
} else if (strlen($title) > 50) { } else if (strlen($title) > 50) {
@ -100,29 +98,22 @@ class Incident implements JsonSerializable
return; return;
} }
if (strlen($title)==0) if (strlen($title) == 0) {
{
$message = _("Please enter text"); $message = _("Please enter text");
return; 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."); $message = _("Please set start and end time! Use ISO 8601 format.");
return; return;
} }
if (empty($_POST['services'])) { if (empty($_POST['services'])) {
$message = _("Please select at least one service"); $message = _("Please select at least one service");
} } else {
else if (!is_array($_POST['services'])) {
{
if (!is_array($_POST['services']))
{
$services = array($_POST['services']); $services = array($_POST['services']);
} } else {
else
{
$services = $_POST['services']; $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']); $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); $end_time = strtotime($input_end_time);
if (!$time) if (!$time) {
{
$message = _("Start date format is not recognized. Please use ISO 8601 format."); $message = _("Start date format is not recognized. Please use ISO 8601 format.");
return; return;
} }
if (!$end_time) if (!$end_time) {
{
$message = _("End date format is not recognized. Please use ISO 8601 format."); $message = _("End date format is not recognized. Please use ISO 8601 format.");
return; return;
} }
if ($time >= $end_time) if ($time >= $end_time) {
{
$message = _("End time is either the same or earlier than start time!"); $message = _("End time is either the same or earlier than start time!");
return; return;
} }
@ -187,7 +175,8 @@ class Incident implements JsonSerializable
* @param Boolean $admin - decides whether admin controls should be rendered * @param Boolean $admin - decides whether admin controls should be rendered
* @return void * @return void
*/ */
public function render($admin=0){ public function render($admin = 0)
{
global $icons; global $icons;
global $classes, $user; global $classes, $user;
$admin = $admin && (($user->get_rank() <= 1) || ($user->get_username() == $this->username)); $admin = $admin && (($user->get_rank() <= 1) || ($user->get_username() == $this->username));
@ -220,7 +209,8 @@ class Incident implements JsonSerializable
<?php <?php
} }
public function jsonSerialize() { public function jsonSerialize()
{
return [ return [
"id" => $this->id, "id" => $this->id,
"date" => $this->timestamp, "date" => $this->timestamp,

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This class is used to negotiate language displayed to user. * This class is used to negotiate language displayed to user.
* Reads browser preferences and chooses the best language from list * 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... * 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; return $this->accepted_langs;
} }
@ -251,7 +253,8 @@ class LocaleNegotiator
* @param String $override adds language to list of preffered languages with highest priority * @param String $override adds language to list of preffered languages with highest priority
* @return String language code that matched best with browser preferences * @return String language code that matched best with browser preferences
*/ */
public function negotiate($override = null){ public function negotiate($override = null)
{
$langs = []; $langs = [];
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
@ -266,8 +269,7 @@ class LocaleNegotiator
if ($val === '') $langs[$lang] = 1; if ($val === '') $langs[$lang] = 1;
} }
if (isset($override)) if (isset($override)) {
{
//More important than the best lang of browser //More important than the best lang of browser
$langs[$override] = 2; $langs[$override] = 2;
} }
@ -312,4 +314,3 @@ class LocaleNegotiator
return $best_match; return $best_match;
} }
} }

View File

@ -15,10 +15,11 @@ if (file_exists("libs/php_idn/idna.php")) {
require_once("../libs/php_idn/idna.php"); require_once("../libs/php_idn/idna.php");
} }
class Mailer { class Mailer
{
public function __construct(){
public function __construct()
{
} }
/** /**
@ -28,7 +29,8 @@ class Mailer {
* @param boolean $html Set to true if we are sending HTML Mailer * @param boolean $html Set to true if we are sending HTML Mailer
* @return boolean True if success * @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 // 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.. // to call the entire send_mail function over and over..
@ -90,7 +92,6 @@ class Mailer {
return false; return false;
} }
return true; return true;
} else { } else {
// Use standard PHP mail() function // Use standard PHP mail() function
$headers = "Content-Type: $content_type; \"charset=utf-8\" " . PHP_EOL; $headers = "Content-Type: $content_type; \"charset=utf-8\" " . PHP_EOL;
@ -102,7 +103,6 @@ class Mailer {
// TODO log error message if mail fails // TODO log error message if mail fails
return true; return true;
} }
} }
/** /**
* Tries to verify the domain using dns request against an MX record of the domain part * 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 * @param String $email Email address to check
* @return boolean True if MX record exits, false if otherwise * @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. // TODO - Handle idn/punycode domain names without being dependent on PHP native libs.
$domain = explode('@', $email); $domain = explode('@', $email);
$domain = EncodePunycodeIDN(array_pop($domain) . '.'); // Add dot at end of domain to avoid local domain lookups $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 * @param boolean $remove_links Set to true if links should be removed from email
* @return String pain text version * @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. // TODO does not handle unsubscribe/manage subscription text very well.
// Replace HTML line breaks with text line breaks // Replace HTML line breaks with text line breaks
$plain_text = str_ireplace(array("<br>", "<br />"), "\n\r", $content); $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 // 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', '@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu', '@<script[^>]*?.*?</script>@siu',
'@<noscript[^>]*?.*?</noscript>@siu', '@<noscript[^>]*?.*?</noscript>@siu',
@ -170,5 +173,4 @@ class Mailer {
return $plain_text; return $plain_text;
} }
} }

View File

@ -103,9 +103,7 @@ class Notification
if ($typeID == 2 && SUBSCRIBE_EMAIL) { if ($typeID == 2 && SUBSCRIBE_EMAIL) {
$arr_email[] = $subscriber['subscriberIDFK']; $arr_email[] = $subscriber['subscriberIDFK'];
} }
} }
} }
if (SUBSCRIBE_TELEGRAM) { if (SUBSCRIBE_TELEGRAM) {
@ -138,7 +136,6 @@ class Notification
if (!is_array($response) || !array_key_exists("ok", $response) || $response['ok'] != 1) { if (!is_array($response) || !array_key_exists("ok", $response) || $response['ok'] != 1) {
return false; return false;
} }
return true; return true;
} }
@ -160,7 +157,8 @@ class Notification
return true; return true;
} }
public function prepare_email(){ public function prepare_email()
{
$Parsedown = new Parsedown(); $Parsedown = new Parsedown();
$str_mail = file_get_contents("../libs/templates/email_status_update.html"); $str_mail = file_get_contents("../libs/templates/email_status_update.html");
@ -189,7 +187,8 @@ class Notification
return $val; 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>"); $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); $val['body'] = sprintf($msg, $this->servicenames, $this->status, $this->title, $this->text, WEB_URL);
return $val; return $val;

View File

@ -14,22 +14,26 @@ class Queue
public $completed_time; public $completed_time;
public $num_errors; public $num_errors;
public $user_id; public $user_id;
public $all_type_id = array('notify_telegram' => 1, public $all_type_id = array(
'notify_email' => 2); 'notify_telegram' => 1,
'notify_email' => 2
);
public $all_status = array('populating' => 1, public $all_status = array(
'populating' => 1,
'ready' => 2, 'ready' => 2,
'processing' => 3, 'processing' => 3,
'completed' => 4, 'completed' => 4,
'failed' => 5); 'failed' => 5
);
public function add_task() { public function add_task()
{
global $mysqli; global $mysqli;
$stmt = $mysqli->prepare("INSERT INTO queue_task (type_id, status, template_data1, template_data2, created_time, user_id) VALUES (?,?,?,?,?,?)"); $stmt = $mysqli->prepare("INSERT INTO queue_task (type_id, status, template_data1, template_data2, created_time, user_id) VALUES (?,?,?,?,?,?)");
if (false === $stmt) { if (false === $stmt) {
//die('prepare() failed: ' . htmlspecialchars($mysqli->error)); //die('prepare() failed: ' . htmlspecialchars($mysqli->error));
echo $mysqli->errno(); echo $mysqli->errno();
} }
#if ( false === $stmt ) { syslog(1, "Error :". $mysqli->error); } #if ( false === $stmt ) { syslog(1, "Error :". $mysqli->error); }
$now = time(); $now = time();
@ -49,7 +53,8 @@ class Queue
* Remove task from the queue * Remove task from the queue
* @return void * @return void
*/ */
public function delete_task($task_id){ public function delete_task($task_id)
{
global $mysqli; global $mysqli;
$stmt = $mysqli->prepare("DELETE FROM queue_task WHERE id = ?"); $stmt = $mysqli->prepare("DELETE FROM queue_task WHERE id = ?");
$stmt->bind_param("i", $task_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. * @param int $new_status The new current status of the task. Must be selected from the $all_status array.
* @return void * @return void
*/ */
public function set_task_status($new_status) { public function set_task_status($new_status)
{
global $mysqli; global $mysqli;
$stmt = $mysqli->prepare("UPDATE queue_task SET status = ? WHERE id = ?"); $stmt = $mysqli->prepare("UPDATE queue_task SET status = ? WHERE id = ?");
$stmt->bind_param("ii", $new_status, $this->task_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 * @param array $arr_data Array filled with subscriber_id
* @return void * @return void
*/ */
public function add_notification($arr_data) { public function add_notification($arr_data)
{
global $mysqli; global $mysqli;
//Default status = 1, retres = 0, task_id = $this->task_id //Default status = 1, retres = 0, task_id = $this->task_id
@ -88,7 +95,9 @@ class Queue
foreach ($arr_data as $value) { foreach ($arr_data as $value) {
$counter++; $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); $query .= sprintf($sub_query, $this->task_id, 1, $value, 0, $seperator);
} }
$sql = "INSERT INTO queue_notify (task_id, status, subscriber_id, retries) VALUES " . $query; $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 $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; global $mysqli;
$stmt = $mysqli->prepare("UPDATE queue_notify SET retries = retries+1 WHERE task_id = ? AND subscriber_id = ?"); $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->bind_param("ii", $task_id, $subscriber_id);
$stmt->execute(); $stmt->execute();
} }
public function delete_notification($task_id, $subscriber_id) { public function delete_notification($task_id, $subscriber_id)
{
global $mysqli; global $mysqli;
$stmt = $mysqli->prepare("DELETE FROM queue_notify WHERE task_id = ? AND subscriber_id = ?"); $stmt = $mysqli->prepare("DELETE FROM queue_notify WHERE task_id = ? AND subscriber_id = ?");
$stmt->bind_param("ii", $task_id, $subscriber_id); $stmt->bind_param("ii", $task_id, $subscriber_id);
$stmt->execute(); $stmt->execute();
} }
// TODO: Fix max attempts for notifications // TODO: Fix max attempts for notifications
public function process_queue(){ public function process_queue()
{
global $mysqli; 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"); $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()) { while ($result = $stmt->fetch_assoc()) {
@ -156,6 +167,5 @@ class Queue
Queue::delete_task($result['id']); Queue::delete_task($result['id']);
} }
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Class for managing services * Class for managing services
*/ */
@ -63,8 +64,7 @@ class ServiceGroup
public static function add() public static function add()
{ {
global $user, $message; global $user, $message;
if (strlen($_POST['group'])>50) if (strlen($_POST['group']) > 50) {
{
$message = _("Service group name is too long! Character limit is 50"); $message = _("Service group name is too long! Character limit is 50");
return; return;
} else if (strlen(trim($_POST['group'])) == 0) { } else if (strlen(trim($_POST['group'])) == 0) {
@ -72,8 +72,7 @@ class ServiceGroup
return; return;
} }
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$name = $_POST["group"]; $name = $_POST["group"];
$description = $_POST["description"]; $description = $_POST["description"];
@ -83,8 +82,7 @@ class ServiceGroup
$stmt->execute(); $stmt->execute();
$stmt->get_result(); $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
}else } else {
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -92,8 +90,7 @@ class ServiceGroup
public static function edit() public static function edit()
{ {
global $user, $message; global $user, $message;
if (strlen($_POST['group'])>50) if (strlen($_POST['group']) > 50) {
{
$message = _("Service group name is too long! Character limit is 50"); $message = _("Service group name is too long! Character limit is 50");
return; return;
} else if (strlen(trim($_POST['group'])) == 0) { } else if (strlen(trim($_POST['group'])) == 0) {
@ -101,8 +98,7 @@ class ServiceGroup
return; return;
} }
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$name = $_POST["group"]; $name = $_POST["group"];
$description = $_POST["description"]; $description = $_POST["description"];
@ -113,8 +109,7 @@ class ServiceGroup
$stmt->execute(); $stmt->execute();
$stmt->get_result(); $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
}else } else {
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -125,8 +120,7 @@ class ServiceGroup
public static function delete() public static function delete()
{ {
global $user, $message; global $user, $message;
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$id = $_GET['delete']; $id = $_GET['delete'];
@ -141,9 +135,7 @@ class ServiceGroup
$query = $stmt->get_result(); $query = $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
} } else {
else
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -153,7 +145,8 @@ class ServiceGroup
* Get list of services groups. * Get list of services groups.
* @return array $groups * @return array $groups
*/ */
public function get_groups() { public function get_groups()
{
global $mysqli; global $mysqli;
$stmt = $mysqli->query("SELECT id, name FROM services_groups ORDER by name ASC"); $stmt = $mysqli->query("SELECT id, name FROM services_groups ORDER by name ASC");

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Class for managing services * Class for managing services
*/ */
@ -72,8 +73,7 @@ class Service implements JsonSerializable
public static function add() public static function add()
{ {
global $user, $message; global $user, $message;
if (strlen($_POST['service'])>50) if (strlen($_POST['service']) > 50) {
{
$message = _("Service name is too long! Character limit is 50"); $message = _("Service name is too long! Character limit is 50");
return; return;
} else if (strlen(trim($_POST['service'])) == 0) { } else if (strlen(trim($_POST['service'])) == 0) {
@ -81,8 +81,7 @@ class Service implements JsonSerializable
return; return;
} }
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$name = htmlspecialchars($_POST['service']); $name = htmlspecialchars($_POST['service']);
$description = htmlspecialchars($_POST['description']); $description = htmlspecialchars($_POST['description']);
@ -92,8 +91,7 @@ class Service implements JsonSerializable
$stmt->execute(); $stmt->execute();
$stmt->get_result(); $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
}else } else {
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -106,8 +104,7 @@ class Service implements JsonSerializable
public static function edit() public static function edit()
{ {
global $user, $message; global $user, $message;
if (strlen($_POST['service'])>50) if (strlen($_POST['service']) > 50) {
{
$message = _("Service name is too long! Character limit is 50"); $message = _("Service name is too long! Character limit is 50");
return; return;
} else if (strlen(trim($_POST['service'])) == 0) { } else if (strlen(trim($_POST['service'])) == 0) {
@ -115,8 +112,7 @@ class Service implements JsonSerializable
return; return;
} }
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$service_id = $_POST["id"]; $service_id = $_POST["id"];
$name = htmlspecialchars($_POST['service']); $name = htmlspecialchars($_POST['service']);
@ -127,8 +123,7 @@ class Service implements JsonSerializable
$stmt->execute(); $stmt->execute();
$stmt->get_result(); $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
}else } else {
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -140,8 +135,7 @@ class Service implements JsonSerializable
public static function delete() public static function delete()
{ {
global $user, $message; global $user, $message;
if ($user->get_rank()<=1) if ($user->get_rank() <= 1) {
{
global $mysqli; global $mysqli;
$id = $_GET['delete']; $id = $_GET['delete'];
@ -151,8 +145,7 @@ class Service implements JsonSerializable
$query = $stmt->get_result(); $query = $stmt->get_result();
while ($res = $query->fetch_assoc()) { while ($res = $query->fetch_assoc()) {
if ($res['count']==1) if ($res['count'] == 1) {
{
Incident::delete($res['status']); Incident::delete($res['status']);
} }
} }
@ -168,9 +161,7 @@ class Service implements JsonSerializable
$query = $stmt->get_result(); $query = $stmt->get_result();
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
} } else {
else
{
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -180,14 +171,14 @@ class Service implements JsonSerializable
* @param Service[] $array array of services * @param Service[] $array array of services
* @return void * @return void
*/ */
public static function current_status($array){ public static function current_status($array)
{
global $all, $some, $classes; global $all, $some, $classes;
$statuses = array(0, 0, 0, 0); $statuses = array(0, 0, 0, 0);
$worst = 5; $worst = 5;
foreach ($array as $service) { foreach ($array as $service) {
if ($service->status<$worst) if ($service->status < $worst) {
{
$worst = $service->get_status(); $worst = $service->get_status();
} }
$statuses[$service->get_status()]++; $statuses[$service->get_status()]++;
@ -195,8 +186,7 @@ class Service implements JsonSerializable
echo '<div id="status-big" class="alert-' . $classes[$worst] . '">'; echo '<div id="status-big" class="alert-' . $classes[$worst] . '">';
if ($statuses[$worst] == count($array)) if ($statuses[$worst] == count($array)) {
{
echo $all[$worst]; echo $all[$worst];
} else { } else {
echo $some[$worst]; echo $some[$worst];
@ -209,7 +199,8 @@ class Service implements JsonSerializable
* @param $boolGroup set to true if the groups name is to be rendered * @param $boolGroup set to true if the groups name is to be rendered
* @return void * @return void
*/ */
public function render(){ public function render()
{
global $statuses; global $statuses;
global $classes; global $classes;
static $arrCompletedGroups = array(); static $arrCompletedGroups = array();
@ -260,7 +251,8 @@ class Service implements JsonSerializable
echo '</div>'; echo '</div>';
} }
public function jsonSerialize() { public function jsonSerialize()
{
global $statuses; global $statuses;
return [ return [
"id" => $this->id, "id" => $this->id,
@ -270,5 +262,4 @@ class Service implements JsonSerializable
"status_string" => $statuses[$this->status] "status_string" => $statuses[$this->status]
]; ];
} }
} }

View File

@ -4,7 +4,7 @@
* Subscriber class * Subscriber class
* *
*/ */
Class Subscriber class Subscriber
{ {
public $id = null; public $id = null;
public $firstname = null; public $firstname = null;
@ -15,7 +15,8 @@ Class Subscriber
public $typeID = null; // Holds subscription type ID public $typeID = null; // Holds subscription type ID
function __construct() { function __construct()
{
$this->firstname = null; $this->firstname = null;
$this->lastname = null; $this->lastname = null;
$this->userID = ""; $this->userID = "";
@ -44,7 +45,6 @@ Class Subscriber
return $row['token']; return $row['token'];
} }
return false; return false;
} }
public function get_subscriber_by_token($token) public function get_subscriber_by_token($token)
{ {
@ -135,7 +135,6 @@ Class Subscriber
$stmt->bind_param("ii", $updateTime, $subscriberID); $stmt->bind_param("ii", $updateTime, $subscriberID);
$stmt->execute(); $stmt->execute();
return true; return true;
} }
public function activate($subscriberID) public function activate($subscriberID)
@ -164,7 +163,6 @@ Class Subscriber
$stmt->execute(); $stmt->execute();
//$query = $stmt->get_result(); //$query = $stmt->get_result();
return true; return true;
} }
public function check_userid_exist() public function check_userid_exist()
@ -223,7 +221,6 @@ Class Subscriber
$this->userID = $row['userID']; $this->userID = $row['userID'];
$this->token = $row['token']; $this->token = $row['token'];
return true; return true;
} else { } else {
// Timeframe outside of given scope -> delete account // Timeframe outside of given scope -> delete account
$stmt2 = $mysqli->prepare("DELETE FROM subscribers WHERE subscriberID = ?"); $stmt2 = $mysqli->prepare("DELETE FROM subscribers WHERE subscriberID = ?");
@ -325,5 +322,4 @@ Class Subscriber
unset($_SESSION['subscriber_id']); unset($_SESSION['subscriber_id']);
unset($_SESSION['subscriber_token']); unset($_SESSION['subscriber_token']);
} }
} }

View File

@ -4,7 +4,7 @@
* Subscriptions class * Subscriptions class
* *
*/ */
Class Subscriptions class Subscriptions
{ {
public function add($userID, $service) public function add($userID, $service)
{ {
@ -41,14 +41,17 @@ Class Subscriptions
$query = $stmt->get_result(); $query = $stmt->get_result();
$strNotifyType = _('E-mail Notification subscription'); $strNotifyType = _('E-mail Notification subscription');
if ( $typeID == 1 ) { $strNotifyType = _('Telegram Notification subscription'); } if ($typeID == 1) {
$strNotifyType = _('Telegram Notification subscription');
}
?> ?>
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-offset-2 col-lg-8"> <div class="col-xs-12 col-lg-offset-2 col-lg-8">
<div class="text-center"> <div class="text-center">
<h3><?php echo $strNotifyType; ?></h3> <h3><?php echo $strNotifyType; ?></h3>
<p><?php echo _("Manage notification subscription for"); echo "&nbsp". $userID; ?></p> <p><?php echo _("Manage notification subscription for");
echo "&nbsp" . $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&amp;type=<?php echo $typeID; ?>&amp;token=<?php echo $token; ?>"><button class="btn btn-danger"><?php echo _("Cancel Subscription"); ?></button></a> <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&amp;type=<?php echo $typeID; ?>&amp;token=<?php echo $token; ?>"><button class="btn btn-danger"><?php echo _("Cancel Subscription"); ?></button></a>
</div> </div>
</div> </div>
@ -60,12 +63,10 @@ Class Subscriptions
$subs = array(); // Will be used to hold IDs of services already selected $subs = array(); // Will be used to hold IDs of services already selected
if ($query->num_rows) { 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>&nbsp;' . $result['name'] . '</a>'; echo '<a href="' . WEB_URL . '/subscriptions.php?remove=' . $result['id'] . '" class="list-group-item"><span class="glyphicon glyphicon-remove text-danger"></span>&nbsp;' . $result['name'] . '</a>';
$subs[] = $result['id']; $subs[] = $result['id'];
} }
} else { } else {
echo '<div class="container"><summary>' . _("You do not currently subscribe to any services. Please add services from the list below.") . '</summary></div>'; 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>'; echo '</div>';
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
Class Telegram class Telegram
{ {
/** /**
@ -14,7 +14,8 @@ Class Telegram
* *
* @since 0.1 * @since 0.1
*/ */
function getTelegramUserData() { function getTelegramUserData()
{
if (isset($_COOKIE['tg_user'])) { if (isset($_COOKIE['tg_user'])) {
$auth_data_json = urldecode($_COOKIE['tg_user']); $auth_data_json = urldecode($_COOKIE['tg_user']);
$auth_data = json_decode($auth_data_json, true); $auth_data = json_decode($auth_data_json, true);
@ -32,7 +33,8 @@ Class Telegram
* @return $auth_data * @return $auth_data
* *
*/ */
function checkTelegramAuthorization($auth_data) { function checkTelegramAuthorization($auth_data)
{
$check_hash = $auth_data['hash']; $check_hash = $auth_data['hash'];
unset($auth_data['hash']); unset($auth_data['hash']);
$data_check_arr = []; $data_check_arr = [];
@ -60,7 +62,8 @@ Class Telegram
* Save the telegram user data in a cookie * Save the telegram user data in a cookie
* @return void * @return void
*/ */
function saveTelegramUserData($auth_data) { function saveTelegramUserData($auth_data)
{
$auth_data_json = json_encode($auth_data); $auth_data_json = json_encode($auth_data);
setcookie('tg_user', $auth_data_json); setcookie('tg_user', $auth_data_json);
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Class for creating and deleting tokens * Class for creating and deleting tokens
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Class that encapsulates everything that can be done with a user * Class that encapsulates everything that can be done with a user
*/ */
@ -24,8 +25,7 @@ class User
$stmt->execute(); $stmt->execute();
$query = $stmt->get_result(); $query = $stmt->get_result();
if (!$query->num_rows) if (!$query->num_rows) {
{
throw new Exception("User doesn't exist."); throw new Exception("User doesn't exist.");
return; return;
} }
@ -86,8 +86,7 @@ class User
global $mysqli, $message, $user; global $mysqli, $message, $user;
$id = $_GET['id']; $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 = $mysqli->prepare("UPDATE users SET active = !active WHERE id=?");
$stmt->bind_param("i", $this->id); $stmt->bind_param("i", $this->id);
$stmt->execute(); $stmt->execute();
@ -108,8 +107,7 @@ class User
public static function add() public static function add()
{ {
global $user, $message, $mysqli; global $user, $message, $mysqli;
if (INSTALL_OVERRIDE || $user->get_rank()==0) if (INSTALL_OVERRIDE || $user->get_rank() == 0) {
{
if (strlen(trim($_POST['name'])) == 0) { if (strlen(trim($_POST['name'])) == 0) {
$messages[] = _("Name"); $messages[] = _("Name");
} }
@ -122,8 +120,7 @@ class User
if (strlen(trim($_POST['password'])) == 0) { if (strlen(trim($_POST['password'])) == 0) {
$messages[] = _("Password"); $messages[] = _("Password");
} }
if(!isset($_POST['permission'])) if (!isset($_POST['permission'])) {
{
$messages[] = _("Rank"); $messages[] = _("Rank");
} }
@ -138,8 +135,7 @@ class User
$email = $_POST['email']; $email = $_POST['email'];
$pass = $_POST['password']; $pass = $_POST['password'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
{
$message = "Invalid email!"; $message = "Invalid email!";
return; return;
} }
@ -159,8 +155,7 @@ class User
} }
if (!empty($variables)) if (!empty($variables)) {
{
$message = _("Please mind the following character limits: "); $message = _("Please mind the following character limits: ");
$message .= implode(", ", $variables); $message .= implode(", ", $variables);
return; return;
@ -175,8 +170,7 @@ class User
$stmt->bind_param("ssssssi", $email, $username, $name, $surname, $hash, $salt, $permission); $stmt->bind_param("ssssssi", $email, $username, $name, $surname, $hash, $salt, $permission);
$stmt->execute(); $stmt->execute();
if ($stmt->affected_rows==0) if ($stmt->affected_rows == 0) {
{
$message = _("Username or email already used"); $message = _("Username or email already used");
return; return;
} }
@ -190,12 +184,10 @@ class User
$headers .= "Reply-To: " . MAILER_NAME . ' <' . MAILER_ADDRESS . '>' . PHP_EOL; $headers .= "Reply-To: " . MAILER_NAME . ' <' . MAILER_ADDRESS . '>' . PHP_EOL;
mail($to, $subject, $msg, $headers); mail($to, $subject, $msg, $headers);
if (!INSTALL_OVERRIDE) if (!INSTALL_OVERRIDE) {
{
header("Location: " . WEB_URL . "/admin/?do=settings"); header("Location: " . WEB_URL . "/admin/?do=settings");
} }
} } else {
else {
$message = _("You don't have the permission to do that!"); $message = _("You don't have the permission to do that!");
} }
} }
@ -210,13 +202,11 @@ class User
public static function login() public static function login()
{ {
global $message, $mysqli; global $message, $mysqli;
if (!isset($_POST['email']) && !isset($_POST['email'])) if (!isset($_POST['email']) && !isset($_POST['email'])) {
{
return; return;
} }
if ((!isset($_POST['email']) || !isset($_POST['email']))) if ((!isset($_POST['email']) || !isset($_POST['email']))) {
{
$message = _("Please fill in your email and password!"); $message = _("Please fill in your email and password!");
return; return;
} }
@ -228,8 +218,7 @@ class User
$stmt->execute(); $stmt->execute();
$query = $stmt->get_result(); $query = $stmt->get_result();
if ($query->num_rows<1) if ($query->num_rows < 1) {
{
$message = _("Wrong email or password"); $message = _("Wrong email or password");
return; return;
} }
@ -239,8 +228,7 @@ class User
$id = $result["id"]; $id = $result["id"];
$active = $result["active"]; $active = $result["active"];
if (!$active) if (!$active) {
{
$message = _("Your account has been disabled. Please contact administrator."); $message = _("Your account has been disabled. Please contact administrator.");
return; return;
} }
@ -251,14 +239,12 @@ class User
$stmt->execute(); $stmt->execute();
$query = $stmt->get_result(); $query = $stmt->get_result();
if (!$query->fetch_assoc()['count']) if (!$query->fetch_assoc()['count']) {
{
$message = _("Wrong email or password"); $message = _("Wrong email or password");
return; return;
} }
if (isset($_POST['remember'])&&$_POST['remember']) if (isset($_POST['remember']) && $_POST['remember']) {
{
$year = strtotime('+356 days', time()); $year = strtotime('+356 days', time());
$token = Token::add($id, 'remember', $year); $token = Token::add($id, 'remember', $year);
setcookie('token', $token, $year, "/"); setcookie('token', $token, $year, "/");
@ -281,17 +267,14 @@ class User
$id = $_COOKIE['user']; $id = $_COOKIE['user'];
$token = $_COOKIE['token']; $token = $_COOKIE['token'];
if (Token::validate($token, $id, "remember")) if (Token::validate($token, $id, "remember")) {
{
$year = strtotime('+356 days', time()); $year = strtotime('+356 days', time());
unset($_COOKIE['token']); unset($_COOKIE['token']);
$_SESSION['user'] = $id; $_SESSION['user'] = $id;
$new_token = Token::add($id, 'remember', $year); $new_token = Token::add($id, 'remember', $year);
setcookie('token', $new_token, $year, "/"); setcookie('token', $new_token, $year, "/");
setcookie('user', $id, $year, "/"); setcookie('user', $id, $year, "/");
} } else {
else
{
unset($_COOKIE['user']); unset($_COOKIE['user']);
unset($_COOKIE['token']); unset($_COOKIE['token']);
setcookie('user', null, -1, '/'); setcookie('user', null, -1, '/');
@ -310,8 +293,7 @@ class User
global $permissions, $user; global $permissions, $user;
?> ?>
<div class="row 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" <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>
alt="<?php echo _("Profile picture");?>"></div>
<div class="col-md-6"> <div class="col-md-6">
<?php if ($this->id == $_SESSION['user'] || $user->get_rank() < 1) { <?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> <label class="form-name" for="surname"><?php echo _("Surname"); ?></label>
</div> </div>
<div class="row"> <div class="row">
<input type="text" name="name" placeholder="<?php echo _("Name"); ?>" <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); ?>>
title="<?php echo _("Name"); ?>" class="form-control form-name" <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); ?>>
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> </div>
</div> </div>
@ -378,12 +356,14 @@ class User
</select><span class="input-group-btn"> </select><span class="input-group-btn">
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Change role"); ?></button> <button type="submit" class="btn btn-primary pull-right"><?php echo _("Change role"); ?></button>
</span> </span>
</div><?php }else{ echo $permissions[$this->rank];}?></div> </div><?php } else {
echo $permissions[$this->rank];
} ?>
</div>
</div> </div>
</form> </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&amp;id=<?php echo $this->id; ?>" method="POST"> <form action="<?php echo WEB_URL; ?>/admin/?do=user&amp;id=<?php echo $this->id; ?>" method="POST">
<div class="row user"> <div class="row user">
<div class="col-md-2 col-md-offset-2"><strong>Email</strong></div> <div class="col-md-2 col-md-offset-2"><strong>Email</strong></div>
@ -397,8 +377,7 @@ class User
</div> </div>
</div> </div>
</form> </form>
<?php }else <?php } else {
{
?> ?>
<div class="row user"> <div class="row user">
<div class="col-md-2 col-md-offset-2"><strong><?php echo _("Email"); ?></strong></div> <div class="col-md-2 col-md-offset-2"><strong><?php echo _("Email"); ?></strong></div>
@ -429,8 +408,7 @@ class User
<?php <?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="row">
<div class="col-md-2 col-md-offset-2"></div> <div class="col-md-2 col-md-offset-2"></div>
<div class="col-md-6"> <div class="col-md-6">
@ -458,15 +436,13 @@ class User
$stmt = $mysqli->prepare("SELECT count(*) FROM users WHERE username LIKE ?"); $stmt = $mysqli->prepare("SELECT count(*) FROM users WHERE username LIKE ?");
$stmt->bind_param("s", $_POST["username"]); $stmt->bind_param("s", $_POST["username"]);
$stmt->execute(); $stmt->execute();
if ($stmt->num_rows > 0) if ($stmt->num_rows > 0) {
{
$message = _("This username is already taken."); $message = _("This username is already taken.");
return; return;
} }
$stmt->close(); $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!"); $message = _("Cannot change username of other users!");
} else { } else {
$stmt = $mysqli->prepare("UPDATE users SET username = ? WHERE id=?"); $stmt = $mysqli->prepare("UPDATE users SET username = ? WHERE id=?");
@ -491,16 +467,14 @@ class User
$messages[] = _("Surname"); $messages[] = _("Surname");
} }
if (!empty($messages)) if (!empty($messages)) {
{
$message = "Please enter " . implode(", ", $messages); $message = "Please enter " . implode(", ", $messages);
return; return;
} }
$id = $this->id; $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!"); $message = _("Cannot change names of other users!");
} else { } else {
$stmt = $mysqli->prepare("UPDATE users SET `name` = ?, `surname` = ? WHERE id=?"); $stmt = $mysqli->prepare("UPDATE users SET `name` = ?, `surname` = ? WHERE id=?");
@ -521,16 +495,13 @@ class User
{ {
global $mysqli, $message; global $mysqli, $message;
$id = $this->id; $id = $this->id;
if ($_POST['password']!=$_POST['password_repeat']) if ($_POST['password'] != $_POST['password_repeat']) {
{
$message = _("Passwords do not match!"); $message = _("Passwords do not match!");
return; return;
} }
if (!$token) if (!$token) {
{ if ($_SESSION['user'] != $id) {
if ($_SESSION['user']!=$id)
{
$message = _("Cannot change password of other users!"); $message = _("Cannot change password of other users!");
} else { } else {
$stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?"); $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->bind_param("is", $id, $hash);
$stmt->execute(); $stmt->execute();
if ($stmt->get_result()->fetch_assoc()['count']) if ($stmt->get_result()->fetch_assoc()['count']) {
{
$pass = $_POST['password']; $pass = $_POST['password'];
$hash = hash('sha256', $pass . $salt); $hash = hash('sha256', $pass . $salt);
$stmt = $mysqli->prepare("UPDATE users SET password_hash = ? WHERE id=?"); $stmt = $mysqli->prepare("UPDATE users SET password_hash = ? WHERE id=?");
@ -562,14 +532,12 @@ class User
$stmt->get_result(); $stmt->get_result();
User::logout(); User::logout();
} } else {
else{
$message = _("Wrong password!"); $message = _("Wrong password!");
} }
} }
} else { } 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 = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?");
$stmt->bind_param("i", $id); $stmt->bind_param("i", $id);
$stmt->execute(); $stmt->execute();
@ -589,9 +557,7 @@ class User
$stmt->bind_param("d", $id); $stmt->bind_param("d", $id);
$stmt->execute(); $stmt->execute();
$stmt->get_result(); $stmt->get_result();
} } else {
else
{
$message = _("Invalid token detected, please retry your request from start!"); $message = _("Invalid token detected, please retry your request from start!");
} }
Token::delete($token); 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. * Sends email with link for email change confirmation (security reasons), link is token protected and valid only once.
* @return void * @return void
*/ */
public function email_link(){ public function email_link()
{
global $user, $mysqli; global $user, $mysqli;
$email = $_POST['email']; $email = $_POST['email'];
$id = $this->id; $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 = $mysqli->prepare("UPDATE users SET email = ? WHERE id=?");
$stmt->bind_param("sd", $email, $id); $stmt->bind_param("sd", $email, $id);
$stmt->execute(); $stmt->execute();
@ -677,8 +643,7 @@ class User
$token = $_GET['token']; $token = $_GET['token'];
$id = $_GET['id']; $id = $_GET['id'];
if (Token::validate($token, $id, "email;%")) if (Token::validate($token, $id, "email;%")) {
{
$data = explode(";", Token::get_data($token, $id)); $data = explode(";", Token::get_data($token, $id));
$email = $data[1]; $email = $data[1];
@ -689,24 +654,21 @@ class User
$stmt->get_result(); $stmt->get_result();
Token::delete($token); Token::delete($token);
header("Location: " . WEB_URL . "/admin/"); header("Location: " . WEB_URL . "/admin/");
} } else {
else
{
$message = _("Invalid token detected, please retry your request from start!"); $message = _("Invalid token detected, please retry your request from start!");
} }
Token::delete($token); Token::delete($token);
} }
/** /**
* Logs current user out. * Logs current user out.
* @return void * @return void
*/ */
public static function logout(){ public static function logout()
session_unset();
if (isset($_COOKIE['token']))
{ {
session_unset();
if (isset($_COOKIE['token'])) {
$token = $_COOKIE['token']; $token = $_COOKIE['token'];
Token::delete($token); Token::delete($token);
unset($_COOKIE['user']); 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. * Changes permissions of current user - only super admin can do this, so it checks permission first.
* @return void * @return void
*/ */
public function change_permission(){ public function change_permission()
global $mysqli, $message, $user;
if ($user->get_rank()==0)
{ {
global $mysqli, $message, $user;
if ($user->get_rank() == 0) {
$permission = $_POST['permission']; $permission = $_POST['permission'];
$id = $_GET['id']; $id = $_GET['id'];
$stmt = $mysqli->prepare("UPDATE users SET permission=? WHERE id=?"); $stmt = $mysqli->prepare("UPDATE users SET permission=? WHERE id=?");
$stmt->bind_param("si", $permission, $id); $stmt->bind_param("si", $permission, $id);
$stmt->execute(); $stmt->execute();
header("Location: " . WEB_URL . "/admin/?do=user&id=" . $id); header("Location: " . WEB_URL . "/admin/?do=user&id=" . $id);
} } else {
else{
$message = _("You don't have permission to do that!"); $message = _("You don't have permission to do that!");
} }
} }

View File

@ -20,4 +20,3 @@ fwrite($f, fread($f2, filesize("IISWebConfig")));
fclose($f); fclose($f);
fclose($f2); fclose($f2);
} }
?>

View File

@ -6,18 +6,16 @@ body {
margin: 0; margin: 0;
height: 100%; height: 100%;
line-height: 24px; line-height: 24px;
font-family: 'Open Sans', sans-serif; font-family: "Open Sans", sans-serif;
} }
#status-container #status-container {
{
border-radius: 0; border-radius: 0;
border-top: 1px solid #e0e0e0; border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0;
} }
#status-container .item:last-child #status-container .item:last-child {
{
border: none; border: none;
} }
@ -25,13 +23,12 @@ body {
border-bottom: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0;
} }
#status-big #status-big {
{
float: none; float: none;
width: 100%; width: 100%;
text-align: center; text-align: center;
font-family: 'Fira Sans', sans-serif; font-family: "Fira Sans", sans-serif;
font-size: 1.5em font-size: 1.5em;
} }
#wrapper { #wrapper {
@ -47,7 +44,7 @@ body {
padding: 15px 35px; padding: 15px 35px;
font-weight: bold; font-weight: bold;
font-size: 1em; font-size: 1em;
font-family: 'Fira Sans', sans-serif; font-family: "Fira Sans", sans-serif;
} }
.status { .status {
@ -58,10 +55,9 @@ body {
padding: 15px 35px; padding: 15px 35px;
text-align: right; text-align: right;
font-size: 0.8em; font-size: 0.8em;
font-family: 'Fira Sans', sans-serif; font-family: "Fira Sans", sans-serif;
} }
#status-container .status.success { #status-container .status.success {
color: #2fcc66 !important; color: #2fcc66 !important;
font-weight: bolder; font-weight: bolder;
@ -78,7 +74,7 @@ body {
} }
#status-container .status.primary { #status-container .status.primary {
color:#3A72BD!important; color: #3a72bd !important;
font-weight: bolder; font-weight: bolder;
} }
@ -86,11 +82,10 @@ body {
border-color: #2fcc66; border-color: #2fcc66;
} }
#footerwrap { #footerwrap {
display: none display: none;
} }
.btn .btn {
{ display: none;
display: none
} }
h3 { h3 {
@ -107,34 +102,36 @@ h2.panel-title{
float: left; float: left;
} }
.panel,.panel-heading,.panel-footer{ .panel,
border-width: 3px .panel-heading,
.panel-footer {
border-width: 3px;
} }
body .panel-danger, body .panel-danger,
.panel-danger > .panel-body, .panel-danger > .panel-body,
.panel-danger > .panel-heading, .panel-danger > .panel-heading,
.panel-danger > .panel-footer { .panel-danger > .panel-footer {
border-color: #a94442 border-color: #a94442;
} }
body .panel-success, body .panel-success,
.panel-success > .panel-body, .panel-success > .panel-body,
.panel-success > .panel-heading, .panel-success > .panel-heading,
.panel-success > .panel-footer { .panel-success > .panel-footer {
border-color: #2fcc66 border-color: #2fcc66;
} }
body .panel-warning, body .panel-warning,
.panel-warning > .panel-body, .panel-warning > .panel-body,
.panel-warning > .panel-heading, .panel-warning > .panel-heading,
.panel-warning > .panel-footer { .panel-warning > .panel-footer {
border-color: #edaa16 border-color: #edaa16;
} }
body .panel-primary, body .panel-primary,
.panel-primary > .panel-body, .panel-primary > .panel-body,
.panel-primary > .panel-heading, .panel-primary > .panel-heading,
.panel-primary > .panel-footer { .panel-primary > .panel-footer {
border-color: #337ab7 border-color: #337ab7;
} }

View File

@ -81,11 +81,9 @@ if ( isset($_GET['new']) ) {
$message = _("Please check<br>"); $message = _("Please check<br>");
$message .= implode("<br> ", $messages); $message .= implode("<br> ", $messages);
} }
} }
if(isset($_POST['emailaddress']) && empty($message)) if (isset($_POST['emailaddress']) && empty($message)) {
{
// Check if email is already registered // Check if email is already registered
$boolUserExist = false; $boolUserExist = false;
@ -100,13 +98,11 @@ if ( isset($_GET['new']) ) {
$subscriber->add($subscriber->typeID, $_POST['emailaddress']); $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 $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")); $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 { } else {
if (!$subscriber->active) { if (!$subscriber->active) {
// Subscriber is registered, but has not been activated yet... // 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")); $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); $subscriber->activate($subscriber->id);
} else { } else {
// subscriber is registered and active // 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")); $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."); $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')); $constellation->render_warning($header, $message, true, WEB_URL, _('Go back'));
} }
} else if (isset($_GET['do']) && $_GET['do'] == 'unsubscribe') { } else if (isset($_GET['do']) && $_GET['do'] == 'unsubscribe') {
// Handle unsubscriptions // Handle unsubscriptions
// TODO This function is universal and should probably live elsewhere?? // 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"); $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."); $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')); $constellation->render_success($header, $message, true, WEB_URL, _('Go back'));
} else { } else {
// TODO Log token for troubleshooting ? // TODO Log token for troubleshooting ?
// Cannot find subscriber - show alert // Cannot find subscriber - show alert

View File

@ -1,11 +1,9 @@
<?php <?php
require_once("libs/parsedown/Parsedown.php"); require_once("libs/parsedown/Parsedown.php");
if (!file_exists("config.php")) if (!file_exists("config.php")) {
{
require_once("template.php"); require_once("template.php");
require_once("install.php"); require_once("install.php");
} elseif (isset($_GET['do'])) { // we can add other actions with $_GET['do'] later. } elseif (isset($_GET['do'])) { // we can add other actions with $_GET['do'] later.
// Fix for translation via _(). We need config.php first... // Fix for translation via _(). We need config.php first...
require_once("config.php"); 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")); define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret"));
$offset = 0; $offset = 0;
if (isset($_GET['ajax'])) if (isset($_GET['ajax'])) {
{
$constellation->render_incidents(false, $_GET['offset'], 5); $constellation->render_incidents(false, $_GET['offset'], 5);
exit(); exit();
}else if (isset($_GET['offset'])) } else if (isset($_GET['offset'])) {
{
$offset = $_GET['offset']; $offset = $_GET['offset'];
} }
@ -101,8 +97,7 @@ Template::render_header("Status");
<?php $constellation->render_status(); ?> <?php $constellation->render_status(); ?>
</div> </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 id="timeline">
<div class="item"> <div class="item">

View File

@ -20,8 +20,7 @@ if(isset($_GET["isDev"])){
$negotiator = new LocaleNegotiator("en_GB"); $negotiator = new LocaleNegotiator("en_GB");
$message = ""; $message = "";
$db = new SSDB(); $db = new SSDB();
if (!isset($_SESSION['locale'])||isset($_GET['lang'])) if (!isset($_SESSION['locale']) || isset($_GET['lang'])) {
{
$override = ((isset($_GET['lang'])) ? $_GET['lang'] : null); $override = ((isset($_GET['lang'])) ? $_GET['lang'] : null);
$best_match = $negotiator->negotiate($override); $best_match = $negotiator->negotiate($override);
$_SESSION['locale'] = $best_match; $_SESSION['locale'] = $best_match;
@ -32,16 +31,14 @@ if (!isset($_SESSION['locale'])||isset($_GET['lang']))
textdomain("server-status"); textdomain("server-status");
} }
if (isset($_POST['server'])) if (isset($_POST['server'])) {
{
$mysqli = new mysqli($_POST['server'], $_POST['dbuser'], $_POST['dbpassword'], $_POST['database']); $mysqli = new mysqli($_POST['server'], $_POST['dbuser'], $_POST['dbpassword'], $_POST['database']);
if ($mysqli->connect_errno) { if ($mysqli->connect_errno) {
$message .= sprintf(_("Connection failed: %s\n"), $mysqli->connect_error); $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!"); $message .= _("Please set valid url!");
} }
@ -78,19 +75,16 @@ if (isset($_POST['server']))
$messages[] = _("Database user"); $messages[] = _("Database user");
} }
if (0 == strlen(trim($_POST['dbpassword']))) if (0 == strlen(trim($_POST['dbpassword']))) {
{
$messages[] = _("Database password"); $messages[] = _("Database password");
} }
if (isset($messages)) if (isset($messages)) {
{
$message .= _("Please enter"); $message .= _("Please enter");
$message .= implode(", ", $messages); $message .= implode(", ", $messages);
} }
} }
if(isset($_POST['server']) && empty($message)) if (isset($_POST['server']) && empty($message)) {
{
define("MAILER_NAME", $_POST['mailer']); define("MAILER_NAME", $_POST['mailer']);
define("MAILER_ADDRESS", $_POST['mailer_email']); define("MAILER_ADDRESS", $_POST['mailer_email']);
define("INSTALL_OVERRIDE", true); define("INSTALL_OVERRIDE", true);
@ -102,27 +96,23 @@ if(isset($_POST['server']) && empty($message))
foreach ($array as $value) { foreach ($array as $value) {
$val = trim($value); $val = trim($value);
if (empty($val)) if (empty($val)) {
{
continue; continue;
} }
$q_res = $mysqli->query($value); $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); $message = sprintf(_("Error while creating database. Please check permission for your account or MYSQL version.<br>Error: %s"), $mysqli->error);
break; break;
} }
} }
if (empty($message)) if (empty($message)) {
{
require_once("classes/constellation.php"); require_once("classes/constellation.php");
User::add(); User::add();
} }
if (empty($message)) if (empty($message)) {
{
//Create config //Create config
$config = file_get_contents("config.php.template"); $config = file_get_contents("config.php.template");
//$config = str_replace("##name##", htmlspecialchars($_POST['servername'], ENT_QUOTES), $config); //$config = str_replace("##name##", htmlspecialchars($_POST['servername'], ENT_QUOTES), $config);
@ -194,16 +184,22 @@ Template::render_header(_("Install"));
$preq_writedir = $preq_fail; $preq_writedir = $preq_fail;
// Check if PHP version if > MINIMUM_PHP_VERSION // 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 // 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 // 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 // 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 // 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 // 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"> <section class="prereq-section clearfix">
@ -226,8 +222,7 @@ Template::render_header(_("Install"));
<h1 class="text-center"><?php echo _("Installation"); ?></h1> <h1 class="text-center"><?php echo _("Installation"); ?></h1>
<?php <?php
if (!empty($message)) if (!empty($message)) {
{
?> ?>
<p class="alert alert-danger"><?php echo $message; ?></p> <p class="alert alert-danger"><?php echo $message; ?></p>
<?php <?php

View File

@ -56,7 +56,6 @@ CREATE TABLE queue_notify (
retries tinyint(1) DEFAULT NULL, retries tinyint(1) DEFAULT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_czech_ci; ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_czech_ci;
CREATE TABLE services_groups ( CREATE TABLE services_groups (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL, name varchar(50) NOT NULL,
@ -64,7 +63,6 @@ CREATE TABLE services_groups (
visibility tinyint(4) NOT NULL, visibility tinyint(4) NOT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
CREATE TABLE queue_task ( CREATE TABLE queue_task (
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
type_id int(11) NOT NULL, 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_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; ADD CONSTRAINT `services_subscriber_ibfk_2` FOREIGN KEY (`serviceIDFK`) REFERENCES `services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT; COMMIT;
ALTER TABLE `subscribers` CHANGE COLUMN lastname lastname varchar(255) DEFAULT NULL;
ALTER TABLE `subscribers` CHANGE COLUMN lastname lastname varchar(255) DEFAULT NULL; # was varchar(255) NOT 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 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` 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`
ALTER TABLE `subscribers` ADD COLUMN token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL AFTER lastname; ADD COLUMN typeID tinyint(1) NOT NULL
ALTER TABLE `subscribers` ADD COLUMN expires int(11) DEFAULT NULL; AFTER subscriberID;
ALTER TABLE `subscribers` ADD COLUMN active tinyint(1) DEFAULT NULL; ALTER TABLE `subscribers`
ALTER TABLE `subscribers` ADD COLUMN create_time int(11) DEFAULT NULL; ADD COLUMN token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL
ALTER TABLE `subscribers` ADD COLUMN update_time int(11) DEFAULT NULL; AFTER lastname;
ALTER TABLE `subscribers` DROP INDEX telegramID; # was UNIQUE (telegramID) ALTER TABLE `subscribers`
ALTER TABLE `subscribers` ADD UNIQUE userID (userID); 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; COMMIT;
ALTER TABLE services
ALTER TABLE services ADD COLUMN description varchar(200) COLLATE utf8_czech_ci NOT NULL; 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 group_id int(11) DEFAULT NULL;
COMMIT; COMMIT;

View File

@ -1,11 +1,20 @@
(function () { (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()); $("#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 $("#end_time_js").val(date[0].toISOString()); // iso date str
}}); },
});
var bgcolore = ["bg-danger", "bg-warning", "bg-primary", "bg-success"]; var bgcolore = ["bg-danger", "bg-warning", "bg-primary", "bg-success"];
var bordercolore = ["border-danger", "border-warning", "border-primary", "border-success"]; var bordercolore = ["border-danger", "border-warning", "border-primary", "border-success"];
@ -29,35 +38,28 @@
var end_time = Date.parse($("#end_time").val()); var end_time = Date.parse($("#end_time").val());
var type = $("#type").val() || 0; var type = $("#type").val() || 0;
if (parseInt(type) === 2 &&(isNaN(time) || isNaN(end_time))) if (parseInt(type) === 2 && (isNaN(time) || isNaN(end_time))) {
{ if (isNaN(end_time)) {
if (isNaN(end_time))
{
$("#time_input").addClass("error"); $("#time_input").addClass("error");
$.growl.error({ message: "Start time is invalid!" }); $.growl.error({ message: "Start time is invalid!" });
} }
if (isNaN(end_time)) if (isNaN(end_time)) {
{
$("#end_time").addClass("error"); $("#end_time").addClass("error");
$.growl.error({ message: "End time is invalid!" }); $.growl.error({ message: "End time is invalid!" });
} }
return false; 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!" }); $.growl.error({ message: "End time is either the same or earlier than start time!" });
$("#time").addClass("error"); $("#time").addClass("error");
$("#end_time").addClass("error"); $("#end_time").addClass("error");
return false; 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!" }); $.growl.error({ message: "Please check at least one service!" });
$("#status-container").addClass("error"); $("#status-container").addClass("error");
return false; return false;
} }
}); });
})(); })();

View File

@ -1,5 +1,4 @@
function timeago() function timeago() {
{
$("time.timeago").timeago(); $("time.timeago").timeago();
$("time.timeago").each(function () { $("time.timeago").each(function () {
var date = new Date($(this).attr("datetime")); var date = new Date($(this).attr("datetime"));
@ -16,17 +15,15 @@ function timeago()
$($(this).data("target")).toggleClass("collapse"); $($(this).data("target")).toggleClass("collapse");
}); });
var incidents = $('.timeline'); var incidents = $(".timeline");
$("body").on("click", "#loadmore", function (e) { $("body").on("click", "#loadmore", function (e) {
e.preventDefault(); e.preventDefault();
var url = $("#loadmore").attr("href") + "&ajax=true"; var url = $("#loadmore").attr("href") + "&ajax=true";
$("#loadmore").remove(); $("#loadmore").remove();
$.get(url, $.get(url, function (data) {
function(data){
incidents.append(data); incidents.append(data);
timeago(); timeago();
}); });
}); });
})(); })();

View File

@ -44,7 +44,6 @@ if( $_SESSION['subscriber_valid'] ){
} }
$subscription->render_subscribed_services($typeID, $subscriberID, $userID, $token); $subscription->render_subscribed_services($typeID, $subscriberID, $userID, $token);
} else { } else {
$header = _("Your session has expired or you tried something we don't suppprt"); $header = _("Your session has expired or you tried something we don't suppprt");

View File

@ -10,7 +10,6 @@ define("WEB_URL", $db->getSetting($mysqli,"url"));
define("MAILER_NAME", $db->getSetting($mysqli, "mailer")); define("MAILER_NAME", $db->getSetting($mysqli, "mailer"));
define("MAILER_ADDRESS", $db->getSetting($mysqli, "mailer_email")); 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("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram"));
define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token")); define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token"));
define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username")); define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username"));

View File

@ -10,15 +10,16 @@ $visibility = array(_("Collapsed"), _("Expanded"), _("Expand on events"));
/** /**
* Class that encapsulates methods to render header and footer * Class that encapsulates methods to render header and footer
*/ */
class Template{ class Template
{
/** /**
* Renders header * Renders header
* @param String $page_name name of the page to be displayed as title * @param String $page_name name of the page to be displayed as title
* @param Boolean $admin decides whether to show admin menu * @param Boolean $admin decides whether to show admin menu
*/ */
public static function render_header($page_name, $admin = false){ public static function render_header($page_name, $admin = false)
if (!$admin)
{ {
if (!$admin) {
// Create subscriber menu sections for later inclusion // Create subscriber menu sections for later inclusion
// Check if we are on admin menu, if so do not display // Check if we are on admin menu, if so do not display
$arr_url = explode("/", $_SERVER['PHP_SELF']); $arr_url = explode("/", $_SERVER['PHP_SELF']);
@ -55,6 +56,7 @@ class Template{
?> ?>
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $page_name . " - " . NAME ?></title> <title><?php echo $page_name . " - " . NAME ?></title>
@ -98,6 +100,7 @@ class Template{
} }
?> ?>
</head> </head>
<body> <body>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark"> <nav class="navbar fixed-top navbar-expand-lg navbar-dark">
<div class="container"> <div class="container">
@ -105,7 +108,11 @@ class Template{
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarToggler"> <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"> <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<?php <?php
if (!$admin) { 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 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 * @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> <div>
<h3><?php echo $toggletext; ?></h3> <h3><?php echo $toggletext; ?></h3>
<label class="switch"> <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> <span class="slider round"></span>
</label> </label>
</div> </div>
@ -184,7 +194,9 @@ class Template{
<div id="footerwrap"> <div id="footerwrap">
<div class="container"> <div class="container">
<div class="row centered"> <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="col-md-4 text-center">
<div class="input-group dropup mb-3"> <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> <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>'; 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> <li><a href="https://poeditor.com/join/project/37SpmJtyOm"><?php echo _("Help with translation!"); ?></a></li>
</ul> </ul>
</div> </div>
</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 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>
</div><!--/container --> <!--/row -->
</div>
<!--/container -->
</div> </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-3.5.1.min.js"></script>
<script src="<?php echo WEB_URL; ?>/js/vendor/jquery.timeago.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> <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 } ?> <?php if ($GOOGLE_RECAPTCHA) { ?><script src='https://www.google.com/recaptcha/api.js'></script><?php } ?>
</body> </body>
</html> </html>
<?php <?php
} }