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(); }
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 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(); }