Recently it occurred to me that someone might try uploading a text file (html or whatever) that had a php delimiter it in so I want to reject any such text files. (We allow html file uploading) Checking for <? and ?> is easy but I also wanted to check for <script language=php> and all the possible permutations of that tag. (It's paranoid but so am I)
Here's my attempt at pattern matching for that string. If any one has any suggestions please let me know.
Otherwise, I hope this helps someone who might need a snippet like this.
I use pcre not ereg because I find it's more flexible and has more features to use.
preg_match("/(<)\s(script)\s+(language)\s(=)\s(\"?|\'?)\s(php)\s(\"?|\'?)\s(>)/i", $txt)
matt.