Skip to content
Permalink
Browse files

NEMS Cloud Services Dashboard menu items redirect works

  • Loading branch information...
NEMS Linux
NEMS Linux committed Jul 19, 2019
1 parent 11cc14e commit 6e5fcd6e14e25ca1a08df1d6ac5f28244115bf0c
Showing with 10 additions and 36 deletions.
  1. +10 −36 cloud/index.php
@@ -5,49 +5,23 @@
}
// Get the HWID
$nemsconf['hwid'] = shell_exec('/usr/local/bin/nems-info hwid');
$hwid = trim(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]);
if (is_array($tmp) && count($tmp) == 2 && trim($tmp[0]) == 'osbkey') $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");
}
}
?>
echo '<html>
<body onload="document.forms[\'redirect\'].submit()">
<form action="https://cloud.nemslinux.com/dashboard/" method="post" name="redirect">
<input type="hidden" name="hwid" value="' . $hwid . '" />
<input type="hidden" name="osbkey" value="' . $osbkey . '" />
</form>
</body>
</html>';

0 comments on commit 6e5fcd6

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