1

このスレッドから、 php ストリームを使用して DWOO をブロックすることについて話しているコードを取得しましたが、このコードの使用方法がわかりません。誰かが私にそれを使用する方法を教えてもらえますか?

最近の問題:
cache/dwoo/compiled フォルダーに作成された大量のキャッシュ ファイルが原因で、Web ホスティングのストレージに深刻な問題が発生しました。codeigniter フレームワークを使用して Web サイトを開発しました。この機能 (cache/dwoo/compiled フォルダーに自動作成されたキャッシュ ファイル) を無効にしたいのは、ストレージの多くのスペースを使用しているためです。

これはコードです:

include 'lib/dwooAutoload.php';
include 'Dwoo/Compiler.php';

$dwoo = new Dwoo();

stream_wrapper_register('dwoomem', 'Dwoo_Template_Memory_StreamWrapper');
$dwoo->addResource('memory', 'Dwoo_Template_Memory');

$tpl = new Dwoo_Template_Memory('test.html');
$dwoo->output($tpl, array('foo'=>'FOO', 'bar'=>'BAR'));

class Dwoo_Template_Memory extends Dwoo_Template_File
{
    protected $chmod = null;

    public function getCompiledFilename(Dwoo $dwoo) {
        // no compile id was provided, set default
        if ($this->compileId===null) {
            $this->compileId = $this->getResourceIdentifier();
        }
        return 'dwoomem://'.$this->compileId;
    }

    protected function makeDirectory($path)
    {
    }
}

class Dwoo_Template_Memory_StreamWrapper
{
    protected static $streams = array();

    function stream_open($path, $mode, $options, &$opened_path)
    {
        if (!isset(self::$streams[$path])) {
            if(!($mem = fopen('php://memory', 'w+'))) {
                return false;
            }
            self::$streams[$path] = $mem;
        }
        $this->res = self::$streams[$path];
        $this->stream_seek(0);
        return true;
    }

    function stream_read($count)
    {
        return fread($this->res, $count);
    }

    function stream_write($data)
    {
        return fwrite($this->res, $data);
    }

    function stream_eof()
    {
        return feof($this->res);
    }

    function stream_seek($offset, $whence=SEEK_SET)
    {
        return fseek($this->res, $offset, $whence);
    }

    function stream_stat()
    {
        return fstat($this->res);
    }

    public static function url_stat($path, $flags)
    {
        return array();
    }
}
4

0 に答える 0