Florian Schaal
2015-12-20 dedf5feaa2cf3072e90ac2bf2ef3885facd2e1a6
Merge branch 'master' of http://git.ispconfig.org/ispconfig/ispconfig3
13 files modified
294 ■■■■ changed files
interface/lib/classes/plugin.inc.php 108 ●●●●● patch | view | raw | blame | history
interface/lib/classes/tform_actions.inc.php 4 ●●●● patch | view | raw | blame | history
interface/lib/classes/tform_base.inc.php 5 ●●●● patch | view | raw | blame | history
interface/lib/classes/tpl.inc.php 65 ●●●● patch | view | raw | blame | history
interface/lib/classes/tpl_cache.inc.php 9 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/directive_snippets_edit.htm 2 ●●● patch | view | raw | blame | history
interface/web/sites/templates/web_vhost_domain_edit.htm 9 ●●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 7 ●●●● patch | view | raw | blame | history
server/lib/classes/plugins.inc.php 17 ●●●● patch | view | raw | blame | history
server/lib/classes/tpl.inc.php 48 ●●●● patch | view | raw | blame | history
server/lib/classes/tpl_cache.inc.php 9 ●●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 5 ●●●● patch | view | raw | blame | history
server/plugins-available/nginx_plugin.inc.php 6 ●●●● patch | view | raw | blame | history
interface/lib/classes/plugin.inc.php
@@ -43,35 +43,51 @@
        if(isset($_SESSION['s']['plugin_cache'])) unset($_SESSION['s']['plugin_cache']);
        $plugins_dir = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
        $plugin_dirs = array();
        $plugin_dirs[] = ISPC_LIB_PATH.FS_DIV.'plugins';
        if(is_dir(ISPC_WEB_PATH)) {
            if($dh = opendir(ISPC_WEB_PATH)) {
                while(($file = readdir($dh)) !== false) {
                    if($file !== '.' && $file !== '..' && is_dir(ISPC_WEB_PATH . FS_DIV . $file) && is_dir(ISPC_WEB_PATH . FS_DIV . $file . FS_DIV . 'lib' . FS_DIV . 'plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . FS_DIV . $file . FS_DIV . 'lib' . FS_DIV . 'plugin.d';
                }
                closedir($dh);
            }
        }
        $_SESSION['s']['plugin_cache'] = array();
        $tmp_plugins = array();
        if (is_dir($plugins_dir)) {
            if ($dh = opendir($plugins_dir)) {
                //** Go trough all files in the plugin dir
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') {
                        $plugin_name = substr($file, 0, -8);
                        $tmp_plugins[$plugin_name] = $file;
        for($d = 0; $d < count($plugin_dirs); $d++) {
            $plugins_dir = $plugin_dirs[$d];
            if (is_dir($plugins_dir)) {
                if ($dh = opendir($plugins_dir)) {
                    $tmp_plugins = array();
                    //** Go trough all files in the plugin dir
                    while (($file = readdir($dh)) !== false) {
                        if($file !== '.' && $file !== '..' && substr($file, -8, 8) == '.inc.php') {
                            $plugin_name = substr($file, 0, -8);
                            $tmp_plugins[$plugin_name] = $file;
                        }
                    }
                }
                //** sort the plugins by name
                ksort($tmp_plugins);
                    closedir($dh);
                    //** sort the plugins by name
                    ksort($tmp_plugins);
                //** load the plugins
                foreach($tmp_plugins as $plugin_name => $file) {
                    include_once $plugins_dir.$file;
                    if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
                    $app->loaded_plugins[$plugin_name] = new $plugin_name;
                    $app->loaded_plugins[$plugin_name]->onLoad();
                    //** load the plugins
                    foreach($tmp_plugins as $plugin_name => $file) {
                        require $plugins_dir . FS_DIV . $file;
                        if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
                        $app->loaded_plugins[$plugin_name] = new $plugin_name;
                        $app->loaded_plugins[$plugin_name]->onLoad();
                    }
                } else {
                    $app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
                }
            } else {
                $app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
                $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
            }
        } else {
            $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
        }
    }
@@ -81,10 +97,10 @@
     for faster lookups without the need to load all plugins for every page.
    */
    public function registerEvent($event_name, $plugin_name, $function_name) {
    public function registerEvent($event_name, $plugin_name, $function_name, $module_name = '') {
        global $app;
        $_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name);
        $_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name, 'module' => $module_name);
        if($this->debug) $app->log("Plugin '$plugin_name' has registered the function '$function_name' for the event '$event_name'", LOGLEVEL_DEBUG);
    }
@@ -92,28 +108,33 @@
        This function is called when a certian action occurs, e.g. a form gets saved or a user is logged in.
    */
    public function raiseEvent($event_name, $data) {
    public function raiseEvent($event_name, $data, $return_data = false) {
        global $app;
        if(!isset($_SESSION['s']['plugin_cache'])) {
            $this->loadPluginCache();
            if($this->debug) $app->log('Loaded the plugin cache.', LOGLEVEL_DEBUG);
        }
        $result = '';
        $sub_events = explode(':', $event_name);
        if(is_array($sub_events)) {
            if(count($sub_events) == 3) {
                $tmp_event = $sub_events[2];
                if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG);
                $this->callPluginEvent($tmp_event, $data);
                $tmpresult = $this->callPluginEvent($tmp_event, $data, $return_data);
                if($return_data == true && $tmpresult) $result .= $tmpresult;
                $tmp_event = $sub_events[0].':'.$sub_events[2];
                if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG);
                $this->callPluginEvent($tmp_event, $data);
                $tmpresult = $this->callPluginEvent($tmp_event, $data, $return_data);
                if($return_data == true && $tmpresult) $result .= $tmpresult;
                $tmp_event = $sub_events[0].':'.$sub_events[1].':'.$sub_events[2];
                if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG);
                $this->callPluginEvent($tmp_event, $data);
                $tmpresult = $this->callPluginEvent($tmp_event, $data, $return_data);
                if($return_data == true && $tmpresult) $result .= $tmpresult;
                /*$sub_events = array_reverse($sub_events);
                $tmp_event = '';
@@ -125,23 +146,36 @@
                */
            } else {
                if($this->debug) $app->log("Called Event '$sub_events[0]'", LOGLEVEL_DEBUG);
                $this->callPluginEvent($sub_events[0], $data);
                $tmpresult = $this->callPluginEvent($sub_events[0], $data, $return_data);
                if($return_data == true && $tmpresult) $result .= $tmpresult;
            }
        }
        if($return_data == true) return $result;
    } // end function raiseEvent
    //* Internal function to load the plugin and call the event function in the plugin.
    private function callPluginEvent($event_name, $data) {
    private function callPluginEvent($event_name, $data, $return_data = false) {
        global $app;
        $result = '';
        //* execute the functions for the events
        if(@is_array($_SESSION['s']['plugin_cache'][$event_name])) {
            foreach($_SESSION['s']['plugin_cache'][$event_name] as $rec) {
                $plugin_name = $rec['plugin'];
                $function_name = $rec['function'];
                $plugin_file = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV.$plugin_name.'.inc.php';
                $module_name = $rec['module'];
                if($module_name != '') {
                    if(strpos($module_name, '..') !== false || strpos($module_name, '/') !== false) {
                        if($this->debug) $app->log('Module name ' . $module_name . ' contains illegal characters.', LOGLEVEL_DEBUG);
                        continue;
                    }
                    $plugin_file = ISPC_WEB_PATH . FS_DIV . $module_name . FS_DIV . 'lib' . FS_DIV . 'plugin.d' . FS_DIV . $plugin_name . '.inc.php';
                } else {
                    $plugin_file = ISPC_LIB_PATH . FS_DIV . 'plugins' . FS_DIV . $plugin_name . '.inc.php';
                }
                if(is_file($plugin_file)) {
                    if(!isset($app->loaded_plugins[$plugin_name])) {
@@ -152,12 +186,14 @@
                    if($this->debug) $app->log("Called method: '$function_name' in plugin '$plugin_name' for event '$event_name'", LOGLEVEL_DEBUG);
                    // call_user_method($function_name,$app->loaded_plugins[$plugin_name],$event_name,$data);
                    call_user_func(array($app->loaded_plugins[$plugin_name], $function_name), $event_name, $data);
                    $tmpresult = call_user_func(array($app->loaded_plugins[$plugin_name], $function_name), $event_name, $data);
                    if($return_data == true && $tmpresult) $result .= $tmpresult;
                }
            }
        }
        if($return_data == true) return $result;
    } // end functiom callPluginEvent
interface/lib/classes/tform_actions.inc.php
@@ -46,7 +46,7 @@
        $app->tpl->newTemplate("tabbed_form.tpl.htm");
        // Load table definition from file
        $app->tform->loadFormDef($tform_def_file);
        $app->tform->loadFormDef($tform_def_file, (isset($_SESSION['s']['module']['name']) ? $_SESSION['s']['module']['name'] : ''));
        // Importing ID
        $this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0;
@@ -594,7 +594,7 @@
                $app->load($plugin_class);
                $this->plugins[$plugin_name] = new $plugin_class;
                $this->plugins[$plugin_name]->setOptions($plugin_name, $plugin_settings['options']);
                // Make the data of the form easily accessible for the plugib
                // Make the data of the form easily accessible for the plugin
                $this->plugins[$plugin_name]->form = $this;
                $this->plugins[$plugin_name]->onLoad();
            }
interface/lib/classes/tform_base.inc.php
@@ -127,6 +127,7 @@
        global $app, $conf;
        include $file;
        $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$form['name'] . ':on_before_formdef', $this);
        $this->formDef = $form;
        $this->module = $module;
