Exemple #1
0
 /**
  * Sets the WINS server.
  *
  * @param string $server WINS server
  *
  * @return void
  * @throws Engine_Exception, Validation_Exception
  */
 public function set_wins_server($server)
 {
     clearos_profile(__METHOD__, __LINE__);
     Validation_Exception::is_valid($this->validate_wins_server($server));
     $this->_set_options_parameter('ms-wins', $server);
 }
Exemple #2
0
 /**
  * Enables/disables YouTube EDU ID
  *
  * @param string  $enable enable/disable YouTube EDU ID header
  * @param array   $id     YouTube EDU ID
  *
  * @return void
  * @throws Engine_Exception, Validation_Exception
  */
 public function set_youtube_edu($enable, $id)
 {
     clearos_profile(__METHOD__, __LINE__);
     if ($enable) {
         Validation_Exception::is_valid($this->validate_youtube_edu_id($id));
         $this->_delete_parameter('acl youtube dstdomain .youtube.com', self::FILE_ACLS_CONFIG);
         $file = new File(self::FILE_ACLS_CONFIG, TRUE);
         $file->delete_lines("/acl youtube dstdomain\\s+.*/");
         $file->add_lines("acl youtube dstdomain .youtube.com\n");
         $ecap_enable = 'ecap_enable on';
     } else {
         // Leave alone or Squid freaks out
         // $this->_delete_parameter('acl youtube dstdomain .youtube.com', self::FILE_ACLS_CONFIG);
         $ecap_enable = 'ecap_enable off';
     }
     $file = new File(self::FILE_ECAP_SQUID_CONFIG, TRUE);
     $file->replace_one_line("/^ecap_enable\\s*/i", "{$ecap_enable}\n");
     if (strlen($id)) {
         $file = new File(self::FILE_ECAP_XML_CONFIG, TRUE);
         $xml_source = $file->get_contents();
         $xml = simplexml_load_string($xml_source);
         if ($xml === FALSE) {
             return;
         }
         foreach ($xml->header as $i => $hdr) {
             if ($hdr['name'] != 'X-YouTube-Edu-Filter') {
                 continue;
             }
             $xml->header[0] = $id;
             break;
         }
         $file->delete_lines('/.*/');
         $file->add_lines($xml->asXML());
     }
 }
Exemple #3
0
 /**
  * Sets reflector.
  *
  * @param boolean $reflector enable/disable reflector
  *
  * @return void
  * @throws Engine_Exception, Validation_Exception
  */
 public function set_reflector($reflector)
 {
     clearos_profile(__METHOD__, __LINE__);
     Validation_Exception::is_valid($this->validate_reflector($reflector));
     if ($reflector) {
         $reflector = 'yes';
     } else {
         $reflector = 'no';
     }
     $this->_set_parameter('enable-reflector', $reflector);
 }
Exemple #4
0
 /**
  * Set the APC notification email.
  *
  * @param string $email a valid email
  *
  * @return void
  * @throws Engine_Exception Validation_Exception
  */
 function set_email($email)
 {
     clearos_profile(__METHOD__, __LINE__);
     // Validation
     // ----------
     Validation_Exception::is_valid($this->validate_email($email));
     $file = new File(self::FILE_APC_CONTROL, TRUE);
     try {
         $file->replace_lines('/^export SYSADMIN=.*/', 'export SYSADMIN=' . $email . "\n");
     } catch (Exception $e) {
         throw new Engine_Exception(clearos_exception_message($e), CLEAROS_ERROR);
     }
 }
 /**
  * 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);
 }