Example #1
0
 /**
  * Loads configlet.
  *
  * @param string $configlet configlet file
  *
  * @access private
  * @return void
  * @throws Engine_Exception
  */
 protected function _load_configlet($configlet)
 {
     clearos_profile(__METHOD__, __LINE__);
     $file = new File($configlet, TRUE);
     $lines = $file->get_contents_as_array();
     $matches = array();
     $config = array();
     foreach ($lines as $line) {
         if (preg_match("/^#/", $line) || preg_match("/^\\s*\$/", $line)) {
             continue;
         }
         $items = preg_split("/\\s+/", $line, 2);
         // ACL lists are ordered, so an index is required
         if (isset($config[$items[0]])) {
             $config[$items[0]]['count']++;
         } else {
             $config[$items[0]]['count'] = 1;
         }
         // $count is just to make code more readable
         $count = $config[$items[0]]['count'];
         $config[$items[0]]['line'][$count] = $items[1];
     }
     return $config;
 }
Example #2
0
 /**
  * Returns interface statistics.
  *
  * @return array interface statistics
  * @throws Engine_Exception
  */
 public function get_interface_statistics()
 {
     clearos_profile(__METHOD__, __LINE__);
     // TODO: move this to the Iface class
     $stats = array();
     $file = new File(self::FILE_STATS);
     $lines = $file->get_contents_as_array();
     $matches = array();
     foreach ($lines as $line) {
         if (preg_match('/^\\s*([^:]*):(.*)/', $line, $matches)) {
             $items = preg_split('/\\s+/', $matches[2]);
             $stats[$matches[1]]['received'] = $items[1];
             $stats[$matches[1]]['sent'] = $items[9];
         }
     }
     return $stats;
 }
Example #3
0
 /**
  * Loads configuration files.
  *
  * @access private
  * @return void
  * @throws Engine_Exception
  */
 protected function _load_config()
 {
     clearos_profile(__METHOD__, __LINE__);
     $lines = array();
     try {
         $file = new File(self::FILE_CONFIG, TRUE);
         $lines = $file->get_contents_as_array();
     } catch (Exception $e) {
         throw new Engine_Exception($e->GetMessage(), COMMON_WARNING);
     }
     $matches = array();
     foreach ($lines as $line) {
         if (preg_match("/^#/", $line) || preg_match("/^\\s*\$/", $line)) {
             continue;
         } else {
             if (preg_match("/(.*)=(.*)/", $line, $matches)) {
                 $key = $matches[1];
                 $value = $matches[2];
                 $this->config[$key] = $value;
             }
         }
     }
     $this->is_loaded = TRUE;
 }