Commit 6e35b8dd authored by Laurent Joly's avatar Laurent Joly
Browse files

Update wpkg_libsql.php

ajout de 3 fonctions de maintenance (protection/deprotection/suppression machine sans uuid)
parent 3585cefd
......@@ -71,7 +71,7 @@
* maintenance_liste_poste($config,$flag,$uuid) : liste des postes avec info uuid + protection
* maintenance_poste_protection($config,$id_poste) passage du poste en mode protege
* maintenance_poste_deprotection($config,$id_poste) passage du poste en mode deprotege
* maintenance_poste_supression($config,$id_poste) autorisation de la suppresion d un poste sans uuid
* maintenance_poste_suppression($config,$id_poste) autorisation de la suppresion d un poste sans uuid
* maintenance_poste_reset_wpkg($config,$id_poste) changement hash du rapport pour forcer la relecture du rapport
*
* ----------------------------------------------------------------------------------------------------
......@@ -1555,4 +1555,106 @@ function maintenance_liste_poste($config,$flag,$uuid)
return $tab;
}
function maintenance_poste_protection($config,$id_poste)
{
$wpkg_link = connexion_db_wpkg($config);
$query = mysqli_prepare($wpkg_link, "SELECT nom_poste, flag_poste FROM `postes` WHERE id_poste=?");
mysqli_stmt_bind_param($query, "i", $id_poste);
mysqli_stmt_execute($query);
mysqli_stmt_bind_result($query, $res_nom_poste, $res_flag_poste);
mysqli_stmt_store_result($query);
$num_rows = mysqli_stmt_num_rows($query);
$nom_poste=0;
if ($num_rows == 1)
{
while (mysqli_stmt_fetch($query))
{
$nom_poste = $res_nom_poste;
$flag_poste = $res_flag_poste;
}
if ($flag_poste!=1)
{
$update_query = mysqli_prepare($wpkg_link, "UPDATE `postes` SET `flag_poste`=1, `date_modification_poste`=NOW() WHERE `id_poste`=?");
mysqli_stmt_bind_param($update_query, "i", $id_poste);
mysqli_stmt_execute($update_query);
mysqli_stmt_close($update_query);
}
else
$nom_poste=0;
}
mysqli_stmt_close($query);
deconnexion_db_wpkg($wpkg_link);
return $nom_poste;
}
function maintenance_poste_deprotection($config,$id_poste)
{
$wpkg_link = connexion_db_wpkg($config);
$query = mysqli_prepare($wpkg_link, "SELECT nom_poste, flag_poste, uuid_poste FROM `postes` WHERE id_poste=?");
mysqli_stmt_bind_param($query, "i", $id_poste);
mysqli_stmt_execute($query);
mysqli_stmt_bind_result($query, $res_nom_poste, $res_flag_poste, $res_uuid_poste);
mysqli_stmt_store_result($query);
$num_rows = mysqli_stmt_num_rows($query);
$nom_poste=0;
if ($num_rows == 1)
{
while (mysqli_stmt_fetch($query))
{
$nom_poste = $res_nom_poste;
$flag_poste = $res_flag_poste;
$uuid_poste = $res_uuid_poste;
}
if ($flag_poste!=0 and $uuid_poste!="")
{
$update_query = mysqli_prepare($wpkg_link, "UPDATE `postes` SET `flag_poste`=0, `date_modification_poste`=NOW() WHERE `id_poste`=?");
mysqli_stmt_bind_param($update_query, "i", $id_poste);
mysqli_stmt_execute($update_query);
mysqli_stmt_close($update_query);
}
else
$nom_poste=0;
}
mysqli_stmt_close($query);
deconnexion_db_wpkg($wpkg_link);
return $nom_poste;
}
function maintenance_poste_suppression($config,$id_poste)
{
$wpkg_link = connexion_db_wpkg($config);
$query = mysqli_prepare($wpkg_link, "SELECT nom_poste, flag_poste, uuid_poste FROM `postes` WHERE id_poste=?");
mysqli_stmt_bind_param($query, "i", $id_poste);
mysqli_stmt_execute($query);
mysqli_stmt_bind_result($query, $res_nom_poste, $res_flag_poste, $res_uuid_poste);
mysqli_stmt_store_result($query);
$num_rows = mysqli_stmt_num_rows($query);
$nom_poste=0;
if ($num_rows == 1)
{
while (mysqli_stmt_fetch($query))
{
$nom_poste = $res_nom_poste;
$flag_poste = $res_flag_poste;
$uuid_poste = $res_uuid_poste;
}
if ($uuid_poste=="")
{
$delete_uuid="DELETE".$id_poste;
$update_query = mysqli_prepare($wpkg_link, "UPDATE `postes` SET `flag_poste`=0, `uuid_poste`=?, `date_modification_poste`=NOW() WHERE `id_poste`=?");
mysqli_stmt_bind_param($update_query, "si", $delete_uuid, $id_poste);
mysqli_stmt_execute($update_query);
mysqli_stmt_close($update_query);
}
else
$nom_poste=0;
}
mysqli_stmt_close($query);
deconnexion_db_wpkg($wpkg_link);
return $nom_poste;
}
?>
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