Admin_disable.php 634 B

123456789101112131415161718192021
  1. <?php
  2. use app\admin\model\Admin;
  3. use Workerman\Lib\Timer;
  4. use Workerman\Worker as WO;
  5. class AdminDisable extends Com{
  6. public static function run(){
  7. $work=self::newWorker();
  8. $work->onWorkerStart=function (WO $worker){
  9. Timer::add(3,function ()use ($worker){
  10. $userNum=Admin::where('id','>',1)
  11. ->where('logintime','<',strtotime('-1month'))
  12. ->where('status','normal')
  13. ->update(['status'=>'hidden']);
  14. $userNum && self::log("禁用了{$userNum}个管理员");
  15. });
  16. };
  17. }
  18. }
  19. AdminDisable::run();