Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
Q: Does your Web site contain files with file types that do not match their Content-Type and/or file extension?
A: You should correct all of these mismatches. Both the Content-Type and the file extension must match the type of the file for a download prompt to appear. Be sure this is true for your Web pages as well. If the Content-Type is plain/text, then they will not render as HTML.
So does this mean it's now a no-no to use a PHP script as an image or a Javascript file by issuing a Content-Type header first and outputting the file?
Do we now have to configure our webservers to parse every file of whatever type we want to create dynamically using PHP?
Or is this just going to affect downloads?[/quote]
It still works fine. What it's saying is it will use the content-type header over the extension, so if you set image/jpeg on a .php file, it'll render it as a jpeg and not anything else. It's good news
But it says the Content-Type must match the file extension. A dynamically generated GD image with .php extension doesn't match the Content-Type: image/jpeg header you'd be sending out.
Do you have SP2? Hell I don't even run Windows anywhere except Virtual PC and that's Win 98 so I've got no way to confirm whether this is the case or not.
As an aside, this cropped up last night when I was trying to write a dynamically generated Javascript file.
With the whole Eolas patent infringement thing you now should embed all flash or quicktime content into an external javascript file to prevent stupid dialog boxes from appearing. Only problem is you can't use PHP to write an external JS file. The only workaround is to include a PHP file which contains the javascript but then the browser would treat it as inline content and start popping up dialogs.
As far as I can tell there is NO WAY around this at all beyond literally having as many JS external files as you need for the display content, so now I need to try and write a PHP script that I can run once to create these files whenever the embedded content files change.
Even though MS is appealing the decision, the Eolas patent infringement case means that ALL embedded content which uses ActiveX controls like Flash movies and QuickTime will pop up a window which says something like "A thing on this page is something something Active X blah blah".
And this will appear for EVERY single embedded item on EVERY single page. There will be no universal dismissal box.
The workaround for this is to use the
<script language="Javascript" type="text/javascript" src="embeded.js"></script>
method to write the object and embed tags. Since this is an external document it can bypass the stupid dialog boxes.
Now, I have a lot of movies/flash files to display in a portfolio arrangement and I can't have this annoying dialog, so I must use the script tags and external js file.
Ideally I would use php to write the tiny changes between each page within the js file.
So I only need one js file (php). BUT, even if you set the Content-Type header in the embedded.php file to text/javascript the browser WILL NOT RENDER the javascript because it doesn't recognise the .php extension in this context or something. I've tried it. It doesn't work.
Beyond creating all the js files with a standalone run-once script there seems to be no way around this at all.
For some reason you can embed <?php tags in the code and output variables but you can't start the document with php script and then just echo out the adjusted content.
That and I don't really like the idea of parsing .js files.
So anyway, here's how I fixed it.
Make three arrays containing the filenames of all images, flash files, and quicktime movies.
Each of these is added to a simple numbered navigation. The flash and movie files are named in a systematic way - name_width_height.extension
The links call back to the same page which determines whether to display a picture, a movie or a flash file. It then checks to see if the corresponding name_width_height.js file exists. If it doesn't exist it reads a base js file into a variable and replaces the --width-- --height-- --filename-- markers that I've put in there with the correct details and creates the new js file. The location of this file is then added to the html within the <script> tag.
The beauty is that it only needs to do this once since after this time the file will exist. I can delete the .js files without worrying and I can add/remove movie and flash files without writing any more js or html, and if I wanted to resize the flash files in particular I can do so by just changing the filename.
Your files will be unaffected in SP2 - the content-type malarkey means IE will pay more attention to a content-type header than it will to an extension. Outputting from PHP a file ending in .js gives little problems, as even though there is a mime type for javascript (application/x-javascript), most browsers happily accept HTML files as JS. The more tangible problems come from outputting images. IE6 before SP2 could detect image types from the data it received. As that could possibly be risky, MS have now made IE perform more rigorous checks on binary data it receives. The simple method for this is ensuring you set your mime types correctly.