System.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?php
  2. namespace app\admin\controller;
  3. use http\Cookie;
  4. use think\Db;
  5. use think\Config;
  6. use think\Cache;
  7. use think\View;
  8. class System extends Base
  9. {
  10. public function test_email()
  11. {
  12. $post = input();
  13. $conf = [
  14. 'nick' => $post['nick'],
  15. ];
  16. $type = strtolower($post['type']);
  17. $to = $post['test'];
  18. $conf['host'] = $GLOBALS['config']['email'][$type]['host'];
  19. $conf['port'] = $GLOBALS['config']['email'][$type]['port'];
  20. $conf['username'] = $GLOBALS['config']['email'][$type]['username'];
  21. $conf['password'] = $GLOBALS['config']['email'][$type]['password'];
  22. $conf['secure'] = $GLOBALS['config']['email'][$type]['secure'];
  23. $this->label_maccms();
  24. $title = $GLOBALS['config']['email']['tpl']['test_title'];
  25. $msg = $GLOBALS['config']['email']['tpl']['test_body'];
  26. $code = mac_get_rndstr(6,'num');
  27. View::instance()->assign(['code'=>$code,'time'=>$GLOBALS['config']['email']['time']]);
  28. $title = View::instance()->display($title);
  29. $msg = View::instance()->display($msg);
  30. $msg = htmlspecialchars_decode($msg);
  31. $res = mac_send_mail($to, $title, $msg, $conf);
  32. if ($res['code']==1) {
  33. return json(['code' => 1, 'msg' => lang('test_ok')]);
  34. }
  35. return json(['code' => 1001, 'msg' => lang('test_err').':'.$res['msg']]);
  36. }
  37. public function test_cache()
  38. {
  39. $param = input();
  40. if (!isset($param['type']) || empty($param['host']) || empty($param['port'])) {
  41. return $this->error(lang('param_err'));
  42. }
  43. $options = [
  44. 'type' => $param['type'],
  45. 'port' => $param['port'],
  46. 'username' => $param['username'],
  47. 'password' => $param['password']
  48. ];
  49. $hd = Cache::connect($options);
  50. $hd->set('test', 'test');
  51. return json(['code' => 1, 'msg' => lang('test_ok')]);
  52. }
  53. public function config()
  54. {
  55. if (Request()->isPost()) {
  56. $config = input('','','htmlentities');
  57. $validate = \think\Loader::validate('Token');
  58. if(!$validate->check($config)){
  59. return $this->error($validate->getError());
  60. }
  61. unset($config['__token__']);
  62. $ads_dir='ads';
  63. $mob_ads_dir='ads';
  64. $path = ROOT_PATH .'template/'.$config['site']['template_dir'].'/info.ini';
  65. $cc = Config::load($path,'ini');
  66. if(!empty($cc['adsdir'])){
  67. $ads_dir = $cc['adsdir'];
  68. }
  69. $path = ROOT_PATH .'template/'.$config['site']['mob_template_dir'].'/info.ini';
  70. $cc = Config::load($path,'ini');
  71. if(!empty($cc['adsdir'])){
  72. $mob_ads_dir = $cc['adsdir'];
  73. }
  74. $config['site']['ads_dir'] = $ads_dir;
  75. $config['site']['mob_ads_dir'] = $mob_ads_dir;
  76. if(empty($config['app']['cache_flag'])){
  77. $config['app']['cache_flag'] = substr(md5(time()),0,10);
  78. }
  79. $config['app']['search_vod_rule'] = join('|', $config['app']['search_vod_rule']);
  80. $config['app']['search_art_rule'] = join('|', $config['app']['search_art_rule']);
  81. $config['extra'] = [];
  82. if(!empty($config['app']['extra_var'])){
  83. $extra_var = str_replace(array(chr(10),chr(13)), array('','#'),$config['app']['extra_var']);
  84. $tmp = explode('#',$extra_var);
  85. foreach($tmp as $a){
  86. if(strpos($a,'$$$')!==false){
  87. $tmp2 = explode('$$$',$a);
  88. $config['extra'][$tmp2[0]] = $tmp2[1];
  89. }
  90. }
  91. unset($tmp,$tmp2);
  92. }
  93. $config['site']['site_tj'] = html_entity_decode($config['site']['site_tj']);
  94. $config_new['site'] = $config['site'];
  95. $config_new['app'] = $config['app'];
  96. $config_new['extra'] = $config['extra'];
  97. $config_old = config('maccms');
  98. $config_new = array_merge($config_old, $config_new);
  99. $tj = $config_new['site']['site_tj'];
  100. if(strpos($tj,'document.w') ===false){
  101. $tj = 'document.write(\'' . str_replace("'","\'",$tj) . '\')';
  102. }
  103. $res = @fwrite(fopen('./static/js/tj.js', 'wb'), $tj);
  104. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  105. if ($res === false) {
  106. return $this->error(lang('save_err'));
  107. }
  108. return $this->success(lang('save_ok'));
  109. }
  110. $templates = glob('./template' . '/*', GLOB_ONLYDIR);
  111. foreach ($templates as $k => &$v) {
  112. $v = str_replace('./template/', '', $v);
  113. }
  114. $this->assign('templates', $templates);
  115. $langs = glob('./application/lang/*.php');
  116. foreach ($langs as $k => &$v) {
  117. $v = str_replace(['./application/lang/','.php'],['',''],$v);
  118. }
  119. $this->assign('langs', $langs);
  120. $usergroup = Db::name('group')->select();
  121. $this->assign('usergroup', $usergroup);
  122. $editors = mac_extends_list('editor');
  123. $this->assign('editors',$editors);
  124. $config = config('maccms');
  125. // 默认get+post
  126. if (!isset($config['app']['input_type'])) {
  127. $config['app']['input_type'] = 1;
  128. }
  129. $this->assign('config', $config);
  130. $this->assign('title', lang('admin/system/config/title'));
  131. return $this->fetch('admin@system/config');
  132. }
  133. public function configurl()
  134. {
  135. if (Request()->isPost()) {
  136. $config = input();
  137. $validate = \think\Loader::validate('Token');
  138. if(!$validate->check($config)){
  139. return $this->error($validate->getError());
  140. }
  141. unset($config['__token__']);
  142. $config_new['view'] = $config['view'];
  143. $config_new['path'] = $config['path'];
  144. $config_new['rewrite'] = $config['rewrite'];
  145. //写路由规则文件
  146. $route = [];
  147. $route['__pattern__'] = [
  148. 'id'=>'[\s\S]*?',
  149. 'ids'=>'[\s\S]*?',
  150. 'wd' => '[\s\S]*',
  151. 'en'=>'[\s\S]*?',
  152. 'state' => '[\s\S]*?',
  153. 'area' => '[\s\S]*',
  154. 'year'=>'[\s\S]*?',
  155. 'lang' => '[\s\S]*?',
  156. 'letter'=>'[\s\S]*?',
  157. 'actor' => '[\s\S]*?',
  158. 'director' => '[\s\S]*?',
  159. 'tag' => '[\s\S]*?',
  160. 'class' => '[\s\S]*?',
  161. 'order'=>'[\s\S]*?',
  162. 'by'=>'[\s\S]*?',
  163. 'file'=>'[\s\S]*?',
  164. 'name'=>'[\s\S]*?',
  165. 'url'=>'[\s\S]*?',
  166. 'type'=>'[\s\S]*?',
  167. 'sex' => '[\s\S]*?',
  168. 'version' => '[\s\S]*?',
  169. 'blood' => '[\s\S]*?',
  170. 'starsign' => '[\s\S]*?',
  171. 'page'=>'\d+',
  172. 'ajax'=>'\d+',
  173. 'tid'=>'\d+',
  174. 'mid'=>'\d+',
  175. 'rid'=>'\d+',
  176. 'pid'=>'\d+',
  177. 'sid'=>'\d+',
  178. 'nid'=>'\d+',
  179. 'uid'=>'\d+',
  180. 'level'=>'\d+',
  181. 'score'=>'\d+',
  182. 'limit'=>'\d+',
  183. ];
  184. $rows = explode(chr(13), str_replace(chr(10), '', $config['rewrite']['route']));
  185. foreach ($rows as $r) {
  186. if (strpos($r, '=>') !== false) {
  187. $a = explode('=>', $r);
  188. $rule = [];
  189. if (strpos($a, ':id') !== false) {
  190. //$rule['id'] = '\w+';
  191. }
  192. $route[trim($a[0])] = [trim($a[1]), [], $rule];
  193. }
  194. }
  195. $res = mac_arr2file(APP_PATH . 'route.php', $route);
  196. if ($res === false) {
  197. return $this->error(lang('write_err_route'));
  198. }
  199. //写扩展配置
  200. $config_old = config('maccms');
  201. $config_new = array_merge($config_old, $config_new);
  202. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  203. if ($res === false) {
  204. return $this->error(lang('write_err_config'));
  205. }
  206. return $this->success(lang('save_ok'));
  207. }
  208. $this->assign('config', config('maccms'));
  209. $this->assign('title', lang('admin/system/configurl/title'));
  210. return $this->fetch('admin@system/configurl');
  211. }
  212. public function configuser()
  213. {
  214. if (Request()->isPost()) {
  215. $config = input('','','htmlentities');
  216. $validate = \think\Loader::validate('Token');
  217. if(!$validate->check($config)){
  218. return $this->error($validate->getError());
  219. }
  220. unset($config['__token__']);
  221. $config_new['user'] = $config['user'];
  222. $config_old = config('maccms');
  223. $config_new = array_merge($config_old, $config_new);
  224. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  225. if ($res === false) {
  226. return $this->error(lang('save_err'));
  227. }
  228. return $this->success(lang('save_ok'));
  229. }
  230. $this->assign('config', config('maccms'));
  231. $this->assign('title', lang('admin/system/configuser/title'));
  232. return $this->fetch('admin@system/configuser');
  233. }
  234. public function configupload()
  235. {
  236. if (Request()->isPost()){
  237. $config = input('','','htmlentities');
  238. $validate = \think\Loader::validate('Token');
  239. if(!$validate->check($config)){
  240. return $this->error($validate->getError());
  241. }
  242. unset($config['__token__']);
  243. $config_new['upload'] = $config['upload'];
  244. $config_old = config('maccms');
  245. $config_new = array_merge($config_old, $config_new);
  246. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  247. if ($res === false) {
  248. return $this->error(lang('save_err'));
  249. }
  250. return $this->success(lang('save_ok'));
  251. }
  252. $this->assign('config', config('maccms'));
  253. $extends = mac_extends_list('upload');
  254. $this->assign('extends',$extends);
  255. $this->assign('title', lang('admin/system/configupload/title'));
  256. return $this->fetch('admin@system/configupload');
  257. }
  258. public function configcomment()
  259. {
  260. if (Request()->isPost()) {
  261. $config = input('','','htmlentities');
  262. $validate = \think\Loader::validate('Token');
  263. if(!$validate->check($config)){
  264. return $this->error($validate->getError());
  265. }
  266. unset($config['__token__']);
  267. $config_new['gbook'] = $config['gbook'];
  268. $config_new['comment'] = $config['comment'];
  269. $config_old = config('maccms');
  270. $config_new = array_merge($config_old, $config_new);
  271. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  272. if ($res === false) {
  273. return $this->error(lang('save_err'));
  274. }
  275. return $this->success(lang('save_ok'));
  276. }
  277. $this->assign('config', config('maccms'));
  278. $this->assign('title', lang('admin/system/configcomment/title'));
  279. return $this->fetch('admin@system/configcomment');
  280. }
  281. public function configweixin()
  282. {
  283. if (Request()->isPost()) {
  284. $config = input('','','htmlentities');
  285. $validate = \think\Loader::validate('Token');
  286. if(!$validate->check($config)){
  287. return $this->error($validate->getError());
  288. }
  289. unset($config['__token__']);
  290. $config_new['weixin'] = $config['weixin'];
  291. $config_old = config('maccms');
  292. $config_new = array_merge($config_old, $config_new);
  293. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  294. if ($res === false) {
  295. return $this->error(lang('save_err'));
  296. }
  297. return $this->success(lang('save_ok'));
  298. }
  299. $this->assign('config', config('maccms'));
  300. $this->assign('title', lang('admin/system/configweixin/title'));
  301. return $this->fetch('admin@system/configweixin');
  302. }
  303. public function configpay()
  304. {
  305. if (Request()->isPost()) {
  306. $config = input('','','htmlentities');
  307. $validate = \think\Loader::validate('Token');
  308. if(!$validate->check($config)){
  309. return $this->error($validate->getError());
  310. }
  311. unset($config['__token__']);
  312. $config_new['pay'] = $config['pay'];
  313. $config_old = config('maccms');
  314. $config_new = array_merge($config_old, $config_new);
  315. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  316. if ($res === false) {
  317. return $this->error(lang('save_err'));
  318. }
  319. return $this->success(lang('save_ok'));
  320. }
  321. $this->assign('http_type',$GLOBALS['http_type']);
  322. $this->assign('config', config('maccms'));
  323. $extends = mac_extends_list('pay');
  324. $this->assign('extends',$extends);
  325. $this->assign('title', lang('admin/system/configpay/title'));
  326. return $this->fetch('admin@system/configpay');
  327. }
  328. public function configconnect()
  329. {
  330. if (Request()->isPost()) {
  331. $config = input('','','htmlentities');
  332. $validate = \think\Loader::validate('Token');
  333. if(!$validate->check($config)){
  334. return $this->error($validate->getError());
  335. }
  336. unset($config['__token__']);
  337. $config_new['connect'] = $config['connect'];
  338. $config_old = config('maccms');
  339. $config_new = array_merge($config_old, $config_new);
  340. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  341. if ($res === false) {
  342. return $this->error(lang('save_err'));
  343. }
  344. return $this->success(lang('save_ok'));
  345. }
  346. $this->assign('config', config('maccms'));
  347. $this->assign('title', lang('admin/system/configconnect/title'));
  348. return $this->fetch('admin@system/configconnect');
  349. }
  350. public function configemail()
  351. {
  352. if (Request()->isPost()) {
  353. $config = input('','','htmlentities');
  354. $validate = \think\Loader::validate('Token');
  355. if(!$validate->check($config)){
  356. return $this->error($validate->getError());
  357. }
  358. unset($config['__token__']);
  359. $config_new['email'] = $config['email'];
  360. $config_old = config('maccms');
  361. $config_new = array_merge($config_old, $config_new);
  362. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  363. if ($res === false) {
  364. return $this->error(lang('save_err'));
  365. }
  366. return $this->success(lang('save_ok'));
  367. }
  368. $this->assign('config', config('maccms'));
  369. $extends = mac_extends_list('email');
  370. $this->assign('extends',$extends);
  371. $this->assign('title', lang('admin/system/configemail/title'));
  372. return $this->fetch('admin@system/configemail');
  373. }
  374. public function configsms()
  375. {
  376. if (Request()->isPost()) {
  377. $config = input('','','htmlentities');
  378. $validate = \think\Loader::validate('Token');
  379. if(!$validate->check($config)){
  380. return $this->error($validate->getError());
  381. }
  382. unset($config['__token__']);
  383. $config_new['sms'] = $config['sms'];
  384. $config_old = config('maccms');
  385. $config_new = array_merge($config_old, $config_new);
  386. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  387. if ($res === false) {
  388. return $this->error(lang('save_err'));
  389. }
  390. return $this->success(lang('save_ok'));
  391. }
  392. $this->assign('config', config('maccms'));
  393. $extends = mac_extends_list('sms');
  394. $this->assign('extends',$extends);
  395. $this->assign('title', lang('admin/system/configsms/title'));
  396. return $this->fetch('admin@system/configsms');
  397. }
  398. public function configapi()
  399. {
  400. if (Request()->isPost()) {
  401. $config = input('','','htmlentities');
  402. $validate = \think\Loader::validate('Token');
  403. if(!$validate->check($config)){
  404. return $this->error($validate->getError());
  405. }
  406. unset($config['__token__']);
  407. $config_new['api'] = $config['api'];
  408. $config_new['api']['vod']['auth'] = mac_replace_text($config_new['api']['vod']['auth'], 2);
  409. $config_new['api']['art']['auth'] = mac_replace_text($config_new['api']['art']['auth'], 2);
  410. $config_new['api']['actor']['auth'] = mac_replace_text($config_new['api']['actor']['auth'], 2);
  411. $config_old = config('maccms');
  412. $config_new = array_merge($config_old, $config_new);
  413. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  414. if ($res === false) {
  415. return $this->error(lang('save_err'));
  416. }
  417. return $this->success(lang('save_ok'));
  418. }
  419. $this->assign('config', config('maccms'));
  420. $this->assign('title', lang('admin/system/configapi/title'));
  421. return $this->fetch('admin@system/configapi');
  422. }
  423. public function configinterface()
  424. {
  425. if (Request()->isPost()) {
  426. $config = input('','','htmlentities');
  427. $validate = \think\Loader::validate('Token');
  428. if(!$validate->check($config)){
  429. return $this->error($validate->getError());
  430. }
  431. unset($config['__token__']);
  432. if($config['interface']['status']==1 && strlen($config['interface']['pass']) < 16){
  433. return $this->error(lang('admin/system/configinterface/pass_check'));
  434. }
  435. $config_new['interface'] = $config['interface'];
  436. $config_new['interface']['vodtype'] = mac_replace_text($config_new['interface']['vodtype'], 2);
  437. $config_new['interface']['arttype'] = mac_replace_text($config_new['interface']['arttype'], 2);
  438. $config_old = config('maccms');
  439. $config_new = array_merge($config_old, $config_new);
  440. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  441. if ($res === false) {
  442. return $this->error(lang('save_err'));
  443. }
  444. //保存缓存
  445. mac_interface_type();
  446. return $this->success(lang('save_ok'));
  447. }
  448. $this->assign('config', config('maccms'));
  449. $this->assign('title', lang('admin/system/configinterface/title'));
  450. return $this->fetch('admin@system/configinterface');
  451. }
  452. public function configcollect()
  453. {
  454. if (Request()->isPost()) {
  455. $config = input('','','htmlentities');
  456. $validate = \think\Loader::validate('Token');
  457. if(!$validate->check($config)){
  458. return $this->error($validate->getError());
  459. }
  460. unset($config['__token__']);
  461. $config_new['collect'] = $config['collect'];
  462. if (empty($config_new['collect']['vod']['inrule'])) {
  463. $config_new['collect']['vod']['inrule'] = ['a'];
  464. }
  465. if (empty($config_new['collect']['vod']['uprule'])) {
  466. $config_new['collect']['vod']['uprule'] = [];
  467. }
  468. if (empty($config_new['collect']['art']['inrule'])) {
  469. $config_new['collect']['art']['inrule'] = ['a'];
  470. }
  471. if (empty($config_new['collect']['art']['uprule'])) {
  472. $config_new['collect']['art']['uprule'] = [];
  473. }
  474. if (empty($config_new['collect']['actor']['inrule'])) {
  475. $config_new['collect']['actor']['inrule'] = ['a'];
  476. }
  477. if (empty($config_new['collect']['actor']['uprule'])) {
  478. $config_new['collect']['actor']['uprule'] = [];
  479. }
  480. if (empty($config_new['collect']['role']['inrule'])) {
  481. $config_new['collect']['role']['inrule'] = ['a'];
  482. }
  483. if (empty($config_new['collect']['role']['uprule'])) {
  484. $config_new['collect']['role']['uprule'] = [];
  485. }
  486. if (empty($config_new['collect']['website']['inrule'])) {
  487. $config_new['collect']['website']['inrule'] = ['a'];
  488. }
  489. if (empty($config_new['collect']['website']['uprule'])) {
  490. $config_new['collect']['website']['uprule'] = [];
  491. }
  492. if (empty($config_new['collect']['comment']['inrule'])) {
  493. $config_new['collect']['comment']['inrule'] = ['a'];
  494. }
  495. if (empty($config_new['collect']['comment']['uprule'])) {
  496. $config_new['collect']['comment']['uprule'] = [];
  497. }
  498. $config_new['collect']['vod']['inrule'] = ',' . join(',', $config_new['collect']['vod']['inrule']);
  499. $config_new['collect']['vod']['uprule'] = ',' . join(',', $config_new['collect']['vod']['uprule']);
  500. $config_new['collect']['art']['inrule'] = ',' . join(',', $config_new['collect']['art']['inrule']);
  501. $config_new['collect']['art']['uprule'] = ',' . join(',', $config_new['collect']['art']['uprule']);
  502. $config_new['collect']['actor']['inrule'] = ',' . join(',', $config_new['collect']['actor']['inrule']);
  503. $config_new['collect']['actor']['uprule'] = ',' . join(',', $config_new['collect']['actor']['uprule']);
  504. $config_new['collect']['role']['inrule'] = ',' . join(',', $config_new['collect']['role']['inrule']);
  505. $config_new['collect']['role']['uprule'] = ',' . join(',', $config_new['collect']['role']['uprule']);
  506. $config_new['collect']['website']['inrule'] = ',' . join(',', $config_new['collect']['website']['inrule']);
  507. $config_new['collect']['website']['uprule'] = ',' . join(',', $config_new['collect']['website']['uprule']);
  508. $config_new['collect']['comment']['inrule'] = ',' . join(',', $config_new['collect']['comment']['inrule']);
  509. $config_new['collect']['comment']['uprule'] = ',' . join(',', $config_new['collect']['comment']['uprule']);
  510. $config_new['collect']['vod']['namewords'] = mac_replace_text($config_new['collect']['vod']['namewords'], 2);
  511. $config_new['collect']['vod']['thesaurus'] = mac_replace_text($config_new['collect']['vod']['thesaurus'], 2);
  512. $config_new['collect']['vod']['words'] = mac_replace_text($config_new['collect']['vod']['words'], 2);
  513. $config_new['collect']['art']['thesaurus'] = mac_replace_text($config_new['collect']['art']['thesaurus'], 2);
  514. $config_new['collect']['art']['words'] = mac_replace_text($config_new['collect']['art']['words'], 2);
  515. $config_new['collect']['actor']['thesaurus'] = mac_replace_text($config_new['collect']['actor']['thesaurus'], 2);
  516. $config_new['collect']['actor']['words'] = mac_replace_text($config_new['collect']['actor']['words'], 2);
  517. $config_new['collect']['role']['thesaurus'] = mac_replace_text($config_new['collect']['role']['thesaurus'], 2);
  518. $config_new['collect']['role']['words'] = mac_replace_text($config_new['collect']['role']['words'], 2);
  519. $config_new['collect']['website']['thesaurus'] = mac_replace_text($config_new['collect']['website']['thesaurus'], 2);
  520. $config_new['collect']['website']['words'] = mac_replace_text($config_new['collect']['website']['words'], 2);
  521. $config_new['collect']['comment']['thesaurus'] = mac_replace_text($config_new['collect']['comment']['thesaurus'], 2);
  522. $config_new['collect']['comment']['words'] = mac_replace_text($config_new['collect']['comment']['words'], 2);
  523. $config_old = config('maccms');
  524. $config_new = array_merge($config_old, $config_new);
  525. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  526. if ($res === false) {
  527. return $this->error(lang('save_err'));
  528. }
  529. return $this->success(lang('save_ok'));
  530. }
  531. $this->assign('config', config('maccms'));
  532. $this->assign('title', lang('admin/system/configcollect/title'));
  533. return $this->fetch('admin@system/configcollect');
  534. }
  535. public function configplay()
  536. {
  537. if (Request()->isPost()) {
  538. $config = input('','','htmlentities');
  539. $validate = \think\Loader::validate('Token');
  540. if(!$validate->check($config)){
  541. return $this->error($validate->getError());
  542. }
  543. unset($config['__token__']);
  544. $config_new['play'] = $config['play'];
  545. $config_old = config('maccms');
  546. $config_new = array_merge($config_old, $config_new);
  547. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  548. if ($res === false) {
  549. return $this->error(lang('save_err'));
  550. }
  551. $path = './static/js/playerconfig.js';
  552. if (!file_exists($path)) {
  553. $path .= '.bak';
  554. }
  555. $fc = @file_get_contents($path);
  556. $jsb = mac_get_body($fc, '//参数开始', '//参数结束');
  557. $content = 'MacPlayerConfig=' . json_encode($config['play']) . ';';
  558. $fc = str_replace($jsb, "\r\n" . $content . "\r\n", $fc);
  559. $res = @fwrite(fopen('./static/js/playerconfig.js', 'wb'), $fc);
  560. if ($res === false) {
  561. return $this->error(lang('save_err'));
  562. }
  563. return $this->success(lang('save_ok'));
  564. }
  565. $fp = './static/js/playerconfig.js';
  566. if (!file_exists($fp)) {
  567. $fp .= '.bak';
  568. }
  569. $fc = file_get_contents($fp);
  570. $jsb = trim(mac_get_body($fc, '//参数开始', '//参数结束'));
  571. $jsb = substr($jsb, 16, strlen($jsb) - 17);
  572. $play = json_decode($jsb, true);
  573. $this->assign('play', $play);
  574. $this->assign('title', lang('admin/system/configplay/title'));
  575. return $this->fetch('admin@system/configplay');
  576. }
  577. public function configseo()
  578. {
  579. if (Request()->isPost()) {
  580. $config = input('','','htmlentities');
  581. $validate = \think\Loader::validate('Token');
  582. if(!$validate->check($config)){
  583. return $this->error($validate->getError());
  584. }
  585. unset($config['__token__']);
  586. $config_new['seo'] = $config['seo'];
  587. $config_old = config('maccms');
  588. $config_new = array_merge($config_old, $config_new);
  589. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  590. if ($res === false) {
  591. return $this->error(lang('save_err'));
  592. }
  593. return $this->success(lang('save_ok'));
  594. }
  595. $this->assign('config', config('maccms'));
  596. $this->assign('title', lang('admin/system/configseo/title'));
  597. return $this->fetch('admin@system/configseo');
  598. }
  599. }