Search This Blog

Loading...

Friday, May 29, 2009

Weekly PHP Script - Start Programs on a server.

Sorry I am a little late on posting up the weekly php code. Its important to remember that good things come to those who wait. You waited, so I have something extra special. This week I will post a script that allows you to start up programs on a server. Its really simple, but you have to be careful how you use it.

The code:

< ? php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('someprogram.exe');
? >

(No Spaces in the PHP tags. Due to blog spot restrictions im currently prohibited from entering in PHP code... Im working on it!)

Basically when a user navigates to the script location (ex: www.yoursite.com/startup.php) Then a program is started on the server. You should not confuse this with starting up a program on the user end. It simply runs a program on the server end without security warnings or restrictions. I wish I had known this earlier because technically if you port forwarded your server and all that jazz you could use this to control your PC instead of the email. Although some ISP's block port 80 and in which case you would be best off using the e-mail approach.

Download this script


Be sure to read up on the warnings and possible security risks of this code at: http://us2.php.net/function.exec

0 comments:

Post a Comment