Video.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace app\admin\controller\video;
  3. use app\common\controller\Backend;
  4. /**
  5. * 会员管理
  6. *
  7. * @icon fa fa-user
  8. */
  9. class Video extends Backend
  10. {
  11. protected $relationSearch = true;
  12. /**
  13. * @var \app\admin\model\User
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = model('Video');
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags']);
  28. if ($this->request->isAjax()) {
  29. //如果发送的来源是Selectpage,则转发到Selectpage
  30. if ($this->request->request('keyField')) {
  31. return $this->selectpage();
  32. }
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $map=[];
  35. if(input('pid')){
  36. $map['video.pid']= input('pid');
  37. }
  38. $total = $this->model
  39. ->with('videolist')
  40. ->where($where)
  41. ->where($map)
  42. ->order($sort, $order)
  43. ->count();
  44. $list = $this->model
  45. ->with('videolist')
  46. ->where($where)
  47. ->where($map)
  48. ->order($sort, $order)
  49. ->limit($offset, $limit)
  50. ->select();
  51. $result = array("total" => $total, "rows" => $list);
  52. return json($result);
  53. }
  54. return $this->view->fetch();
  55. }
  56. /**
  57. * 编辑
  58. */
  59. public function edit($ids = NULL,$pid = NULL)
  60. {
  61. $row = $this->model->get($ids);
  62. if (!$row)
  63. $this->error(__('No Results were found'));
  64. if($row['lx']==1){
  65. $lx='video/mp4';
  66. $lxname='视频';
  67. }elseif ($row['lx']==2) {
  68. $lx='audio/mpeg';
  69. $lxname='音频';
  70. }elseif ($row['lx']==3){
  71. $lx='wenz';
  72. $lxname='文章';
  73. }else {
  74. $lx='';
  75. $lxname='';
  76. }
  77. $this->view->assign('lx', $lx);
  78. $this->view->assign('lxname', $lxname);
  79. $Videolist = model('Videolist')->get($pid);
  80. $this->view->assign('Videolist', $Videolist);
  81. return parent::edit($ids);
  82. }
  83. public function getsignature(){
  84. $site=config('site');
  85. $secret_id = $site['txydbapi']['secret_id'];
  86. $secret_key = $site['txydbapi']['secret_key'];
  87. // 确定签名的当前时间和失效时间
  88. $current = time();
  89. $expired = $current + 86400; // 签名有效期:1天
  90. // 向参数列表填入参数
  91. $arg_list = array(
  92. "secretId" => $secret_id,
  93. "currentTimeStamp" => $current,
  94. "expireTime" => $expired,
  95. "random" => rand());
  96. // 计算签名
  97. $original = http_build_query($arg_list);
  98. $signature = base64_encode(hash_hmac('SHA1', $original, $secret_key, true).$original);
  99. echo json_encode(['code' => '1', 'signature' => $signature]);
  100. }
  101. public function add($pid = NULL)
  102. {
  103. $Videolist = model('Videolist')->get($pid);
  104. if($Videolist['lx']==1){
  105. $lx='video/mp4';
  106. $lxname='视频';
  107. }elseif ($Videolist['lx']==2) {
  108. $lx='audio/mp3';
  109. $lxname='音频';
  110. }elseif ($Videolist['lx']==3){
  111. $lx='wenz';
  112. $lxname='文章';
  113. }else {
  114. $lx='';
  115. $lxname='';
  116. }
  117. $this->view->assign('lx', $lx);
  118. $this->view->assign('lxname', $lxname);
  119. $this->view->assign('Videolist', $Videolist);
  120. if($Videolist){
  121. return parent::add();
  122. }else{
  123. echo '请到视频管理里添加';
  124. }
  125. }
  126. }