Fleaseo.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Fleaseo extends AdminControl {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/flea.lang.php');
  20. if (config('ds_config.flea_isuse') != '1') {
  21. $this->error(lang('flea_isuse_off_tips'), 'dashboard/welcome');
  22. }
  23. }
  24. function index() {
  25. /**
  26. * 实例化模型
  27. */
  28. $config_model = model('config');
  29. /**
  30. * 保存信息
  31. */
  32. if (request()->isPost()) {
  33. $update_array = array();
  34. $update_array['flea_site_title'] = trim(input('post.flea_site_title'));
  35. $update_array['flea_site_description'] = trim(input('post.flea_site_description'));
  36. $update_array['flea_site_keywords'] = trim(input('post.flea_site_keywords'));
  37. $result = $config_model->editConfig($update_array);
  38. if ($result === true) {
  39. $this->success(lang('ds_common_save_succ'));
  40. } else {
  41. $this->error(lang('ds_common_save_fail'));
  42. }
  43. } else {
  44. /**
  45. * 读取设置内容 $list_setting
  46. */
  47. $list_setting = rkcache('config', true);
  48. /**
  49. * 模板输出
  50. */
  51. View::assign('list_setting', $list_setting);
  52. $this->setAdminCurItem('index');
  53. return View::fetch('index');
  54. }
  55. }
  56. /**
  57. * 闲置首页广告
  58. */
  59. public function adv_manage() {
  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. $menu_array = array(
  159. array(
  160. 'name' => 'index', 'text' => lang('flea_seo'), 'url' => (string) url('Fleaseo/index')
  161. ),
  162. );
  163. return $menu_array;
  164. }
  165. }