note 50208 deleted from function.shell-exec by nlopess
| From: | nlopess@php.net | Date: | Tue, 22 Feb 2005 11:20:54 +0000 |
| Subject: | note 50208 deleted from function.shell-exec by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85369@lists.php.net to get a copy of this message | ||
Note Submitter: AT-HE ( at_he at h0tmail dot com )
Reason: bad code
----
hi.. i am just learning php since a few days.. i had mount a website in my own pc and want let
users to post messages..
anyway, i wrote a very tiny page that let you run some commands remotely, that is useful mostly as
example of ereg_replace and shell_exec :D
<!-----run.php-----
<pre>
<?php
$salida=ereg_replace("<","<",shell_exec($_POST["comando"]));
echo "comando:
",$_POST["comando"],"<br>",$salida,"<br>";
?>
<form action="run.php" method="post">
comando: <input type="text" name="comando">
</form>
</pre>
-----eof----->
the ereg_replace is only for replace the "<" character at the output for his code,
which html reads as a tag..
- first tou must write something in the form..
- when page is opened again it takes it, replaces "<" characters and puts in $salida
variable (it may be useful later)..
- then prints out and you can write something again :)
.. i haven't change the ">" and other characters.. (see ereg_replace posts)
one inconvinient is that you can't change drive/dir.. i was thinking running some like this
before
echo $lastpath;
shell_exec($lastdrv);shell_exec("cd "+$lastpath);
then run our command.. but i dont know if exiting shell_exec restores the home dir again.. next we
must update our path again (if somebody wrotes "cd" command for example), and get $lastdrv
with some filter:
$lastpath=shell_exec("cd");
(anyway, $lastdrive will be the first 2 characters of $lastpath :P )
that's all 4now
greetings ;)