System.php 27 KB

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