Advertisement
Guest User

Untitled

a guest
Mar 6th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?php
  3. echo "Hello Squid";
  4. echo "\n";
  5. function readline($prompt = null) {
  6.     if($prompt) {
  7.         echo $prompt;
  8.     }
  9.     $fp = fopen("php://stdin","r");
  10.     $line = rtrim(fgets($fp, 1024));
  11.     fclose($fp);
  12.     return $line;
  13. }
  14.  
  15. function shutoff() {
  16.     echo "Shutting down.\n";
  17.     file_put_contents("/home/basel/Desktop/php/h.txt","----end----\n\n", FILE_APPEND);
  18.     exit;
  19. }
  20. //register_shutdown_function('shutoff');
  21. $cur = 0;
  22. foreach ($argv as $ffffff) {
  23.     $cur += 1;
  24.     file_put_contents("/home/basel/Desktop/php/h.txt","arg" . $cur . ": " . $ffffff."\n", FILE_APPEND);
  25. }
  26. file_put_contents("/home/basel/Desktop/php/h.txt","\n", FILE_APPEND);
  27. $shut = 0;
  28. while ($shut != 1) {
  29.     //$gg = readline("Command:");
  30.     $gg = readline();
  31.     if (!is_null($gg)) {
  32.         if ($gg === "shutdown") {
  33.             file_put_contents("/home/basel/Desktop/php/ht.txt",":" . $gg."\n",FILE_APPEND);
  34.             file_put_contents("/home/basel/Desktop/php/ht.txt","----end----\n\n",FILE_APPEND);
  35.             break;
  36.             $shut = 1;
  37.         } else {
  38.             file_put_contents("/home/basel/Desktop/php/ht.txt",":" . $gg."\n",FILE_APPEND);
  39.         }
  40.     }
  41. }
  42. shutoff();
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement