123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?php
- namespace app\admin\controller;
- use think\facade\View;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 控制器
- */
- class Fleaseo extends AdminControl
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/flea.lang.php');
- if (config('ds_config.flea_isuse') != '1') {
- $this->error(lang('flea_isuse_off_tips'), 'dashboard/welcome');
- }
- }
- function index()
- {
- /**
- * 实例化模型
- */
- $config_model = model('config');
- /**
- * 保存信息
- */
- if (request()->isPost()) {
- $update_array = array();
- $update_array['flea_site_title'] = trim(input('post.flea_site_title'));
- $update_array['flea_site_description'] = trim(input('post.flea_site_description'));
- $update_array['flea_site_keywords'] = trim(input('post.flea_site_keywords'));
- $result = $config_model->editConfig($update_array);
- if ($result === true) {
- $this->success(lang('ds_common_save_succ'));
- } else {
- $this->error(lang('ds_common_save_fail'));
- }
- } else {
- /**
- * 读取设置内容 $list_setting
- */
- $list_setting = rkcache('config', true);
- /**
- * 模板输出
- */
- View::assign('list_setting', $list_setting);
- $this->setAdminCurItem('index');
- return View::fetch('index');
- }
- }
- /**
- * 闲置首页广告
- */
- public function adv_manage()
- {
- $config_model = model('config');
- if (request()->isPost()) {
- $input = array();
- //上传图片
- $file_name = 'flea_1.jpg';
- if (!empty($_FILES['adv_pic1']['name'])) {
- $res = ds_upload_pic(ATTACH_PATH, 'adv_pic1', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $input[1]['pic'] = $file_name;
- $input[1]['url'] = input('post.adv_url1');
- } else {
- $this->error($res['msg']);
- }
- } elseif (input('post.old_adv_pic1') != '') {
- $input[1]['pic'] = input('post.old_adv_pic1');
- $input[1]['url'] = input('post.adv_url1');
- }
- if (!empty($_FILES['adv_pic2']['name'])) {
- $file_name = 'flea_2.jpg';
- $res = ds_upload_pic(ATTACH_PATH, 'adv_pic2', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $input[2]['pic'] = $file_name;
- $input[2]['url'] = input('post.adv_url2');
- } else {
- $this->error($res['msg']);
- }
- } elseif (input('post.old_adv_pic2') != '') {
- $input[2]['pic'] = input('post.old_adv_pic2');
- $input[2]['url'] = input('post.adv_url2');
- }
- if (!empty($_FILES['adv_pic3']['name'])) {
- $file_name = 'flea_3.jpg';
- $res = ds_upload_pic(ATTACH_PATH, 'adv_pic3', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $input[3]['pic'] = $file_name;
- $input[3]['url'] = input('post.adv_url3');
- } else {
- $this->error($res['msg']);
- }
- } elseif (input('post.old_adv_pic3') != '') {
- $input[3]['pic'] = input('post.old_adv_pic3');
- $input[3]['url'] = input('post.adv_url3');
- }
- if (!empty($_FILES['adv_pic4']['name'])) {
- $file_name = 'flea_4.jpg';
- $res = ds_upload_pic(ATTACH_PATH, 'adv_pic4', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $input[4]['pic'] = $file_name;
- $input[4]['url'] = input('post.adv_url4');
- } else {
- $this->error($res['msg']);
- }
- } elseif (input('post.old_adv_pic4') != '') {
- $input[4]['pic'] = input('post.old_adv_pic4');
- $input[4]['url'] = input('post.adv_url4');
- }
- if (!empty($_FILES['adv_pic5']['name'])) {
- $file_name = 'flea_5.jpg';
- $res = ds_upload_pic(ATTACH_PATH, 'adv_pic5', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $input[5]['pic'] = $file_name;
- $input[5]['url'] = input('post.adv_url5');
- } else {
- $this->error($res['msg']);
- }
- } elseif (input('post.old_adv_pic4') != '') {
- $input[5]['pic'] = input('post.old_adv_pic5');
- $input[5]['url'] = input('post.adv_url5');
- }
- $update_array = array();
- if (count($input) > 0) {
- $update_array['flea_loginpic'] = serialize($input);
- }
- $result = $config_model->editConfig($update_array);
- if ($result === true) {
- $this->log(lang('ds_edit') . lang('loginSettings'), 1);
- $this->success(lang('ds_common_save_succ'));
- } else {
- $this->log(lang('ds_edit') . lang('loginSettings'), 0);
- $this->error(lang('ds_common_save_fail'));
- }
- } else {
- $list_setting = rkcache('config', true);
- if ($list_setting['flea_loginpic'] != '') {
- $adv_list = unserialize($list_setting['flea_loginpic']);
- } else {
- $adv_list = '';
- }
- View::assign('adv_list', $adv_list);
- return View::fetch('adv');
- }
- }
- protected function getAdminItemList()
- {
- $menu_array = array(
- array(
- 'name' => 'index', 'text' => lang('flea_seo'), 'url' => (string) url('Fleaseo/index')
- ),
- );
- return $menu_array;
- }
- }
|