public function actionPending() { /// DETECTED SAMPLES ACTIONS ALogger::log('detected files...', 'cyan'); $m_detected = new SampleDetected('search'); $m_detected->deleteFiles("pending_action_sde = 'delete'"); unset($m_detected); /// CLEAN SAMPLES ACTIONS ALogger::log('clean files...', 'cyan'); $m_undetected = new SampleClean('search'); $m_undetected->deleteFiles("pending_action_scl = 'delete'"); unset($m_undetected); }
public static function deleteWhereCondition($condition) { $files = Yii::app()->db->createCommand("SELECT * FROM bogus_archives_bga WHERE {$condition}")->queryAll(); ALogger::log('Found ' . count($files) . ' archives to delete.'); foreach ($files as $f) { $bogusPath = PathFinder::get(VIREX_INCOMING_PATH, $f['detection_bga'], 'bogus', true); try { unlink($bogusPath . $f['id_bga']); } catch (Exception $e) { ALogger::error($e->getMessage()); $err = 1; } if (!isset($err)) { Yii::app()->db->createCommand("DELETE FROM bogus_archives_bga WHERE id_bga = " . $f['id_bga'])->execute(); } else { unset($err); } } }
public function add_new() { ALogger::log('AUrlArchive::search archives in urls folder'); $this->stats_errors = 0; // reinit stats $this->stats_ok = 0; $files = scandir($this->baseUrl); ALogger::log('Total files found: ' . (count($files) - 2) . ' archives'); if (count($files) > 2) { foreach ($files as $file) { if ($file != '.' && $file != '..' && $file != '_lockfile' && strpos($file, '.filepart') === false) { ALogger::start_action('processing ' . $file . '..'); try { $this->last_error = ''; if ($this->process_file($this->baseUrl . $file)) { if (file_exists($this->baseUrl . $file)) { unlink($this->baseUrl . $file); } $this->stats_ok++; } else { $this->move_to_bogus($this->baseUrl . $file); $this->stats_errors++; } } catch (Exception $e) { ALogger::error($e->getMessage(), true); // log critical error } ALogger::end_action(); // logging done message } } } // showing final stats if ($this->stats_errors + $this->stats_ok > 0) { ALogger::log('Success: ' . $this->stats_ok . ' archives'); ALogger::log('Errors : ' . $this->stats_errors . ' archives'); } }
public function deleteFiles($where, $values = array()) { $nerrors = 0; $nok = 0; $stillExists = Yii::app()->db->createCommand("SELECT count(*) 'n' FROM samples_detected_sde WHERE md5_sde=:md5"); $deleteId = Yii::app()->db->createCommand("DELETE FROM samples_detected_sde WHERE id_sde=:id"); $start = 0; while ($files = Yii::app()->db->createCommand("SELECT hex(md5_sde) 'hex', md5_sde, id_sde FROM samples_detected_sde WHERE " . $where)->queryAll(true, $values)) { ALogger::log('Found ' . count($files) . ' samples to delete.'); $start += 5000; foreach ($files as $f) { ALogger::start_action('deleting ' . $f['md5_sde'] . '..'); $deleteId->execute(array('id' => $f['id_sde'])); $exists = $stillExists->bindValue(':md5', $f['md5_sde'])->queryRow(); if (!$exists['n']) { // I delete it only if is not in db anymore( it can be deleted only from monthly and still be in daily for example..) $fName = PathFinder::get(VIREX_STORAGE_PATH, 'detected', '') . substr($f['hex'], 0, 3) . '/' . substr($f['hex'], 3, 3) . '/' . substr($f['hex'], 6, 3) . '/' . $f['hex']; if (file_exists($fName)) { try { if (unlink($fName)) { $nok++; } } catch (Exception $e) { ALogger::error($e->get_message()); $nerrors++; } } else { // ALogger::error('file not found'); $nerrors++; $nok++; } } else { $nok++; } ALogger::end_action(); } } if ($nerrors + $nok > 0) { ALogger::log('Deleted: ' . $nok . ' samples'); ALogger::log('Errors : ' . $nerrors . ' samples'); ALogger::empty_line(); } }
public function actionDelete_fake_emails() { $nr = Yii::app()->db->createCommand('DELETE FROM external_users_usr WHERE register_date_usr < SUBDATE(NOW(), INTERVAL 2 DAY) AND status_usr = 0')->execute(); ALogger::log($nr . ' users deleted!'); ALogger::empty_line(); }