summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol
diff options
context:
space:
mode:
authorUdo Walter2017-09-01 15:27:06 +0200
committerUdo Walter2017-09-01 15:27:06 +0200
commit599c259845cd94a0bb64233b9935ea8c38be65b0 (patch)
treef6b2601d774aa5a0ca8785015d997545ef9952f7 /modules-available/rebootcontrol
parent[js_stupidtable] changed one-line code to formatted code; (diff)
parent[locationinfo] Add backend for Microsoft Exchange Server (diff)
downloadslx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.tar.gz
slx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.tar.xz
slx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.zip
Merge remote-tracking branch 'origin/master' into permission-manager
Diffstat (limited to 'modules-available/rebootcontrol')
-rw-r--r--modules-available/rebootcontrol/api.inc.php12
-rw-r--r--modules-available/rebootcontrol/config.json2
-rw-r--r--modules-available/rebootcontrol/inc/rebootqueries.inc.php25
-rw-r--r--modules-available/rebootcontrol/lang/de/template-tags.json6
-rw-r--r--modules-available/rebootcontrol/templates/_page.html4
5 files changed, 37 insertions, 12 deletions
diff --git a/modules-available/rebootcontrol/api.inc.php b/modules-available/rebootcontrol/api.inc.php
index 77687f8e..dad25375 100644
--- a/modules-available/rebootcontrol/api.inc.php
+++ b/modules-available/rebootcontrol/api.inc.php
@@ -1,4 +1,13 @@
<?php
+
+if (Request::any('action') === 'rebuild' && isLocalExecution()) {
+ if (Module::isAvailable('sysconfig')) {
+ SSHKey::getPublicKey();
+ ConfigTgz::rebuildAllConfigs();
+ echo "OK";
+ }
+ exit(0);
+}
/*
Needed POST-Parameters:
'token' -- for authentification
@@ -15,7 +24,8 @@ foreach ($ips as $client) {
$clients[] = array("ip" => $client);
}
-if (Request::post('token') == Property::get("rebootcontrol_APIPOSTKEY")) {
+$apikey = Property::get("rebootcontrol_APIPOSTKEY", 'not-set');
+if (!empty($apikey) && Request::post('token') === $apikey) {
if (Request::isPost()) {
if (Request::post('action') == 'shutdown') {
$shutdown = true;
diff --git a/modules-available/rebootcontrol/config.json b/modules-available/rebootcontrol/config.json
index 2cc05822..d8ab5868 100644
--- a/modules-available/rebootcontrol/config.json
+++ b/modules-available/rebootcontrol/config.json
@@ -1,4 +1,4 @@
{
- "category":"main.content",
+ "category":"main.beta",
"dependencies": [ "locations", "js_stupidtable" ]
}
diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
index df3c13d8..8f65b756 100644
--- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
@@ -5,10 +5,12 @@ class RebootQueries
// Get Client+IP+CurrentVM+CurrentUser+Location to fill the table
public static function getMachineTable($locationId) {
+ $queryArgs = array('cutoff' => strtotime('-30 days'));
if ($locationId === 0) {
$where = 'machine.locationid IS NULL';
} else {
$where = 'machine.locationid = :locationid';
+ $queryArgs['locationid'] = $locationId;
}
$leftJoin = '';
$sessionField = 'machine.currentsession';
@@ -19,12 +21,25 @@ class RebootQueries
}
$res = Database::simpleQuery("
SELECT machine.machineuuid, machine.hostname, machine.clientip,
- IF(machine.lastboot = 0 OR UNIX_TIMESTAMP() - machine.lastseen >= 600, 0, 1) AS status,
+ machine.lastboot, machine.lastseen, machine.logintime,
$sessionField, machine.currentuser, machine.locationid
FROM machine
$leftJoin
- WHERE " . $where, array('locationid' => $locationId));
- return $res->fetchAll(PDO::FETCH_ASSOC);
+ WHERE $where AND machine.lastseen > :cutoff", $queryArgs);
+ $ret = $res->fetchAll(PDO::FETCH_ASSOC);
+ $NOW = time();
+ foreach ($ret as &$row) {
+ if ($row['lastboot'] == 0 || $NOW - $row['lastseen'] > 600) {
+ $row['status'] = 0;
+ } else {
+ $row['status'] = 1;
+ }
+ if ($row['status'] === 0 || $row['logintime'] == 0) {
+ $row['currentuser'] = '';
+ $row['currentsession'] = '';
+ }
+ }
+ return $ret;
}
/**
@@ -36,8 +51,8 @@ class RebootQueries
{
if (empty($list))
return array();
- $qs = '?' . str_repeat(',?', count($list) - 1);
- $res = Database::simpleQuery("SELECT machineuuid, clientip, locationid FROM machine WHERE machineuuid IN ($qs)", $list);
+ $res = Database::simpleQuery("SELECT machineuuid, clientip, locationid FROM machine
+ WHERE machineuuid IN (:list)", compact('list'));
return $res->fetchAll(PDO::FETCH_ASSOC);
}
diff --git a/modules-available/rebootcontrol/lang/de/template-tags.json b/modules-available/rebootcontrol/lang/de/template-tags.json
index 2a04e746..57164f02 100644
--- a/modules-available/rebootcontrol/lang/de/template-tags.json
+++ b/modules-available/rebootcontrol/lang/de/template-tags.json
@@ -1,5 +1,5 @@
{
- "lang_authFail": "Athentifizierung fehlgeschlagen",
+ "lang_authFail": "Authentifizierung fehlgeschlagen",
"lang_client": "Client",
"lang_connecting": "Verbinde...",
"lang_error": "Nicht erreichbar",
@@ -14,7 +14,7 @@
"lang_reboot": "Neustarten",
"lang_rebootAt": "Neustart um:",
"lang_rebootButton": "Neustarten",
- "lang_rebootCheck": "Wollen Sie wirklich die ausgew\u00e4hlten Rechner neustarten?",
+ "lang_rebootCheck": "Wollen Sie die ausgew\u00e4hlten Rechner wirklich neustarten?",
"lang_rebooting": "Neustart...",
"lang_selectall": "Alle ausw\u00e4hlen",
"lang_selected": "Ausgew\u00e4hlt",
@@ -23,7 +23,7 @@
"lang_shutdown": "Herunterfahren",
"lang_shutdownAt": "Herunterfahren um: ",
"lang_shutdownButton": "Herunterfahren",
- "lang_shutdownCheck": "Wollen Sie wirklich die ausgew\u00e4hlten Rechner herunterfahren?",
+ "lang_shutdownCheck": "Wollen Sie die ausgew\u00e4hlten Rechner wirklich herunterfahren?",
"lang_shutdownIn": "Herunterfahren in: ",
"lang_status": "Status",
"lang_unselectall": "Alle abw\u00e4hlen",
diff --git a/modules-available/rebootcontrol/templates/_page.html b/modules-available/rebootcontrol/templates/_page.html
index 0fc3c166..4d2bf60e 100644
--- a/modules-available/rebootcontrol/templates/_page.html
+++ b/modules-available/rebootcontrol/templates/_page.html
@@ -40,10 +40,10 @@
<td>{{clientip}}</td>
<td class="statusColumn">
{{#status}}
- {{lang_on}}
+ <span class="text-success">{{lang_on}}</span>
{{/status}}
{{^status}}
- {{lang_off}}
+ <span class="text-danger">{{lang_off}}</span>
{{/status}}
</td>
<td>{{#status}}{{currentsession}}{{/status}}</td>