System.php 29 KB

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