@@ -150,8 +151,10 @@
            $wb = $app->functions->array_merge($wb_global, $wb);
        }
        if(isset($wb_global)) unset($wb_global);
        $this->wordbook = $wb;
        $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'] . ':on_after_formdef', $this);
        $this->dateformat = $app->lng('conf_format_dateshort');
        $this->datetimeformat = $app->lng('conf_format_datetime');
interface/lib/classes/tpl.inc.php
@@ -839,28 +839,34 @@
         * @access private
         * @return mixed data/string or boolean
         */
        private function _getData ($tmplfile, $do_eval=false)
        private function _getData ($tmplfile, $do_eval=false, $tmpl_from_string = false)
        {
            //* check the current file depth
            if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) {
                return;
            } else {
                if ($this->_debug){
                    array_push($this->_debugIncludedfiles, $tmplfile);
                    if($tmpl_from_string) array_push($this->_debugIncludedfiles, 'String: ' . substr($tmplfile, 0, 25) . '...');
                    else array_push($this->_debugIncludedfiles, $tmplfile);
                }
                if ($do_eval) {
                    array_push($this->_currentincludedir, dirname($tmplfile));
                    if($tmpl_from_string == true) array_push($this->_currentincludedir, end($this->_currentincludedir));
                    else array_push($this->_currentincludedir, dirname($tmplfile));
                    $this->_includedepth++;
                }
            }
            if($this->_cache && $this->_checkCache($tmplfile)) { //* cache exists so lets use it
            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);
            } else { //* no cache lets parse the file
                $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
                fclose($fp);
                if($tmpl_from_string == true) {
                    $data = $tmplfile;
                } else {
                    $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
                    fclose($fp);
                }
                $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*';
                $regex.= 'tmpl_([\w]+)\s*';
@@ -884,7 +890,7 @@
            }
            //* now we must parse the $data and check for any <tmpl_include>'s
            if ($this->_debug) $this->doDebugWarnings(file($tmplfile), $tmplfile);
            if ($this->_debug && $tmpl_from_string == false) $this->doDebugWarnings(file($tmplfile), $tmplfile);
            if ($do_eval) {
                $success = @eval('?>'.$data.'<?php return 1;');
@@ -1061,6 +1067,46 @@
            }
        }
        /**
         * returns a string containing hook data
         * @param string $type
         * @param string $name
         * @return string hook data
         */
        private function _parseHook ($name)
        {
            global $app;
            if(!$name) return false;
            $module = isset($_SESSION['s']['module']['name']) ? $_SESSION['s']['module']['name'] : '';
            $form = isset($app->tform->formDef['name']) ? $app->tform->formDef['name'] : '';
            $events = array();
            if($module) {
                $events[] = $module . ':' . ($form ? $form : '') . ':' . $name;
                $events[] = $module . ':' . ($form ? $form : '') . ':on_template_content';
            } else {
                $events[] = $name;
                $events[] = 'on_template_content';
            }
            $events = array_unique($events);
            for($e = 0; $e < count($events); $e++) {
                $tmpresult = $app->plugin->raiseEvent($events[$e], array(
                    'name' => $name,
                    'module' => $module,
                    'form' => $form
                ), true);
                if(!$tmpresult) $tmpresult = '';
                else $tmpresult = $this->_getData($tmpresult, false, true);
                $result .= $tmpresult;
            }
            return $result;
        }
        /**
         * returns a string used for parsing in tmpl_loop statements.
@@ -1254,7 +1300,10 @@
                if ($this->OPTIONS['ENABLE_PHPINCLUDE']) {
                    return '<?php include(\''.$file.'\'); ?>';
                }
            case 'hook':
                return $this->_parseHook(@$var);
            case 'include':
                return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>';
interface/lib/classes/tpl_cache.inc.php
@@ -101,8 +101,8 @@
     * FUNCTION: _checkCache
     * checks if there's a cache, if there is then it will read the cache file as the template.
     */
    function _checkCache ($tmplfile) {
        $this->_cachefile = $this->_getFilename($tmplfile);
    function _checkCache ($tmplfile, $tmpl_from_string = false) {
        $this->_cachefile = $this->_getFilename($tmplfile, $tmpl_from_string);
        if ($this->_clearcache) {
            if (file_exists($this->_cachefile)) unlink($this->_cachefile);
            return false;
@@ -133,8 +133,9 @@
     * gets the full pathname for the cached file
     *
     */
    function _getFilename($tmplfile) {
        return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    function _getFilename($tmplfile, $tmpl_from_string = false) {
        if($tmpl_from_string == true) return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaRSTRING'.$tmplfile).'.'.$this->OPTIONS['CACHE_EXTENSION'];
        else return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    }
interface/web/admin/templates/directive_snippets_edit.htm
@@ -16,7 +16,7 @@
            </div>
            <div class="form-group">
                <label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
                <div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
                <div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
            </div>
            <div class="form-group php">
                <label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>
interface/web/sites/templates/web_vhost_domain_edit.htm
@@ -13,7 +13,7 @@
</tmpl_if>
        {tmpl_hook name="begin_form"}
        <tmpl_if name="vhostdomain_type" value="domain">
            <tmpl_if name="is_admin">
                <div class="form-group">
@@ -222,26 +222,29 @@
                    {tmpl_var name='php'}
                </select></div>
            </div>
            {tmpl_hook name="field_fastcgi_php_version"}
            <div class="form-group fastcgi_php_version">
                <label for="fastcgi_php_version" class="col-sm-3 control-label">{tmpl_var name='fastcgi_php_version_txt'}</label>
                <div class="col-sm-9"><select name="fastcgi_php_version" id="fastcgi_php_version" class="form-control">
                    {tmpl_var name='fastcgi_php_version'}
                </select></div>
            </div>
            {tmpl_var name="directive_snippets_id"}
            {tmpl_var name="directive_snippets_id"}
            {tmpl_hook name="field_enable_pagespeed"}
            <div class="form-group nginx pagespeed">
                <label class="col-sm-3 control-label">{tmpl_var name='enable_pagespeed_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name="enable_pagespeed"}
                </div>
            </div>
            {tmpl_hook name="field_active"}
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='active'}
                </div>
            </div>
            {tmpl_hook name="end_form"}
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
server/conf/vhost.conf.master
@@ -1,3 +1,4 @@
<tmpl_hook name='apache2_vhost:header'>
<Directory {tmpl_var name='web_basedir'}/{tmpl_var name='domain'}>
        AllowOverride None
@@ -9,8 +10,9 @@
        </tmpl_if>
</Directory>
<tmpl_loop name="vhosts">
<tmpl_loop name='vhosts'>
<VirtualHost {tmpl_var name='ip_address'}:{tmpl_var name='port'}>
<tmpl_hook name='apache2_vhost:vhost_header'>
<tmpl_if name='php' op='==' value='suphp'>
        DocumentRoot <tmpl_var name='web_document_root'>
</tmpl_else>
@@ -444,5 +446,8 @@
        </IfModule>
<tmpl_var name='apache_directives'>
<tmpl_hook name='apache2_vhost:vhost_footer'>
</VirtualHost>
</tmpl_loop>
<tmpl_hook name='apache2_vhost:footer'>
server/lib/classes/plugins.inc.php
@@ -73,7 +73,6 @@
        } else {
            $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
        }
    }
    /*
@@ -138,12 +137,14 @@
    }
    function raiseAction($action_name, $data) {
    function raiseAction($action_name, $data, $return_data = false) {
        global $app;
        //* Get the subscriptions for this action
        $actions = (isset($this->subscribed_actions[$action_name]))?$this->subscribed_actions[$action_name]:'';
        if($this->debug) $app->log('Raised action: '.$action_name, LOGLEVEL_DEBUG);
        $result = '';
        if(is_array($actions)) {
            foreach($actions as $action) {
@@ -154,8 +155,13 @@
                $app->log("Calling function '$function_name' from plugin '$plugin_name' raised by action '$action_name'.", LOGLEVEL_DEBUG);
                $state = call_user_func(array($app->loaded_plugins[$plugin_name], $function_name), $action_name, $data);
                //* ensure that we return the highest warning / error level if a error occured in one of the functions
                if($state == 'warning' && $state_out != 'error') $state_out = 'warning';
                if($state == 'error') $state_out = 'error';
                if($return_data) {
                    if($state) $result .= $state;
                } else {
                    if($state == 'warning' && $state_out != 'error') $state_out = 'warning';
                    elseif($state == 'error') $state_out = 'error';
                }
                unset($plugin_name);
                unset($function_name);
            }
@@ -163,7 +169,8 @@
        unset($action);
        unset($actions);
        return $state_out;
        if($return_data == true) return $result;
        else return $state_out;
    }
}
server/lib/classes/tpl.inc.php
@@ -839,28 +839,34 @@
         * @access private
         * @return mixed data/string or boolean
         */
        private function _getData ($tmplfile, $do_eval=false)
        private function _getData ($tmplfile, $do_eval=false, $tmpl_from_string = false)
        {
            //* check the current file depth
            if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) {
                return;
            } else {
                if ($this->_debug){
                    array_push($this->_debugIncludedfiles, $tmplfile);
                    if($tmpl_from_string) array_push($this->_debugIncludedfiles, 'String: ' . substr($tmplfile, 0, 25) . '...');
                    else array_push($this->_debugIncludedfiles, $tmplfile);
                }
                if ($do_eval) {
                    array_push($this->_currentincludedir, dirname($tmplfile));
                    if($tmpl_from_string == true) array_push($this->_currentincludedir, end($this->_currentincludedir));
                    else array_push($this->_currentincludedir, dirname($tmplfile));
                    $this->_includedepth++;
                }
            }
            if($this->_cache && $this->_checkCache($tmplfile)) { //* cache exists so lets use it
            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);
            } else { //* no cache lets parse the file
                $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
                fclose($fp);
                if($tmpl_from_string == true) {
                    $data = $tmplfile;
                } else {
                    $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
                    fclose($fp);
                }
                $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*';
                $regex.= 'tmpl_([\w]+)\s*';
@@ -884,7 +890,7 @@
            }
            //* now we must parse the $data and check for any <tmpl_include>'s
            if ($this->_debug) $this->doDebugWarnings(file($tmplfile), $tmplfile);
            if ($this->_debug && $tmpl_from_string == false) $this->doDebugWarnings(file($tmplfile), $tmplfile);
            if ($do_eval) {
                $success = @eval('?>'.$data.'<?php return 1;');
@@ -1061,6 +1067,29 @@
            }
        }
        /**
         * returns a string containing hook data
         * @param string $type
         * @param string $name
         * @return string hook data
         */
        private function _parseHook ($name)
        {
            global $app;
            $namespace = '';
            if(strpos($name, ':') !== false) list($namespace, $name) = explode(':', $name, 2);
            $result = $app->plugins->raiseAction('on_template_content_hook', array(
                'name' => $name,
                'namespace' => $namespace,
                'vars' => $this->_vars
            ), true);
            if(!$result) $result = '';
            else $result = $this->_getData($result, false, true);
            return $result;
        }
        /**
         * returns a string used for parsing in tmpl_loop statements.
@@ -1254,7 +1283,10 @@
                if ($this->OPTIONS['ENABLE_PHPINCLUDE']) {
                    return '<?php include(\''.$file.'\'); ?>';
                }
            case 'hook':
                return $this->_parseHook(@$var);
            case 'include':
                return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>';
server/lib/classes/tpl_cache.inc.php
@@ -101,8 +101,8 @@
     * FUNCTION: _checkCache
     * checks if there's a cache, if there is then it will read the cache file as the template.
     */
    function _checkCache ($tmplfile) {
        $this->_cachefile = $this->_getFilename($tmplfile);
    function _checkCache ($tmplfile, $tmpl_from_string = false) {
        $this->_cachefile = $this->_getFilename($tmplfile, $tmpl_from_string);
        if ($this->_clearcache) {
            if (file_exists($this->_cachefile)) unlink($this->_cachefile);
            return false;
@@ -133,8 +133,9 @@
     * gets the full pathname for the cached file
     *
     */
    function _getFilename($tmplfile) {
        return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    function _getFilename($tmplfile, $tmpl_from_string = false) {
        if($tmpl_from_string == true) return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaRSTRING'.$tmplfile).'.'.$this->OPTIONS['CACHE_EXTENSION'];
        else return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    }
server/plugins-available/apache2_plugin.inc.php
@@ -1091,7 +1091,10 @@
        // Make sure we only have Unix linebreaks
        $vhost_data['apache_directives'] = str_replace("\r\n", "\n", $vhost_data['apache_directives']);
        $vhost_data['apache_directives'] = str_replace("\r", "\n", $vhost_data['apache_directives']);
        $trans = array('{DOCROOT}' => $vhost_data['web_document_root_www']);
        $trans = array(
            '{DOCROOT}' => $vhost_data['web_document_root_www'],
            '{DOCROOT_CLIENT}' => $vhost_data['web_document_root']
        );
        $vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans);
        // Check if a SSL cert exists
server/plugins-available/nginx_plugin.inc.php
@@ -1133,7 +1133,11 @@
        $nginx_directives = str_replace("\r", "\n", $nginx_directives);
        $nginx_directive_lines = explode("\n", $nginx_directives);
        if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){
            $trans = array('{DOCROOT}' => $vhost_data['web_document_root_www'], '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';');
            $trans = array(
                '{DOCROOT}' => $vhost_data['web_document_root_www'],
                '{DOCROOT_CLIENT}' => $vhost_data['web_document_root'],
                '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';'
            );
            foreach($nginx_directive_lines as $nginx_directive_line){
                $final_nginx_directives[] = array('nginx_directive' => strtr($nginx_directive_line, $trans));
            }