Do not overload, use method initialize() to customize the module and its environment instead! * @author Martin Diedrich (mdiedrich) */ public function monitord_webfrontend_module() { if(!$this->monitord_ini = @parse_ini_file('./monitord_config.ini', true)) { throw new exception('No monitord_config.ini found, left uncofigured - aborting.', '300'); } $this->modulename = substr(substr(get_class($this), 9), 0, strrpos(substr(get_class($this), 9), "_")); if(!$this->module_ini = @parse_ini_file('./' . $this->modulename . '.module.ini', true)) { throw new exception('No module.ini found for ' . get_class($this) . ', left uncofigured - aborting.', '300'); } $this->initialize(); if(!$this->dbconn = @mysql_connect($this->monitord_ini['database']['host'], $this->monitord_ini['database']['user'], $this->monitord_ini['database']['pass'])) { throw new exception(mysql_errno() . ', ' . mysql_error() . ' in ' . get_class($this), $this->monitord_ini['failcodes']['dbconn']); } if(!@mysql_select_db($this->monitord_ini['database']['database'], $this->dbconn)) { throw new exception(mysql_errno() . ', ' . mysql_error() . ' in ' . get_class($this), $this->monitord_ini['failcodes']['dbselect']); } } /** * @brief Writes a link/button in menu * * To be called by base page (index.php) making the module available for the user by writing a link * @author Martin Diedrich (mdiedrich) */ public function write_menu_button() { if($this->module_ini['main']['enable'] == '1') { if((sizeof($_GET) > 0) && ($_GET['module'] == $this->modulename)) { echo '
' . $this->moduletitle . '
'; } else { echo '
' . $this->moduletitle . '
'; } } } /** * @brief Should this module be executed? * * To be called by base page (index.php) as all other modules to activate by matching HTTP GET param * @author Martin Diedrich (mdiedrich) */ protected function decide_to_be_called() { if((isset($_GET['module']) && $_GET['module'] == $this->modulename)) { if($this->module_ini['main']['enable'] == '1') { return true; } else { throw new exception('Module disabled.', '308'); } } return false; } /** * @brief The module's main output method * * Overload this! It's the method to show the module's output, being called after it's initialization * @author Martin Diedrich (mdiedrich) */ protected function output_content() { throw new exception('Not implemented yet: output_content', '305'); } /** * @brief The module's universe * * Overload this! It's the method to initialize the module's own context and environment being called by constructor * @author Martin Diedrich (mdiedrich) */ protected function initialize() { throw new exception('Not implemented yet: initialize', '305'); } /** * @brief Generates SQL-Query for its qiven type or purpose * * Overload this! It's the method to show the module's output, being called after it's initialization * @author Martin Diedrich (mdiedrich) */ protected function get_db_query() { throw new exception('No dbquery implemented... extend this output_manager class!'); } /** * @brief wraps output_content - output only when decide_to_be_called() returns true * @author Martin Diedrich (mdiedrich) */ public function trigger_output_content($active_modules) { if($this->decide_to_be_called()) { $this->output_content($active_modules); return true; } return false; } /** * @brief Sends HTTP headers - refresh times etc. * * Important to know: This method changes the behaviour of http_refreshs - if given in module.ini this value is used. If disabled in module.ini no header is being sent even if in monitord.ini http_refreshing is enabled! * @author Martin Diedrich (mdiedrich) */ public function send_http_headers() { if($this->decide_to_be_called()) { if(isset($this->module_ini['main']['http_refresh_enable']) && isset($this->module_ini['main']['http_refresh_seconds']) && $this->module_ini['main']['http_refresh_enable'] == 1) { header( 'refresh: ' . $this->module_ini['main']['http_refresh_seconds'] . ';' ); return true; } elseif(isset($this->module_ini['main']['http_refresh_enable']) && $this->module_ini['main']['http_refresh_enable'] == 0) { return true; } if(isset($this->monitord_ini['main']['http_refresh_seconds']) && isset($this->monitord_ini['main']['http_refresh_enable']) && $this->monitord_ini['main']['http_refresh_enable'] == 1) { header( 'refresh: ' . $this->monitord_ini['main']['http_refresh_seconds'] . ';' ); return true; } return false; } } /** * @brief echos the module's version in HTML as a SPAN */ public function show_version($always = false) { if($always || $this->module_ini['main']['enable']) { echo '' . $this->modulename . ': Version ' . substr($this->revision, 11, -2) . ' / ' . substr($this->date, 38, -3) . '
'; } } } ?>