diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php index 928c215e203503b381af30e4e0c054a6de121000..2104cf61a5f50ea4dbd3e2bd52eb19c496158496 100644 --- a/interface/lib/classes/tpl.inc.php +++ b/interface/lib/classes/tpl.inc.php @@ -858,14 +858,12 @@ if (!defined('vlibTemplateClassLoaded')) { if($this->_cache && $this->_checkCache($tmplfile, $tmpl_from_string)) { //* cache exists so lets use it - $data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile)); - fclose($fp); + $data = file_get_contents($this->_cachefile); } else { //* no cache lets parse the file if($tmpl_from_string == true) { $data = $tmplfile; } else { - $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); - fclose($fp); + $data = file_get_contents($tmplfile); } $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*'; diff --git a/server/lib/classes/tpl.inc.php b/server/lib/classes/tpl.inc.php index 5e595f69fe01e6715f6d8ba7665147a81390aede..70dc2e783cf4c37b4bafe0e73c453a30e47e16cd 100644 --- a/server/lib/classes/tpl.inc.php +++ b/server/lib/classes/tpl.inc.php @@ -858,14 +858,12 @@ if (!defined('vlibTemplateClassLoaded')) { if($this->_cache && $this->_checkCache($tmplfile, $tmpl_from_string)) { //* cache exists so lets use it - $data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile)); - fclose($fp); + $data = file_get_contents($this->_cachefile); } else { //* no cache lets parse the file if($tmpl_from_string == true) { $data = $tmplfile; } else { - $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); - fclose($fp); + $data = file_get_contents($tmplfile); } $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*'; diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index c2b2abf8865b87557d77f809adcb1903443caa4f..23bca9b3ddd62cac38c57d8959551adcec14df47 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1155,19 +1155,21 @@ class nginx_plugin { } // use vLib for template logic - $nginx_directives_new = ''; - $ngx_conf_tpl = new tpl(); - $ngx_conf_tpl_tmp_file = tempnam($conf['temppath'], "ngx"); - file_put_contents($ngx_conf_tpl_tmp_file, $nginx_directives); - $ngx_conf_tpl->newTemplate($ngx_conf_tpl_tmp_file); - $ngx_conf_tpl->setVar('use_tcp', $use_tcp); - $ngx_conf_tpl->setVar('use_socket', $use_socket); - $ngx_conf_tpl->setVar('fpm_socket', $fpm_socket); - $ngx_conf_tpl->setVar($vhost_data); - $nginx_directives_new = $ngx_conf_tpl->grab(); - if(is_file($ngx_conf_tpl_tmp_file)) unlink($ngx_conf_tpl_tmp_file); - if($nginx_directives_new != '') $nginx_directives = $nginx_directives_new; - unset($nginx_directives_new); + if(trim($nginx_directives) != '') { + $nginx_directives_new = ''; + $ngx_conf_tpl = new tpl(); + $ngx_conf_tpl_tmp_file = tempnam($conf['temppath'], "ngx"); + file_put_contents($ngx_conf_tpl_tmp_file, $nginx_directives); + $ngx_conf_tpl->newTemplate($ngx_conf_tpl_tmp_file); + $ngx_conf_tpl->setVar('use_tcp', $use_tcp); + $ngx_conf_tpl->setVar('use_socket', $use_socket); + $ngx_conf_tpl->setVar('fpm_socket', $fpm_socket); + $ngx_conf_tpl->setVar($vhost_data); + $nginx_directives_new = $ngx_conf_tpl->grab(); + if(is_file($ngx_conf_tpl_tmp_file)) unlink($ngx_conf_tpl_tmp_file); + if($nginx_directives_new != '') $nginx_directives = $nginx_directives_new; + unset($nginx_directives_new); + } // Make sure we only have Unix linebreaks $nginx_directives = str_replace("\r\n", "\n", $nginx_directives);