Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\controller;
  14. use app\admin\controller\Base;
  15. use think\Controller;
  16. use think\Db;
  17. use think\Page;
  18. use app\admin\logic\UpgradeLogic;
  19. use app\admin\logic\EyouCmsLogic;
  20. class Index extends Base
  21. {
  22. public $eyouCmsLogic;
  23. public function _initialize()
  24. {
  25. parent::_initialize();
  26. $this->eyouCmsLogic = new EyouCmsLogic;
  27. //初始化admin_menu表(将原来左边栏目设置为跟原来一样)
  28. $ajaxLogic = new \app\admin\logic\AjaxLogic;
  29. $ajaxLogic->initialize_admin_menu();
  30. }
  31. public function index()
  32. {
  33. // $dbtables = Db::query('SHOW TABLE STATUS');
  34. // $list = array();
  35. // foreach ($dbtables as $k => $v) {
  36. // if (preg_match('/^'.PREFIX.'/i', $v['Name'])) {
  37. // $list[$k] = $v;
  38. // }
  39. // }
  40. // $str = '';
  41. // foreach ($list as $_k => $_v) {
  42. // $table = $_v['Name'];
  43. // $str .= $table.'|';
  44. // $str2 = "|";
  45. // $fields = Db::table($table)->getTableFields();
  46. // foreach ($fields as $key => $value) {
  47. // if ($key == 0) {
  48. // $str .= "{$value}";
  49. // } else {
  50. // $str .= ",{$value}";
  51. // $str2 .= ";";
  52. // }
  53. // }
  54. // $str = $str . $str2 . "|". PHP_EOL . PHP_EOL;
  55. // }
  56. // echo($str);
  57. // exit;
  58. $language_db = Db::name('language');
  59. /*多语言列表*/
  60. $web_language_switch = tpCache('global.web_language_switch');
  61. $languages = [];
  62. $languages = $language_db->field('a.mark, a.title')
  63. ->alias('a')
  64. ->where('a.status',1)
  65. ->order('sort_order asc,id asc')
  66. ->getAllWithIndex('mark');
  67. $this->assign('languages', $languages);
  68. $this->assign('web_language_switch', $web_language_switch);
  69. /*--end*/
  70. $web_adminlogo = tpCache('web.web_adminlogo', [], $this->main_lang);
  71. $this->assign('web_adminlogo', handle_subdir_pic($web_adminlogo));
  72. /*代理贴牌功能限制-s*/
  73. $function_switch = $upgrade = true;
  74. if (function_exists('checkAuthRule')) {
  75. // 功能地图
  76. $function_switch = checkAuthRule(2004008);
  77. // 系统更新
  78. $upgrade = checkAuthRule('upgrade');
  79. }
  80. $this->assign('function_switch', $function_switch);
  81. $this->assign('upgrade', $upgrade);
  82. /*代理贴牌功能限制-e*/
  83. /*小程序开关*/
  84. $diyminipro_list = [];
  85. if ($this->admin_lang == $this->main_lang) {
  86. $diyminipro_list = Db::name('weapp')->field('id,code,name,config')->where(['code'=>['IN',['Diyminipro','DiyminiproMall','BdDiyminipro','TtDiyminipro']],'status'=>1])->order('code desc')->select();
  87. foreach ($diyminipro_list as $key => $val) {
  88. $val['config'] = (array)json_decode($val['config']);
  89. $val['litpic'] = empty($val['config']['litpic']) ? '' : handle_subdir_pic($val['config']['litpic']);
  90. if ('Diyminipro' == $val['code']) {
  91. $val['name'] = '微信企业小程序';
  92. } else if ('DiyminiproMall' == $val['code']) {
  93. $val['name'] = '微信商城小程序';
  94. } else if ('BdDiyminipro' == $val['code']) {
  95. $val['name'] = '百度企业小程序';
  96. } else if ('TtDiyminipro' == $val['code']) {
  97. $val['name'] = '抖音企业小程序';
  98. }
  99. $diyminipro_list[$key] = $val;
  100. }
  101. }
  102. $this->assign('diyminipro_list', $diyminipro_list);
  103. /*end*/
  104. //获取前台入口链接
  105. $this->assign('home_url', $this->eyouCmsLogic->shouye($this->globalConfig));
  106. /*--end*/
  107. $this->assign('admin_info', getAdminInfo(session('admin_id')));
  108. //左侧菜单列表(old)
  109. // $this->assign('menu',getMenuList());
  110. //获取所有权限
  111. $all_menu_tree = getAllMenu();
  112. $all_menu_list = tree_to_list($all_menu_tree,'child','id');
  113. $this->assign('all_menu_list',$all_menu_list);
  114. //获取选中的权限
  115. $ajaxLogic = new \app\admin\logic\AjaxLogic;
  116. $ajaxLogic->admin_menu_clear();
  117. // $ajaxLogic->eyou_v165_del_func();
  118. $menu_list = Db::name("admin_menu")->where(['status'=>1,'is_menu'=>1])->order("sort_order asc,update_time asc,id asc")->select();
  119. foreach ($menu_list as $key => $val) {
  120. if (stristr($val['param'], '|sm|Diyminipro|')) {
  121. $val['title'] = '微信企业小程序';
  122. } else if (stristr($val['param'], '|sm|DiyminiproMall|')) {
  123. $val['title'] = '微信商城小程序';
  124. } else if (stristr($val['param'], '|sm|BdDiyminipro|')) {
  125. $val['title'] = '百度企业小程序';
  126. } else if (stristr($val['param'], '|sm|TtDiyminipro|')) {
  127. $val['title'] = '抖音企业小程序';
  128. }
  129. $menu_list[$key] = $val;
  130. // 其他语言不显示留言管理
  131. /*if ($this->admin_lang != $this->main_lang) {
  132. foreach ([2004018] as $_k => $_v) {
  133. if ($_v == $val['menu_id']) {
  134. unset($menu_list[$key]);
  135. }
  136. }
  137. }*/
  138. }
  139. $menu_list = getAdminMenuList($menu_list);
  140. $this->assign('menu_list',$menu_list);
  141. //获取因为没有开启相关模块没有权限的节点
  142. $not_role_menu_id_arr = get_not_role_menu_id();
  143. $this->assign('not_role_menu_id_arr',$not_role_menu_id_arr);
  144. // 是否开启安全补丁
  145. $security_patch = tpSetting('upgrade.upgrade_security_patch');
  146. if (empty($security_patch)) $security_patch = 0;
  147. $this->assign('security_patch', $security_patch);
  148. // 统计未读的站内信数量
  149. action('admin/Notify/count_unread_notify');
  150. return $this->fetch();
  151. }
  152. public function welcome()
  153. {
  154. $assign_data = [];
  155. // 更新数据缓存表信息
  156. $this->update_sql_cache_table();
  157. /*小程序组件更新*/
  158. $assign_data['is_update_component_access'] = 1;
  159. if (!is_dir('./weapp/Diyminipro/') || $this->admin_lang != $this->main_lang) {
  160. $assign_data['is_update_component_access'] = 0;
  161. }
  162. /*end*/
  163. // 纠正上传附件的大小,始终以空间大小为准
  164. $file_size = $this->globalConfig['file_size'];
  165. $maxFileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 0;
  166. $maxFileupload = intval($maxFileupload);
  167. if (empty($file_size) || $file_size > $maxFileupload) {
  168. /*多语言*/
  169. if (is_language()) {
  170. $langRow = Db::name('language')->cache(true, EYOUCMS_CACHE_TIME, 'language')
  171. ->order('id asc')
  172. ->select();
  173. foreach ($langRow as $key => $val) {
  174. tpCache('basic', ['file_size'=>$maxFileupload], $val['mark']);
  175. }
  176. } else { // 单语言
  177. tpCache('basic', ['file_size'=>$maxFileupload]);
  178. }
  179. /*--end*/
  180. }
  181. /*检查密码复杂度*/
  182. $admin_login_pwdlevel = -1;
  183. $system_explanation_welcome_2 = !empty($this->globalConfig['system_explanation_welcome_2']) ? $this->globalConfig['system_explanation_welcome_2'] : 0;
  184. if (empty($system_explanation_welcome_2)) {
  185. $admin_login_pwdlevel = session('admin_login_pwdlevel');
  186. if (!session('?admin_login_pwdlevel') || 3 < intval($admin_login_pwdlevel)) {
  187. $system_explanation_welcome_2 = 1;
  188. }
  189. }
  190. $assign_data['admin_login_pwdlevel'] = $admin_login_pwdlevel;
  191. $assign_data['system_explanation_welcome_2'] = $system_explanation_welcome_2;
  192. /*end*/
  193. /*代理贴牌功能限制-s*/
  194. $assign_data['upgrade'] = true;
  195. if (function_exists('checkAuthRule')) {
  196. //系统更新
  197. $assign_data['upgrade'] = checkAuthRule('upgrade');
  198. }
  199. /*代理贴牌功能限制-e*/
  200. // 是否开启安全补丁
  201. $assign_data['security_patch'] = (int)tpSetting('upgrade.upgrade_security_patch');
  202. // 升级弹窗
  203. if (2 == $this->globalConfig['web_show_popup_upgrade'] && $this->php_servicemeal <= 0) {
  204. $this->globalConfig['web_show_popup_upgrade'] = -1;
  205. }
  206. $assign_data['web_show_popup_upgrade'] = $this->globalConfig['web_show_popup_upgrade'];
  207. // 升级系统时,同时处理sql语句
  208. $this->synExecuteSql();
  209. $ajaxLogic = new \app\admin\logic\AjaxLogic;
  210. // $ajaxLogic->update_template('users'); // 升级前台会员中心的模板文件
  211. $ajaxLogic->system_langnum_file(); // 记录当前是多语言还是单语言到文件里
  212. $ajaxLogic->system_citysite_file(); // 记录当前是否多站点到文件里
  213. $ajaxLogic->admin_logic_1609900642(); // 内置方法
  214. // 纠正SQL缓存表结果字段类型(v1.6.1节点去掉--陈风任)
  215. $ajaxLogic->admin_logic_1623036205();
  216. // 评价主表评分由原先的(好评、中评、差评)转至实际星评数(1、2、3、4、5)(v1.6.1节点去掉--陈风任)
  217. $ajaxLogic->admin_logic_1651114275();
  218. //融合多商家模板升级数据库表、字段变动
  219. $ajaxLogic->admin_logic_1658220528();
  220. // 添加商城订单主表字段(消费获得积分数(obtain_scores);订单是否已赠送积分(is_obtain_scores))
  221. $ajaxLogic->admin_logic_1677653220();
  222. // 更新会员积分数据表,积分类型字段 type
  223. $ajaxLogic->admin_logic_1680749290();
  224. // 纠正文章模型发布的文章数据中【付费预览】-【自动截取】的大小,由KB改为字节,article_pay表的size字段(1024字节=1KB)
  225. $ajaxLogic->admin_logic_1685094852();
  226. // 运费模板数据同步--陈风任
  227. $ajaxLogic->admin_logic_1687687709();
  228. $viewfile = 'welcome';
  229. $web_theme_welcome_tplname = empty($this->globalConfig['web_theme_welcome_tplname']) ? '' : $this->globalConfig['web_theme_welcome_tplname'];
  230. if (!empty($web_theme_welcome_tplname) && file_exists("application/admin/template/theme/{$web_theme_welcome_tplname}")) {
  231. $welcome_tplname = str_ireplace('.htm', '', $web_theme_welcome_tplname);
  232. $viewfile = "theme/{$welcome_tplname}";
  233. }
  234. if (preg_match('/^(.*)\/welcome_shop$/i', $viewfile)) {
  235. // 商城版欢迎页主题
  236. $this->eyouCmsLogic->welcome_shop($assign_data, $this->globalConfig, $this->usersConfig);
  237. } else if (preg_match('/^(.*)\/welcome_taskflow$/i', $viewfile)) {
  238. // 任务流版欢迎页主题
  239. $this->eyouCmsLogic->welcome_taskflow($assign_data, $this->globalConfig, $this->usersConfig);
  240. } else {
  241. // 默认欢迎页主题
  242. $this->eyouCmsLogic->welcome_default($assign_data, $this->globalConfig, $this->usersConfig);
  243. }
  244. $this->assign($assign_data);
  245. return $this->fetch($viewfile);
  246. }
  247. /**
  248. * 实时概况快捷导航管理
  249. */
  250. public function ajax_surveyquickmenu()
  251. {
  252. if (IS_AJAX_POST) {
  253. $checkedids = input('post.checkedids/a', []);
  254. if (count($checkedids) != 4){
  255. $this->error('保存数量必须为4个');
  256. }
  257. $ids = input('post.ids/a', []);
  258. $saveData = [];
  259. foreach ($ids as $key => $val) {
  260. if (in_array($val, $checkedids)) {
  261. $checked = 1;
  262. } else {
  263. $checked = 0;
  264. }
  265. $saveData[$key] = [
  266. 'id' => $val,
  267. 'checked' => $checked,
  268. 'sort_order' => intval($key) + 1,
  269. 'update_time' => getTime(),
  270. ];
  271. }
  272. if (!empty($saveData)) {
  273. $r = model('Quickentry')->saveAll($saveData);
  274. if ($r !== false) {
  275. $this->success('操作成功', url('Index/welcome'));
  276. }
  277. }
  278. $this->error('操作失败');
  279. }
  280. $menuList = Db::name('quickentry')->where([
  281. 'type' => 21,
  282. 'groups' => 1,
  283. 'status' => 1,
  284. ])->order('sort_order asc, id asc')->select();
  285. $this->assign('menuList',$menuList);
  286. return $this->fetch();
  287. }
  288. /**
  289. * 实时概况快捷导航管理 - 任务流版
  290. */
  291. public function ajax_surveyquickmenu_taskflow()
  292. {
  293. if (IS_AJAX_POST) {
  294. $checkedids = input('post.checkedids/a', []);
  295. $ids = input('post.ids/a', []);
  296. $saveData = [];
  297. foreach ($ids as $key => $val) {
  298. if (in_array($val, $checkedids)) {
  299. $checked = 1;
  300. } else {
  301. $checked = 0;
  302. }
  303. $saveData[$key] = [
  304. 'id' => $val,
  305. 'checked' => $checked,
  306. 'sort_order' => intval($key) + 1,
  307. 'update_time' => getTime(),
  308. ];
  309. }
  310. if (!empty($saveData)) {
  311. $r = model('Quickentry')->saveAll($saveData);
  312. if ($r !== false) {
  313. $this->success('操作成功', url('Index/welcome'));
  314. }
  315. }
  316. $this->error('操作失败');
  317. }
  318. $menuList = Db::name('quickentry')->where([
  319. 'type' => 31,
  320. 'groups' => 1,
  321. 'status' => 1,
  322. ])->order('sort_order asc, id asc')->select();
  323. $this->assign('menuList',$menuList);
  324. return $this->fetch();
  325. }
  326. /**
  327. * 升级系统时,同时处理sql语句
  328. * @return [type] [description]
  329. */
  330. private function synExecuteSql()
  331. {
  332. // 新增订单提醒的邮箱模板
  333. if (!tpCache('global.system_smtp_tpl_5')){
  334. /*多语言*/
  335. if (is_language()) {
  336. $langRow = Db::name('language')->cache(true, EYOUCMS_CACHE_TIME, 'language')
  337. ->order('id asc')
  338. ->select();
  339. foreach ($langRow as $key => $val) {
  340. $r = Db::name('smtp_tpl')->insert([
  341. 'tpl_name' => '订单提醒',
  342. 'tpl_title' => '您有新的订单消息,请查收!',
  343. 'tpl_content' => '${content}',
  344. 'send_scene' => 5,
  345. 'is_open' => 1,
  346. 'lang' => $val['mark'],
  347. 'add_time' => getTime(),
  348. ]);
  349. false !== $r && tpCache('system', ['system_smtp_tpl_5' => 1], $val['mark']);
  350. }
  351. } else { // 单语言
  352. $r = Db::name('smtp_tpl')->insert([
  353. 'tpl_name' => '订单提醒',
  354. 'tpl_title' => '您有新的订单消息,请查收!',
  355. 'tpl_content' => '${content}',
  356. 'send_scene' => 5,
  357. 'is_open' => 1,
  358. 'lang' => $this->admin_lang,
  359. 'add_time' => getTime(),
  360. ]);
  361. false !== $r && tpCache('system', ['system_smtp_tpl_5' => 1]);
  362. }
  363. /*--end*/
  364. }
  365. }
  366. /**
  367. * 内容统计管理
  368. */
  369. public function ajax_content_total()
  370. {
  371. if (IS_AJAX_POST) {
  372. $checkedids = input('post.checkedids/a', []);
  373. $ids = input('post.ids/a', []);
  374. $saveData = [];
  375. foreach ($ids as $key => $val) {
  376. if (in_array($val, $checkedids)) {
  377. $checked = 1;
  378. } else {
  379. $checked = 0;
  380. }
  381. $saveData[$key] = [
  382. 'id' => $val,
  383. 'checked' => $checked,
  384. 'sort_order' => intval($key) + 1,
  385. 'update_time' => getTime(),
  386. ];
  387. }
  388. if (!empty($saveData)) {
  389. $r = model('Quickentry')->saveAll($saveData);
  390. if ($r) {
  391. $this->success('操作成功', url('Index/welcome'));
  392. }
  393. }
  394. $this->error('操作失败');
  395. }
  396. /*同步v1.3.9以及早期版本的自定义模型*/
  397. $this->syn_custom_quickmenu(2);
  398. /*end*/
  399. $totalList = Db::name('quickentry')->where([
  400. 'type' => ['IN', [2]],
  401. 'status' => 1,
  402. ])->order('sort_order asc, id asc')->select();
  403. $this->assign('totalList',$totalList);
  404. return $this->fetch();
  405. }
  406. /**
  407. * 快捷导航管理
  408. */
  409. public function ajax_quickmenu()
  410. {
  411. if (IS_AJAX_POST) {
  412. $checkedids = input('post.checkedids/a', []);
  413. $ids = input('post.ids/a', []);
  414. $saveData = [];
  415. foreach ($ids as $key => $val) {
  416. if (in_array($val, $checkedids)) {
  417. $checked = 1;
  418. } else {
  419. $checked = 0;
  420. }
  421. $saveData[$key] = [
  422. 'id' => $val,
  423. 'checked' => $checked,
  424. 'sort_order' => intval($key) + 1,
  425. 'update_time' => getTime(),
  426. ];
  427. }
  428. if (!empty($saveData)) {
  429. $r = model('Quickentry')->saveAll($saveData);
  430. if ($r) {
  431. $this->success('操作成功', url('Index/welcome'));
  432. }
  433. }
  434. $this->error('操作失败');
  435. }
  436. $welcome_type = input('param.welcome_type/s');
  437. if ($welcome_type == 'shop') {
  438. $type = [11];
  439. } else {
  440. /*同步v1.3.9以及早期版本的自定义模型*/
  441. $this->syn_custom_quickmenu(1);
  442. /*end*/
  443. $type = [1];
  444. }
  445. $menuList = Db::name('quickentry')->where([
  446. 'type' => ['IN', $type],
  447. 'groups' => 0,
  448. 'status' => 1,
  449. ])->order('sort_order asc, id asc')->select();
  450. foreach ($menuList as $key => $val) {
  451. if ($this->php_servicemeal <= 2 && $val['controller'] == 'Shop' && $val['action'] == 'index') {
  452. unset($menuList[$key]);
  453. continue;
  454. }
  455. if (!empty($this->globalConfig['web_recycle_switch']) && $val['controller'] == 'RecycleBin' && $val['action'] == 'archives_index'){
  456. unset($menuList[$key]);
  457. continue;
  458. }
  459. if (is_language() && $this->main_lang != $this->admin_lang) {
  460. $controllerArr = ['Weapp','Filemanager','Sitemap','Admin','Member','Seo','Channeltype','Tools'];
  461. if (empty($globalConfig['language_split'])) {
  462. $controllerArr[] = 'RecycleBin';
  463. }
  464. $ctlActArr = ['System@water','System@thumb','System@api_conf'];
  465. if (in_array($val['controller'], $controllerArr) || in_array($val['controller'].'@'.$val['action'], $ctlActArr)) {
  466. unset($menuList[$key]);
  467. continue;
  468. }
  469. }
  470. }
  471. $this->assign('menuList',$menuList);
  472. return $this->fetch();
  473. }
  474. /**
  475. *
  476. * 插件快捷导航管理
  477. */
  478. public function ajax_weapp_quickmenu()
  479. {
  480. if (IS_AJAX_POST) {
  481. $checkedids = input('post.checkedids/a', []);
  482. $ids = input('post.ids/a', []);
  483. $saveData = [];
  484. foreach ($ids as $key => $val) {
  485. if (in_array($val, $checkedids)) {
  486. $checked = 1;
  487. } else {
  488. $checked = 0;
  489. }
  490. $saveData[$key] = [
  491. 'id' => $val,
  492. 'checked' => $checked,
  493. 'quick_sort' => intval($key) + 1,
  494. 'update_time' => getTime(),
  495. ];
  496. }
  497. if (!empty($saveData)) {
  498. $r = model('Weapp')->saveAll($saveData);
  499. if ($r !== false) {
  500. $this->success('操作成功', url('Index/welcome'));
  501. }
  502. }
  503. $this->error('操作失败');
  504. }
  505. $where = ['status'=>1];
  506. $menuList = Db::name('weapp')->where($where)->order('quick_sort asc, id asc')->select();
  507. $this->assign('menuList',$menuList);
  508. return $this->fetch();
  509. }
  510. /**
  511. * 同步自定义模型的快捷导航
  512. */
  513. private function syn_custom_quickmenu($type = 1)
  514. {
  515. $row = Db::name('quickentry')->where([
  516. 'controller' => 'Custom',
  517. 'type' => $type,
  518. ])->count();
  519. if (empty($row)) {
  520. $customRow = Db::name('channeltype')->field('id,ntitle')
  521. ->where(['ifsystem'=>0])->select();
  522. $saveData = [];
  523. foreach ($customRow as $key => $val) {
  524. $saveData[] = [
  525. 'title' => $val['ntitle'],
  526. 'laytext' => $val['ntitle'].'列表',
  527. 'type' => $type,
  528. 'controller' => 'Custom',
  529. 'action' => 'index',
  530. 'vars' => 'channel='.$val['id'],
  531. 'groups' => 1,
  532. 'sort_order' => 100,
  533. 'add_time' => getTime(),
  534. 'update_time' => getTime(),
  535. ];
  536. }
  537. model('Quickentry')->saveAll($saveData);
  538. }
  539. }
  540. /**
  541. * 录入商业授权
  542. */
  543. public function authortoken()
  544. {
  545. $is_force = input('param.is_force/d', 0);
  546. $redata = verify_authortoken($is_force);
  547. if (!empty($redata['code'])) {
  548. $source = realpath('public/static/admin/images/logo_ey.png');
  549. $destination = realpath('public/static/admin/images/logo.png');
  550. @copy($source, $destination);
  551. adminLog('验证商业授权');
  552. $this->success('授权校验成功', $this->request->baseFile(), '', 1, [], '_parent');
  553. }
  554. $msg = empty($redata['msg']) ? '域名('.$this->request->host(true).')未授权' : $redata['msg'];
  555. $this->error($msg, $this->request->baseFile(), '', 5, [], '_parent');
  556. }
  557. /**
  558. * 更换后台logo
  559. */
  560. public function edit_adminlogo()
  561. {
  562. $filename = input('param.filename/s', '');
  563. if (!empty($filename)) {
  564. $source = realpath(preg_replace('#^'.ROOT_DIR.'/#i', '', $filename)); // 支持子目录
  565. $web_is_authortoken = tpCache('global.web_is_authortoken');
  566. if (empty($web_is_authortoken)) {
  567. $destination = realpath('public/static/admin/images/logo.png');
  568. } else {
  569. $destination = realpath('public/static/admin/images/logo_ey.png');
  570. }
  571. if (@copy($source, $destination)) {
  572. $this->success('操作成功');
  573. }
  574. }
  575. $this->error('操作失败');
  576. }
  577. /**
  578. * 待处理事项
  579. */
  580. public function pending_matters()
  581. {
  582. $html = '<div style="text-align: center; margin: 20px 0px; color:red;">惹妹子生气了,没啥好处理!</div>';
  583. echo $html;
  584. }
  585. /**
  586. * ajax 修改指定表数据字段 一般修改状态 比如 是否推荐 是否开启 等 图标切换的
  587. * table,id_name,id_value,field,value
  588. */
  589. public function changeTableVal()
  590. {
  591. if (IS_AJAX_POST) {
  592. $url = null;
  593. $data = [
  594. 'refresh' => 0,
  595. ];
  596. $param = input('param.');
  597. $table = input('param.table/s'); // 表名
  598. $id_name = input('param.id_name/s'); // 表主键id名
  599. $id_value = input('param.id_value/d'); // 表主键id值
  600. $field = input('param.field/s'); // 修改哪个字段
  601. $value = input('param.value/s', '', null); // 修改字段值
  602. $value = eyPreventShell($value) ? $value : strip_sql($value);
  603. $_POST[$id_name] = $id_value;
  604. if ('archives' == $table && 'arcrank' == $field) {
  605. $ScreeningTable = $table;
  606. $ScreeningField = $field;
  607. $ScreeningValue = $value;
  608. $ScreeningAid = $id_value;
  609. }
  610. /*插件专用*/
  611. if ('weapp' == $table) {
  612. if (1 == intval($value)) { // 启用
  613. action('Weapp/enable', ['id' => $id_value]);
  614. } else if (-1 == intval($value)) { // 禁用
  615. action('Weapp/disable', ['id' => $id_value]);
  616. }
  617. }
  618. /*end*/
  619. /*处理数据的安全性*/
  620. if (empty($id_value)) {
  621. $this->error('查询条件id不合法!');
  622. }
  623. foreach ($param as $key => $val) {
  624. if ('value' == $key) {
  625. if (stristr($val, '&lt;') && stristr($val, '&gt;')) {
  626. $val = htmlspecialchars_decode($val);
  627. }
  628. if (preg_match('/<script([^\>]*)>/i', $val)) {
  629. $this->error('数据含有非法入侵字符!');
  630. }
  631. } else {
  632. if (!preg_match('/^([A-Za-z0-9_-]*)$/i', $val)) {
  633. $this->error('数据含有非法入侵字符!');
  634. }
  635. }
  636. }
  637. /*end*/
  638. switch ($table) {
  639. // 会员等级表
  640. case 'users_level':
  641. {
  642. $return = model('UsersLevel')->isRequired($id_name,$id_value,$field,$value);
  643. if (is_array($return)) {
  644. $this->error($return['msg']);
  645. }
  646. }
  647. break;
  648. // 会员属性表
  649. case 'users_parameter':
  650. {
  651. $return = model('UsersParameter')->isRequired($id_name,$id_value,$field,$value);
  652. if (is_array($return)) {
  653. $time = !empty($return['time']) ? $return['time'] : 3;
  654. $this->error($return['msg'], null, [], $time);
  655. }
  656. }
  657. break;
  658. // 会员中心菜单表
  659. case 'users_menu':
  660. {
  661. if ('is_userpage' == $field) {
  662. Db::name('users_menu')->where('id','gt',0)->update([
  663. 'is_userpage' => 0,
  664. 'update_time' => getTime(),
  665. ]);
  666. }
  667. $data['refresh'] = 1;
  668. }
  669. break;
  670. // 会员投稿功能
  671. case 'archives':
  672. {
  673. if ('arcrank' == $field) {
  674. if (0 == $value) {
  675. $value = -1;
  676. }else{
  677. $value = 0;
  678. }
  679. }
  680. }
  681. break;
  682. // 会员产品类型表
  683. case 'users_type_manage':
  684. {
  685. if (in_array($field, ['type_name','price'])) {
  686. if (empty($value)) {
  687. $this->error('不可为空');
  688. }
  689. }
  690. }
  691. break;
  692. // 留言属性表
  693. case 'guestbook_attribute':
  694. {
  695. $return = model('GuestbookAttribute')->isValidate($id_name,$id_value,$field,$value);
  696. if (is_array($return)) {
  697. $time = !empty($return['time']) ? $return['time'] : 3;
  698. $this->error($return['msg'], null, [], $time);
  699. }
  700. }
  701. break;
  702. // 小程序页面表
  703. case 'diyminipro_page':
  704. {
  705. $re = Db::name('diyminipro_page')->where([
  706. 'is_home' => 1,
  707. $id_name => ['EQ', $id_value],
  708. ])->count();
  709. if (!empty($re)) {
  710. $this->error('禁止取消默认项', null, [], 3);
  711. }
  712. }
  713. break;
  714. // 文档属性表
  715. case 'archives_flag':
  716. {
  717. if ('sort_order' == $field) {
  718. $data['refresh'] = 1;
  719. $data['time'] = 500;
  720. }
  721. }
  722. break;
  723. // 会员中心移动端底部菜单表
  724. case 'users_bottom_menu':
  725. {
  726. if ('sort_order' == $field) {
  727. $data['refresh'] = 1;
  728. $data['time'] = 500;
  729. }
  730. }
  731. break;
  732. // 友情链接分组表
  733. case 'links_group':
  734. {
  735. if ('sort_order' == $field) {
  736. $data['refresh'] = 1;
  737. $data['time'] = 500;
  738. }
  739. }
  740. break;
  741. // 栏目表
  742. case 'arctype':
  743. {
  744. if ('is_hidden' == $field) {
  745. $value = (1 == $value) ? 0 : 1;
  746. }
  747. }
  748. break;
  749. // 多语言表
  750. case 'language':
  751. {
  752. $return = model('Language')->isValidateStatus($field,$value);
  753. if (is_array($return)) {
  754. $time = !empty($return['time']) ? $return['time'] : 3;
  755. $this->error($return['msg'], null, [], $time);
  756. }
  757. }
  758. break;
  759. // 积分商品列表
  760. case 'memgift':
  761. {
  762. if ('sort_order' == $field) {
  763. $data['refresh'] = 1;
  764. $data['time'] = 500;
  765. }
  766. }
  767. break;
  768. default:
  769. # code...
  770. break;
  771. }
  772. $savedata = [
  773. $field => $value,
  774. 'update_time' => getTime(),
  775. ];
  776. switch ($table) {
  777. case 'diyminipro_page':
  778. {
  779. if ('is_home' == $field) {
  780. if ($value == 1) {
  781. $savedata['page_type'] = 1;
  782. } else {
  783. $savedata['page_type'] = -1;
  784. }
  785. }
  786. break;
  787. }
  788. }
  789. // 根据条件保存修改的数据
  790. $r = Db::name($table)->where([$id_name => $id_value])->cache(true,null,$table)->save($savedata);
  791. if ($r !== false) {
  792. if (!empty($ScreeningTable) && !empty($ScreeningField) && 'archives' == $ScreeningTable && 'arcrank' == $ScreeningField) {
  793. $Result = model('SqlCacheTable')->ScreeningArchives($ScreeningAid, $ScreeningValue);
  794. if (!empty($Result)) {
  795. $data['refresh'] = 1;
  796. $data['time'] = 500;
  797. }
  798. }elseif ('users' == $table && 'is_activation' == $field){
  799. $data['refresh'] = 1;
  800. $data['time'] = 500;
  801. }
  802. // 以下代码可以考虑去掉,与行为里的清除缓存重复 AppEndBehavior.php / clearHtmlCache
  803. switch ($table) {
  804. case 'auth_modular':
  805. extra_cache('admin_auth_modular_list_logic', null);
  806. extra_cache('admin_all_menu', null);
  807. break;
  808. case 'diyminipro_page':
  809. {
  810. if ('is_home' == $field) {
  811. $data['refresh'] = 1;
  812. Db::name('diyminipro_page')->where([
  813. $id_name => ['NEQ', $id_value],
  814. 'lang' => $this->admin_lang,
  815. ])->update([
  816. 'is_home' => 0,
  817. 'page_type' => -1,
  818. 'update_time' => getTime()
  819. ]);
  820. }
  821. break;
  822. }
  823. // 会员投稿功能
  824. case 'archives':
  825. {
  826. if ('arcrank' == $field) {
  827. Db::name('taglist')->where('aid', $id_value)->update([
  828. 'arcrank'=>$value,
  829. 'update_time' => getTime(),
  830. ]);
  831. \think\Cache::clear('taglist');
  832. adminLog('文档'.($value >=0 ? '通过审核' : '取消审核').':'.$id_value);
  833. if (isset($value) && -1 === intval($value)) {
  834. // 系统快捷下架时,积分商品的被动处理
  835. model('ShopPublicHandle')->pointsGoodsPassiveHandle([$id_value]);
  836. }
  837. // 清空sql_cache_table数据缓存表 并 添加查询执行语句到mysql缓存表
  838. Db::name('sql_cache_table')->execute('TRUNCATE TABLE '.config('database.prefix').'sql_cache_table');
  839. model('SqlCacheTable')->InsertSqlCacheTable(true);
  840. }
  841. break;
  842. }
  843. // 问答插件
  844. case 'weapp_ask_users_level':
  845. {
  846. if ('ask_is_release' == $field) {
  847. Db::name('users_level')->where('level_id', $id_value)->update([
  848. 'ask_is_release'=>$value,
  849. 'update_time' => getTime(),
  850. ]);
  851. } else if ('ask_is_review' == $field) {
  852. Db::name('users_level')->where('level_id', $id_value)->update([
  853. 'ask_is_review'=>$value,
  854. 'update_time' => getTime(),
  855. ]);
  856. }
  857. \think\Cache::clear('users_level');
  858. break;
  859. }
  860. // 会员字段
  861. case 'users_list':
  862. case 'users_parameter':
  863. {
  864. \think\Cache::clear('users_parameter');
  865. \think\Cache::clear('users_list');
  866. break;
  867. }
  868. // 广告
  869. case 'ad':
  870. case 'ad_position':
  871. {
  872. \think\Cache::clear('ad_position');
  873. \think\Cache::clear('ad');
  874. break;
  875. }
  876. default:
  877. // 清除logic逻辑定义的缓存
  878. extra_cache('admin_'.$table.'_list_logic', null);
  879. break;
  880. }
  881. \think\Cache::clear($table);
  882. delFile(HTML_ROOT.'index');
  883. $this->success('更新成功', $url, $data);
  884. }
  885. $this->error('更新失败', null, []);
  886. }
  887. }
  888. /**
  889. * 功能地图
  890. */
  891. public function switch_map()
  892. {
  893. /*权限控制 by 小虎哥*/
  894. $auth_role_info = session('admin_info.auth_role_info');
  895. if(0 < intval(session('admin_info.role_id')) && ! empty($auth_role_info) && intval($auth_role_info['switch_map']) <= 0){
  896. $this->error('您没有操作权限,请联系超级管理员分配权限');
  897. }
  898. /*--end*/
  899. $msg = '操作成功';
  900. $seo_pseudo = $this->globalConfig['seo_pseudo'];
  901. $web_users_tpl_theme = $this->globalConfig['web_users_tpl_theme'];
  902. empty($web_users_tpl_theme) && $web_users_tpl_theme = 'users';
  903. if (IS_POST) {
  904. $inc_type = input('post.inc_type/s');
  905. $name = input('post.name/s');
  906. $value = input('post.value/s');
  907. $is_force = input('post.is_force/d'); // 是否强制开启,跳过检测提示,目前用于(多语言、多站点)
  908. $data = [];
  909. switch ($inc_type) {
  910. case 'pay':
  911. case 'shop':
  912. {
  913. getUsersConfigData($inc_type, [$name => $value]);
  914. // 开启商城
  915. if (1 == $value) {
  916. /*多语言 - 同时开启会员中心*/
  917. if (is_language()) {
  918. $langRow = \think\Db::name('language')->order('id asc')
  919. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  920. ->select();
  921. foreach ($langRow as $key => $val) {
  922. tpCache('web', ['web_users_switch' => 1], $val['mark']);
  923. }
  924. } else { // 单语言
  925. tpCache('web', ['web_users_switch' => 1]);
  926. }
  927. /*--end*/
  928. // 同时显示发布文档时的价格文本框
  929. Db::name('channelfield')->where([
  930. 'name' => 'users_price',
  931. 'channel_id' => 2,
  932. ])->update([
  933. 'ifeditable' => 1,
  934. 'update_time' => getTime(),
  935. ]);
  936. }
  937. if (in_array($name, ['shop_open'])) {
  938. // $data['reload'] = 1;
  939. /*检测是否存在订单中心模板*/
  940. $shop_tpl_list = glob("./template/".TPL_THEME."pc/{$web_users_tpl_theme}/shop_*");
  941. if (!empty($value) && empty($shop_tpl_list)) {
  942. $is_syn = 1;
  943. } else {
  944. $is_syn = 0;
  945. }
  946. $data['is_syn'] = $is_syn;
  947. /*--end*/
  948. // 同步会员中心的左侧菜单
  949. if ('shop_open' == $name) {
  950. Db::name('users_menu')->where([
  951. 'mca' => 'user/Shop/shop_centre',
  952. ])->update([
  953. 'status' => (1 == $value) ? 1 : 0,
  954. 'update_time' => getTime(),
  955. ]);
  956. }
  957. } else if ('pay_open' == $name) {
  958. // 同步会员中心的左侧菜单
  959. Db::name('users_menu')->where([
  960. 'mca' => 'user/Pay/pay_consumer_details',
  961. ])->update([
  962. 'status' => (1 == $value) ? 1 : 0,
  963. 'update_time' => getTime(),
  964. ]);
  965. //同步会员中心手机端底部菜单开关
  966. Db::name('users_bottom_menu')->where([
  967. 'mca' => ['IN',['user/Pay/pay_account_recharge']]
  968. ])->update([
  969. 'status' => (1 == $value) ? 1 : 0,
  970. 'update_time' => getTime(),
  971. ]);
  972. }
  973. //同步会员中心手机端底部菜单开关 ---start
  974. Db::name('users_bottom_menu')->where([
  975. 'mca' => ['IN',['user/Shop/shop_centre','user/Shop/shop_cart_list']]
  976. ])->update([
  977. 'status' => (1 == $value) ? 1 : 0,
  978. 'update_time' => getTime(),
  979. ]);
  980. //同步会员中心手机端底部菜单开关 ---end
  981. break;
  982. }
  983. case 'users':
  984. {
  985. // 会员投稿
  986. if ('users_open_release' == $name) {
  987. if (empty($this->php_servicemeal) && !empty($value)) {
  988. $str = '6K+l5Yqf6IO95Y+q6ZmQ5LqO5o6I5p2D5Z+f5ZCN77yB';
  989. $this->error(base64_decode($str));
  990. }
  991. }
  992. //同步会员中心手机端底部菜单开关 ---start
  993. Db::name('users_bottom_menu')->where([
  994. 'mca' => ['IN',['user/UsersRelease/article_add','user/UsersRelease/release_centre']]
  995. ])->update([
  996. 'status' => (1 == $value) ? 1 : 0,
  997. 'update_time' => getTime(),
  998. ]);
  999. //同步会员中心手机端底部菜单开关 ---end
  1000. // 会员投稿
  1001. $r = Db::name('users_menu')->where([
  1002. 'mca' => 'user/UsersRelease/release_centre',
  1003. ])->update([
  1004. 'status' => (1 == $value) ? 1 : 0,
  1005. 'update_time' => getTime(),
  1006. ]);
  1007. if ($r !== false) {
  1008. getUsersConfigData($inc_type, [$name => $value]);
  1009. if (1 == $value) {
  1010. /*多语言 - 同时开启会员中心*/
  1011. if (is_language()) {
  1012. $langRow = \think\Db::name('language')->order('id asc')
  1013. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1014. ->select();
  1015. foreach ($langRow as $key => $val) {
  1016. tpCache('web', ['web_users_switch' => 1], $val['mark']);
  1017. }
  1018. } else { // 单语言
  1019. tpCache('web', ['web_users_switch' => 1]);
  1020. }
  1021. /*--end*/
  1022. }
  1023. }
  1024. break;
  1025. }
  1026. case 'level':
  1027. {
  1028. // 会员升级
  1029. //同步会员中心手机端底部菜单开关 ---start
  1030. Db::name('users_bottom_menu')->where([
  1031. 'mca' => ['IN',['user/Level/level_centre','user/Pay/pay_account_recharge']]
  1032. ])->update([
  1033. 'status' => (1 == $value) ? 1 : 0,
  1034. 'update_time' => getTime(),
  1035. ]);
  1036. //同步会员中心手机端底部菜单开关 ---end
  1037. // 会员升级
  1038. $r = Db::name('users_menu')->where([
  1039. 'mca' => 'user/Level/level_centre',
  1040. ])->update([
  1041. 'status' => (1 == $value) ? 1 : 0,
  1042. 'update_time' => getTime(),
  1043. ]);
  1044. if ($r) {
  1045. getUsersConfigData($inc_type, [$name => $value]);
  1046. if (1 == $value) {
  1047. /*多语言 - 同时开启会员中心*/
  1048. if (is_language()) {
  1049. $langRow = \think\Db::name('language')->order('id asc')
  1050. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1051. ->select();
  1052. foreach ($langRow as $key => $val) {
  1053. tpCache('web', ['web_users_switch' => 1], $val['mark']);
  1054. }
  1055. } else { // 单语言
  1056. tpCache('web', ['web_users_switch' => 1]);
  1057. }
  1058. /*--end*/
  1059. }
  1060. }
  1061. break;
  1062. }
  1063. case 'web':
  1064. {
  1065. if (empty($is_force)) {
  1066. if ($name == 'web_language_switch' && $value == 1) { // 多语言开关
  1067. if (!empty($this->globalConfig['web_citysite_open'])) {
  1068. $this->error('强制开启多语言,会自动关闭城市分站。');
  1069. }
  1070. } else if ($name == 'web_citysite_open' && $value == 1) { // 多站点开关
  1071. if (!empty($this->globalConfig['web_language_switch'])) {
  1072. $this->error('强制开启城市分站,会自动关闭多语言。');
  1073. }
  1074. }
  1075. }
  1076. /*多语言*/
  1077. if (is_language()) {
  1078. $langRow = \think\Db::name('language')->order('id asc')
  1079. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1080. ->select();
  1081. foreach ($langRow as $key => $val) {
  1082. tpCache($inc_type, [$name => $value], $val['mark']);
  1083. }
  1084. } else { // 单语言
  1085. tpCache($inc_type, [$name => $value]);
  1086. }
  1087. /*--end*/
  1088. if (in_array($name, ['web_users_switch'])) {
  1089. // $data['reload'] = 1;
  1090. /*检测是否存在会员中心模板*/
  1091. if (!empty($value) && !file_exists('template/'.TPL_THEME.'pc/'.$web_users_tpl_theme)) {
  1092. $is_syn = 1;
  1093. } else {
  1094. $is_syn = 0;
  1095. }
  1096. $data['is_syn'] = $is_syn;
  1097. /*--end*/
  1098. // 同时关闭会员相关的开关
  1099. if (empty($value)) {
  1100. getUsersConfigData('users', ['users_open_release' => 0]); // 会员投稿
  1101. getUsersConfigData('level', ['level_member_upgrade' => 0]); // 会员升级
  1102. getUsersConfigData('shop', ['shop_open' => 0]); // 商城中心
  1103. getUsersConfigData('pay', ['pay_open' => 0]); // 支付功能
  1104. }
  1105. } else if ($name == 'web_language_switch') { // 多语言开关
  1106. // 统计多语言数量
  1107. model('Language')->setLangNum();
  1108. // 重新生成sitemap.xml
  1109. sitemap_all();
  1110. // 强制关闭多站点
  1111. if (!empty($is_force)) {
  1112. $data['reload'] = 1;
  1113. /*多语言*/
  1114. if (is_language()) {
  1115. $langRow = \think\Db::name('language')->order('id asc')
  1116. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1117. ->select();
  1118. foreach ($langRow as $key => $val) {
  1119. tpCache('web', ['web_citysite_open' => 0], $val['mark']);
  1120. }
  1121. } else { // 单语言
  1122. tpCache('web', ['web_citysite_open' => 0]);
  1123. }
  1124. /*--end*/
  1125. model('Citysite')->setCitysiteOpen();
  1126. }
  1127. // 清除页面缓存
  1128. delFile(HTML_ROOT);
  1129. } else if ($name == 'web_citysite_open') { // 多城市站点开关
  1130. model('Citysite')->setCitysiteOpen();
  1131. // 强制关闭多语言
  1132. if (!empty($is_force)) {
  1133. $data['reload'] = 1;
  1134. $msg = "已开启城市分站<br/>1、仅支持动态URL、伪静态这两种模式;<br/>2、可在下方的【高级扩展】进入城市分站;";
  1135. }
  1136. /*多语言*/
  1137. if (is_language()) {
  1138. $langRow = \think\Db::name('language')->order('id asc')
  1139. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1140. ->select();
  1141. foreach ($langRow as $key => $val) {
  1142. tpCache('web', ['web_language_switch' => 0], $val['mark']);
  1143. if (!empty($value) && 2 == $seo_pseudo) {
  1144. tpCache('seo', ['seo_pseudo'=>1, 'seo_dynamic_format'=>1], $val['mark']);
  1145. if (file_exists('./index.html')) {
  1146. @unlink('./index.html');
  1147. }
  1148. }
  1149. }
  1150. } else { // 单语言
  1151. tpCache('web', ['web_language_switch' => 0]);
  1152. if (!empty($value) && 2 == $seo_pseudo) {
  1153. tpCache('seo', ['seo_pseudo'=>1, 'seo_dynamic_format'=>1]);
  1154. if (file_exists('./index.html')) {
  1155. @unlink('./index.html');
  1156. }
  1157. }
  1158. }
  1159. /*--end*/
  1160. // 统计多语言数量
  1161. model('Language')->setLangNum();
  1162. // 重新生成sitemap.xml
  1163. sitemap_all();
  1164. // 清除页面缓存
  1165. delFile(HTML_ROOT);
  1166. }
  1167. break;
  1168. }
  1169. }
  1170. $this->success($msg, null, $data);
  1171. }
  1172. /*代理贴牌功能限制-s*/
  1173. $weapp_switch = true;
  1174. if (function_exists('checkAuthRule')) {
  1175. //插件应用
  1176. $weapp_switch = checkAuthRule(2005);
  1177. }
  1178. $this->assign('weapp_switch', $weapp_switch);
  1179. /*代理贴牌功能限制-e*/
  1180. $UsersConfigData = getUsersConfigData('all');
  1181. if (file_exists('./data/conf/memgift_open.txt')) {
  1182. $UsersConfigData['memgift_open'] = 1;
  1183. }
  1184. $this->assign('userConfig',$UsersConfigData);
  1185. $is_online = 0;
  1186. if (is_realdomain()) {
  1187. $is_online = 1;
  1188. }
  1189. $this->assign('is_online',$is_online);
  1190. /*检测是否存在会员中心模板*/
  1191. if (!file_exists('template/'.TPL_THEME.'pc/'.$web_users_tpl_theme)) {
  1192. $is_themeusers_exist = 1;
  1193. } else {
  1194. $is_themeusers_exist = 0;
  1195. }
  1196. $this->assign('is_themeusers_exist',$is_themeusers_exist);
  1197. /*--end*/
  1198. /*检测是否存在商城中心模板*/
  1199. $shop_tpl_list = glob("./template/".TPL_THEME."pc/{$web_users_tpl_theme}/shop_*");
  1200. if (empty($shop_tpl_list)) {
  1201. $is_themeshop_exist = 1;
  1202. } else {
  1203. $is_themeshop_exist = 0;
  1204. }
  1205. $this->assign('is_themeshop_exist',$is_themeshop_exist);
  1206. /*--end*/
  1207. /*支付接口*/
  1208. $pay = Db::name('pay_api_config')->where('status', 1)->order('pay_id asc')->select();
  1209. foreach ($pay as $key => $val) {
  1210. if (1 == $val['system_built']) {
  1211. $val['litpic'] = $this->root_dir . "/public/static/admin/images/{$val['pay_mark']}.png";
  1212. } else {
  1213. $val['litpic'] = $this->root_dir . "/weapp/{$val['pay_mark']}/logo.png";
  1214. }
  1215. $pay[$key] = $val;
  1216. }
  1217. $this->assign('pay_list', $pay);
  1218. /*--end*/
  1219. //获取所有权限列表(id为键值的list格式)
  1220. $all_menu_tree = getAllMenu();
  1221. $all_menu_list = tree_to_list($all_menu_tree,'child','id');
  1222. $this->assign('all_menu_list',$all_menu_list);
  1223. //选中的且需要展示在“当前导航”菜单栏目
  1224. $admin_menu_list = Db::name("admin_menu")->field("menu_id,controller_name,action_name,title,icon,is_menu,is_switch")->where(['is_menu'=>1,'status'=>1])->order("sort_order asc,update_time asc")->select();
  1225. $admin_menu_id_arr = []; //在“当前导航”栏目显示菜单集合
  1226. foreach ($admin_menu_list as $key=>$val){
  1227. $admin_menu_id_arr[] = $val['menu_id'];
  1228. // 其他语言不显示留言管理
  1229. /*if ($this->admin_lang != $this->main_lang) {
  1230. foreach ([2004018] as $_k => $_v) {
  1231. if ($_v == $val['menu_id']) {
  1232. unset($admin_menu_list[$key]);
  1233. }
  1234. }
  1235. }*/
  1236. }
  1237. //用户手动关闭的权限集合
  1238. $this->assign('admin_menu_id_arr', $admin_menu_id_arr);
  1239. $menu_list = getAdminMenuList($admin_menu_list);
  1240. $this->assign('menu_list',$menu_list);
  1241. //获取因为没有开启相关模块没有权限的节点(用于初始化)
  1242. $not_role_menu_id_arr = get_not_role_menu_id();
  1243. $this->assign('not_role_menu_id_arr',$not_role_menu_id_arr);
  1244. //模块开关与入口关联(用于动态js)
  1245. $global = include APP_PATH.MODULE_NAME.'/conf/global.php';
  1246. $this->assign('module_rele_menu',$global['module_rele_menu']);
  1247. $this->assign('module_default_menu',$global['module_default_menu']);
  1248. $this->assign('module_reverse_menu',$global['module_reverse_menu']);
  1249. // 可视编辑入口
  1250. $is_show_uiset = 0;
  1251. if (file_exists(ROOT_PATH.'template/'.TPL_THEME.'pc/uiset.txt') || file_exists(ROOT_PATH.'template/'.TPL_THEME.'mobile/uiset.txt')) {
  1252. $is_show_uiset = 1;
  1253. }
  1254. $this->assign('is_show_uiset', $is_show_uiset);
  1255. //创始人才有权限控制
  1256. $admin_info = session('admin_info');
  1257. $is_founder = !empty($admin_info['is_founder']) ? $admin_info['is_founder'] : 0;
  1258. $this->assign('is_founder', $is_founder);
  1259. $security_ask_open = (int)tpSetting('security.security_ask_open');
  1260. $this->assign('security_ask_open', $security_ask_open);
  1261. $shopLogic = new \app\admin\logic\ShopLogic;
  1262. // 列出营销功能里已使用的模块
  1263. $marketFunc = $shopLogic->marketLogic();
  1264. $this->assign('marketFunc', $marketFunc);
  1265. // 列出功能地图里已使用的模块
  1266. $useFunc = $shopLogic->useFuncLogic();
  1267. $this->assign('useFunc', $useFunc);
  1268. return $this->fetch();
  1269. }
  1270. // 更新数据缓存表信息
  1271. public function update_sql_cache_table()
  1272. {
  1273. $CacheMaxID = Db::name('sql_cache_table')->where('sql_name', 'ArchivesMaxID')->getField('sql_result');
  1274. if (empty($CacheMaxID)) {
  1275. // 添加查询执行语句到mysql缓存表
  1276. model('SqlCacheTable')->InsertSqlCacheTable(true);
  1277. } else {
  1278. $ArchivesMaxID = Db::name('archives')->max('aid');
  1279. if ($ArchivesMaxID != $CacheMaxID) {
  1280. /*清空sql_cache_table数据缓存表 并 添加查询执行语句到mysql缓存表*/
  1281. Db::name('sql_cache_table')->execute('TRUNCATE TABLE '.config('database.prefix').'sql_cache_table');
  1282. model('SqlCacheTable')->InsertSqlCacheTable(true);
  1283. /* END */
  1284. }
  1285. }
  1286. }
  1287. /**
  1288. * 主题风格
  1289. * @return [type] [description]
  1290. */
  1291. public function theme_index()
  1292. {
  1293. // 主题风格
  1294. // $list = Db::name('admin_theme')->where(['theme_type'=>1])->order('is_system desc, sort_order asc, theme_id asc')->select();
  1295. // $this->assign('list', $list);
  1296. // 登录页自定义模板
  1297. $login_tplist = glob('application/admin/template/theme/login_*.htm');
  1298. foreach ($login_tplist as $key => $val) {
  1299. $val = preg_replace('/^(.*)login_([\w\-]+)\.htm$/i', 'login_${2}.htm', $val);
  1300. $login_tplist[$key] = $val;
  1301. }
  1302. $this->assign('login_tplist', $login_tplist);
  1303. // 欢迎页主题风格
  1304. $welcome_list = Db::name('admin_theme')->where(['theme_type'=>2])->order('is_system desc, sort_order asc, theme_id asc')->select();
  1305. foreach ($welcome_list as $key => $val) {
  1306. $val['disabled'] = $val['disabled_tips'] = '';
  1307. if ($val['welcome_tplname'] == 'welcome_shop.htm') {
  1308. if (empty($this->usersConfig['shop_open'])) {
  1309. $val['disabled'] = ' disabled="disabled" readonly="true" ';
  1310. $val['disabled_tips'] = ' title="需开启商城中心才能使用" ';
  1311. }
  1312. } else if ($val['welcome_tplname'] == 'welcome_taskflow.htm') {
  1313. $weappRow = model('weapp')->getWeappList('TaskFlow');
  1314. if (!is_dir('./weapp/TaskFlow/') || empty($weappRow['status'])) {
  1315. $val['disabled'] = ' disabled="disabled" readonly="true" ';
  1316. $val['disabled_tips'] = ' title="需安装【工作任务流】插件才能使用" ';
  1317. }
  1318. }
  1319. $welcome_list[$key] = $val;
  1320. }
  1321. $this->assign('welcome_list', $welcome_list);
  1322. return $this->fetch();
  1323. }
  1324. /**
  1325. * 主题设置 - 保存
  1326. * @return [type] [description]
  1327. */
  1328. public function theme_conf()
  1329. {
  1330. if (IS_POST) {
  1331. $post = input('post.');
  1332. $webData = [];
  1333. $image_ext = config('global.image_ext');
  1334. $image_ext_arr = explode(',', $image_ext);
  1335. foreach ($post as $key => $val) {
  1336. $val = trim($val);
  1337. if (in_array($key, ['admin_logo','login_logo','login_bgimg'])) { // 后台LOGO/登录LOGO
  1338. $source = preg_replace('#^'.$this->root_dir.'#i', '', $val); // 支持子目录
  1339. $source_ext = pathinfo('.'.$source, PATHINFO_EXTENSION);
  1340. if (!empty($source_ext) && !in_array($source_ext, $image_ext_arr)) {
  1341. $this->error('上传图片扩展名错误!');
  1342. }
  1343. }
  1344. if ('theme_id' == $key) {
  1345. $key = 'web_theme_styleid';
  1346. } else if ('login_logo' == $key) {
  1347. $key = 'web_loginlogo';
  1348. } else if ('login_bgimg_model' == $key) {
  1349. $key = 'web_loginbgimg_model';
  1350. } else if ('login_bgimg' == $key) {
  1351. $key = 'web_loginbgimg';
  1352. } else if ('theme_color_model' == $key) {
  1353. $key = 'web_theme_color_model';
  1354. } else if ('theme_main_color' == $key) {
  1355. $key = 'web_theme_color';
  1356. } else if ('theme_assist_color' == $key) {
  1357. $key = 'web_assist_color';
  1358. } else if ('admin_logo' == $key) {
  1359. $key = 'web_adminlogo';
  1360. } else if ('login_tplname' == $key) {
  1361. $key = 'web_theme_login_tplname';
  1362. }
  1363. $webData[$key] = $val;
  1364. }
  1365. $webData['web_theme_style_uptime'] = getTime();
  1366. if (!empty($webData)) {
  1367. /*多语言*/
  1368. if (is_language()) {
  1369. $langRow = \think\Db::name('language')->order('id asc')
  1370. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1371. ->select();
  1372. foreach ($langRow as $key => $val) {
  1373. tpCache('web', $webData, $val['mark']);
  1374. }
  1375. } else {
  1376. tpCache('web', $webData);
  1377. }
  1378. /*--end*/
  1379. $ajaxLogic = new \app\admin\logic\AjaxLogic;
  1380. $ajaxLogic->admin_update_theme_css();
  1381. }
  1382. $is_change = 0;
  1383. // $theme_info = Db::name('admin_theme')->field('theme_title,theme_pic,add_time,update_time', true)->where(['theme_id'=>$post['theme_id']])->find();
  1384. // foreach ($post as $key => $val) {
  1385. // if (in_array($key, ['login_logo','login_bgimg','admin_logo'])) {
  1386. // $val = handle_subdir_pic($val);
  1387. // $theme_info[$key] = handle_subdir_pic($theme_info[$key]);
  1388. // }
  1389. // if (isset($theme_info[$key]) && $theme_info[$key] != $val) {
  1390. // $is_change = 1;
  1391. // break;
  1392. // }
  1393. // }
  1394. // if (empty($post['is_select_theme'])) {
  1395. // $is_change = 0;
  1396. // }
  1397. $this->success('操作成功,需刷新后台看效果!', null, ['is_change'=>$is_change]);
  1398. }
  1399. }
  1400. /**
  1401. * 欢迎页设置 - 保存
  1402. * @return [type] [description]
  1403. */
  1404. public function theme_welcome_conf()
  1405. {
  1406. if (IS_POST) {
  1407. $post = input('post.');
  1408. $webData = ['web_theme_welcome_tplname'=>$post['welcome_tplname']];
  1409. /*多语言*/
  1410. if (is_language()) {
  1411. $langRow = \think\Db::name('language')->order('id asc')
  1412. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1413. ->select();
  1414. foreach ($langRow as $key => $val) {
  1415. tpCache('web', $webData, $val['mark']);
  1416. }
  1417. } else {
  1418. tpCache('web', $webData);
  1419. }
  1420. /*--end*/
  1421. $this->success('操作成功');
  1422. }
  1423. }
  1424. /**
  1425. * 新增主题风格
  1426. * @return [type] [description]
  1427. */
  1428. public function theme_add_login()
  1429. {
  1430. if (IS_POST) {
  1431. $post = input('post.');
  1432. $post['theme_title'] = trim($post['theme_title']);
  1433. if (empty($post['theme_title'])) {
  1434. $this->error('主题名称不能为空!');
  1435. }
  1436. if (isset($post['theme_id'])) {
  1437. unset($post['theme_id']);
  1438. }
  1439. $newData = [
  1440. 'theme_type'=>1,
  1441. 'is_system' => 0,
  1442. 'sort_order' => 100,
  1443. 'add_time' => getTime(),
  1444. 'update_time' => getTime(),
  1445. ];
  1446. $newData = array_merge($post, $newData);
  1447. $theme_id = Db::name('admin_theme')->insertGetId($newData);
  1448. if ($theme_id !== false) {
  1449. /*多语言*/
  1450. if (is_language()) {
  1451. $langRow = \think\Db::name('language')->order('id asc')
  1452. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1453. ->select();
  1454. foreach ($langRow as $key => $val) {
  1455. tpCache('web', ['web_theme_styleid'=>$theme_id], $val['mark']);
  1456. }
  1457. } else {
  1458. tpCache('web', ['web_theme_styleid'=>$theme_id]);
  1459. }
  1460. /*--end*/
  1461. $this->success('操作成功,需刷新后台看效果!');
  1462. }
  1463. $this->error('操作失败');
  1464. }
  1465. }
  1466. /**
  1467. * 获取主题风格信息
  1468. * @return [type] [description]
  1469. */
  1470. public function ajax_get_theme_info()
  1471. {
  1472. $theme_id = input('param.theme_id/d');
  1473. $info = Db::name('admin_theme')->where(['theme_id'=>$theme_id])->find();
  1474. $this->success('读取成功', null, ['info'=>$info]);
  1475. }
  1476. /**
  1477. * 生成随机欢迎页文件名,确保唯一性
  1478. */
  1479. private function theme_rand_filename($filename = '', $prefix = 'style', $filename_list = [])
  1480. {
  1481. if (empty($filename)) {
  1482. $filename = $prefix . mt_rand(100,999);
  1483. }
  1484. if (in_array($filename, $filename_list)) {
  1485. $filename = $prefix . mt_rand(100,999);
  1486. return $this->theme_rand_filename($filename, $prefix, $filename_list);
  1487. }
  1488. return $filename;
  1489. }
  1490. //ajax获取任务流数据
  1491. public function get_task_list()
  1492. {
  1493. $this->eyouCmsLogic->get_task_list();
  1494. }
  1495. /**
  1496. * 创建指定模板文件
  1497. * @return [type] [description]
  1498. */
  1499. public function ajax_theme_tplfile_add()
  1500. {
  1501. $type = input('param.type/s', '');
  1502. $tpldirpath = '';
  1503. if ('welcome' == $type) {
  1504. $select_input_id = 'welcome_tplname';
  1505. $tpldirpath = '/application/admin/template/theme';
  1506. } else if ('login' == $type) {
  1507. $select_input_id = 'login_tplname';
  1508. $tpldirpath = '/application/admin/template/theme';
  1509. }
  1510. $view_suffix = config('template.view_suffix');
  1511. if (IS_POST) {
  1512. $post = input('post.', '', null);
  1513. $content = input('post.content', '', null);
  1514. $post['filename'] = trim($post['filename']);
  1515. $post['theme_title'] = empty($post['theme_title']) ? '' : trim($post['theme_title']);
  1516. if ('welcome' == $post['type']) {
  1517. if (empty($post['theme_title'])) {
  1518. $this->error('模板名称不能为空!');
  1519. }
  1520. }
  1521. if (!empty($post['filename'])) {
  1522. if (!preg_match("/^[\w\-\_]{1,}$/u", $post['filename'])) {
  1523. $this->error('文件名称只允许字母、数字、下划线、连接符的任意组合!');
  1524. }
  1525. $filename = "{$type}_{$post['filename']}.{$view_suffix}";
  1526. } else {
  1527. $this->error('文件名称不能为空!');
  1528. }
  1529. if (file_exists(ROOT_PATH.ltrim($tpldirpath, '/').'/'.$filename)) {
  1530. $this->error('文件名称已经存在,请重新命名!', null, ['focus'=>'filename']);
  1531. }
  1532. $nosubmit = input('param.nosubmit/d');
  1533. if (1 == $nosubmit) {
  1534. $this->success('检测通过');
  1535. }
  1536. if (empty($content)) {
  1537. $this->error('HTML代码不能为空!');
  1538. }
  1539. $filemanagerLogic = new \app\admin\logic\FilemanagerLogic;
  1540. $file = ROOT_PATH.trim($tpldirpath, '/').'/'.$filename;
  1541. if (!is_writable(dirname($file))) {
  1542. $this->error("请把以下目录设置为可写入权限<br/>{$tpldirpath}");
  1543. }
  1544. $ext = preg_replace('/^(.*)\.([^\.]+)$/i', '${2}', $filename);
  1545. if ('htm' == $ext) {
  1546. $content = htmlspecialchars_decode($content, ENT_QUOTES);
  1547. if (preg_match('#<([^?]*)\?php#i', $content) || preg_match('#<\?(\s*)=#i', $content) || (preg_match('#<\?#i', $content) && preg_match('#\?>#i', $content)) || preg_match('#\{eyou\:php([^\}]*)\}#i', $content) || preg_match('#\{php([^\}]*)\}#i', $content) || preg_match('#(\s+)language(\s*)=(\s*)("|\')?php("|\')?#i', $content)) {
  1548. $this->error('模板里不允许有php语法,为了安全考虑,请通过FTP工具进行编辑上传。');
  1549. }
  1550. foreach ($filemanagerLogic->disableFuns as $key => $val) {
  1551. $val_new = msubstr($val, 0, 1).'-'.msubstr($val, 1);
  1552. $content = preg_replace("/(@)?".$val."(\s*)\(/i", "{$val_new}(", $content);
  1553. }
  1554. }
  1555. $fp = fopen($file, "w");
  1556. fputs($fp, $content);
  1557. fclose($fp);
  1558. $theme_id = 0;
  1559. if ('welcome' == $post['type']) {
  1560. $newData = [
  1561. 'theme_type'=>2,
  1562. 'theme_title'=>$post['theme_title'],
  1563. 'theme_pic'=>ROOT_DIR."/public/static/admin/images/theme/theme_pic_default.png",
  1564. 'welcome_tplname'=>$filename,
  1565. 'is_system' => 0,
  1566. 'sort_order' => 100,
  1567. 'add_time' => getTime(),
  1568. 'update_time' => getTime(),
  1569. ];
  1570. $theme_id = Db::name('admin_theme')->insertGetId($newData);
  1571. }
  1572. $data = [
  1573. 'filename'=>$filename,
  1574. 'type'=>$type,
  1575. 'select_input_id'=>$select_input_id,
  1576. 'theme_id'=>$theme_id,
  1577. 'theme_title'=>$post['theme_title'],
  1578. ];
  1579. $this->success('操作成功', null, $data);
  1580. }
  1581. $content = '';
  1582. if ('welcome' == $type) {
  1583. $content = file_get_contents(APP_PATH.'admin/template/index/welcome.htm');
  1584. } else if ('login' == $type) {
  1585. $content = file_get_contents(APP_PATH.'admin/template/admin/login.htm');
  1586. }
  1587. $this->assign('content', $content);
  1588. $this->assign('type', $type);
  1589. $this->assign('tpldirpath', $tpldirpath);
  1590. return $this->fetch('theme_tplfile_add');
  1591. }
  1592. /**
  1593. * 编辑指定模板文件
  1594. * @return [type] [description]
  1595. */
  1596. public function ajax_theme_tplfile_edit()
  1597. {
  1598. $type = input('param.type/s', '');
  1599. if ('welcome' == $type) {
  1600. $select_input_id = 'welcome_tplname';
  1601. } else if ('login' == $type) {
  1602. $select_input_id = 'login_tplname';
  1603. }
  1604. $tpldirpath = '/application/admin/template/theme';
  1605. $view_suffix = config('template.view_suffix');
  1606. if (IS_POST) {
  1607. $post = input('post.', '', null);
  1608. if (!empty($post['theme_id'])) {
  1609. $content = input('post.content', '', null);
  1610. $post['filename'] = trim($post['filename']);
  1611. $post['theme_title'] = empty($post['theme_title']) ? '' : trim($post['theme_title']);
  1612. if ('welcome' == $post['type']) {
  1613. if (empty($post['theme_title'])) {
  1614. $this->error('模板名称不能为空!');
  1615. }
  1616. }
  1617. if (!empty($post['filename'])) {
  1618. if (!preg_match("/^[\w\-\_]{1,}$/u", $post['filename'])) {
  1619. $this->error('文件名称只允许字母、数字、下划线、连接符的任意组合!');
  1620. }
  1621. $filename = "{$type}_{$post['filename']}.{$view_suffix}";
  1622. } else {
  1623. $this->error('文件名称不能为空!');
  1624. }
  1625. if ($filename != $post['welcome_tplname'] && file_exists(ROOT_PATH.ltrim($tpldirpath, '/').'/'.$filename)) {
  1626. $this->error('文件名称已经存在,请重新命名!', null, ['focus'=>'filename']);
  1627. }
  1628. $nosubmit = input('param.nosubmit/d');
  1629. if (1 == $nosubmit) {
  1630. $this->success('检测通过');
  1631. }
  1632. if (empty($content)) {
  1633. $this->error('HTML代码不能为空!');
  1634. }
  1635. $filemanagerLogic = new \app\admin\logic\FilemanagerLogic;
  1636. $file = ROOT_PATH.trim($tpldirpath, '/').'/'.$filename;
  1637. if (!is_writable(dirname($file))) {
  1638. $this->error("请把以下目录设置为可写入权限<br/>{$tpldirpath}");
  1639. }
  1640. $ext = preg_replace('/^(.*)\.([^\.]+)$/i', '${2}', $filename);
  1641. if ('htm' == $ext) {
  1642. $content = htmlspecialchars_decode($content, ENT_QUOTES);
  1643. if (preg_match('#<([^?]*)\?php#i', $content) || preg_match('#<\?(\s*)=#i', $content) || (preg_match('#<\?#i', $content) && preg_match('#\?>#i', $content)) || preg_match('#\{eyou\:php([^\}]*)\}#i', $content) || preg_match('#\{php([^\}]*)\}#i', $content) || preg_match('#(\s+)language(\s*)=(\s*)("|\')?php("|\')?#i', $content)) {
  1644. $this->error('模板里不允许有php语法,为了安全考虑,请通过FTP工具进行编辑上传。');
  1645. }
  1646. foreach ($filemanagerLogic->disableFuns as $key => $val) {
  1647. $val_new = msubstr($val, 0, 1).'-'.msubstr($val, 1);
  1648. $content = preg_replace("/(@)?".$val."(\s*)\(/i", "{$val_new}(", $content);
  1649. }
  1650. }
  1651. $fp = fopen($file, "w");
  1652. if ($fp != false && fwrite($fp, $content)) {
  1653. fclose($fp);
  1654. if ($filename != $post['welcome_tplname']) {
  1655. rename(ROOT_PATH.ltrim($tpldirpath, '/').'/'.$post['welcome_tplname'], ROOT_PATH.ltrim($tpldirpath, '/').'/'.$filename);
  1656. }
  1657. }
  1658. if ('welcome' == $post['type']) {
  1659. $newData = [
  1660. 'theme_type'=>2,
  1661. 'theme_title'=>$post['theme_title'],
  1662. 'theme_pic'=>ROOT_DIR."/public/static/admin/images/theme/theme_pic_default.png",
  1663. 'welcome_tplname'=>$filename,
  1664. 'is_system' => 0,
  1665. 'update_time' => getTime(),
  1666. ];
  1667. Db::name('admin_theme')->where(['theme_id'=>$post['theme_id']])->update($newData);
  1668. }
  1669. $data = [
  1670. 'filename'=>$filename,
  1671. 'type'=>$type,
  1672. 'select_input_id'=>$select_input_id,
  1673. 'theme_id'=>$post['theme_id'],
  1674. 'theme_title'=>$post['theme_title'],
  1675. ];
  1676. $this->success('操作成功', null, $data);
  1677. }
  1678. $this->error('操作失败');
  1679. }
  1680. $theme_id = input('param.theme_id/d', 0);
  1681. $info = Db::name('admin_theme')->where(['theme_id'=>$theme_id])->find();
  1682. if (empty($info)) {
  1683. $this->error('数据不存在,请联系管理员!');
  1684. exit;
  1685. }
  1686. if (!empty($info['is_system'])) {
  1687. $this->error('内置模板禁止编辑,系统更新会覆盖');
  1688. }
  1689. $is_default_theme = 0;
  1690. if (!empty($info['is_system']) && empty($info['welcome_tplname'])) {
  1691. $is_default_theme = 1;
  1692. if ('welcome' == $type) {
  1693. $content = file_get_contents(APP_PATH."admin/template/index/{$type}.{$view_suffix}");
  1694. $info['welcome_tplname'] = "welcome.{$view_suffix}";
  1695. } else if ('login' == $type) {
  1696. $viewfile = 'login';
  1697. if (2 <= $this->php_servicemeal) {
  1698. $viewfile = 'login_zy';
  1699. }
  1700. $content = file_get_contents(APP_PATH."admin/template/admin/{$viewfile}.{$view_suffix}");
  1701. $info['welcome_tplname'] = "{$viewfile}.{$view_suffix}";
  1702. }
  1703. } else {
  1704. $content = file_get_contents(APP_PATH."admin/template/theme/{$info['welcome_tplname']}");
  1705. }
  1706. $info['filename'] = preg_replace('/^'.$type.'(_([^\.]+))?\.'.$view_suffix.'$/i', '${2}', $info['welcome_tplname']);
  1707. $this->assign('content', $content);
  1708. $this->assign('type', $type);
  1709. $this->assign('tpldirpath', $tpldirpath);
  1710. $this->assign('is_default_theme', $is_default_theme);
  1711. $this->assign('info', $info);
  1712. return $this->fetch('theme_tplfile_edit');
  1713. }
  1714. /**
  1715. * 删除指定模板文件
  1716. */
  1717. public function ajax_theme_tplfile_del()
  1718. {
  1719. $theme_id = input('param.theme_id/d');
  1720. if (IS_POST && !empty($theme_id)) {
  1721. $type = input('param.type/s', '');
  1722. $select_input_id = '';
  1723. if ('welcome' == $type) {
  1724. $select_input_id = 'welcome_tplname';
  1725. } else if ('login' == $type) {
  1726. $select_input_id = 'login_tplname';
  1727. }
  1728. $tpldirpath = '/application/admin/template/theme';
  1729. $info = Db::name('admin_theme')->where(['theme_id'=>$theme_id])->find();
  1730. $r = Db::name('admin_theme')->where(['theme_id'=>$theme_id])->delete();
  1731. if ($r !== false) {
  1732. @unlink('.'.$tpldirpath.'/'.$info['welcome_tplname']);
  1733. adminLog('删除欢迎页模板:'.$info['theme_title']);
  1734. $this->success('删除成功', null, ['select_input_id'=>$select_input_id]);
  1735. }
  1736. }
  1737. $this->error('删除失败');
  1738. }
  1739. }