[PHP] Emulate Terminal (PING example) | Émuler un terminal (exemple de PING) [PHP] Emulate Terminal (PING example) | Émuler un terminal (exemple de PING) | Scripts | Codes

Scripts | Codes

All languages in three languages :-)



Envoyer un ping et voir le résultat comme sur le terminal.
L'utilisation est simple, juste écrire les arguments de la commande PING dans les champs appropriés.
Vous pouvez modifier la commande pour mettre ce que vous voulez, juste modifier ce qu'il y a à l'intérieur de la commande systeme().

Send a ping and see the result as in the terminal.

Operation is simple, just write the arguments of the PING command in the appropriate fields.
You can change the command to put whatever you want, just change what is within the control system().

إرسل أمر PING و شاهد النتيجة كما في Terminal .

الاستعمال سهل فقط كتابة معطيات الأمر في الحقول المناسبة.
إذا أردت أن تستعمل أمر آخر عوضه في الدالة ()‎‎ ‎system

Open in a new window
<?
//#################################################
// find more codes on codes-n-scripts.blogspot.com
//#################################################
?>
<html>
 <head>
  <title>Web Ping</title>
  <style type='text/css'>
   pre {
    background:black;
 border:1px lime solid;
 color:lime;
   }
   td {
    font-family:monospace;
   }
  </style>
 </head>
 <body>
  <?php

   # clean the strings to prevent injection attacks
   $BADCHARS='/[^\.\w]/';
   $HOST=preg_replace($BADCHARS, '', $_GET['host']);
   $C=preg_replace($BADCHARS, '', $_GET['c']);
   $I=preg_replace($BADCHARS, '', $_GET['i']);
 
   if ($I=="") { $I=1; } # assign default values
   if ($C=="") { $C=4; } # assign default values

   if ($HOST!="") { # this is where the magic happens
    echo '<pre>';
    $last_line = system('/bin/ping '.$HOST.' -c '.$C.' -i '.$I, $retval);
    echo '</pre>';
   }
 
  ?>
  <form action='ping.php' method='get'>
   <table>
    <tr>
     <td>Hostname/IP:</td><td><input type='text' name='host' value='<?php echo $HOST ?>'/></td>
    </tr>
 <tr>
  <td>count:</td><td><input type='text' name='c' value='<?php echo $C ?>' /></td>
 </tr>
 <tr>
  <td>interval:</td><td><input type='text' name='i' value='<?php echo $I ?>' /></td>
 </tr>
    <tr>
     <td colspan='2'>
      <input type='submit' value='Ping It' /><br><br><br>
     </td>
    </tr>
   </table>
  </form>
 </body>
</html>

0 commentaires

Post a Comment

Subscribe to: Post Comments (Atom)
attendez....