/** * Apc default controller * * @return view */ function index() { clearos_profile(__METHOD__, __LINE__); $this->lang->load('apcups'); $this->load->library('apcups/Apc'); $data = $this->apc->get_status(); // Load views //----------- $this->page->view_form('apcups/dashboard/status', $data, lang('apcups_app_name')); }
/** * Sets parameter in PPTP configuration file. * * @param string $parameter parameter in options file * @param string $value value for given parameter * * @access private * @return void */ protected function _set_config_parameter($parameter, $value) { clearos_profile(__METHOD__, __LINE__); $file = new File(self::FILE_CONFIG); $match = $file->replace_lines("/^{$parameter}\\s*/i", "{$parameter} {$value}\n"); if (!$match) { $file->add_lines_after("{$parameter} {$value}\n", "/^[^#]/"); } }
/** * Validation routine for YouTube EDU ID. * * @param string $id YouTube EDU ID. * * @return boolean */ public function validate_youtube_edu_id($id) { clearos_profile(__METHOD__, __LINE__); if (!strlen($id)) { return lang('web_proxy_youtube_id_invalid'); } }
/** * Validation routine for powerdown * * @param string $percent percent to powerdown on * * @return mixed string containing error if invalid */ public function validate_powerdown($powerdown) { clearos_profile(__METHOD__, __LINE__); if ($powerdown <= 0 || $powerdown >= 100) { return lang('apcups_invalid_powerdown'); } }
/** * Sets a parameter in the config file. * * @param string $key name of the key in the config file * @param string $value value for the key * * @access private * @return void * @throws Engine_Exception */ protected function _set_parameter($key, $value) { clearos_profile(__METHOD__, __LINE__); $file = new File(self::FILE_CONFIG); $match = $file->replace_lines("/^{$key}\\s*=/", "{$key}={$value}\n"); if ($match === 0) { $match = $file->replace_lines("/^#\\s*{$key}\\s*=/", "{$key}={$value}\n"); if ($match === 0) { $file->add_lines("{$key}={$value}\n"); } } $this->is_loaded = FALSE; }
/** * Sets state of proxy bypass rule. * * @param boolean $state state of the rule * @param string $address host/IP address to remove * * @return void * @throws Engine_Exception, Validation_Exception */ public function set_proxy_bypass_state($state, $address) { clearos_profile(__METHOD__, __LINE__); Validation_Exception::is_valid($this->validate_address($address)); $rule = new Rule(); $rule->set_address($address); $rule->set_flags(Rule::PROXY_BYPASS); if (!($rule = $this->_find_rule($rule))) { return; } $this->_delete_rule($rule); if ($state) { $rule->enable(); } else { $rule->disable(); } $this->_add_rule($rule); }