Firefox PHP

hack: ensure temp/cache dir exists

Posted by freedman 
hack: ensure temp/cache dir exists
September 10, 2006 10:55AM
Recently, in the interest of performance, I turned the folder I was using for the phorum temp dir to a tmpfs/ramdisk. As such, whenever my system is rebooted, the filesystem was cleared and the cache directory was gone.

Rather than add something to a startup script which is likely not something most people running phorum can do, it seemed to make more sense to add a line of code in the templates.php file:

at line 347, I insterted the following line:
if (!is_dir($bn=dirname($filename))) mkdir($bn,0775); //added 060910 by freedman


which makes that block read:
function phorum_write_templatefile($filename, $content, $is_toplevel = false)
{
if (!is_dir($bn=dirname($filename))) mkdir($bn,0775); //added 060910 by freedman
if($fp=fopen($filename, "w")) {


it didn't seem necessary to do anything more robust, since if there's a problem creating the directory, you get the same error messages as before, and any checking more than looking for the directory to exist would waste time since it is checked possibly numerous times for each page view.
Sorry, only registered users may post in this forum.

Click here to login