/**
  * 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'));
 }
Beispiel #2
0
 /**
  * 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", "/^[^#]/");
     }
 }
Beispiel #3
0
 /**
  * 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');
     }
 }
Beispiel #4
0
 /**
  * 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');
     }
 }
Beispiel #5
0
 /**
  * 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);
 }