Re: Patterns
| From: | Richard Lynch | Date: | Sat, 09 Jun 2007 00:13:18 +0000 |
| Subject: | Re: Patterns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256419@lists.php.net to get a copy of this message | ||
On Thu, June 7, 2007 10:59 am, Steve Marquez wrote:
> Greetings. I just want to say thanks for the help over the past couple
> of
> days.
>
> I am trying to get a form to delete a file.
>
> If the file ends in .php, then I want it to unlink from a certain
> folder.
> However, if the file ends in .html or .htm, I want it to unlink from
> another
> folder.
>
> Is there any way to do this?
if (isset($_POST['filename')){
$filename = $_POST['filename'];
if (preg_match('|^[^/]*\\.php$|', $filename)){
//file ends in .php, unlink it from X
}
elseif (preg_match('|^[^/]*\\.html?$|', $filename)){
//file ends in .htm|.html, unlink it from Y
}
else{
error_log("Probably hack attempt from $_SERVER[REMOTE_ADDR]");
die("Invalid input");
}
}
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?