player.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_class('admin', 'admin', 0);
  4. pc_base::load_app_func('global', 'video');
  5. class player extends admin {
  6. public function __construct() {
  7. parent::__construct();
  8. $this->userid = $_SESSION['userid'];
  9. pc_base::load_app_class('ku6api', 'video', 0);
  10. $this->setting = getcache('video');
  11. if(empty($this->setting['sn']) || empty($this->setting['skey'])) {
  12. header("Location: ".APP_PATH."index.php?m=video&c=video&a=open&meunid=".$_GET['meunid'].'&pc_hash='.$_GET['pc_hash']);
  13. }
  14. $this->ku6api = new ku6api($this->setting['sn'], $this->setting['skey']);
  15. if(!$this->ku6api->testapi()) {
  16. header("Location: ".APP_PATH."index.php?m=video&c=video&a=open&meunid=".$_GET['meunid'].'&pc_hash='.$_GET['pc_hash']);
  17. }
  18. }
  19. /**
  20. *
  21. * 视频列表
  22. */
  23. public function init() {
  24. $infos = $this->player_list(1);
  25. include $this->admin_tpl('player_list');
  26. }
  27. /**
  28. * function edit
  29. * 修改播放器属性
  30. */
  31. public function edit() {
  32. if (isset($_POST['dosubmit'])) {
  33. if(in_array($_POST['field'],array('default','auto','replay','share','show_elite','ssv'))) {
  34. if(preg_match('/([a-z0-9_\-\.])/i',$_POST['style'])) {
  35. if ($return = $this->ku6api->player_edit($_POST['field'],$_POST['style'])) {
  36. echo $return['data'][$_POST['field']];
  37. $this->player_list();
  38. }
  39. }
  40. }
  41. }
  42. }
  43. private function player_list($return_data = 0) {
  44. $infos = $this->ku6api->player_list();
  45. $infos = $infos['data'];
  46. $player_caches = array();
  47. foreach($infos as $info) {
  48. if($info['default']==1) {
  49. $player_caches[$info['channelid']]['default'] = $info['style'];
  50. }
  51. $player_caches[$info['channelid']]['STY-'.$info['style']] = $info;
  52. }
  53. setcache('player',$player_caches,'video');
  54. if($return_data) return $infos;
  55. /*
  56. 1=>array(
  57. 'default'=> 'idZwHK_aOJ7E-oGT',
  58. 'STY-idZwHK_aOJ7E-oGT'=> array('auto'=>1),
  59. 'STY-7i8TjPi7A3o.'=> array(),
  60. ),
  61. */
  62. }
  63. }
  64. ?>