note 20062 added to function.system
| From: | z1a7n8g @ / @ a | Date: | Thu, 21 Mar 2002 01:22:32 +0000 |
| Subject: | note 20062 added to function.system | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28016@lists.php.net to get a copy of this message | ||
I am currently using a form driven administration
page to start an ftp server remotely from a web page in FreeBSD 4.5 using PHP 4.1.2 & apache
1.3.23. (Sorry guys, no CVS!!)
This code will emulate a CLI command from your browser (anywhere!!) and execute it if your PHP
module/binary has the correct permissions...
<code><pre>
//your front end
<form ..your form stuff here...>
<input type="text" name=command>
<your additional form stuff>
///the gutz
<?
$arg=explode( " ", $command, 4 )
if ($arg[0] = "system")
{
system($arg[1] . " " . $arg[2] . " " . $arg[3]..etc);
}?>
</code></pre>
This works, however it is simple and lacks any error output.
try:
<pre><code>
<?system(command > /path/to/yourfile.php);
$fPtr=@fopen("yourfile.php",r);
$line=fgets($fPtr,filesize("yourfile.php");
while ($line)
{
$formatted_line=ereg_replace("your favorite newline
semantic","<BR>",$line);
print $formatted_line;
}
?>
</pre></code>
Keep in mind the SECURITY implications with the use of this and like scripts. You've been
warned.
--
http://www.php.net/manual/en/function.system.php
http://master.php.net/manage/user-notes.php?action=edit+20062
http://master.php.net/manage/user-notes.php?action=delete+20062
http://master.php.net/manage/user-notes.php?action=reject+20062