mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
git-svn-id: file:///svn/phpbb/trunk@8680 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
ad739a358c
commit
95462dca58
1 changed files with 21 additions and 6 deletions
|
@ -29,17 +29,28 @@ class template_filter extends php_user_filter
|
||||||
private $block_names = array();
|
private $block_names = array();
|
||||||
private $block_else_level = array();
|
private $block_else_level = array();
|
||||||
|
|
||||||
|
private $chunk;
|
||||||
|
|
||||||
function filter($in, $out, &$consumed/*, $closing*/)
|
function filter($in, $out, &$consumed/*, $closing*/)
|
||||||
{
|
{
|
||||||
while ($bucket = stream_bucket_make_writeable($in))
|
while ($bucket = stream_bucket_make_writeable($in))
|
||||||
{
|
{
|
||||||
$bucket->data = $this->compile($bucket->data);
|
$last_nl = strrpos($bucket->data, "\n");
|
||||||
|
$data = $this->chunk . substr($bucket->data, 0, $last_nl);
|
||||||
|
$this->chunk = substr($bucket->data, $last_nl);
|
||||||
|
$bucket->data = $this->compile($data);
|
||||||
$consumed += $bucket->datalen;
|
$consumed += $bucket->datalen;
|
||||||
stream_bucket_append($out, $bucket);
|
stream_bucket_append($out, $bucket);
|
||||||
}
|
}
|
||||||
return PSFS_PASS_ON;
|
return PSFS_PASS_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onCreate()
|
||||||
|
{
|
||||||
|
$this->chunk = '';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private function compile($data)
|
private function compile($data)
|
||||||
{
|
{
|
||||||
return preg_replace_callback($this->regex, array($this, 'replace'), $data);
|
return preg_replace_callback($this->regex, array($this, 'replace'), $data);
|
||||||
|
@ -643,6 +654,8 @@ stream_filter_register('template', 'template_filter');
|
||||||
*/
|
*/
|
||||||
class template_compile
|
class template_compile
|
||||||
{
|
{
|
||||||
|
const BUFFER = 8192;
|
||||||
|
|
||||||
private $template;
|
private $template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -689,13 +702,15 @@ class template_compile
|
||||||
stream_filter_append($destination_handle, 'template');
|
stream_filter_append($destination_handle, 'template');
|
||||||
|
|
||||||
@flock($destination_handle, LOCK_EX);
|
@flock($destination_handle, LOCK_EX);
|
||||||
@stream_copy_to_stream($source_handle, $destination_handle);
|
while (!feof($source_handle))
|
||||||
|
{
|
||||||
|
@fwrite($destination_handle, fread($source_handle, self::BUFFER));
|
||||||
|
}
|
||||||
|
@fwrite($destination_handle, "\n");
|
||||||
@flock($destination_handle, LOCK_UN);
|
@flock($destination_handle, LOCK_UN);
|
||||||
@fclose($destination_handle);
|
@fclose($destination_handle);
|
||||||
@fclose($source_handle);
|
@fclose($source_handle);
|
||||||
|
|
||||||
@chmod($filename, 0666);
|
@chmod($filename, 0666);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue