System.php 31 KB

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