Ajax.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\controller;
  14. use think\Db;
  15. use think\Session;
  16. use app\admin\logic\AjaxLogic;
  17. /**
  18. * 所有ajax请求或者不经过权限验证的方法全放在这里
  19. */
  20. class Ajax extends Base {
  21. private $ajaxLogic;
  22. public function _initialize() {
  23. parent::_initialize();
  24. $this->ajaxLogic = new AjaxLogic;
  25. }
  26. /**
  27. * 进入欢迎页面需要异步处理的业务
  28. */
  29. public function welcome_handle()
  30. {
  31. $this->ajaxLogic->welcome_handle();
  32. }
  33. /**
  34. * 隐藏后台欢迎页的系统提示
  35. */
  36. public function explanation_welcome()
  37. {
  38. $type = input('param.type/d', 0);
  39. $tpCacheKey = 'system_explanation_welcome';
  40. if (1 < $type) {
  41. $tpCacheKey .= '_'.$type;
  42. }
  43. /*多语言*/
  44. if (is_language()) {
  45. $langRow = \think\Db::name('language')->field('mark')->order('id asc')->select();
  46. foreach ($langRow as $key => $val) {
  47. tpCache('system', [$tpCacheKey=>1], $val['mark']);
  48. }
  49. } else { // 单语言
  50. tpCache('system', [$tpCacheKey=>1]);
  51. }
  52. /*--end*/
  53. }
  54. /**
  55. * 版本检测更新弹窗
  56. */
  57. public function check_upgrade_version()
  58. {
  59. $upgradeLogic = new \app\admin\logic\UpgradeLogic;
  60. $upgradeMsg = $upgradeLogic->checkVersion(); // 升级包消息
  61. $this->success('检测成功', null, $upgradeMsg);
  62. }
  63. /**
  64. * 更新stiemap.xml地图
  65. */
  66. public function update_sitemap($controller, $action)
  67. {
  68. if (IS_AJAX_POST) {
  69. $channeltype_row = \think\Cache::get("extra_global_channeltype");
  70. if (empty($channeltype_row)) {
  71. $ctlArr = \think\Db::name('channeltype')
  72. ->where('id','NOTIN', [6,8])
  73. ->column('ctl_name');
  74. } else {
  75. $ctlArr = array();
  76. foreach($channeltype_row as $key => $val){
  77. if (!in_array($val['id'], [6,8])) {
  78. $ctlArr[] = $val['ctl_name'];
  79. }
  80. }
  81. }
  82. $systemCtl= ['Arctype'];
  83. $ctlArr = array_merge($systemCtl, $ctlArr);
  84. $actArr = ['add','edit'];
  85. if (in_array($controller, $ctlArr) && in_array($action, $actArr)) {
  86. Session::pause(); // 暂停session,防止session阻塞机制
  87. sitemap_auto();
  88. $this->success('更新sitemap成功!');
  89. }
  90. }
  91. $this->error('更新sitemap失败!');
  92. }
  93. }