diff --git a/library/Rain/Tpl.php b/library/Rain/Tpl.php index 32f6333..8c4e846 100644 --- a/library/Rain/Tpl.php +++ b/library/Rain/Tpl.php @@ -39,6 +39,7 @@ class Tpl { 'sandbox' => true, 'remove_comments' => false, 'registered_tags' => array(), + 'nfs' => false, ); // tags registered by the developers diff --git a/library/Rain/Tpl/Parser.php b/library/Rain/Tpl/Parser.php index df33049..b940f15 100644 --- a/library/Rain/Tpl/Parser.php +++ b/library/Rain/Tpl/Parser.php @@ -113,6 +113,15 @@ public function compileFile( $parsedTemplateFilepath ) { + //Copy on TMP file used for NFS + if ($this->config['nfs']) + { + $tmpFile = uniqid(); + copy($templateFilepath, '/tmp/'.$tmpFile); + $templateFilepath = '/tmp/'.$tmpFile; + } + + // open the template $fp = fopen($templateFilepath, "r"); @@ -160,6 +169,10 @@ public function compileFile( // close the file fclose($fp); + + //Delete TMP file + if ($this->config['nfs']) + unlink($templateFilepath); } /** @@ -173,6 +186,14 @@ public function compileFile( */ public function compileString($templateName, $templateBasedir, $templateFilepath, $parsedTemplateFilepath, $code) { + //Copy on TMP file used for NFS + if ($this->config['nfs']) + { + $tmpFile = uniqid(); + copy($templateFilepath, '/tmp/'.$tmpFile); + $templateFilepath = '/tmp/'.$tmpFile; + } + // open the template $fp = fopen($parsedTemplateFilepath, "w"); @@ -215,6 +236,10 @@ public function compileString($templateName, $templateBasedir, $templateFilepath // close the file fclose($fp); + + //Delete TMP file + if ($this->config['nfs']) + unlink($templateFilepath); } /**