Voddowner.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class VodDowner extends Base
  5. {
  6. var $_pre;
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->_pre = 'voddowner';
  11. }
  12. public function index()
  13. {
  14. $list = config($this->_pre);
  15. $this->assign('list',$list);
  16. $this->assign('title',lang('admin/voddowner/title'));
  17. return $this->fetch('admin@voddowner/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. $list[$param['from']] = $param;
  34. $sort=[];
  35. foreach ($list as $k=>&$v){
  36. $sort[] = $v['sort'];
  37. }
  38. array_multisort($sort, SORT_DESC, SORT_FLAG_CASE , $list);
  39. $res = mac_arr2file( APP_PATH .'extra/'.$this->_pre.'.php', $list);
  40. if($res===false){
  41. return $this->error(lang('save_err'));
  42. }
  43. return $this->success(lang('save_ok'));
  44. }
  45. $info = $list[$param['id']];
  46. $this->assign('info',$info);
  47. $this->assign('title',lang('admin/voddowner/title'));
  48. return $this->fetch('admin@voddowner/info');
  49. }
  50. public function del()
  51. {
  52. $param = input();
  53. $list = config($this->_pre);
  54. unset($list[$param['ids']]);
  55. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  56. if($res===false){
  57. return $this->error(lang('del_err'));
  58. }
  59. return $this->success(lang('del_ok'));
  60. }
  61. public function field()
  62. {
  63. $param = input();
  64. $ids = $param['ids'];
  65. $col = $param['col'];
  66. $val = $param['val'];
  67. if(!empty($ids) && in_array($col,['ps','status'])){
  68. $list = config($this->_pre);
  69. $ids = explode(',',$ids);
  70. foreach($list as $k=>&$v){
  71. if(in_array($k,$ids)){
  72. $v[$col] = $val;
  73. }
  74. }
  75. $res = mac_arr2file(APP_PATH. 'extra/'.$this->_pre.'.php', $list);
  76. if($res===false){
  77. return $this->error(lang('save_err'));
  78. }
  79. return $this->success(lang('save_ok'));
  80. }
  81. return $this->error(lang('param_err'));
  82. }
  83. }