how do i use php to pass commands onto a server?
hi all how do i use php to pass commands onto a server?
like i want to be able to: 1. delete the content of a file (or just delete the file and make a new one if it's easier) 2. read the content from a file 3. write new data to a file via an input box 4. run a command on the server any help would be really appreciated |
a tutorial on forms with php
http://www.phpf1.com/tutorial/php-form.html php file i/o http://www.felixgers.de/teaching/php/fileIO.html as for running a command on the server perhaps the system() function, however that is a security hole |
the tutorial on forms with php and the php file i/o looks like what i need and about a security hole only i will have access to this php script so it'll be "safe" imo but please feel free to correct me (p.s. i have a dedicated server so only i have access to it)
will post here later with what i have to ether ask for more help or for others to use if needed thank you |
if the script can be accessed via internet then it is possible that it could be potentially exploited, on second thought, what kind of 'dedicated server' is it and do you have root access to it?
|
it's an amd 2.5ghz dual core, 4gb ram 320gb x2 VERY nice server and yes root access
also i'll be using a .htaccess like below: Quote:
|
1. delete the content of a file (or just delete the file and make a new one if it's easier)
unlink ($filename); system ("echo \"\" > filename"); 2. read the content from a file $fp = fopen($filename, "r"); $string = fgets ($fp); 3. write new data to a file via an input box the contents of the input box are passed via the POST or GET mechanism of the HTTP transfer get the passed values like $_REQUEST['idname'] fwrite ($fp, $_REQUEST['idname'], strlen($_REQUEST['idname'])); 4. run a command on the server system ("echo \"\" > filename"); ---------- T74marcell Arch Linux |
wow thanks T74marcell for answers 1,2,3 but if i wanted them in a php file with an option to select/do each one how would i do that without making them in there own script?
and for answer 4 can i do that with any command like system ("wget http://domain.com/file.zip"); |
bump?
|
All times are GMT -5. The time now is 09:48 AM. |