System.php 28 KB

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