Example #1
0
 /**
  * Process the archives found in the incoming folders
  * 
  * @param string $detection
  * @param string $type
  * @param bool $help
  * @param bool $clearlock
  * @return void 
  */
 public function actionProcess($detection = '', $type = '', $help = false, $clearlock = false)
 {
     if (!in_array($detection, array('', 'detected', 'clean'))) {
         $help = true;
     }
     if (!in_array($type, array('', 'daily', 'monthly', 'bogus', 'url'))) {
         $help = true;
     }
     if ($help) {
         echo "\r\nUSAGE EXAMPLE:\r\n    archives process                                        // extracts all files from all archives\r\n    archives process --type=daily                           // extracts all files from daily archives (both detected and clean)\r\n    archives process --detection=clean --type=monthly       // extracts all files from clean monthly archives\r\n\r\nOPTIONS:\r\n    detection = [clean|detected]\r\n    type = [daily|monthly|bogus|url]\r\n";
         die;
     }
     if (!$this->handleFolderLock(VIREX_INCOMING_PATH, $clearlock)) {
         return;
     }
     $this->pending_actions();
     $errors_count = 0;
     if ($detection) {
         $dees = array($detection);
     } else {
         $dees = array('detected', 'clean');
     }
     if ($type) {
         $tees = array($type);
     } else {
         $tees = array('daily', 'monthly', 'url', 'bogus');
     }
     $archiver = new AFileArchive();
     $urchiver = new AUrlArchive();
     foreach ($tees as $tee) {
         foreach ($dees as $dee) {
             if ($tee == 'url') {
                 $files = $urchiver->return_all();
             }
             if (in_array($tee, array('daily', 'monthly'))) {
                 $files = $archiver->process_archives($dee, $tee);
                 $this->show_files($files, ucfirst($tee) . ' ' . $dee);
             }
         }
     }
     $this->actionSendemails();
     ALogger::end_step();
     $this->clearLock(VIREX_INCOMING_PATH);
 }
Example #2
0
 public static function logStats()
 {
     if (!self::$debug) {
         return true;
     }
     if (!ALogger::end_step()) {
         ALogger::empty_line();
     }
     $execTime = number_format(microtime(true) - self::$startTime, 2) . 's';
     $msg = "Time: " . self::color(self::CWHITE, $execTime) . "; Memory: " . self::color(self::CWHITE, FileHelper::formatSize(memory_get_peak_usage(true)));
     self::$show_time_on_logs = false;
     self::log($msg, null, 'debug', false);
     list($ok, $errors) = self::getStats();
     $errors = self::color(self::CLIGHT_RED, $errors);
     $ok = self::color(self::CLIGHT_GREEN, $ok);
     self::log('Errors: ' . $errors . '; Succesfull: ' . $ok, null, 'debug', false);
     self::empty_line();
 }