Vodserver.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. return $this->success(lang('save_ok'));
  48. }
  49. $info = $list[$param['id']];
  50. $this->assign('info',$info);
  51. $this->assign('title',lang('admin/vodserver/title'));
  52. return $this->fetch('admin@vodserver/info');
  53. }
  54. public function del()
  55. {
  56. $param = input();
  57. $list = config($this->_pre);
  58. unset($list[$param['ids']]);
  59. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  60. if($res===false){
  61. return $this->error(lang('del_err'));
  62. }
  63. return $this->success(lang('del_ok'));
  64. }
  65. public function field()
  66. {
  67. $param = input();
  68. $ids = $param['ids'];
  69. $col = $param['col'];
  70. $val = $param['val'];
  71. if(!empty($ids) && in_array($col,['parse_status','status'])){
  72. $list = config($this->_pre);
  73. foreach($list as $k=>&$v){
  74. $v[$col] = $val;
  75. }
  76. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  77. if($res===false){
  78. return $this->error(lang('save_err'));
  79. }
  80. return $this->success(lang('save_ok'));
  81. }
  82. return $this->error(lang('param_err'));
  83. }
  84. }