Admin_disable.php 678 B

12345678910111213141516171819202122
  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=new WO();
  8. $work->name='disable never login admin in one month';
  9. $work->onWorkerStart=function (WO $worker){
  10. Timer::add(3,function ()use ($worker){
  11. $userNum=Admin::where('id','>',1)
  12. ->where('logintime','<',strtotime('-1month'))
  13. ->where('status','normal')
  14. ->update(['status'=>'hidden']);
  15. $worker::log("禁用了{$userNum}个管理员");
  16. });
  17. };
  18. }
  19. }
  20. AdminDisable::run();