Initial Check-In

master
Gary 2022-01-10 01:22:50 +00:00
commit bf2ea9ce66
12 changed files with 273 additions and 0 deletions

44
README.md 100644
View File

@ -0,0 +1,44 @@
# NOC Screen Tab Rotator
This app will automatically rotate and refresh tabs based on the hostname of the ?hostname variable passed to the script.
The config Has the following:
* **defaults** - common defaults across all clients
* * **tabTime** - how long each tab should be displayed for (Default: 30)
* * **tabRefresh** - Global setting for if a tab should be refreshed before display (Default: true)
* * **masterRefresh** - How often should the overal page be reloaded in seconds - default 86400
* **screens** - A list of clients
* * **__hostname__** - config for the host
* * * **tabTime** - Overide for this host
* * * **tabRefresh** - Overide for this host
* * * **masterRefresh** - Overide for this host
* * * **urls** - A dict of URLs to display
* * * * **__url__** - the URL to load
* * * * * **tabRefresh** - optionall overide if this tab should(n't) be refresh before display
Example Config:
```js
{
"defaults": {
"tabTime": 30,
"tabRefresh": true,
"masterRefresh": 86400
},
"screens": {
"screen0": {
"urls": {
"http://www.example.com/": {"tabRefresh": false},
"http://news.bbc.co.uk/": {}
}
},
"screen1": {
"tabTime": 60,
"urls": {
"http://www.google.com/": {}
}
}
}
}
```

View File

@ -0,0 +1,21 @@
{
"defaults": {
"tabTime": 30,
"tabRefresh": true,
"masterRefresh": 86400
},
"screens": {
"screen0": {
"urls": {
"http://www.example.com/": {"tabRefresh": false},
"http://news.bbc.co.uk/": {}
}
},
"screen1": {
"tabTime": 60,
"urls": {
"http://www.google.com/": {}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 KiB

73
www/index.php 100644
View File

@ -0,0 +1,73 @@
<?php
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if(!isset($_REQUEST['hostname'])) {
$hostname = "host not known";
} else {
$hostname = $_REQUEST['hostname'];
}
$settings = json_decode(file_get_contents("../settings.json"), true);
if(isset($settings['screens'][$hostname])) {
header("Location: /screen/screenRender.php?hostname=$hostname");
exit;
} else {
date_default_timezone_set("UTC");
$num = rand(1,8);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>NOC Screen</title>
<style type="text/css">
body { background-repeat: no-repeat; background-image: url('/screen/background-00<?php echo $num; ?>.jpg'); background-size: cover; }
.content {
width:200px;
height:125px;
position:absolute;
left:50%;
top:50%;
margin:-75px 0 0 -135px;
color: white;
}
.sitename {
position: absolute;
left: 0%;
bottom: 0%;
margin: 15px 15px 15px 15px;
padding: 10px;
color: rgb(21,55,96);
font-family: sans-serif;
font-size: 48px;
text-align: left;
background-color: rgba(202,202,202,0.6);
border-radius: 15px;
}
</style>
<meta http-equiv="refresh" content="60">
</head>
<body>
<div class="content">
</div>
<div class="sitename">
<center><img src='/screen/logo.png' alt='' width=150px valign=middle /><font style='font-size: 81px;'>&nbsp;<b>screen ip</b></font></center>
<center><b><font style='font-size: 64px;'><?=$_SERVER['REMOTE_ADDR'];?></font></b><br/>unadopted - <?=$hostname?> - will refresh in 60 seconds</center>
</div>
</body>
</html>

View File

@ -0,0 +1,135 @@
<?php
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if(!isset($_REQUEST['hostname'])) {
$hostname = "host not known";
} else {
$hostname = $_REQUEST['hostname'];
}
$settings = json_decode(file_get_contents("../settings.json"), true);
if(!isset($settings['screens'][$hostname])) {
header("Location: /screen/?hostname=$hostname");
exit;
} elseif (!isset($settings['screens'][$hostname]['urls']) || (sizeof($settings['screens'][$hostname]['urls'])<1)) {
header("Location: /screen/?hostname=$hostname");
exit;
} else {
date_default_timezone_set("UTC");
$urls = $settings['screens'][$hostname]['urls'];
$urlk = array_keys($urls);
$urlcount = sizeof($urls);
}
if (isset($settings['screens'][$hostname]['masterRefresh'])) {
$masterRefresh = $settings['screens'][$hostname]['masterRefresh'];
} elseif (isset($settings['defaults']['masterRefresh'])) {
$masterRefresh = $settings['defaults']['masterRefresh'];
} else {
$masterRefresh = '86400';
}
if (isset($settings['screens'][$hostname]['tabTime'])) {
$tabTime = intval($settings['screens'][$hostname]['tabTime']) + 2;
} elseif (isset($settings['defaults']['tabTime'])) {
$tabTime = intval($settings['defaults']['tabTime']) + 2;
} else {
$tabTime = '30';
}
if (isset($settings['screens'][$hostname]['tabRefresh'])) {
$tabRefresh = $settings['screens'][$hostname]['tabRefresh'];
} elseif (isset($settings['defaults']['tabRefresh'])) {
$tabRefresh = $settings['defaults']['tabRefresh'];
} else {
$tabRefresh = true;
}
?>
<html>
<head>
<title>NOC Screen</title>
<meta http-equiv="refresh" content="<?php echo $masterRefresh ?>">
<style>
body {overflow: hidden;}
</style>
<script>
<!--
<?php
for ($ui = 1; $ui <= $urlcount; $ui++) {
echo "url$ui = '".$urlk[$ui-1]."';\n";
}
echo "CURPAGE = 'screen1';\n";
echo "function StartTimers() {\n";
for ($ui = 1; $ui <= $urlcount; $ui++) {
echo " frame$ui.location = url$ui;\n";
}
echo " setInterval('ScreenRefresh()',".$tabTime."000);\n";
echo " setTimeout('ScreenRefresh()',2000);\n";
echo "}\n";
echo "function ScreenRefresh() {\n";
echo " console.log(CURPAGE);\n";
if ($urlcount>1) {
for ($ui = 1; $ui <= $urlcount; $ui++) {
echo " screen$ui.style = 'display: none;';\n";
}
echo " if (CURPAGE == 'screen1') {\n";
echo " setTimeout(\"screen1.style = 'display: block;';\",2000);\n";
if (isset($urls[$urlk[0]]['tabRefresh']) && $urls[$urlk[0]]['tabRefresh']) {
echo " frame1.location = url1;\n";
} elseif (!isset($urls[$urlk[0]]['tabRefresh']) && $tabRefresh) {
echo " frame1.location = url1;\n";
}
echo " CURPAGE = 'screen2';\n";
for ($ui = 2; $ui <= $urlcount; $ui++) {
echo " } else if (CURPAGE == 'screen$ui') {\n";
echo " setTimeout(\"screen$ui.style = 'display: block;';\",2000);\n";
if (isset($urls[$ui-1]['tabRefresh']) && $urls[$ui-1]['tabRefresh']) {
echo " frame$ui.location = url$ui;\n";
} elseif (!isset($urls[$ui-1]['tabRefresh']) && $tabRefresh) {
echo " frame$ui.location = url$ui;\n";
}
echo " CURPAGE = 'screen".($ui+1)."';\n";
}
echo " }\n if (CURPAGE == 'screen".($urlcount+1)."') { CURPAGE = 'screen1'; }\n";
} else {
if (isset($urls[$urlk[0]]['tabRefresh']) && $urls[$urlk[0]]['tabRefresh']) {
echo " frame1.location = url1;\n";
} elseif (!isset($urls[$urlk[0]]['tabRefresh']) && $tabRefresh) {
echo " frame1.location = url1;\n";
} else {
echo " return;\n";
}
}
echo "}\n";
?>
-->
</script>
</head>
<body onload="StartTimers()" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>
<div id="sound_element" style="display:none;"></div>
<?php
for ($ui = 1; $ui <= $urlcount; $ui++) {
echo "<div id='screen$ui'>\n";
echo " <iframe src='loading.html' name='frame$ui' id='frame$ui' width=100% height=100% frameborder=0></iframe>\n";
echo "</div>\n";
}
?>
</body>
</html>