Skip to content
Permalink
Browse files

Add NEMS Cloud Services Dashboard

  • Loading branch information...
NEMS Linux
NEMS Linux committed Jul 19, 2019
1 parent 140b323 commit 11cc14e71fb270106aee08bb42087112cc205803
Showing with 57 additions and 0 deletions.
  1. +53 −0 cloud/index.php
  2. +4 −0 inc/header.php
@@ -0,0 +1,53 @@
<?php
$cloudauth = intval(shell_exec('/usr/local/bin/nems-info cloudauthcache'));
if ($cloudauth != 1) {
exit('This NEMS Server is not authorized to access NEMS Cloud Services.' . PHP_EOL . 'Please sign up and configure your connection in NEMS SST.');
}
// Get the HWID
$nemsconf['hwid'] = shell_exec('/usr/local/bin/nems-info hwid');
// Load the NEMS Cloud Services License Key
$nemsconffile = '/usr/local/share/nems/nems.conf'; // www-admin must have access to read/write
$conf = file($nemsconffile);
if (is_array($conf)) { // Load the existing conf data
foreach ($conf as $line) {
$tmp = explode('=',$line);
if (is_array($tmp) && count($tmp) == 2 && trim($tmp[0]) == 'osbkey') $nemsconf['osbkey'] = trim($tmp[1]);
}
}
redirect_post('https://cloud.nemslinux.com/dashboard/',$nemsconf);
/**
* Redirect with POST data.
*
* @param string $url URL.
* @param array $post_data POST data. Example: array('foo' => 'var', 'id' => 123)
* @param array $headers Optional. Extra headers to send.
*/
function redirect_post($url, array $data, array $headers = null) {
$params = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
if (!is_null($headers)) {
$params['http']['header'] = '';
foreach ($headers as $k => $v) {
$params['http']['header'] .= "$k: $v\n";
}
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if ($fp) {
echo @stream_get_contents($fp);
die();
} else {
// Error
throw new Exception("Error loading '$url', $php_errormsg");
}
}
?>
@@ -122,6 +122,10 @@ function resizeIframe(obj) {
<?php if (ver('nems') >= 1.4) echo '<li><a href="/adagios/" target="_blank">Adagios</a></li>'; ?>
<?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>'; ?>
<?php
$cloudauth = intval(shell_exec('/usr/local/bin/nems-info cloudauthcache'));
if ($cloudauth == 1) echo '<li><a href="/cloud/" target="_blank">NEMS Cloud Services Dashboard</a></li>';
?>

<li><h4 style="padding: 0 0 4px 4px; margin: 0;">Legacy</h4></li>
<?php

0 comments on commit 11cc14e

Please sign in to comment.
You can’t perform that action at this time.