Fleaseo.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Fleaseo extends AdminControl {
  18. public function initialize() {
  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. $config_model = model('config');
  30. /**
  31. * 保存信息
  32. */
  33. if (request()->isPost()) {
  34. $update_array = array();
  35. $update_array['flea_site_title'] = trim(input('post.flea_site_title'));
  36. $update_array['flea_site_description'] = trim(input('post.flea_site_description'));
  37. $update_array['flea_site_keywords'] = trim(input('post.flea_site_keywords'));
  38. $result = $config_model->editConfig($update_array);
  39. if ($result === true) {
  40. $this->success(lang('ds_common_save_succ'));
  41. } else {
  42. $this->error(lang('ds_common_save_fail'));
  43. }
  44. } else {
  45. /**
  46. * 读取设置内容 $list_setting
  47. */
  48. $list_setting = rkcache('config', true);
  49. /**
  50. * 模板输出
  51. */
  52. View::assign('list_setting', $list_setting);
  53. $this->setAdminCurItem('index');
  54. return View::fetch('index');
  55. }
  56. }
  57. /**
  58. * 闲置首页广告
  59. */
  60. public function adv_manage() {
  61. $config_model = model('config');
  62. if (request()->isPost()) {
  63. $input = array();
  64. //上传图片
  65. $file_name = 'flea_1.jpg';
  66. if (!empty($_FILES['adv_pic1']['name'])) {
  67. $res=ds_upload_pic(ATTACH_PATH,'adv_pic1',$file_name);
  68. if($res['code']){
  69. $file_name=$res['data']['file_name'];
  70. $input[1]['pic'] = $file_name;
  71. $input[1]['url'] = input('post.adv_url1');
  72. }else{
  73. $this->error($res['msg']);
  74. }
  75. } elseif (input('post.old_adv_pic1') != '') {
  76. $input[1]['pic'] = input('post.old_adv_pic1');
  77. $input[1]['url'] = input('post.adv_url1');
  78. }
  79. if (!empty($_FILES['adv_pic2']['name'])) {
  80. $file_name = 'flea_2.jpg';
  81. $res=ds_upload_pic(ATTACH_PATH,'adv_pic2',$file_name);
  82. if($res['code']){
  83. $file_name=$res['data']['file_name'];
  84. $input[2]['pic'] = $file_name;
  85. $input[2]['url'] = input('post.adv_url2');
  86. }else{
  87. $this->error($res['msg']);
  88. }
  89. } elseif (input('post.old_adv_pic2') != '') {
  90. $input[2]['pic'] = input('post.old_adv_pic2');
  91. $input[2]['url'] = input('post.adv_url2');
  92. }
  93. if (!empty($_FILES['adv_pic3']['name'])) {
  94. $file_name = 'flea_3.jpg';
  95. $res=ds_upload_pic(ATTACH_PATH,'adv_pic3',$file_name);
  96. if($res['code']){
  97. $file_name=$res['data']['file_name'];
  98. $input[3]['pic'] = $file_name;
  99. $input[3]['url'] = input('post.adv_url3');
  100. }else{
  101. $this->error($res['msg']);
  102. }
  103. } elseif (input('post.old_adv_pic3') != '') {
  104. $input[3]['pic'] = input('post.old_adv_pic3');
  105. $input[3]['url'] = input('post.adv_url3');
  106. }
  107. if (!empty($_FILES['adv_pic4']['name'])) {
  108. $file_name = 'flea_4.jpg';
  109. $res=ds_upload_pic(ATTACH_PATH,'adv_pic4',$file_name);
  110. if($res['code']){
  111. $file_name=$res['data']['file_name'];
  112. $input[4]['pic'] = $file_name;
  113. $input[4]['url'] = input('post.adv_url4');
  114. }else{
  115. $this->error($res['msg']);
  116. }
  117. } elseif (input('post.old_adv_pic4') != '') {
  118. $input[4]['pic'] = input('post.old_adv_pic4');
  119. $input[4]['url'] = input('post.adv_url4');
  120. }
  121. if (!empty($_FILES['adv_pic5']['name'])) {
  122. $file_name = 'flea_5.jpg';
  123. $res=ds_upload_pic(ATTACH_PATH,'adv_pic5',$file_name);
  124. if($res['code']){
  125. $file_name=$res['data']['file_name'];
  126. $input[5]['pic'] = $file_name;
  127. $input[5]['url'] = input('post.adv_url5');
  128. }else{
  129. $this->error($res['msg']);
  130. }
  131. } elseif (input('post.old_adv_pic4') != '') {
  132. $input[5]['pic'] = input('post.old_adv_pic5');
  133. $input[5]['url'] = input('post.adv_url5');
  134. }
  135. $update_array = array();
  136. if (count($input) > 0) {
  137. $update_array['flea_loginpic'] = serialize($input);
  138. }
  139. $result = $config_model->editConfig($update_array);
  140. if ($result === true) {
  141. $this->log(lang('ds_edit') . lang('loginSettings'), 1);
  142. $this->success(lang('ds_common_save_succ'));
  143. } else {
  144. $this->log(lang('ds_edit') . lang('loginSettings'), 0);
  145. $this->error(lang('ds_common_save_fail'));
  146. }
  147. } else {
  148. $list_setting = rkcache('config', true);
  149. if ($list_setting['flea_loginpic'] != '') {
  150. $adv_list = unserialize($list_setting['flea_loginpic']);
  151. } else {
  152. $adv_list = '';
  153. }
  154. View::assign('adv_list', $adv_list);
  155. return View::fetch('adv');
  156. }
  157. }
  158. protected function getAdminItemList() {
  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. }