Commit 35bc7b7b authored by Laurent Joly's avatar Laurent Joly
Browse files

page maintenance gestion poste (en mode dev)

parent 197da71f
<?php
/**
* Maintenance suppression des postes
* @Projet LCS / SambaEdu
* @auteurs Laurent Joly
* @note
* @Licence Distribue sous la licence GPL
*/
// loading libs and init
include "entete.inc.php";
include "ihm.inc.php";
include "wpkg_lib.php";
include "wpkg_libsql.php";
$login = isauth();
if (! $login) {
echo "<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
$request = '/wpkg/index.php';
echo "top.location.href = '/auth.php?request=" . rawurlencode($request) . "';\n";
echo "//-->\n</script>\n";
exit();
}
if (! have_right($config, "computer_is_admin"))
die(gettext("Vous n'avez pas les droits suffisants pour acc&#233;der &#224; cette fonction") . "</BODY></HTML>");
// HTMLpurifier
$conf = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($conf);
if (isset($_GET["tri"]))
$tri = $purifier->purify($_GET["tri"]) + 0;
else
$tri = 0;
if (isset($_GET['flag']))
$get_flag = $purifier->purify($_GET['flag']);
else
$get_flag = -1;
if (isset($_GET['uuid']))
$get_uuid = $purifier->purify($_GET['uuid']);
else
$get_uuid = -1;
$page_id=1;
include("maintenance_top.php");
echo "<form method='get' action=''>\n";
echo "</form>\n";
function maintenance_liste_poste($config)
{
$wpkg_link = connexion_db_wpkg($config);
$query = mysqli_prepare($wpkg_link, "SELECT p.id_poste, p.nom_poste, p.OS_poste, p.date_rapport_poste, p.ip_poste, p.mac_address_poste, p.file_log_poste, p.file_rapport_poste, p.date_modification_poste, p.flag_poste, p.uuid_poste, count(distinct pa.id_app) as nb_appli, sum(pa.statut_poste_app='Installed') as nb_appli_installed
FROM (`postes` p)
LEFT JOIN (`poste_app` pa) ON pa.id_poste=p.id_poste
WHERE 1=1
GROUP BY p.nom_poste ASC
ORDER BY p.date_modification_poste ASC");
mysqli_stmt_execute($query);
mysqli_stmt_bind_result($query, $res_id_poste, $res_nom_poste, $res_OS_poste, $res_date_rapport_poste, $res_ip_poste, $res_mac_address_poste, $res_file_log_poste, $res_file_rapport_poste, $res_date_modification_poste, $res_flag_poste, $res_uuid_poste, $res_nb_appli, $res_nb_appli_installed);
mysqli_stmt_store_result($query);
$num_rows = mysqli_stmt_num_rows($query);
$tab = array();
if ($num_rows != 0) {
while (mysqli_stmt_fetch($query))
{
$tab[strtolower($res_nom_poste)] = array(
"id" => $res_id_poste,
"nom_poste" => strtolower($res_nom_poste),
"OS_poste" => $res_OS_poste,
"date_rapport_poste" => $res_date_rapport_poste,
"IP_poste" => $res_ip_poste,
"mac_address_poste" => $res_mac_address_poste,
"file_log_poste" => $res_file_log_poste,
"file_rapport_poste" => $res_file_rapport_poste,
"date_modification_poste" => $res_date_modification_poste,
"uuid_poste" => $res_uuid_poste,
"flag_poste" => $res_flag_poste,
"nb_appli_installed" => $res_nb_appli_installed,
"nb_appli" => $res_nb_appli
);
}
}
mysqli_stmt_close($query);
deconnexion_db_wpkg($wpkg_link);
return $tab;
}
$liste_poste=maintenance_liste_poste($config);
$tri_poste = array();
$tri_flag = array();
$tri_date = array();
$tri_ip = array();
$tri_mac = array();
$tri_nb_app = array();
foreach ($liste_poste as $key => $row) {
$tri_poste[] = $key;
$tri_flag[] = $row["flag_poste"];
$tri_date[] = $row["date_modification_poste"];
$tri_ip[] = ip2long($row["IP_poste"]);
$tri_mac[] = $row["mac_address_poste"];
$tri_nb_app[] = $row["nb_appli_installed"];
}
if ($liste_poste) {
switch ($tri) {
case 0:
array_multisort($tri_poste, SORT_ASC, $liste_poste);
break;
case 1:
array_multisort($tri_poste, SORT_DESC, $liste_poste);
break;
case 2:
array_multisort($tri_flag, SORT_ASC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 3:
array_multisort($tri_flag, SORT_DESC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 4:
array_multisort($tri_nb_app, SORT_DESC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 5:
array_multisort($tri_nb_app, SORT_ASC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 6:
array_multisort($tri_date, SORT_DESC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 7:
array_multisort($tri_date, SORT_ASC, $tri_poste, SORT_ASC, $liste_poste);
break;
case 8:
array_multisort($tri_ip, SORT_ASC, $liste_poste);
break;
case 9:
array_multisort($tri_ip, SORT_DESC, $liste_poste);
break;
case 10:
array_multisort($tri_mac, SORT_ASC, $liste_poste);
break;
case 11:
array_multisort($tri_mac, SORT_DESC, $liste_poste);
break;
default:
array_multisort($tri_poste, SORT_ASC, $liste_poste);
break;
}
}
echo "<table cellspadding='2' cellspacing='1' border='0' align='center' bgcolor='black'>\n";
echo "<tr style='color:white'>";
echo "<th width='120' rowspan='2'><a href='?tri=";
if ($tri == 0)
echo "1";
else
echo "0";
echo "' style='color:" . $regular_lnk . "'>Nom du poste</a></th>";
echo "<th width='50' rowspan='2'>OS</th>";
echo "<th width='120' rowspan='2'><a href='?tri=";
if ($tri == 2)
echo "3";
else
echo "2";
echo "' style='color:" . $regular_lnk . "'>Statut</a></th>";
echo "<th width='180' colspan='2'>Nombre d'applications</th>";
echo "<th width='200' rowspan='2'><a href='?tri=";
if ($tri == 6)
echo "7";
else
echo "6";
echo "' style='color:" . $regular_lnk . "'>Date du dernier rapport</a></th>";
echo "<th width='120' rowspan='2'><a href='?tri=";
if ($tri == 8)
echo "9";
else
echo "8";
echo "' style='color:" . $regular_lnk . "'>Adresse IP</a></th>";
echo "<th width='160' rowspan='2'><a href='?tri=";
if ($tri == 10)
echo "11";
else
echo "10";
echo "' style='color:" . $regular_lnk . "'>Adresse mac</a></th>";
echo "<th width='160' rowspan='2'>Uuid machine</a></th>";
echo "</tr>\n";
echo "<tr style='color:white'>";
echo "<th width='90'>Total</th>";
echo "<th width='90'><a href='?tri=";
if ($tri == 4)
echo "5";
else
echo "4";
echo "' style='color:" . $regular_lnk . "'>Installées</a></th>";
echo "</tr>\n";
foreach ($liste_poste as $nom_poste => $lp)
{
$affichage = 0;
switch ($lp["flag_poste"]) {
case 0:
$bg = $ok_bg;
$lnk = $ok_lnk;
$txt = $ok_txt;
$affichage = 1;
break;
case 1:
$bg = $error_bg;
$lnk = $error_lnk;
$txt = $error_txt;
$affichage = 1;
break;
case 2:
$bg = $warning_bg;
$lnk = $warning_lnk;
$txt = $warning_txt;
$affichage = 1;
break;
}
if ($affichage == 1)
{
echo "<tr bgcolor='" . $bg . "' style='color: " . $txt . "'>";
echo "<td align='center'><a href='poste_statuts.php?id_host=" . $nom_poste . "' style='color: " . $lnk . "'>" . $nom_poste . "</a></td>";
echo "<td align='center' bgcolor='" . $wintype_txt . "'>";
echo '<img src="images/';
switch ($lp["OS_poste"]) {
case 'Windows XP':
echo "winxp.png";
break;
case 'Windows 7':
echo "win7.png";
break;
case 'Windows 10':
echo "win10.png";
break;
default:
echo "vide.png";
break;
}
echo '" width="20" height="20">';
echo "</td>";
echo "<td align='center'>";
switch ($lp["flag_poste"]) {
case 0:
echo "Non prot&#233;g&#233;";
break;
case 1:
echo "Prot&#233;g&#233;";
break;
case 2:
echo "Autre";
break;
}
echo "</td>";
echo "<td align='center'>" . $lp["nb_appli"] . "</td>";
echo "<td align='center'>" . $lp["nb_appli_installed"] . "</td>";
echo "<td align='center'><a href='log.php?logfile=" . $lp["file_rapport_poste"] . "' target='rapport_poste' style='color: " . $lnk . "'>" . $lp["date"] . " à " . $lp["time"] . "</a></td>";
echo "<td align='center'>" . $lp["IP_poste"] . "</td>";
echo "<td align='center'>" . $lp["mac_address_poste"] . "</td>";
echo "<td align='center'>" . $lp["uuid_poste"] . "</td>";
echo "</tr>\n";
}
}
echo "</table>\n";
include ("pdp.inc.php");
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment