Re: [PHP] Patterns





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?
.



Relevant Pages

  • permissions problem with unlink()
    ... I am having trouble getting unlink() to work on my local machine ... (win 2000, Apache, php 4.2.2) ... I have looked at and checked the permissions on all the relevant folders via ...
    (comp.lang.php)
  • Re: Pleas Help Me (File Upload and delete)
    ... I am using Windows Xp using Xamp to run my php application ... while unlink the file i received one error like Access denied in my ...
    (comp.lang.php)
  • Re: [PHP] Patterns
    ... On 6/7/07, Steve Marquez wrote: ... If the file ends in .php, then I want it to unlink from a certain folder. ... // Do your unlinkroutine for .htm/.html files here.... ...
    (php.general)
  • Re: Chown???
    ... >via FTP software. ... If your user and the webserver share membership of a group, ... then unlink to remove it. ... But even simpler - if you can't delete via FTP, it's because PHP created the ...
    (alt.php)
  • Pleas Help Me (File Upload and delete)
    ... I am using Windows Xp using Xamp to run my php application ... while unlink the file i received one error like Access denied in my ... local machine how can i give write permission to this particular ...
    (comp.lang.php)