Page 1 of 2

PHP Command Line

Posted: Mon Dec 03, 2007 5:38 pm
by Tails5
I've made a php script, which executes things on my computer, for when I'm not at home. But I need a little help making it do exactly what I want, I'd like it to automatically scale the textarea and input box to the users browser, and be able to fully emulate the command line so I can type "cd .." and all that to navigate around instead of having to remember the exact path of everything, and also to keep the previous output, along with the command entered, as if it were really cmd.exe. It's source code is:[php]<html>
<head>
<title>
Command Script
</title>
</head>
<body bgcolor="#000">
<form action="run.php" method="post">
<textarea name="text" rows=20 cols="60" disabled="disabled"><?php
passthru($_POST['run']);
?></textarea>


<input type="text" name="run" size=80 />
</form>
</body>
</html>[/php]The file is run.php, it redirects to itself to run the arguments. If anyone can help me, it would be greatly appreciated. I run Windows XP Home, with Apache2.2 and PHP 5.2.5.

Posted: Mon Dec 03, 2007 9:19 pm
by Lixas
in this case would be very good decision to use ajax. in your case, saja is perfect

Posted: Mon Dec 03, 2007 10:13 pm
by Tails5
While that's helpful, I don't know 'saja'. My web-design knowledge is limited to HTML, CSS, PHP, ASPX, and some Java

Posted: Tue Dec 04, 2007 5:58 pm
by Lixas
saja is "Secure AJAX for PHP" You jus need to create a class that do all you job, and using saja's framework run that class and function. It's ajax based solution, so i think it's da best fo u

http://saja.sourceforge.net/demo/

Posted: Tue Dec 04, 2007 9:39 pm
by Tails5
Okay, I'll look into that, thanks Lixas :)

Posted: Fri Dec 07, 2007 4:55 pm
by csoftdev
won't it be too dangerous to allow commands to be executed that way? what if someone pass it delete command?

Posted: Fri Dec 07, 2007 8:11 pm
by Tails5
:P My .htaccess file denies access from ANY computer unless they either have my IP address, or my password. So I'm safe :)

Posted: Mon Dec 10, 2007 2:40 pm
by TheCrymsonLegends
That is odd, could I ask what exactly you would try to run on your computer when you are away from the computer? Unless you attempt to connect to your computer to be able to use it from another computer I wouldn't really see the point, but none the less I am still quite confused as to how this would be a good thing. Not even LAN Networks work good for sharing programs only files and connectivity to the internet, so I would love to hear what you are going to use this for so I can understand :D

Posted: Tue Dec 11, 2007 2:37 am
by Tails5
Well mainly I want to be able to emulate teh command line to control things like... restarting Apache, SQL, and FTP, and query the status of services by using

Code: Select all

sc query <ServiceName>
and also I need to be in certain folders sometimes but the one I've got uses cmd.exe which defaults to C:\**** and Settings\Francisco\ for all of the commands, as it starts a new cmd.exe for each command I enter.

Posted: Tue Dec 11, 2007 8:05 am
by thetarget
hey, thanks for sharing. A little turn and twist for security will be good. No doubt ht.access does its job, but another layer of security is better.