Today, I’d like to point out three nice articles to make your Easter holiday a bit more “mind broadening.” The first article points out a few examples of leadership from different perspectives. Why the combination of different skills might lead to great team results, why (extreme) transparency could be a good way to develop great output. It is brief but really worth reading:
This article is about the differences of leaders and managers. And why there aren’t as many differences.
And just for the fun of it: Why creativity needs time.
If you ever wanted to serve big or many files through PHP and needed to check permissions or do any other calculation upfront file delivery, you might want to think about an Apache module called mod_xsendfile. With it you’re able to separate permission checks and other script related stuff from the slow part of file delivery in which PHP is not best at.
And getting it up and running is pretty simple.
Now, in your virtual host configure your host to pick up the module and maybe define a folder wich the module is allowed to send files from.
#enable the module for your host
#define a white list folder outside your DocumentRoot
That’s it on the Apache side of things.
Now, simply tell Apache to handle the file transfer itself in your script. This is done by sending the X-Sendfile-Header. No more needs to be done. No file reading, nothing. The whole delivery is being delegated to Apache.
//some code to check permissions, get the file name, rescue the world or whatever
header ('Content-Type: application/octet-stream');
header ('Content-Disposition: attachment; filename='.$some_file_name );
And that’s it. Now all your validation stuff will be done by PHP while file delivery is done by Apache.