Bonjour,
j'ai vraiment besoin d'aide parce que je suis en train chercher un moyen de contrôler un serveur distant au travers d'un page php.
j'ai fait un système d'alerte(avec des feux tricolores pour donner l'état du serveur. en fait l'idée c'est de pouvoir en appuyant sur bouton start, envoyer la commande appropriée et afficher en même temps l'état du serveur. donc il me faut deux processus j'imagine. donc le premier pour lancer la commande en background et le second pour afficher l'état du serveur.
ce que j'ai fait actuellement c'est de lancer des commandes dos test(avec shell_exec, exec) mais la page php attend la fin de l’exécution de la commande avant de continuer. s'il y a des idées ou mieux pour m'aider à arriver à mes fins, je suis preneur.
voici mon code qui fait la simulation de l'état du serveur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
<?php
include "head.php";
?>
 
<script>
 
function setState(){
		document.getElementById("mes_feux").style.backgroundImage = 'url("img/feux_vert.jpg")';
}
 
function start(valeur)
{
	if(valeur==1)
	{
		document.getElementById("mes_feux").style.backgroundImage = 'url("img/feux_rouge.jpg")';
	}
	else
	if(valeur==0)
	{
	  document.getElementById("mes_feux").style.backgroundImage = 'url("img/feux_orange.jpg")';
	  setTimeout(setState, 6000);
	}
}	
</script>
 
<form action="servers_administration.php" method="post" name="formulaire">
	<table>
	<thead>
		<th>
			Server
		</th>
		<th>
			Command
		</th>
		<th>
			Status
		</th>
	</thead>
		<tr>
			<td>
				<input type="radio" name="server" value="lum1" onClick="" <?php if (isset($_POST["server"]))
																								if($_POST["server"]=="lum1"){?>
																										checked="checked"<?php }?>/>lum1<br>
				<input type="radio" name="server" value="lum4" onClick="" <?php if (isset($_POST["server"]))
																								if($_POST["server"]=="lum4"){?>
																										checked="checked"<?php }?>/>lum4<br>
			</td>
			<td style="background-color:#FFFFFF;" align=right>
				<input type="radio" name="feux" value="R" onClick="start(1);" <?php if (isset($_POST["feux"]))
																								if($_POST["feux"]=="R"){?>
																										checked="checked"<?php }?>/>stop<br>
				<input type="radio" name="feux" value="V" onClick="start(0);" <?php if (isset($_POST["feux"]))
																								if($_POST["feux"]=="V"){?>
																										checked="checked"<?php }?>/>start<br>
				<input name="other" type="button" value ="Other commands" onClick="">
			</td>
 
			<?php 
				$init = 0;
				$choix  = "";
						if(isset($_POST["feux"])&&(!isset($_GET['val'])))
						$choix = $_POST["feux"];	
			?>
			<td style="background-color:#FFFFFF;">
				<div id="mes_feux" style="height:150px; width:50px; background-image:url('img/feux.jpg')>">									
				</div>
			</td>
 
		</tr>
	</table>
</form>
 
<?php
include "foot.php";
?>
merci d'avance.