8722 sujets

Développement web côté serveur, CMS

voilà je voudrai installer un panell web sur mon site via un block, pour démarrer éteindre mon serveur, j'ai créé en 2 fichier first.php et action.php:
first.php:
[CENTER]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Gestion du serveur</title>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>
<p>
   </p>
   <form name="first" action="action.php" method="POST" onsubmit="return onsubmitform();">
<input type="submit" name="action"    onclick="document.pressed=this.value" value="start" />
<input type="submit" name="action"    onclick="document.pressed=this.value" value="stop" />
<input type="submit" name="action"    onclick="document.pressed=this.value" value="restart" />
</form>
</div>
</body>
</html>
[/CENTER]

action.php:
[CENTER]
<?php
$address="0.0.0.0";
$port="22";
$user="test";
$password="000000";
$script="/var/srcds/test.sh";

// Connexion SSH
$shell = ssh2_connect($address, $port);
if (!$shell) return false;
$auth = ssh2_auth_password($shell, $user, $password);
if (!$auth) return false;

if ($action == "start") {
    $command  = $script . $action
    $stream = ssh2_exec($shell, $command);
    if ($stream){
        stream_set_blocking($stream, true);
        echo stream_get_contents($stream);
        return true;
    }
    else {
        return false;
    }
}

if ($action == "stop") {
    $command  = $script . $action
    $stream = ssh2_exec($shell, $command);
    if ($stream){
        stream_set_blocking($stream, true);
         echo stream_get_contents($stream);
        return true;
    }
    else {
        return false;
    }
}

if ($action == "restart") {
    $command  = $script . $action
    $stream = ssh2_exec($shell, $command);
    if ($stream){
        stream_set_blocking($stream, true);
         echo stream_get_contents($stream);
        return true;
    }
    else {
        return false;
    }
} 
?>
[/CENTER]

voilà mais 3 boutons s'affiche correctement sur first.php,
ensuite après avoir fait stop par exemple on part sur la page action.php et plus rien page blanche, que faire?
merci à vous
Modifié par demetrope (09 Apr 2013 - 16:19)
non en modifiant mon fichier pour le poste j'ai créer cette erreur involontairement,
j'ai édité et corrigé sur le premier poste
dans mon action.php, ça change rien:

$address="0.0.0.0";
$port="22";
$user="test";
$password="000000";
$script="/var/srcds/test.sh";
$action=$_post['action'];

merci
Modifié par demetrope (10 Apr 2013 - 10:40)