note 118821 added to function.rmdir
| From: | dj dot thd at hotmail dot com | Date: | Thu, 11 Feb 2016 09:16:48 +0000 |
| Subject: | note 118821 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204919@lists.php.net to get a copy of this message | ||
Never ever use jurchiks101 at gmail dot com code!!! It contains command injection vulnerability!!!
If you want to do it that way, use something like this instead:
<?php
if (PHP_OS === 'Windows')
{
exec(sprintf("rd /s /q %s", escapeshellarg($path)));
}
else
{
exec(sprintf("rm -rf %s", escapeshellarg($path)));
}
?>
Note the escapeshellarg usage to escape any possible unwanted character, this avoids putting
commands in $path variable so the possibility of someone "pwning" the server with this
code
----
Server IP: 72.52.91.14
Probable Submitter: 149.11.18.114
----
Manual Page -- http://php.net/manual/en/function.rmdir.php
Edit -- https://master.php.net/note/edit/118821
Del: integrated -- https://master.php.net/note/delete/118821/integrated
Del: useless -- https://master.php.net/note/delete/118821/useless
Del: bad code -- https://master.php.net/note/delete/118821/bad+code
Del: spam -- https://master.php.net/note/delete/118821/spam
Del: non-english -- https://master.php.net/note/delete/118821/non-english
Del: in docs -- https://master.php.net/note/delete/118821/in+docs
Del: other reasons-- https://master.php.net/note/delete/118821
Reject -- https://master.php.net/note/reject/118821
Search -- https://master.php.net/manage/user-notes.php