Loginbg.php 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\loginbg;
  3. use think\Addons;
  4. /**
  5. * 登录背景图插件
  6. */
  7. class Loginbg 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. $config = $this->getConfig();
  28. if ($config['mode'] == 'random' || $config['mode'] == 'daily')
  29. {
  30. $index = $config['mode'] == 'random' ? mt_rand(1, 4000) : date("Ymd") % 4000;
  31. $background = "http://img.infinitynewtab.com/wallpaper/" . $index . ".jpg";
  32. }
  33. else
  34. {
  35. $background = cdnurl($config['image']);
  36. }
  37. \think\View::instance()->assign('background', $background);
  38. }
  39. }