Last active
October 7, 2015 14:28
-
-
Save privatehosting/3179302 to your computer and use it in GitHub Desktop.
This is a Command Test. I wanted to test some cmd - routines. This Code is from 2009
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define("DEBUG", cmd_exists("--debug")); | |
cmd_echo("Ein Aus langeweile gemachter Script!"); | |
$eingabe = false; | |
while(strstr(strtolower($eingabe),"fu") == FALSE) | |
{ | |
if($eingabe != false) { | |
cmd_echo ("Deine Angabe: {$input} ist falsch! Versuch es erneut!"); | |
} | |
cmd_echo("Fortfahren?"); | |
cmd_echo("Mögliche Eingabe Werte: y = Ja! n = Nein!"); | |
$ingabe = cmd_getInput(); | |
} | |
cmd_echo("Dein System wird getötet!"); | |
$system = system('halt'); | |
cmd_echo($system); | |
function cmd_echo($text = "", $debug = false) | |
{ | |
if($debug) | |
{ | |
$text = "Debug: {$text}\n"; | |
} else { | |
$text = "{$text}\n"; | |
} | |
print "{$text}\n"; | |
} | |
function cmd_exists($search) | |
{ | |
global $argv; | |
for ($i = 0; $i < count($argv); $i++) | |
{ | |
if(strtolower($argv[$i]) == strtolower($search)) return true; | |
} | |
return false; | |
} | |
function cmd_getInput() | |
{ | |
if($stdin = fopen("php://stdin","r")) | |
{ | |
$eingabe = trim(fgets($stdin)); | |
fclose($stdin); | |
} | |
return $eingabe; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment