Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Grenoble
Eole-Wol
Commits
2a83c155
Unverified
Commit
2a83c155
authored
Aug 05, 2019
by
David Beniamine
Browse files
Hide table on action
parent
f63ca23b
Changes
1
Hide whitespace changes
Inline
Side-by-side
wol/www/index.php
View file @
2a83c155
...
...
@@ -22,141 +22,142 @@
<div
id=
"box"
style=
"font-size:large"
>
<div
id=
"content"
>
<h1>
Interface de gestion des postes
</h1>
<?php
ini_set
(
'display_errors'
,
1
);
ini_set
(
'display_startup_errors'
,
1
);
error_reporting
(
E_ALL
);
$lines
=
explode
(
PHP_EOL
,
shell_exec
(
"../scripts/get_registry.sh"
));
?>
<p>
<?php
echo
count
(
$lines
);
?>
postes sont inscrits sur ce serveur
</p>
<h2>
Actions globables
</h2>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAll"
>
<input
type=
"submit"
value=
"Mettre à jour tous les postes"
title=
"Mettre à jour tous les postes"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAllApt"
>
<input
type=
"submit"
value=
"Mettre à jour tous les postes avec mises à jour APT"
title=
"Mettre à jour tous les postes avec mises à jour APT"
>
</form>
<h2>
Gestion des postes
</h2>
<table>
<tr>
<th>
Nom
</th>
<th>
IP(s)
</th>
<th>
MAC
</th>
<th>
Version Debian
</th>
<th>
Version Primtux
</th>
<th>
État apt
</th>
<th>
État git
</th>
<th>
Date dernier contact
</th>
<th>
Actions
</th>
</tr>
<?php
$registry
=
array
();
foreach
(
$lines
as
$line
){
if
(
$line
!=
""
){
$entry
=
explode
(
' '
,
$line
);
array_push
(
$registry
,
$entry
);
# Format date mac name ip [num_apt_upgrade deb_version pt_version git_branch git_update]
echo
"<tr>"
;
echo
"<td>"
.
$entry
[
2
]
.
"</td>"
;
echo
"<td> "
.
$entry
[
3
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
1
]
.
"</td>"
;
#echo "<td>".$entry[0]."</td>";
if
(
count
(
$entry
)
>
4
){
echo
"<td>"
.
$entry
[
5
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
6
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
4
]
.
" mises à jour en attente</td>"
;
echo
"<td> branch "
.
$entry
[
7
]
.
" "
.
$entry
[
8
]
.
" commits en retard</td>"
;
}
else
{
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
}
# Last seen
echo
"<td>"
.
$entry
[
0
]
.
"</td>"
;
echo
"<td>"
;
# Actions
?>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"wake"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
];
?>
"
>
<input
type=
"submit"
value=
"Démarrer"
title=
"Démarrer la machine"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgrade"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
];
?>
"
>
<input
type=
"submit"
value=
"Mettre à jour"
title=
"Mettre à jour"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAPT"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
]
?>
;"
>
<input
type=
"submit"
value=
"Mettre à jour + Apt"
title=
"Mettre à jour + apt"
>
</form>
<?php
echo
"</td></tr>"
;
}
}
extract
(
$_POST
);
if
(
!
isset
(
$action
)){
$lines
=
explode
(
PHP_EOL
,
shell_exec
(
"../scripts/get_registry.sh"
));
?>
</table>
<pre>
<?php
json_encode
(
$registry
);
?>
</pre>
<?php
extract
(
$_POST
);
if
(
!
isset
(
$action
)){
exit
();
<h1>
Interface de gestion des postes
</h1>
<p>
<?php
echo
count
(
$lines
);
?>
postes sont inscrits sur ce serveur
</p>
<h2>
Actions globables
</h2>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAll"
>
<input
type=
"submit"
value=
"Mettre à jour tous les postes"
title=
"Mettre à jour tous les postes"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAllApt"
>
<input
type=
"submit"
value=
"Mettre à jour tous les postes avec mises à jour APT"
title=
"Mettre à jour tous les postes avec mises à jour APT"
>
</form>
<h2>
Gestion des postes
</h2>
<table>
<tr>
<th>
Nom
</th>
<th>
IP(s)
</th>
<th>
MAC
</th>
<th>
Version Debian
</th>
<th>
Version Primtux
</th>
<th>
État apt
</th>
<th>
État git
</th>
<th>
Date dernier contact
</th>
<th>
Actions
</th>
</tr>
<?php
$registry
=
array
();
foreach
(
$lines
as
$line
){
if
(
$line
!=
""
){
$entry
=
explode
(
' '
,
$line
);
array_push
(
$registry
,
$entry
);
# Format date mac name ip [num_apt_upgrade deb_version pt_version git_branch git_update]
echo
"<tr>"
;
echo
"<td>"
.
$entry
[
2
]
.
"</td>"
;
echo
"<td> "
.
$entry
[
3
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
1
]
.
"</td>"
;
#echo "<td>".$entry[0]."</td>";
if
(
count
(
$entry
)
>
4
){
echo
"<td>"
.
$entry
[
5
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
6
]
.
"</td>"
;
echo
"<td>"
.
$entry
[
4
]
.
" mises à jour en attente</td>"
;
echo
"<td> branch "
.
$entry
[
7
]
.
" "
.
$entry
[
8
]
.
" commits en retard</td>"
;
}
else
{
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
echo
"<td>NA</td>"
;
}
# Last seen
echo
"<td>"
.
$entry
[
0
]
.
"</td>"
;
echo
"<td>"
;
# Actions
?>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"wake"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
];
?>
"
>
<input
type=
"submit"
value=
"Démarrer"
title=
"Démarrer la machine"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgrade"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
];
?>
"
>
<input
type=
"submit"
value=
"Mettre à jour"
title=
"Mettre à jour"
>
</form>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"hidden"
name=
"action"
value=
"upgradeAPT"
>
<input
type=
"hidden"
name=
"mac"
value=
"
<?php
echo
$entry
[
1
]
?>
;"
>
<input
type=
"submit"
value=
"Mettre à jour + Apt"
title=
"Mettre à jour + apt"
>
</form>
<?php
echo
"</td></tr>"
;
}
}
switch
(
$action
){
case
"wake"
:
echo
"<div id='result'><p>Démarrage demandé pour la machine
$mac
, veuillez patienter</p></div>"
;
?>
</table>
<pre>
<?php
json_encode
(
$registry
);
?>
</pre>
<?php
}
else
{
switch
(
$action
){
case
"wake"
:
echo
"<div id='result'><p>Démarrage demandé pour la machine
$mac
, veuillez patienter</p></div>"
;
?>
<script
language=
"javascript"
>
// the wakeonlan is handled via ajax to show timeout progress
function
sendpost
(
retry
){
$
.
ajax
({
type
:
"
POST
"
,
data
:
'
<?php
echo
"mac=
$mac
"
?>
'
,
url
:
'
boot.php
'
,
timeout
:
30000
,
error
:
function
(
reponse
){
if
(
retry
>
0
){
// We probably have not waited long enough, let retry
$
(
"
#result
"
).
html
(
"
Recherche de la machine sur le réseau.<br/>Merci de patienter encore un peu (max
"
+
retry
*
5
+
"
sec).
"
)
;
sendpost
(
retry
-
1
);
}
else
{
// Actual error
$
(
"
#result
"
).
html
(
'
Erreur : machine absente du réseau après 120 secondes.<br />Pensez à vérifier l
\'
adresse MAC
\'
<?php
echo
"
$mac
"
?>
\'
'
)
;
<script
language=
"javascript"
>
// the wakeonlan is handled via ajax to show timeout progress
function
sendpost
(
retry
){
$
.
ajax
({
type
:
"
POST
"
,
data
:
'
<?php
echo
"mac=
$mac
"
?>
'
,
url
:
'
boot.php
'
,
timeout
:
30000
,
error
:
function
(
reponse
){
if
(
retry
>
0
){
// We probably have not waited long enough, let retry
$
(
"
#result
"
).
html
(
"
Recherche de la machine sur le réseau.<br/>Merci de patienter encore un peu (max
"
+
retry
*
5
+
"
sec).
"
)
;
sendpost
(
retry
-
1
);
}
else
{
// Actual error
$
(
"
#result
"
).
html
(
'
Erreur : machine absente du réseau après 120 secondes.<br />Pensez à vérifier l
\'
adresse MAC
\'
<?php
echo
"
$mac
"
?>
\'
'
)
;
}
},
success
:
function
(
response
)
{
// All good !
$
(
"
#result
"
).
html
(
response
)
;
}
},
success
:
function
(
response
)
{
// All good !
$
(
"
#result
"
).
html
(
response
)
;
}
});
}
// Ask for machine boot with timeout 24*5 = 120 seconds
sendpost
(
24
);
</script>
});
}
// Ask for machine boot with timeout 24*5 = 120 seconds
sendpost
(
24
);
</script>
<?php
break
;
case
"upgradeAll"
:
echo
"I should upgradeAll machines, not implemented yet"
;
breaK
;
case
"upgradeAllApt"
:
echo
"I should upgradeAllApt machines, not implemented yet"
;
breaK
;
break
;
case
"upgradeAll"
:
echo
"I should upgradeAll machines, not implemented yet"
;
breaK
;
case
"upgradeAllApt"
:
echo
"I should upgradeAllApt machines, not implemented yet"
;
breaK
;
case
"upgrade"
:
echo
"I should upgrade
$mac
, not implemented yet"
;
break
;
case
"upgradeAPT"
:
echo
"I should upgrade
$mac
with apt, not implemented yet"
;
break
;
case
"upgrade"
:
echo
"I should upgrade
$mac
, not implemented yet"
;
break
;
case
"upgradeAPT"
:
echo
"I should upgrade
$mac
with apt, not implemented yet"
;
break
;
}
}
?>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment