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