System.php 26 KB

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