Welcome Guest, Not a member yet? Register   Sign In
CI bug with is_really_writable
#2

[eluser]Unknown[/eluser]
My hacked together solution is to use a custom cron class library. Which, in the constructor I just call some "cleanup functions". Basically, if the file is 30 seconds old AND not being run from the thumbnail controller, then go ahead and delete the cache files.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cron {
    function Cron()
    {
        $this->cleanCache();
    }
        function cleanCache()
    {
        $CI =& get_instance();
        $url = $CI->uri->segment(1);
        if ($url != "thumb")
        {
            $last_change = 0;
            if ($dh = opendir(getcwd() . "/system/cache")) {
            while (($file = readdir($dh)) !== false) {
            if ($file != "." && $file != ".." && $file != "index.html")
            {
                if ((time() - filemtime(getcwd() . "/system/cache/" .$file)) >= 30) //tick tock, 60 seconds until the cache gets deleted!
                {
                    @unlink(getcwd() . "/system/cache/" .$file);
                }
                 //echo "$file was last modified: " . date ("F d Y H:i:s.", filemtime(getcwd() . "/system/cache/" .$file)) . "<br>";
                //echo $file . '<br>';
            }
            }
                closedir($dh);
            }
        }
    }
}
?&gt;

To show that this is a bug - this classless PHP file runs fine:
Code:
&lt;?php
$dir = "C:\somedir";

// Open a known directory, and proceed to read its contents
if (!isset($_GET['p']))
{
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
        if ($file != "." && $file != "..")
        {
            echo '<img src="testcache.php?p=' . $file . '"><br>';
            echo "filename: $file <br>\n";
        }
        }
        closedir($dh);
    }
}
} else {
    readfile(getcwd() . "\\cache\\" . $_GET['p']);
}
?&gt;
==========================
But if you were to put that into a controller...for example:
Code:
&lt;?php
class Thumb extends Controller
{
    function show($file="")
    {
        readfile($file);
    }
}
?&gt;
and
Code:
&lt;?php
class Pics extends Controller
{
    function look()
    {
                $dir = "C:\somedir";
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                if ($file != "." && $file != "..")
                {
                    echo '<img src="' . site_url("><br>';
                    echo "filename: $file <br>\n";
                }
                }
                closedir($dh);
            }
        }
    }
}
?&gt;

Now, of course, this may be a bug with PHP, Windows, and/or Apache specifically my mix of versions...
Apache: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9
OS: Windows XP Tablet (which is really just XP Pro).
I did install Apache from the XAMPP package.


Messages In This Thread
CI bug with is_really_writable - by El Forum - 08-16-2009, 02:54 PM
CI bug with is_really_writable - by El Forum - 08-16-2009, 02:54 PM
CI bug with is_really_writable - by El Forum - 08-16-2009, 10:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB