Merge branch 'master' of http://git.ispconfig.org/ispconfig/ispconfig3
| | |
| | | |
| | | 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(); |
| | | |
| | | 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') { |
| | | if($file !== '.' && $file !== '..' && substr($file, -8, 8) == '.inc.php') { |
| | | $plugin_name = substr($file, 0, -8); |
| | | $tmp_plugins[$plugin_name] = $file; |
| | | } |
| | | } |
| | | 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; |
| | | 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('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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'])) { |
| | |
| | | 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 = ''; |
| | |
| | | */ |
| | | } 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']; |
| | | $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])) { |
| | |
| | | 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 |
| | | |
| | | |
| | |
| | | $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; |
| | |
| | | $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(); |
| | | } |
| | |
| | | global $app, $conf; |
| | | |
| | | include $file; |
| | | $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$form['name'] . ':on_before_formdef', $this); |
| | | $this->formDef = $form; |
| | | |
| | | $this->module = $module; |
| | |
| | | |
| | | $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'); |
| | | |
| | |
| | | * @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 |
| | | 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*'; |
| | |
| | | } |
| | | |
| | | //* 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;'); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | |
| | | return '<?php include(\''.$file.'\'); ?>'; |
| | | } |
| | | |
| | | case 'hook': |
| | | return $this->_parseHook(@$var); |
| | | |
| | | case 'include': |
| | | return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; |
| | | |
| | |
| | | * 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; |
| | |
| | | * 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']; |
| | | } |
| | | |
| | | |
| | |
| | | </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"> {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> {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> |
| | |
| | | </tmpl_if> |
| | | |
| | | |
| | | |
| | | {tmpl_hook name="begin_form"} |
| | | <tmpl_if name="vhostdomain_type" value="domain"> |
| | | <tmpl_if name="is_admin"> |
| | | <div class="form-group"> |
| | |
| | | {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"> |
| | |
| | | </select></div> |
| | | </div> |
| | | {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'}"> |
| | | |
| | |
| | | <tmpl_hook name='apache2_vhost:header'> |
| | | |
| | | <Directory {tmpl_var name='web_basedir'}/{tmpl_var name='domain'}> |
| | | AllowOverride None |
| | |
| | | </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> |
| | |
| | | </IfModule> |
| | | |
| | | <tmpl_var name='apache_directives'> |
| | | <tmpl_hook name='apache2_vhost:vhost_footer'> |
| | | </VirtualHost> |
| | | </tmpl_loop> |
| | | |
| | | <tmpl_hook name='apache2_vhost:footer'> |
| | |
| | | } else { |
| | | $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR); |
| | | } |
| | | |
| | | } |
| | | |
| | | /* |
| | |
| | | } |
| | | |
| | | |
| | | 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) { |
| | |
| | | $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($return_data) { |
| | | if($state) $result .= $state; |
| | | } else { |
| | | if($state == 'warning' && $state_out != 'error') $state_out = 'warning'; |
| | | if($state == 'error') $state_out = 'error'; |
| | | elseif($state == 'error') $state_out = 'error'; |
| | | } |
| | | |
| | | unset($plugin_name); |
| | | unset($function_name); |
| | | } |
| | |
| | | unset($action); |
| | | unset($actions); |
| | | |
| | | return $state_out; |
| | | if($return_data == true) return $result; |
| | | else return $state_out; |
| | | } |
| | | |
| | | } |
| | |
| | | * @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 |
| | | 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*'; |
| | |
| | | } |
| | | |
| | | //* 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;'); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | |
| | | return '<?php include(\''.$file.'\'); ?>'; |
| | | } |
| | | |
| | | case 'hook': |
| | | return $this->_parseHook(@$var); |
| | | |
| | | case 'include': |
| | | return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; |
| | | |
| | |
| | | * 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; |
| | |
| | | * 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']; |
| | | } |
| | | |
| | | |
| | |
| | | // 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 |
| | |
| | | $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)); |
| | | } |