Re: Patterns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux