Fleaseo.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Fleaseo extends AdminControl
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/flea.lang.php');
  18. if (config('ds_config.flea_isuse') != '1') {
  19. $this->error(lang('flea_isuse_off_tips'), 'dashboard/welcome');
  20. }
  21. }
  22. function index()
  23. {
  24. /**
  25. * 实例化模型
  26. */
  27. $config_model = model('config');
  28. /**
  29. * 保存信息
  30. */
  31. if (request()->isPost()) {
  32. $update_array = array();
  33. $update_array['flea_site_title'] = trim(input('post.flea_site_title'));
  34. $update_array['flea_site_description'] = trim(input('post.flea_site_description'));
  35. $update_array['flea_site_keywords'] = trim(input('post.flea_site_keywords'));
  36. $result = $config_model->editConfig($update_array);
  37. if ($result === true) {
  38. $this->success(lang('ds_common_save_succ'));
  39. } else {
  40. $this->error(lang('ds_common_save_fail'));
  41. }
  42. } else {
  43. /**
  44. * 读取设置内容 $list_setting
  45. */
  46. $list_setting = rkcache('config', true);
  47. /**
  48. * 模板输出
  49. */
  50. View::assign('list_setting', $list_setting);
  51. $this->setAdminCurItem('index');
  52. return View::fetch('index');
  53. }
  54. }
  55. /**
  56. * 闲置首页广告
  57. */
  58. public function adv_manage()
  59. {
  60. $config_model = model('config');
  61. if (request()->isPost()) {
  62. $input = array();
  63. //上传图片
  64. $file_name = 'flea_1.jpg';
  65. if (!empty($_FILES['adv_pic1']['name'])) {
  66. $res = ds_upload_pic(ATTACH_PATH, 'adv_pic1', $file_name);
  67. if ($res['code']) {
  68. $file_name = $res['data']['file_name'];
  69. $input[1]['pic'] = $file_name;
  70. $input[1]['url'] = input('post.adv_url1');
  71. } else {
  72. $this->error($res['msg']);
  73. }
  74. } elseif (input('post.old_adv_pic1') != '') {
  75. $input[1]['pic'] = input('post.old_adv_pic1');
  76. $input[1]['url'] = input('post.adv_url1');
  77. }
  78. if (!empty($_FILES['adv_pic2']['name'])) {
  79. $file_name = 'flea_2.jpg';
  80. $res = ds_upload_pic(ATTACH_PATH, 'adv_pic2', $file_name);
  81. if ($res['code']) {
  82. $file_name = $res['data']['file_name'];
  83. $input[2]['pic'] = $file_name;
  84. $input[2]['url'] = input('post.adv_url2');
  85. } else {
  86. $this->error($res['msg']);
  87. }
  88. } elseif (input('post.old_adv_pic2') != '') {
  89. $input[2]['pic'] = input('post.old_adv_pic2');
  90. $input[2]['url'] = input('post.adv_url2');
  91. }
  92. if (!empty($_FILES['adv_pic3']['name'])) {
  93. $file_name = 'flea_3.jpg';
  94. $res = ds_upload_pic(ATTACH_PATH, 'adv_pic3', $file_name);
  95. if ($res['code']) {
  96. $file_name = $res['data']['file_name'];
  97. $input[3]['pic'] = $file_name;
  98. $input[3]['url'] = input('post.adv_url3');
  99. } else {
  100. $this->error($res['msg']);
  101. }
  102. } elseif (input('post.old_adv_pic3') != '') {
  103. $input[3]['pic'] = input('post.old_adv_pic3');
  104. $input[3]['url'] = input('post.adv_url3');
  105. }
  106. if (!empty($_FILES['adv_pic4']['name'])) {
  107. $file_name = 'flea_4.jpg';
  108. $res = ds_upload_pic(ATTACH_PATH, 'adv_pic4', $file_name);
  109. if ($res['code']) {
  110. $file_name = $res['data']['file_name'];
  111. $input[4]['pic'] = $file_name;
  112. $input[4]['url'] = input('post.adv_url4');
  113. } else {
  114. $this->error($res['msg']);
  115. }
  116. } elseif (input('post.old_adv_pic4') != '') {
  117. $input[4]['pic'] = input('post.old_adv_pic4');
  118. $input[4]['url'] = input('post.adv_url4');
  119. }
  120. if (!empty($_FILES['adv_pic5']['name'])) {
  121. $file_name = 'flea_5.jpg';
  122. $res = ds_upload_pic(ATTACH_PATH, 'adv_pic5', $file_name);
  123. if ($res['code']) {
  124. $file_name = $res['data']['file_name'];
  125. $input[5]['pic'] = $file_name;
  126. $input[5]['url'] = input('post.adv_url5');
  127. } else {
  128. $this->error($res['msg']);
  129. }
  130. } elseif (input('post.old_adv_pic4') != '') {
  131. $input[5]['pic'] = input('post.old_adv_pic5');
  132. $input[5]['url'] = input('post.adv_url5');
  133. }
  134. $update_array = array();
  135. if (count($input) > 0) {
  136. $update_array['flea_loginpic'] = serialize($input);
  137. }
  138. $result = $config_model->editConfig($update_array);
  139. if ($result === true) {
  140. $this->log(lang('ds_edit') . lang('loginSettings'), 1);
  141. $this->success(lang('ds_common_save_succ'));
  142. } else {
  143. $this->log(lang('ds_edit') . lang('loginSettings'), 0);
  144. $this->error(lang('ds_common_save_fail'));
  145. }
  146. } else {
  147. $list_setting = rkcache('config', true);
  148. if ($list_setting['flea_loginpic'] != '') {
  149. $adv_list = unserialize($list_setting['flea_loginpic']);
  150. } else {
  151. $adv_list = '';
  152. }
  153. View::assign('adv_list', $adv_list);
  154. return View::fetch('adv');
  155. }
  156. }
  157. protected function getAdminItemList()
  158. {
  159. $menu_array = array(
  160. array(
  161. 'name' => 'index', 'text' => lang('flea_seo'), 'url' => (string) url('Fleaseo/index')
  162. ),
  163. );
  164. return $menu_array;
  165. }
  166. }