Skip to content

Commit

Permalink
Merge pull request #145 from Tealk/update-bootstrap
Browse files Browse the repository at this point in the history
Merge Tealk's nice major design updates and small code tweaks
  • Loading branch information
yigitkerem authored Apr 21, 2021
2 parents f33bf99 + eb2f8b7 commit eb50012
Show file tree
Hide file tree
Showing 96 changed files with 61,060 additions and 3,108 deletions.
21 changes: 10 additions & 11 deletions 404.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php
<?php
require_once("template.php");
if (!file_exists("config.php"))
{
if (!file_exists("config.php")) {
require_once("install.php");
}else{
require_once("config.php");
} else {
require_once("config.php");

Template::render_header("Page not found");
Template::render_header("Page not found", "notfound");
?>
<div class="text-center">
<h1><?php echo _("Page Not Found");?></h1>
<p><?php echo _("Sorry, but the page you were trying to view does not exist.");?></p>
<h1><?php echo _("Page Not Found"); ?></h1>
<p><?php echo _("Sorry, but the page you were trying to view does not exist."); ?></p>
</div>
<?php
Template::render_footer();
}
<?php
Template::render_footer();
}
156 changes: 80 additions & 76 deletions admin/dashboard.php
Original file line number Diff line number Diff line change
@@ -1,110 +1,114 @@
<?php
$offset = 0;
if (isset($_GET['ajax']))
{
$constellation->render_incidents(false,$_GET['offset'],5);
if (isset($_GET['ajax'])) {
$constellation->render_incidents(false, $_GET['offset'], 5);
exit();
}else if (isset($_GET['offset']))
{
} else if (isset($_GET['offset'])) {
$offset = $_GET['offset'];
}

if (isset($_GET['new']) && $_GET['new']=="incident")
{
if (isset($_GET['new']) && $_GET['new'] == "incident") {
Incident::add();
}

if (isset($_GET['delete']))
{
if (isset($_GET['delete'])) {
Incident::delete($_GET['delete']);
}
if (isset($_GET['tasks'])) {
Queue::process_queue();
Queue::process_queue();
}

Template::render_header(_("Dashboard"), true);
Template::render_header(_("Dashboard"), "dashboard", true);
?>

<div class="text-center">
<h1><?php echo _("Dashboard");?></h1>
<h3><?php echo _("Welcome");?> <?php echo $user->get_name();?></h3>
</div>
<div class="text-center">
<h1><?php echo _("Dashboard"); ?></h1>
<h3><?php echo _("Welcome"); ?> <?php echo $user->get_name(); ?></h3>
</div>

<div id="current">
<?php
$services = $constellation->render_status(true);
?>
</div>
<div id="timeline">
<div class="item">
<div class="timeline">
<div class="line text-muted"></div>
<h3><?php echo _("New incident");?></h3>
<form id="new-incident" action="<?php echo WEB_URL;?>/admin/?new=incident" method="POST" class="clearfix">
<div class="panel">
<?php if (isset($message))
{?>
<p class="alert alert-danger"><?php echo $message?></p>
<div id="current">
<?php
$services = $constellation->render_status(true);
?>
</div>
<div id="timeline">
<div class="item">
<div class="timeline">
<div class="line text-muted"></div>
<h3><?php echo _("New incident"); ?></h3>
<form id="new-incident" action="<?php echo WEB_URL; ?>/admin/?new=incident" method="POST">
<div class="servicelist">
<?php if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p>
<?php
} ?>
<div id="status-container" class="clearfix">
<?php
if (isset($_POST['services']) && !is_array($_POST['services']))
{
$post_services = array($_POST['services']);
}else{
$post_services = array();
}
<div id="status-container">
<?php
if (isset($_POST['services']) && !is_array($_POST['services'])) {
$post_services = array($_POST['services']);
} else {
$post_services = array();
}

foreach($services as $service){
?>
<div class="item clearfix">
<div class="service"><?php if ($service->get_status()!=-1){?><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(); ?>"><?php } ?><label for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label></div>
<div class="status <?php if ($service->get_status()!=-1){echo $classes[$service->get_status()];}?>"><?php if ($service->get_status()!=-1){echo $statuses[$service->get_status()];}?></div>
</div>
<?php
}
?>
foreach ($services as $service) {
?>
<div class="input-group mb-2">
<?php if ($service->get_status() != -1) { ?>
<div class="input-group-text service">
<input type="checkbox" name="services[]" value="<?php echo $service->get_id(); ?>" <?php echo (in_array($service->get_id(), $post_services)) ? "checked" : ''; ?> id="service-<?php echo $service->get_id(); ?>">
</div>
<label id="name" class="input-group-text form-control" for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label>
<label id="status" class="input-group-text btn-<?php if ($service->get_status() != -1) {
echo $classes[$service->get_status()];
} ?>" for="service-<?php echo $service->get_id(); ?>"><?php echo $statuses[$service->get_status()]; ?></label>
<?php } ?>
</div>
<?php
}
?>
</div>
</div>
<div class="panel new panel-primary">
<div class="panel-heading icon">
<i class="glyphicon glyphicon-info-sign"></i>
</div>
<div class="panel-heading clearfix">
<input type="text" name="title" id="title" placeholder="<?php echo _("Title");?>" value="<?php echo (isset($_POST['title'])?htmlspecialchars($_POST['title']):''); ?>" required> <span id="time"><input id="time_input" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="time" value="<?php echo (isset($_POST['time'])?htmlspecialchars($_POST['time']):''); ?>" class="pull-right" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" placeholder="<?php echo _("Time");?>">
<input id="time_input_js" name="time_js" type="hidden" class="pull-right">
</span>
</div>
<div class="panel-body">
<textarea name="text" placeholder="<?php echo _("Here goes your text...");?>" required><?php echo (isset($_POST['text'])?htmlspecialchars($_POST['text']):''); ?></textarea>
</div>
<div class="panel-footer clearfix">
<small><?php echo _("Posted by");?>: <?php echo $user->get_username();?> <span class="pull-right" id="end_time_wrapper"><?php echo _("Ending");?>:&nbsp;<input id="end_time" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="end_time" class="pull-right" placeholder="<?php echo _("End time");?>" value="<?php echo (isset($_POST['end_time'])?htmlspecialchars($_POST['end_time']):''); ?>"></span></small>
<input id="end_time_js" name="end_time_js" type="hidden" class="pull-right">
</div>
<article class="card new border-primary mb-3">
<div class="card-colore icon bg-primary"><i class="fa fa-info"></i></div>
<div class="card-colore card-header bg-primary border-primary">
<input type="text" name="title" id="title" placeholder="<?php echo _("Title"); ?>" value="<?php echo (isset($_POST['title']) ? htmlspecialchars($_POST['title']) : ''); ?>" required>
<span id="time" class="float-end">
<input id="time_input" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="time" value="<?php echo (isset($_POST['time']) ? htmlspecialchars($_POST['time']) : ''); ?>" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" placeholder="<?php echo _("Time"); ?>">
<input id="time_input_js" name="time_js" type="hidden">
</span>
</div>
<select class="form-control pull-left" id="type" name="type">
<div class="card-body text-primary">
<p class="card-text"><textarea name="text" placeholder="<?php echo _("Here goes your text..."); ?>" required><?php echo (isset($_POST['text']) ? htmlspecialchars($_POST['text']) : ''); ?></textarea></p>
</div>
<div class="card-footer bg-transparent border-primary">
<small><?php echo _("Posted by"); ?>: <?php echo $user->get_username(); ?></small>
<span class="float-end" id="end_time_wrapper"><?php echo _("Ending"); ?>:&nbsp;
<input id="end_time" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="end_time" placeholder="<?php echo _("End time"); ?>" value="<?php echo (isset($_POST['end_time']) ? htmlspecialchars($_POST['end_time']) : ''); ?>">
<input id="end_time_js" name="end_time_js" type="hidden">
</span>
</div>
</article>
<div class="input-group">
<select class="form-select" id="type" name="type">
<?php
if (isset($_POST['type']))
{
if (isset($_POST['type'])) {
$selected_status = $_POST['type'];
}else
{
} else {
$selected_status = 2;
}

foreach ($statuses as $key => $value) {
echo '<option value="'.$key.'"'.(($key==$selected_status)?' selected':'').'>'.$value.'</option>';
echo '<option value="' . $key . '"' . (($key == $selected_status) ? ' selected' : '') . '>' . $value . '</option>';
}
?>
</select>
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button>
</form>
<?php
$constellation->render_incidents(true,$offset,5,true);
$constellation->render_incidents(false,$offset,5,true);
?>
</div>
<button class="card-colore btn btn-secondary" type="submit"><?php echo _("Submit"); ?></button>
</div>
</form>
<?php
$constellation->render_incidents(true, $offset, 5, true);
$constellation->render_incidents(false, $offset, 5, true);
?>
</div>
</div>
</div>
87 changes: 36 additions & 51 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

if (!file_exists("../config.php"))
{
if (!file_exists("../config.php")) {
header("Location: ../");
}
else{
} else {
require_once("../config.php");
require_once("../classes/constellation.php");
require_once("../classes/mailer.php");
Expand All @@ -14,11 +12,11 @@
require_once("../classes/queue.php");
require_once("../classes/db-class.php");
$db = new SSDB();
define("NAME", $db->getSetting($mysqli,"name"));
define("TITLE", $db->getSetting($mysqli,"title"));
define("WEB_URL", $db->getSetting($mysqli,"url"));
define("MAILER_NAME", $db->getSetting($mysqli,"mailer"));
define("MAILER_ADDRESS", $db->getSetting($mysqli,"mailer_email"));
define("NAME", $db->getSetting($mysqli, "name"));
define("TITLE", $db->getSetting($mysqli, "title"));
define("WEB_URL", $db->getSetting($mysqli, "url"));
define("MAILER_NAME", $db->getSetting($mysqli, "mailer"));
define("MAILER_ADDRESS", $db->getSetting($mysqli, "mailer_email"));

define("GOOGLE_RECAPTCHA", $db->getBooleanSetting($mysqli, "google_recaptcha"));
define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret"));
Expand All @@ -39,76 +37,63 @@

// Process the subscriber notification queue
// If CRON_SERVER_IP is not set, call notification once incident has been saved
if ( empty(CRON_SERVER_IP) )
{
if ( isset($_GET['sent']) && $_GET['sent'] == true )
{
if (empty(CRON_SERVER_IP)) {
if (isset($_GET['sent']) && $_GET['sent'] == true) {
Queue::process_queue();
}
}
else if ( isset($_GET['task']) && $_GET['task'] == 'cron' )
{
} else if (isset($_GET['task']) && $_GET['task'] == 'cron') {
// Else, base it on call to /admin?task=cron being called from IP defined by CRON_SERVER_IP
if (! empty(CRON_SERVER_IP) && $_SERVER['REMOTE_ADDR'] == CRON_SERVER_IP )
{
Queue::process_queue();
syslog(1, "CRON server processed");
}
else {
syslog(1, "CRON called from unauthorised server");
if (!empty(CRON_SERVER_IP) && $_SERVER['REMOTE_ADDR'] == CRON_SERVER_IP) {
Queue::process_queue();
syslog(1, "CRON server processed");
} else {
syslog(1, "CRON called from unauthorised server");
}
}


if(isset($_COOKIE['user'])&&!isset($_SESSION['user']))
{
if (isset($_COOKIE['user']) && !isset($_SESSION['user'])) {
User::restore_session();
}

if (!isset($_SESSION['user']))
{
if (isset($_GET['do']) && $_GET['do']=="lost-password")
{
if (!isset($_SESSION['user'])) {
if (isset($_GET['do']) && $_GET['do'] == "lost-password") {
require_once("lost-password.php");
}else if (isset($_GET['do']) && $_GET['do']=="change-email"){
} else if (isset($_GET['do']) && $_GET['do'] == "change-email") {
$user_pwd = new User($_GET['id']);
$user_pwd->change_email();
require_once("login-form.php");
}
else{
} else {
User::login();
require_once("login-form.php");
}
}
else
{
} else {
$user = new User($_SESSION['user']);
if (!$user->is_active())
{
if (!$user->is_active()) {
User::logout();
}

if (!isset($_GET['do'])){
if (!isset($_GET['do'])) {
$do = "";
}else{
} else {
$do = $_GET['do'];
}

switch ($do) {
case 'change-email':
$user = new User($_GET['id']);
$user->change_email();
case 'user':
require_once("user.php");
break;
case 'user':
require_once("user.php");
break;

case 'settings':
require_once("settings.php");
break;
case 'settings':
require_once("settings.php");
break;

case 'new-user':
require_once("new-user.php");
break;
case 'new-user':
require_once("new-user.php");
break;

case 'new-service':
case 'edit-service':
Expand All @@ -128,9 +113,9 @@
User::logout();
break;

default:
require_once("dashboard.php");
break;
default:
require_once("dashboard.php");
break;
}

Template::render_footer(true);
Expand Down
Loading

0 comments on commit eb50012

Please sign in to comment.