src/Rah/Cache.php
public function store()
    {
        if (empty($this->request->file) || get_pref('production_status') != 'live') {
            return;
        }

        foreach ($this->config->skipPaths as $path) {
            if (strpos($this->request->uri, $path) === 0) {
                return;
            }
        }

        $this->getHeaders();

        if (isset($this->headers['content-type']) &&
            strpos($this->headers['content-type'], 'text/html') === false
        ) {
            return;
        }

        $page = ob_get_contents();

        if (($r = callback_event('rah_cache.store', '', 0, array(
            'contents' => $page,
            'headers'  => $this->headers,
        ))) !== '') {
            $page = $r;
        }

        if (!$page) {
            return;
        }

        file_put_contents($this->request->file, $page);

        $size = strlen($page);
        $crc = crc32($page);
        $data = gzcompress($page, 6);
        $data = substr($data, 0, strlen($data)-4);
        $data = "\x1f\x8b\x08\x00\x00\x00\x00\x00".$data;
        $data .= pack('V', $crc);
        $data .= pack('V', $size);
        file_put_contents($this->request->file.'.gz', $data);

        callback_event('rah_cache.created');
    }
public function store()
    {
        if (empty($this->request->file) || get_pref('production_status') != 'live') {
            return;
        }

        foreach ($this->config->skipPaths as $path) {
            if (strpos($this->request->uri, $path) === 0) {
                return;
            }
        }

        $this->getHeaders();

        if (isset($this->headers['content-type']) &&
            strpos($this->headers['content-type'], 'text/html') === false
        ) {
            return;
        }

        $page = ob_get_contents();

        if (($r = callback_event('rah_cache.store', '', 0, array(
            'contents' => $page,
            'headers'  => $this->headers,
        ))) !== '') {
            $page = $r;
        }

        if (!$page) {
            return;
        }

        file_put_contents($this->request->file, $page);

        $size = strlen($page);
        $crc = crc32($page);
        $data = gzcompress($page, 6);
        $data = substr($data, 0, strlen($data)-4);
        $data = "\x1f\x8b\x08\x00\x00\x00\x00\x00".$data;
        $data .= pack('V', $crc);
        $data .= pack('V', $size);
        file_put_contents($this->request->file.'.gz', $data);

        callback_event('rah_cache.created');
    }
public function store ( ) { if ( empty ( $ this -> request -> file ) || get_pref ( 'production_status' ) != 'live' ) { return ; } foreach ( $ this -> config -> skipPaths as $ path ) { if ( strpos ( $ this -> request -> uri , $ path ) === 0 ) { return ; } } $ this -> getHeaders ( ) ; if ( isset ( $ this -> headers [ 'content-type' ] ) && strpos ( $ this -> headers [ 'content-type' ] , 'text/html' ) === false ) { return ; } $ page = ob_get_contents ( ) ; if ( ( $ r = callback_event ( 'rah_cache.store' , '' , 0 , array ( 'contents' => $ page , 'headers' => $ this -> headers , ) ) ) !== '' ) { $ page = $ r ; } if ( ! $ page ) { return ; } file_put_contents ( $ this -> request -> file , $ page ) ; $ size = strlen ( $ page ) ; $ crc = crc32 ( $ page ) ; $ data = gzcompress ( $ page , 6 ) ; $ data = substr ( $ data , 0 , strlen ( $ data ) - 4 ) ; $ data = "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $ data ; $ data .= pack ( 'V' , $ crc ) ; $ data .= pack ( 'V' , $ size ) ; file_put_contents ( $ this -> request -> file . '.gz' , $ data ) ; callback_event ( 'rah_cache.created' ) ; }
Writes the page to the cache directory.
Writes the page to the cache directory .