Ejemplo n.º 1
0
 /**
  * Runs clear cache.
  *
  * @param boolean $background background flag
  *
  * @return void
  * @throws Engine_Exception
  */
 public function run_clear_cache($background = TRUE)
 {
     clearos_profile(__METHOD__, __LINE__);
     $options['background'] = TRUE;
     $shell = new Shell();
     $shell->execute(self::COMMAND_CLEAR_CACHE, '', TRUE, $options);
 }
Ejemplo n.º 2
0
 /**
  * Get status.
  *
  * @return void
  * @throws Engine_Exception
  */
 function get_status()
 {
     clearos_profile(__METHOD__, __LINE__);
     $shell = new Shell();
     $args = '-u ';
     $options['env'] = "LANG=en_US";
     $retval = $shell->execute(self::CMD_APC_ACCESS, $args, FALSE, $options);
     if ($retval != 0) {
         $errstr = $shell->get_last_output_line();
         throw new Engine_Exception($errstr, COMMON_WARNING);
     }
     $lines = $shell->get_output();
     $data = array();
     foreach ($lines as $line) {
         if (preg_match("/(.*?):(.*)\$/", $line, $match)) {
             $data[trim(strtolower($match[1]))] = trim($match[2]);
         }
         if (preg_match('/loadpct|bcharge/', trim(strtolower($match[1])))) {
             $data[trim(strtolower($match[1]))] = trim($match[2]) . ' %';
         } else {
             if (trim(strtolower($match[1])) == 'timeleft') {
                 $data[trim(strtolower($match[1]))] = trim($match[2]) . ' ' . strtolower(lang('base_minutes'));
                 $data['timeleft_brief'] = trim($match[2]);
             }
         }
         if (trim(strtolower($match[1])) == 'battdate') {
             $data['battage'] = floor((time() - strtotime(trim($match[2]))) / (60 * 60 * 24)) . ' ' . strtolower(lang('base_days'));
         }
     }
     return $data;
 }