Skip to content

Commit

Permalink
Colorize based on day's color
Browse files Browse the repository at this point in the history
  • Loading branch information
NEMS Linux committed Feb 25, 2019
1 parent 5f2ab96 commit 4fbc796
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
5 changes: 0 additions & 5 deletions config/index.php
Expand Up @@ -718,11 +718,6 @@ function sanitize($string) {
if (checkConfEnabled('monitorix') == true) $checked = 'CHECKED="CHECKED"'; else $checked = '';
echo '<label class="toggle text-right"><input ' . $checked . ' name="monitorix" type="checkbox" class="services reboot"><i></i>Monitorix</label>';

if (ver('nems') >= 1.4) {
if (checkConfEnabled('cockpit') == true) $checked = 'CHECKED="CHECKED"'; else $checked = '';
echo '<label class="toggle text-right"><input ' . $checked . ' name="cockpit" type="checkbox" class="services reboot"><i></i>Cockpit</label>';
}

if (ver('nems') >= 1.4) {
if (checkConfEnabled('tvpw') == true) $checked = 'CHECKED="CHECKED"'; else $checked = '';
echo '<label class="toggle text-right"><input ' . $checked . ' name="tvpw" type="checkbox" class="services"><i></i>Allow TV Dashboard Without Password</label>';
Expand Down
8 changes: 0 additions & 8 deletions config/services.php
Expand Up @@ -37,14 +37,6 @@
}
break;

case 'cockpit':
if ($_POST['value'] == 'off') {
$config['service.' . $name] = 0;
} elseif ($_POST['value'] == 'on') {
$config['service.' . $name] = 1;
}
break;

case 'rpi-monitor':
if ($_POST['value'] == 'off') {
$config['service.' . $name] = 0;
Expand Down
28 changes: 28 additions & 0 deletions inc/bgcolor.php
@@ -0,0 +1,28 @@
<?php

$defaultbgcolor = '040111';

$key = strtotime('today');
// caches the response each day
$cachefile = '/tmp/bgcolor-' . $key;
if (file_exists($cachefile)) {
$result = trim(file_get_contents($cachefile));
} else {
$json_url = 'https://cloud.nemslinux.com/bgcolor/' . $key . '.json';
$ch = curl_init( $json_url );
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
);
curl_setopt_array( $ch, $options );
$result = curl_exec($ch);
file_put_contents($cachefile,$result);
}
$resultobj = json_decode($result);
if (isset($resultobj->$key)) {
$bgcolor = $resultobj->$key;
} else {
$bgcolor = $defaultbgcolor;
}

?>
6 changes: 3 additions & 3 deletions inc/header.php
@@ -1,5 +1,5 @@
<?php
$bgcolor = '040111';
require_once('bgcolor.php');
?><!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
Expand Down Expand Up @@ -116,7 +116,7 @@ function resizeIframe(obj) {
<?php if (ver('nems') >= 1.4) echo '<li><a href="/mobile/" target="_blank">NEMS Mobile UI</a></li>'; ?>
<?php if (ver('nems') >= 1.4) echo '<li><a href="/tv/" target="_blank">NEMS TV Dashboard</a></li>'; ?>

<li><h4 style="padding: 0 0 4px 4px; margin-bottom: 0;">Legacy</h4></li>
<li><h4 style="padding: 0 0 4px 4px; margin: 0;">Legacy</h4></li>
<?php
if (ver('nems') >= 1.4) {
echo '<li><a href="/nagios/" target="_blank">Nagios Core</a></li>';
Expand All @@ -138,7 +138,7 @@ function resizeIframe(obj) {

<ul class="dropdown-menu">
<?php if (checkConfEnabled('monitorix')) { echo '<li><a href="/monitorix/">Monitorix</a></li>'; } ?>
<?php if (ver('nems') >= 1.4 && checkConfEnabled('cockpit')) echo '<li><a href="https://' . $self->host . ':9090" target="_blank">Cockpit</a></li>'; ?>
<?php if (ver('nems') >= 1.4) echo '<li><a href="https://' . $self->host . ':9090" target="_blank">Cockpit</a></li>'; ?>
<?php if ((ver('platform')->num < 10) && checkConfEnabled('rpi-monitor')) { echo '<li><a href="http://' . $self->host . ':8888" target="_blank">RPi-Monitor</a></li>'; } ?>
<?php if (ver('nems') <= 1.4 && checkConfEnabled('webmin')) { echo '<li><a href="https://' . $self->host . ':10000" target="_blank">Webmin</a></li>'; } ?>
<?php if (ver('nems') >= 1.3) echo '<li><a href="https://' . $self->host . ':2812" target="_blank"><em>monit</em> Service Monitor</a></li>'; ?>
Expand Down
2 changes: 2 additions & 0 deletions init.php
Expand Up @@ -2,6 +2,7 @@
if (isset($functions_loaded) && $functions_loaded == 1) {
$ip = trim(shell_exec('/usr/local/bin/nems-info ip'));
$platform = ver('platform');
require_once('inc/bgcolor.php');
?><!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
Expand All @@ -17,6 +18,7 @@

<!-- Favicon -->
<link rel="shortcut icon" href="/favicon.ico">
<meta name="theme-color" content="#<?= $bgcolor ?>">

<!-- Web Fonts -->
<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Open+Sans:400,300,600&amp;subset=cyrillic,latin'>
Expand Down

0 comments on commit 4fbc796

Please sign in to comment.