Vodserver.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class VodServer extends Base
  5. {
  6. var $_pre;
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->_pre = 'vodserver';
  11. }
  12. public function index()
  13. {
  14. $list = config($this->_pre);
  15. $this->assign('list',$list);
  16. $this->assign('title',lang('admin/vodserver/title'));
  17. return $this->fetch('admin@vodserver/index');
  18. }
  19. public function info()
  20. {
  21. $param = input();
  22. $list = config($this->_pre);
  23. if (Request()->isPost()) {
  24. $validate = \think\Loader::validate('Token');
  25. if(!$validate->check($param)){
  26. return $this->error($validate->getError());
  27. }
  28. unset($param['__token__']);
  29. unset($param['flag']);
  30. if(is_numeric($param['from'])){
  31. $param['from'] .='_';
  32. }
  33. if (strpos($param['from'], '.') !== false || strpos($param['from'], '/') !== false || strpos($param['from'], '\\') !== false) {
  34. $this->error(lang('param_err'));
  35. return;
  36. }
  37. $list[$param['from']] = $param;
  38. $sort=[];
  39. foreach ($list as $k=>&$v){
  40. $sort[] = $v['sort'];
  41. }
  42. array_multisort($sort, SORT_DESC, SORT_FLAG_CASE , $list);
  43. $res = mac_arr2file( APP_PATH .'extra/'.$this->_pre.'.php', $list);
  44. if($res===false){
  45. return $this->error(lang('save_err'));
  46. }
  47. cache('cache_data','1');
  48. return $this->success(lang('save_ok'));
  49. }
  50. $info = $list[$param['id']];
  51. $this->assign('info',$info);
  52. $this->assign('title',lang('admin/vodserver/title'));
  53. return $this->fetch('admin@vodserver/info');
  54. }
  55. public function del()
  56. {
  57. $param = input();
  58. $list = config($this->_pre);
  59. unset($list[$param['ids']]);
  60. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  61. if($res===false){
  62. return $this->error(lang('del_err'));
  63. }
  64. cache('cache_data','1');
  65. return $this->success(lang('del_ok'));
  66. }
  67. public function field()
  68. {
  69. $param = input();
  70. $ids = $param['ids'];
  71. $col = $param['col'];
  72. $val = $param['val'];
  73. if(!empty($ids) && in_array($col,['parse_status','status'])){
  74. $list = config($this->_pre);
  75. foreach($list as $k=>&$v){
  76. $v[$col] = $val;
  77. }
  78. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  79. if($res===false){
  80. return $this->error(lang('save_err'));
  81. }
  82. return $this->success(lang('save_ok'));
  83. }
  84. return $this->error(lang('param_err'));
  85. }
  86. }