Adminloginbg.php 995 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\adminloginbg;
  3. use think\Addons;
  4. /**
  5. * 登录背景图插件
  6. */
  7. class Adminloginbg extends Addons
  8. {
  9. /**
  10. * 插件安装方法
  11. * @return bool
  12. */
  13. public function install()
  14. {
  15. return true;
  16. }
  17. /**
  18. * 插件卸载方法
  19. * @return bool
  20. */
  21. public function uninstall()
  22. {
  23. return true;
  24. }
  25. public function adminLoginInit(\think\Request &$request)
  26. {
  27. $info = $this->getInfo();
  28. if($info['state'] ==1) {
  29. $config = $this->getConfig();
  30. if ($config['mode'] == 'random' || $config['mode'] == 'daily') {
  31. $index = $config['mode'] == 'random' ? mt_rand(1, 4000) : date("Ymd") % 4000;
  32. $background = "http://img.infinitynewtab.com/wallpaper/" . $index . ".jpg";
  33. } else {
  34. $background = $config['image'];
  35. }
  36. \think\View::instance()->assign('background', $background);
  37. }
  38. }
  39. }