Jump to content

CGI Scripts preg_match


Mr.Shawn

Recommended Posts

Hello guys, I'm trying to do a checking of the filename provided such that it is not a CGI scripts. How do I check it with preg_match? Currently I do have the following for checking php but I wonder how can I check for other extensions such as .js, .html, etc.

 

if (preg_match('/php/i', substr($file, -3))) {
die("PHP file not downloadable");
exit;
}

Link to comment
https://forums.phpfreaks.com/topic/98594-cgi-scripts-preg_match/
Share on other sites

preg_match('~\.cgi$~im', $string);

 

 

Really I would check the mime type or file type with some other php function, or check the headers of the file itself by reading it, people can still change their extensions to whatever they want, but the content (headers) of the file never lies.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.