VideoAction.class.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class VideoAction extends CommonAction{
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. require_once APP_ROOT_PATH."/admin/Lib/Action/VideoCommonAction.class.php";
  14. }
  15. /**
  16. * 在线直播列表
  17. */
  18. public function online_index()
  19. {
  20. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  21. require_once(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  22. $now=get_gmtime();
  23. if(intval($_REQUEST['cate_id'])>0)
  24. {
  25. $parameter.= "cate_id=" . intval($_REQUEST['cate_id']). "&";
  26. $sql_w .= "cate_id=".intval($_REQUEST['cate_id'])." and ";
  27. }
  28. if(intval($_REQUEST['classified_id'])>0)
  29. {
  30. $parameter.= "classified_id=" . intval($_REQUEST['classified_id']). "&";
  31. $sql_w .= "classified_id=".intval($_REQUEST['classified_id'])." and ";
  32. }
  33. if(strim($_REQUEST['nick_name'])!=''){
  34. //name
  35. $user=M("User")->where("nick_name like '%".trim($_REQUEST['nick_name'])."%' ")->findAll();
  36. foreach($user as $k=>$v){
  37. $user_arr_id[$k] =intval($v['id']);
  38. }
  39. $parameter.= "user_id in (".implode(",",$user_arr_id).")&";
  40. $sql_w .= "user_id in (".implode(",",$user_arr_id).") and ";
  41. }else if(intval($_REQUEST['user_id'])>0)
  42. {
  43. $parameter.= "user_id=" . intval($_REQUEST['user_id']). "&";
  44. $sql_w .= "user_id=".intval($_REQUEST['user_id'])." and ";
  45. }
  46. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($_REQUEST['create_time_2']);
  47. $create_time_2=to_timespan($create_time_2)+24*3600;
  48. if(trim($_REQUEST['create_time_1'])!='')
  49. {
  50. $parameter.="create_time between '". to_timespan($_REQUEST['create_time_1']) . "' and '". $create_time_2 ."'&";
  51. $sql_w .="create_time between '". to_timespan($_REQUEST['create_time_1']). "' and '". $create_time_2 ."' and ";
  52. }
  53. $parameter.= "live_in in (1,3)&";
  54. $sql_w .= "live_in in (1,3) and ";
  55. $model = D ();
  56. $sql_str = "SELECT *,".
  57. "watch_number+virtual_watch_number+robot_num as all_watch_number " .
  58. " FROM ".DB_PREFIX."video WHERE 1=1 ";
  59. $count_sql = "SELECT count(*) as tpcount FROM ".DB_PREFIX."video WHERE 1=1 ";
  60. $sql_str .= " and ".$sql_w." 1=1";
  61. $count_sql .= " and ".$sql_w." 1=1";
  62. $voList = $this->_Sql_list($model, $sql_str, "&".$parameter,'sort_num',0,$count_sql);
  63. //取洪峰观看人数
  64. foreach ($voList as &$value){
  65. if (intval($value['live_in']) == 3){
  66. $value['max_watch'] = "回播视频不显示";
  67. }else{
  68. $sql_video = "SELECT MAX(watch_number) as max_watch FROM ".DB_PREFIX."video_monitor WHERE video_id=".$value['id'];
  69. $monitor_res = $GLOBALS['db']->getRow($sql_video);//洪峰观看人数
  70. $value['max_watch'] = $monitor_res['max_watch'];
  71. if(defined('CHILD_ROOM') && CHILD_ROOM == 1){
  72. if($GLOBALS['db']->getOne("SELECT COUNT(id) FROM ".DB_PREFIX."child_room WHERE child_id=".$value['id'])) {
  73. $value['max_watch'] = "子房间视频不显示";
  74. }
  75. }
  76. }
  77. $value['pay_editable'] = 0;
  78. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1&&defined('OPEN_EDIT_VIDEO_PAY')&&OPEN_EDIT_VIDEO_PAY==1){
  79. $value['pay_editable'] = 1;
  80. if($value['is_live_pay']==1&&$value['live_pay_type']==0){
  81. $value['pay_editable'] = 0;
  82. }
  83. }
  84. }
  85. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  86. $this->assign ( 'is_pay_live', 1 );
  87. }else{
  88. $this->assign ( 'is_pay_live', 0 );
  89. }
  90. if(defined('CHILD_ROOM') && CHILD_ROOM == 1){
  91. $this->assign ( 'is_child_room', 1 );
  92. }else{
  93. $this->assign ( 'is_child_room', 0 );
  94. }
  95. $this->assign ( 'url_name', get_manage_url_name());
  96. $this->assign ( 'list', $voList );
  97. $cate_list = M("VideoCate")->findAll();
  98. $classified_list = M("VideoClassified")->findAll();
  99. $this->assign("classified_list",$classified_list);
  100. $this->assign("cate_list",$cate_list);
  101. $this->display ();
  102. }
  103. //付费设置
  104. public function set_live_pay()
  105. {
  106. fanwe_require( APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  107. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  108. $video_id = intval($_REQUEST['id']);
  109. $video_redis = new VideoRedisService($video_id);
  110. $video = $video_redis->getRow_db($video_id,array('id','is_live_pay','live_fee'));
  111. $this->assign("video",$video);
  112. $this->display();
  113. }
  114. //修改付费设置
  115. public function modify_live_pay(){
  116. $video_id = intval($_REQUEST['id']);
  117. $video['id'] = $video_id;
  118. $video['live_pay_type'] = 0;
  119. $video['live_fee'] = 0;
  120. $video['is_live_pay'] = intval($_REQUEST['is_live_pay']);//是否付费
  121. $live_fee = intval($_REQUEST['live_fee']);//观看费用
  122. if($video['is_live_pay']){
  123. $video['live_pay_type'] = 1;
  124. $video['live_fee'] = $live_fee;
  125. }
  126. if($video['live_fee'] && !preg_match('/^[0-9]*[1-9][0-9]*$/', $video['live_fee']))
  127. {
  128. $this->error("观看费用必须为大于0的整数");
  129. }
  130. $list=M("Video")->save ($video);
  131. if (false !== $list) {
  132. //redis同步
  133. require_once APP_ROOT_PATH."/mapi/lib/core/common.php";
  134. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  135. sync_video_to_redis($video_id, '*', false);
  136. save_log($video_id.L("UPDATE_SUCCESS"),1);
  137. $this->success(L("UPDATE_SUCCESS"));
  138. } else {
  139. //错误提示
  140. save_log($video_id.L("UPDATE_FAILED"),0);
  141. $this->error(L("UPDATE_SUCCESS"));
  142. }
  143. }
  144. //修改上线状态
  145. public function set_demand_video_status(){
  146. require_once APP_ROOT_PATH."/mapi/lib/core/common.php";
  147. $ajax = intval($_REQUEST['ajax']);
  148. $id = $_REQUEST['id'];
  149. $result['status'] = 0;
  150. if (isset ( $id )) {
  151. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  152. $rel_data = M('Video')->where($condition)->findAll();
  153. $success_info = array();
  154. $fail_info = array();
  155. foreach($rel_data as $data)
  156. {
  157. if ($data['live_in'] == 3){
  158. //下架
  159. $m_config = load_auto_cache("m_config");
  160. if($m_config['ios_check_version'] != ''){
  161. $sql = "select u.mobile from ".DB_PREFIX."video v left join ".DB_PREFIX."user u on u.id=v.user_id where v.id = ".$data['id'];
  162. $mobile = $GLOBALS['db']->getOne($sql,true,true);
  163. if($mobile == '13888888888' || $mobile=='13999999999'){
  164. $sql = "select count(*) from ".DB_PREFIX."video v left join ".DB_PREFIX."user u on u.id=v.user_id where v.live_in=3 and (u.mobile = '13888888888' or u.mobile = '13999999999')";
  165. $video_count = $GLOBALS['db']->getOne($sql,true,true);
  166. if(intval($video_count)<=1){
  167. $result['status'] = 0;
  168. $result['info'] = '下线失败,审核期间必须有一个审核账号的历史直播!';
  169. admin_ajax_return($result);
  170. }
  171. }
  172. }
  173. //同时下线子房间
  174. if (defined('CHILD_ROOM') && CHILD_ROOM == 1) {
  175. $this->end_child_room($data['id']);
  176. }
  177. $re = video_status($data['id'],1);
  178. }
  179. //redis 同步结束
  180. $success_info[] = $data['id'];
  181. if($re){
  182. $result['status'] = 1;
  183. }else{
  184. $fail_info[] = $data['id'];
  185. }
  186. /*}else{
  187. $fail_info[] = $data['id'];
  188. }*/
  189. }
  190. if($success_info) $success_info = implode(",",$success_info);
  191. if($fail_info) $fail_info = implode(",",$fail_info);
  192. if ($re) {
  193. save_log($success_info.l("DEMAND_VIDEO_STATUS_SUCCESS"),1);
  194. $result['info'] = '修改成功!';
  195. }else {
  196. if($success_info){
  197. save_log($success_info.l("DEMAND_VIDEO_STATUS_SUCCESS"),1);
  198. }
  199. save_log($fail_info.l("DEMAND_VIDEO_STATUS_FAILED"),0);
  200. $result['info'] = $fail_info.'修改失败!';
  201. }
  202. } else {
  203. $result['status'] = 0;
  204. $result['info'] = '编号错误';
  205. }
  206. admin_ajax_return($result);
  207. }
  208. //查看直播
  209. /*public function play_bak(){
  210. $id = $_REQUEST['id'];
  211. $condition['id'] = $id;
  212. $video = M('Video')->where($condition)->find();
  213. $this->assign("video",$video);
  214. $m_config = load_auto_cache("m_config");//初始化手机端配置
  215. $app_id = $m_config['vodset_app_id'];
  216. $this->assign('app_id',$app_id);
  217. if($video['live_in']!=1){
  218. require_once APP_ROOT_PATH."/mapi/lib/core/common.php";
  219. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  220. $root = get_vodset_by_video_id($id);
  221. if(isset($root['vodset'])){
  222. $play_list = array();
  223. $vodset = $root['vodset'];
  224. foreach($vodset as $k=>$v){
  225. $playSet = $v['fileSet'];
  226. for($i=sizeof($playSet)-1;$i>=0;$i--){
  227. $play_list[] = $playSet[$i]['fileId'];
  228. }
  229. }
  230. $this->assign("playlist",implode(',',$play_list));
  231. $this->assign("video_url",$play_list[0]);
  232. $this->assign("poster",$vodset[0]['fileSet'][sizeof($vodset[0]['fileSet'])-1]['image_url']);
  233. }else{
  234. $this->assign("error",$root['error']);
  235. }
  236. }
  237. $this->display();
  238. }*/
  239. //查看直播(web2.1播放器)
  240. public function play(){
  241. $id = $_REQUEST['id'];
  242. $condition['id'] = $id;
  243. $video = M('Video')->where($condition)->find();
  244. $m_config = load_auto_cache("m_config");//初始化手机端配置
  245. $app_id = $m_config['vodset_app_id'];
  246. $this->assign('app_id',$app_id);
  247. if($video['live_in']!=1){
  248. if($video['play_url'] !='') {
  249. $video['mp4_url'] = get_spec_image($video['play_url']);
  250. }else{
  251. require_once APP_ROOT_PATH."/mapi/lib/core/common.php";
  252. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  253. $root = get_vodset_by_video_id($id);
  254. if(isset($root['vodset'])){
  255. $play_list = array();
  256. $vodset = $root['vodset'];
  257. foreach($vodset as $k=>$v){
  258. $playSet = $v['fileSet'];
  259. for($i=sizeof($playSet)-1;$i>=0;$i--){
  260. $play_list[] = $playSet[$i]['fileId'];
  261. $play_url_list[] = $playSet[$i]['playSet'];
  262. }
  263. }
  264. foreach($play_url_list as $k2=>$v2){
  265. foreach($v2 as $kk=>$vv) {
  266. //mp4
  267. if ($vv['definition'] == 0&&strpos($vv['url'], '.mp4')) {//原画mp4 播放URL
  268. $video['mp4_url'] = $vv['url'];
  269. }
  270. if ($vv['definition'] == 10) {//手机mp4 播放URL
  271. $video['mp4_sj_url'] = $vv['url'];
  272. }
  273. if ($vv['definition'] == 20) {//标清mp4 播放URL
  274. $video['mp4_sd_url'] = $vv['url'];
  275. }
  276. if ($vv['definition'] == 40 || $vv['definition'] == 30) {//高清mp4 播放URL
  277. $video['mp4_hd_url'] = $vv['url'];
  278. }
  279. //m3u8
  280. if ($vv['definition'] == 0 &&strpos($vv['url'], '.m3u8')) {//原画m3u8 播放URL
  281. $video['m3u8_url'] = $vv['url'];
  282. }
  283. if (($vv['definition'] == 210)&&strpos($vv['url'], '.m3u8')) {//手机m3u8 播放URL
  284. $video['m3u8_url'] = $vv['url'];
  285. }
  286. if (($vv['definition'] == 220)&&strpos($vv['url'], '.m3u8')) {//标清m3u8 播放URL
  287. $video['m3u8_sd_url'] = $vv['url'];
  288. }
  289. if (($vv['definition'] == 230)&&strpos($vv['url'], '.m3u8')) {//高清m3u8 播放URL
  290. $video['m3u8_hd_url'] = $vv['url'];
  291. }
  292. //flv
  293. if (strpos($vv['url'], '.flv')&&$vv['definition'] == 0) {//原画flv 播放URL
  294. $video['flv_url'] = $vv['url'];
  295. }
  296. if (strpos($vv['url'], '.flv')&&$vv['definition'] == 0) {//手机flv 播放URL
  297. $video['flv_sj_url'] = $vv['url'];
  298. }
  299. if (strpos($vv['url'], '.flv')&&$vv['definition'] == 0) {//标清flv 播放URL
  300. $video['flv_sd_url'] = $vv['url'];
  301. }
  302. if (strpos($vv['url'], '.flv')&&$vv['definition'] == 0) {//高清flv 播放URL
  303. $video['flv_hd_url'] = $vv['url'];
  304. }
  305. //rtmp
  306. if (!strpos($vv['url'], '.flv')&&!strpos($vv['url'], '.mp4')&&!strpos($vv['url'], '.m3u8')&&$vv['definition'] == 0) {//原画rtmp 播放URL
  307. $video['rtmp_url'] = $vv['url'];
  308. }
  309. if (!strpos($vv['url'], '.flv')&&!strpos($vv['url'], '.mp4')&&!strpos($vv['url'], '.m3u8')&&$vv['definition'] == 0) {//手机rtmp 播放URL
  310. $video['rtmp_sj_url'] = $vv['url'];
  311. }
  312. if (!strpos($vv['url'], '.flv')&&!strpos($vv['url'], '.mp4')&&!strpos($vv['url'], '.m3u8')&&$vv['definition'] == 0) {//标清rtmp 播放URL
  313. $video['rtmp_sd_url'] = $vv['url'];
  314. }
  315. if (!strpos($vv['url'], '.flv')&&!strpos($vv['url'], '.mp4')&&!strpos($vv['url'], '.m3u8')&&$vv['definition'] == 0) {//高清rtmp 播放URL
  316. $video['rtmp_hd_url'] = $vv['url'];
  317. }
  318. }
  319. }
  320. $this->assign("poster",$vodset[0]['fileSet'][sizeof($vodset[0]['fileSet'])-1]['image_url']);
  321. }else{
  322. $this->assign("error",$root['error']);
  323. }
  324. }
  325. }else{
  326. //直播
  327. $video['mp4_url'] = $video['play_mp4'];
  328. $video['m3u8_url'] = $video['play_hls'];
  329. $video['flv_url'] = $video['play_flv'];
  330. $video['rtmp_url'] = $video['play_rtmp'];
  331. }
  332. $this->assign("video",$video);
  333. $this->display();
  334. }
  335. public function video_set()
  336. {
  337. fanwe_require( APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  338. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  339. $video_id = intval($_REQUEST['id']);
  340. $video_redis = new VideoRedisService($video_id);
  341. $video = $video_redis->getRow_db($video_id,array('id','virtual_number','max_robot_num','virtual_watch_number'));
  342. $this->assign("video",$video);
  343. $this->display();
  344. }
  345. public function modify_video_set(){
  346. fanwe_require( APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  347. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  348. $video_id = intval($_REQUEST['id']);
  349. $video['virtual_number'] = intval($_REQUEST['virtual_number']);//1用户带机器人最大比例
  350. $video['virtual_watch_number'] = intval($_REQUEST['virtual_watch_number']);//直接设置机器人数
  351. $video['max_robot_num'] = intval($_REQUEST['robot_num']);//最大机器人头像数
  352. $robot_num = M("User")->where("is_effect=1 and is_robot = 1")->count();
  353. if($video['robot_num']>$robot_num)
  354. {
  355. $this->error("最大机器人头像数不能大于系统机器人头像总数".$robot_num);
  356. }
  357. $video_redis = new VideoRedisService($video_id);
  358. $video_redis->update_db($video_id,$video);
  359. M(MODULE_NAME)->where("id=".$video_id)->setField("max_robot_num",$video['max_robot_num']);
  360. $video_redis->update('video_virtual_watch_number',array($video_id=> $video['virtual_watch_number']));
  361. save_log(l("ADMIN_MODIFY_ACCOUNT"),1);
  362. $this->success(L("UPDATE_SUCCESS"));
  363. }
  364. //虚拟人数列表
  365. public function list_virtual(){
  366. $video_info=M("Video")->where("id='".intval($_REQUEST['id'])."'")->find();
  367. $this->assign("video_info",$video_info);
  368. if(intval($_REQUEST['id'])>0)
  369. {
  370. $map['room_id'] = intval($_REQUEST['id']);
  371. }
  372. if (method_exists ( $this, '_filter' )) {
  373. $this->_filter ( $map );
  374. }
  375. $model = D ("VideoVirtual");
  376. if (! empty ( $model )) {
  377. $this->_list ( $model, $map );
  378. }
  379. $list = $this->get("list");
  380. $this->display ();
  381. }
  382. //添加虚拟人数
  383. public function add_virtual(){
  384. $video=M("Video")->where("id='".intval($_REQUEST['room_id'])."'")->find();
  385. $video['nick_name']=M("User")->where("id='".intval($video['user_id'])."'")->getField("nick_name");
  386. $this->assign("video",$video);
  387. $this->display ();
  388. }
  389. //编辑虚拟人数
  390. public function edit_virtual(){
  391. $id = intval($_REQUEST ['id']);
  392. $condition['id'] = $id;
  393. $vo = M('VideoVirtual')->where($condition)->find();
  394. $video=M('Video')->where("id='".intval($vo['room_id'])."'")->find();
  395. $video['nick_name']=M("User")->where("id='".intval($video['user_id'])."'")->getField("nick_name");
  396. $this->assign("video",$video);
  397. $this->assign("vo",$vo);
  398. $this->display ();
  399. }
  400. //写入
  401. public function insert_virtual(){
  402. B('FilterString');
  403. $data = M('VideoVirtual')->create ();
  404. $this->assign("jumpUrl",u(MODULE_NAME."/add_virtual",array("room_id"=>$_REQUEST['room_id'])));
  405. if(intval($data['virtual_num'])==0)
  406. {
  407. $this->error("请输入虚拟人数");
  408. }
  409. if(trim($data['plan_start_time'])=='')
  410. {
  411. $this->error("请输入开始时间");
  412. }
  413. if(intval($data['plan_end_time'])==0)
  414. {
  415. $this->error("请输入结束时间");
  416. }
  417. if(intval($data['add_type'])==1&&intval($data['interval_time'])==0)
  418. {
  419. $this->error("请输入间隔时间");
  420. }
  421. $log_info =$data['room_id']."房间虚拟列表,";
  422. $list=M('VideoVirtual')->add($data);
  423. if (false !== $list) {
  424. save_log($log_info.L("INSERT_SUCCESS"),1);
  425. $this->success(L("INSERT_SUCCESS"));
  426. }else{
  427. //错误提示
  428. save_log($log_info.L("INSERT_FAILED"),0);
  429. $this->error(L("INSERT_FAILED"));
  430. }
  431. }
  432. //更新
  433. public function update_virtual(){
  434. B('FilterString');
  435. $data = M('VideoVirtual')->create ();
  436. $this->assign("jumpUrl",u(MODULE_NAME."/edit_virtual",array("id"=>$data['id'])));
  437. if(intval($data['virtual_num'])==0)
  438. {
  439. $this->error("请输入虚拟人数");
  440. }
  441. if(trim($data['plan_start_time'])=='')
  442. {
  443. $this->error("请输入开始时间");
  444. }
  445. if(intval($data['plan_end_time'])==0)
  446. {
  447. $this->error("请输入结束时间");
  448. }
  449. if(intval($data['add_type'])==1&&intval($data['interval_time'])==0)
  450. {
  451. $this->error("请输入间隔时间");
  452. }
  453. $log_info =$data['room_id']."房间虚拟列表,";
  454. $list=M('VideoVirtual')->save ($data);
  455. if (false !== $list) {
  456. save_log($log_info.L("UPDATE_SUCCESS"),1);
  457. $this->success(L("UPDATE_SUCCESS"));
  458. }else{
  459. //错误提示
  460. save_log($log_info.L("UPDATE_FAILED"),0);
  461. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  462. }
  463. }
  464. public function del_virtual(){
  465. $id = $_REQUEST ['id'];
  466. $ajax = 1;
  467. if (isset ( $id )) {
  468. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  469. $rel_data = M("VideoVirtual")->where($condition)->findAll();
  470. foreach($rel_data as $data)
  471. {
  472. $room_id = $data['room_id'];
  473. $info[] = $data['id'];
  474. }
  475. if($info) $info = implode(",",$info);
  476. $info = "房间ID".$room_id."的虚拟人数:".$info;
  477. $list = M("VideoVirtual")->where ( $condition )->delete();
  478. if ($list!==false) {
  479. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  480. $result['info'] = "删除成功!";
  481. $result['status'] = 1;
  482. admin_ajax_return($result);
  483. } else {
  484. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  485. $result['info'] = "删除失败!";
  486. $result['status'] = 0;
  487. admin_ajax_return($result);
  488. }
  489. } else {
  490. $this->error (l("INVALID_OPERATION"),$ajax);
  491. }
  492. }
  493. function push_anchor(){
  494. $room_id = $_REQUEST ['id'];
  495. //创建直播推送消息
  496. $video = $GLOBALS['db']->getRow("select v.title,v.city,u.id as user_id,u.nick_name,u.head_image from ".DB_PREFIX."video as v left join ".DB_PREFIX."user as u on u.id=v.user_id where v.id=".$room_id);
  497. if($video){
  498. $pushdata = array(
  499. 'user_id' =>$video['user_id'], //'主播ID',
  500. 'nick_name' => $video['nick_name'],//'主播昵称',
  501. 'create_time' =>NOW_TIME, //'创建时间',
  502. 'cate_title' =>$video['title'],// '直播主题',
  503. 'room_id' =>$room_id,// '房间ID',
  504. 'city' =>$video['city'],// '直播城市地址',
  505. 'head_image' =>$video['head_image'],
  506. 'status' =>0, //'推送状态(0:未推送,1:推送中;2:已推送)'
  507. );
  508. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."push_anchor", $pushdata,'INSERT');
  509. if ($list!==false) {
  510. save_log('推送'.$video['nick_name'].'给粉丝',1);
  511. $this->success ('推送成功',1);
  512. } else {
  513. save_log('推送'.$video['nick_name'].'给粉丝',0);
  514. $this->error ('推送成功',1);
  515. }
  516. }
  517. }
  518. function push_anchor_all(){
  519. $room_id = $_REQUEST ['id'];
  520. //创建直播推送消息
  521. $video = $GLOBALS['db']->getRow("select v.title,v.city,u.id as user_id,u.nick_name,u.head_image from ".DB_PREFIX."video as v left join ".DB_PREFIX."user as u on u.id=v.user_id where v.id=".$room_id);
  522. if($video){
  523. $pushdata = array(
  524. 'user_id' =>$video['user_id'], //'主播ID',
  525. 'nick_name' => $video['nick_name'],//'主播昵称',
  526. 'create_time' =>NOW_TIME, //'创建时间',
  527. 'cate_title' =>$video['title'],// '直播主题',
  528. 'room_id' =>$room_id,// '房间ID',
  529. 'city' =>$video['city'],// '直播城市地址',
  530. 'head_image' =>$video['head_image'],
  531. 'status' =>0, //'推送状态(0:未推送,1:推送中;2:已推送)'
  532. 'pust_type' =>1,
  533. );
  534. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."push_anchor", $pushdata,'INSERT');
  535. if ($list!==false) {
  536. save_log('推送'.$video['nick_name'].'到全服',1);
  537. $this->success ('推送成功',1);
  538. } else {
  539. save_log('推送'.$video['nick_name'].'到全服',0);
  540. $this->error ('推送成功',1);
  541. }
  542. }
  543. }
  544. //关闭房间
  545. function close_live(){
  546. $common = new VideoCommon();
  547. $data = $_REQUEST;
  548. $common->close_live($data);
  549. }
  550. //禁言
  551. public function forbid(){
  552. $id = $_REQUEST['id'];
  553. $video = M("Video")->getById($id);
  554. $this->assign("video",$video);
  555. if($video){
  556. $map['group_id'] = $video['group_id'];
  557. if(strim($_REQUEST['nick_name'])!=''){//name
  558. $user=M("User")->where("nick_name='".strim($_REQUEST['nick_name'])."'")->find();
  559. $map['user_id'] = intval($user['id']);
  560. }
  561. if (method_exists ( $this, '_filter' )) {
  562. $this->_filter ( $map );
  563. }
  564. $model = D ("VideoForbidSendMsg");
  565. if (! empty ( $model )) {
  566. $this->_list ( $model, $map );
  567. }
  568. }
  569. $this->display ();
  570. }
  571. //删除禁言
  572. public function del_forbid_list(){
  573. $ajax = intval($_REQUEST['ajax']);
  574. $id = $_REQUEST ['id'];
  575. if (isset ( $id )) {
  576. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  577. $rel_data = M("VideoForbidSendMsg")->where($condition)->findAll();
  578. foreach($rel_data as $data)
  579. {
  580. $deal_id = $data['group_id'];
  581. $info[] = $data['user_id'];
  582. }
  583. if($info) $info = implode(",",$info);
  584. $info = "群组ID".$deal_id."的禁言主播:".$info;
  585. $list = M("VideoForbidSendMsg")->where ( $condition )->delete();
  586. if ($list!==false) {
  587. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  588. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  589. } else {
  590. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  591. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  592. }
  593. } else {
  594. $this->error (l("INVALID_OPERATION"),$ajax);
  595. }
  596. }
  597. public function set_sort()
  598. {
  599. $id = intval($_REQUEST['id']);
  600. $sort = intval($_REQUEST['sort']);
  601. $name=$this->getActionName();
  602. $log_info = M($name)->where("id=".$id)->find();
  603. //print_r($log_info['user_id']);
  604. if(!check_sort($sort))
  605. {
  606. $this->error(l("SORT_FAILED"),1);
  607. }
  608. M("Video")->where("id=".$id)->setField("sort",$sort);
  609. //print_r(M($name)->GetLastSql());
  610. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  611. require_once APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php';
  612. $video_redis = new VideoRedisService($log_info['user_id']);
  613. //print_r($video_redis);
  614. //更新视频排序信息
  615. $return = $video_redis->update_video_sort($log_info['id'],$sort);
  616. save_log($log_info['title'].l("SORT_SUCCESS"),1);
  617. //clear_auto_cache("get_help_cache");
  618. $this->success(l("SORT_SUCCESS"),1);
  619. }
  620. //设置推荐
  621. public function set_recommend()
  622. {
  623. $id = intval($_REQUEST['id']);
  624. $recommend= intval($_REQUEST['recommend']);
  625. $name=$this->getActionName();
  626. //$log_info = M($name)->where("id=".$id)->find();
  627. $c_is_effect = M($name)->where("id=".$id)->getField("is_recommend"); //当前状态
  628. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  629. $result=M($name)->where("id=".$id)->setField("is_recommend",$n_is_effect);
  630. save_log("房间号".$id.l("SET_RECOMMEND_".$n_is_effect),1);
  631. $this->ajaxReturn($n_is_effect,l("SET_BAN_".$n_is_effect),1);
  632. }
  633. //设备信息
  634. public function equipment_info(){
  635. $id = intval($_REQUEST['id']);
  636. $video = M("Video")->getById($id);
  637. $user = M("User")->getById($video['user_id']);
  638. $user['nick_name'] = emoji_decode($user['nick_name']);
  639. $sql = "SELECT column_name FROM information_schema.columns WHERE TABLE_SCHEMA = '".$GLOBALS['db_config']['DB_NAME']."' and TABLE_NAME = 'fanwe_video_monitor' and (column_name = 'appCPURate' or column_name = 'sysCPURate' or column_name = 'sendKBps' or column_name = 'recvKBps' or column_name = 'sendLossRate' or column_name = 'fps' or column_name = 'device')";
  640. $columns_info = $GLOBALS['db']->getAll($sql);
  641. $columns_arr = array();
  642. foreach($columns_info as $val){
  643. if(!in_array($val['column_name'],$columns_arr)){
  644. $columns_arr[] = $val['column_name'];
  645. }
  646. }
  647. $info =$GLOBALS['db']->getAll("SELECT watch_number,vote_number,appCPURate,sysCPURate,sendKBps,recvKBps,sendLossRate,fps,monitor_time FROM ".DB_PREFIX."video_monitor WHERE video_id=".$id);
  648. $count =$GLOBALS['db']->getOne("SELECT count(monitor_time) FROM ".DB_PREFIX."video_monitor WHERE video_id=".$id);
  649. if($info){
  650. foreach($info as $k=>$v){
  651. $watch[$k] =$info[$k]['watch_number'];
  652. $vote_numberarray[$k] =$info[$k]['vote_number'];
  653. $appCPUarray[$k] =$info[$k]['appCPURate'];
  654. $sysCPUarray[$k] =$info[$k]['sysCPURate'];
  655. $sendKBpsarray[$k] =$info[$k]['sendKBps'];
  656. $recvKBpsarray[$k] =$info[$k]['recvKBps'];
  657. $sendLossRatearray[$k] =$info[$k]['sendLossRate'];
  658. $fpsarray[$k] =$info[$k]['fps'];
  659. $monitor_time[$k] =$info[$k]['monitor_time'];
  660. }
  661. }
  662. $timesql =$GLOBALS['db']->getCol("SELECT monitor_time FROM ".DB_PREFIX."video_monitor WHERE video_id=".$id,true,true);
  663. foreach($timesql as $k=>$v){
  664. $timesql[$k] = date('H:i:s',strtotime($v));
  665. }
  666. $watch_number = implode ( ',',$watch);
  667. $vote_number = implode ( ',',$vote_numberarray);
  668. $appCPURate = implode ( ',',$appCPUarray);
  669. $sysCPURate = implode ( ',',$sysCPUarray);
  670. $sendKBps = implode ( ',',$sendKBpsarray);
  671. $recvKBps = implode ( ',',$recvKBpsarray);
  672. $sendLossRate = implode ( ',',$sendLossRatearray);
  673. $fps = implode ( ',',$fpsarray);
  674. $monitor_time = implode ( ',',$timesql);
  675. if($count>15){
  676. $limit = ceil(count($appCPUarray)/20); //间隔
  677. $appCPU = array();
  678. for($i=0;$i<count($appCPUarray);$i+=$limit){
  679. $appCPU[] = $appCPUarray[$i];
  680. }
  681. $appCPURate = implode ( ',',$appCPU);
  682. for($i=0;$i<count($timesql);$i+=$limit){
  683. $timearray[] = $timesql[$i];
  684. }
  685. $monitor_time = implode(',', $timearray);
  686. $sysCPU = array();
  687. for($i=0;$i<count($sysCPUarray);$i+=$limit){
  688. $sysCPU[] = $sysCPUarray[$i];
  689. }
  690. $sysCPURate = implode ( ',',$sysCPU);
  691. $send = array();
  692. for($i=0;$i<count($sendKBpsarray);$i+=$limit){
  693. $send[] = $sendKBpsarray[$i];
  694. }
  695. $sendKBps = implode ( ',',$send);
  696. $recv = array();
  697. for($i=0;$i<count($recvKBpsarray);$i+=$limit){
  698. $recv[] = $recvKBpsarray[$i];
  699. }
  700. $recvKBps = implode ( ',',$recv);
  701. $sendLoss = array();
  702. for($i=0;$i<count($sendLossRatearray);$i+=$limit){
  703. $sendLoss[] = $sendLossRatearray[$i];
  704. }
  705. $sendLossRate = implode ( ',',$sendLoss);
  706. $FPS = array();
  707. for($i=0;$i<count($fpsarray);$i+=$limit){
  708. $FPS[] = $fpsarray[$i];
  709. }
  710. $fps = implode ( ',',$FPS);
  711. $watch_num = array();
  712. for($i=0;$i<count($watch);$i+=$limit){
  713. $watch_num[] = $watch[$i];
  714. }
  715. $watch_number = implode ( ',',$watch_num);
  716. $vote_num = array();
  717. for($i=0;$i<count($vote_numberarray);$i+=$limit){
  718. $vote_num[] = $vote_numberarray[$i];
  719. }
  720. $vote_number = implode ( ',',$vote_num);
  721. }
  722. //设备型号
  723. if(in_array('appCPURate',$columns_arr)){
  724. $device =$GLOBALS['db']->getOne("SELECT device FROM ".DB_PREFIX."video_monitor WHERE video_id=".$id,true,true);
  725. }
  726. $this->assign("monitor_time",$monitor_time);
  727. $this->assign("vote_number",$vote_number);
  728. $this->assign("watch_number",$watch_number);
  729. $this->assign("appCPURate",$appCPURate);
  730. $this->assign("sysCPURate",$sysCPURate);
  731. $this->assign("sendKBps",$sendKBps);
  732. $this->assign("recvKBps",$recvKBps);
  733. $this->assign("sendLossRate",$sendLossRate);
  734. $this->assign("fps",$fps);
  735. $this->assign("device",$device);
  736. $this->assign("user",$user);
  737. $this->display ();
  738. }
  739. public function set_hot_on()
  740. {
  741. $id = intval($_REQUEST['id']);
  742. $ajax = intval($_REQUEST['ajax']);
  743. $user_info = M("User")->getById($id);
  744. $c_is_effect = M("User")->where("id=".$id)->getField("is_hot_on"); //当前状态
  745. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  746. $result=M("User")->where("id=".$id)->setField("is_hot_on",$n_is_effect);
  747. $user_data = array();
  748. if($result){
  749. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  750. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  751. $user_redis = new UserRedisService();
  752. $user_data['is_hot_on'] = $n_is_effect;
  753. $user_redis->update_db($id, $user_data);
  754. }
  755. save_log($user_info['nick_name'].l("SET_HOT_ON_".$n_is_effect),1);
  756. $this->ajaxReturn($n_is_effect,l("SET_HOT_ON_".$n_is_effect),1);
  757. }
  758. //推流地址
  759. public function push_url()
  760. {
  761. $video_id = intval($_REQUEST['id']);
  762. $push_url_info =$GLOBALS['db']->getRow("SELECT id,push_rtmp,play_flv,play_rtmp,play_mp4,play_hls FROM ".DB_PREFIX."video WHERE id=".$video_id,true,true);
  763. $this->assign("push_url",$push_url_info);
  764. $this->display();
  765. }
  766. public function add()
  767. {
  768. $send_user = M("User")->where("is_admin=1 ")->findAll();
  769. $this->assign ( 'send_user', $send_user );
  770. $this->display();
  771. }
  772. public function insert(){
  773. fanwe_require( APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  774. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  775. $video_redis = new VideoRedisService();
  776. $user_id = intval($_REQUEST['send_user_id']);
  777. $prop_id = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."prop where name='红包'");
  778. if(!$prop_id){
  779. $this->error('道具列表中不存在红包礼物,请添加后再发送');
  780. }
  781. $num = intval($_REQUEST['num']);//礼物数量
  782. $is_plus =0;
  783. $video_id = intval($_REQUEST['room_id']);;//直播ID 也是room_id
  784. $prop = load_auto_cache("prop_id",array('id'=>$prop_id));
  785. $prop['diamonds'] =intval($_REQUEST['diamonds']);
  786. $prop['score'] =intval($_REQUEST['diamonds']);
  787. $prop['ticket'] =0;
  788. $prop['robot_diamonds'] =0;
  789. if ($num <= 0) $num = 1;
  790. $total = $num * $prop['diamonds'];
  791. $total_ticket = intval($num * $prop['ticket']);
  792. $robot_diamonds = intval($prop['robot_diamonds']);
  793. $send_diamonds=$GLOBALS['db']->getone("select diamonds from ".DB_PREFIX."user where id =".$user_id);
  794. if($send_diamonds<$prop['diamonds']){
  795. $this->error('发送人钻石数量必须大于红包大小');
  796. }
  797. if($_REQUEST['send_type']==2){
  798. $all = array_unique(preg_split("/[\s]+/", $_REQUEST['room_id']));
  799. $al = implode(",", $all);
  800. $video = $GLOBALS['db']->getCol("select id from " . DB_PREFIX ."video where live_in = 1 or live_in =3");
  801. $video_string = implode(",",$video);
  802. for ($i=0;$i<count($all);$i++){
  803. if(strpos($video_string,$all[$i])!== false){
  804. }else{
  805. $this->error('您输入的房间号不存在,请确认后重新输入');
  806. }
  807. }
  808. }else {
  809. $all = $GLOBALS['db']->getCol("select id from " . DB_PREFIX ."video where live_in = 1 or live_in =3");
  810. $al = implode(",", $all);
  811. if (empty($all)) {
  812. $this->error('当前没有正在直播的房间,请重新确认');
  813. }
  814. }
  815. if($prop['diamonds']<count($all)){
  816. $this->error('红包大小不能小于直播间数量');
  817. }
  818. $watch_number= $GLOBALS['db']->getone("select sum(watch_number) from ".DB_PREFIX."video where id in($al)");
  819. $watch_number= $watch_number+count($all);
  820. foreach ($all as $k => $v) {
  821. if($_REQUEST['send_type']==2){
  822. $group_id = M("Video")->where("id=" . $v)->getField("group_id");
  823. $video_id =M("Video")->where("id=" . $v)->getField("id");
  824. $robot_num = M("Video")->where("id=" . $v)->getField("watch_number");
  825. }else{
  826. $group_id = M("Video")->where("id=" . $v)->getField("group_id");
  827. $video_id =M("Video")->where("id=" . $v)->getField("id");
  828. $robot_num = M("Video")->where("id=" . $v)->getField("watch_number");
  829. }
  830. $video = $video_redis->getRow_db($video_id,array('id','user_id','group_id','prop_table','room_type'));
  831. $podcast_id = intval($video['user_id']);//送给谁,有群组ID(group_id),除了红包外其它的都是送给:群主
  832. $room_type = intval($video['room_type']);//直播间类型 房间类型 : 1私有群(Private),0公开群(Public),2聊天室(ChatRoom),3互动直播聊天室(AVChatRoom)
  833. $total_diamonds =round(($robot_num+1)/$watch_number*$total);
  834. if(($send_diamonds-$total_diamonds)<$total_diamonds){
  835. $total_diamonds = intval(($robot_num+1)/$watch_number*$total);
  836. }
  837. if($video['room_type'] == 1){
  838. $total_score =0;
  839. }else{
  840. $total_score =$total_diamonds;
  841. }
  842. $from='app';//判断发送来源 pc或者app
  843. fanwe_require (APP_ROOT_PATH.'mapi/lib/deal.action.php');
  844. $ba=new dealModule();
  845. $ba->pack_prop($video['prop_table'],$video_redis,$total_diamonds,$total_score,$total_ticket,$num,$prop,$is_plus,$video_id,$user_id,$prop_id,$podcast_id,$group_id,$room_type,$from,$robot_diamonds);
  846. }
  847. // elseif($_REQUEST['send_type']==0) {
  848. //
  849. // $all= $GLOBALS['db']->getCol("select group_id from ".DB_PREFIX."video where live_in=1");
  850. // $al = implode(",", $all);
  851. // if(empty($all)){
  852. // $this->error('当前没有正在直播的房间,请重新确认');
  853. // }else{
  854. // $watch_number= $GLOBALS['db']->getone("select sum(robot_num) from ".DB_PREFIX."video where id in($al)");
  855. //
  856. // if($watch_number){
  857. // foreach ($all as $k => $v) {
  858. // $group_id = M("Video")->where("group_id=" . $v)->getField("group_id");
  859. // $video_id =$group_id;
  860. // $robot_num = M("Video")->where("group_id=" . $group_id)->getField("robot_num");
  861. // $total_diamonds = ceil($robot_num/$watch_number*$total);
  862. // fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/VideoRedisService.php');
  863. // $video_redis = new VideoRedisService();
  864. // $video = $video_redis->getRow_db($video_id, array('id', 'user_id', 'group_id', 'prop_table'));
  865. // $podcast_id = intval($video['user_id']);//送给谁,有群组ID(group_id),除了红包外其它的都是送给:群主
  866. // $room_type = intval($video['room_type']);//直播间类型 房间类型 : 1私有群(Private),0公开群(Public),2聊天室(ChatRoom),3互动直播聊天室(AVChatRoom)
  867. // $from = strim($_REQUEST['from']);//判断发送来源 pc或者app
  868. // $pInTrans = $GLOBALS['db']->StartTrans();
  869. // fanwe_require(APP_ROOT_PATH . 'mapi/lib/deal.action.php');
  870. // $ba = new dealModule();
  871. // $ba->pack_prop($pInTrans, $total_diamonds, $total_score, $total_ticket, $num, $prop, $is_plus, $video_id,$user_id, $prop_id, $podcast_id, $group_id, $room_type, $from, $robot_diamonds);
  872. //
  873. // }
  874. // }
  875. // }
  876. //
  877. //
  878. //
  879. // }
  880. //成功提示
  881. save_log($total_diamonds.L("INSERT_SUCCESS"),1);
  882. $this->success(L("INSERT_SUCCESS"));
  883. }
  884. //手动置顶
  885. public function stick(){
  886. $room_id = $_REQUEST['id'];
  887. $sort_init =$GLOBALS['db']->getRow("select sort_init,stick from ".DB_PREFIX."video where id =".$room_id);
  888. $where = 'id='.$room_id;
  889. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  890. require_once APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php';
  891. $video_redis = new VideoRedisService();
  892. $data['stick'] = 1;
  893. $info = '';
  894. if($sort_init['stick']==1) {
  895. $data['stick'] = 0;
  896. $info = '取消';
  897. }
  898. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."video",$data,'UPDATE',$where);
  899. if ($list!==false) {
  900. $video_redis->update_db($room_id, $data);
  901. $this->success ($info.'置顶成功',1);
  902. }else{
  903. $this->error ($info.'置顶失败',1);
  904. }
  905. }
  906. public function end_child_room($id)
  907. {
  908. $data = $GLOBALS['db']->getAll("SELECT child_id FROM " . DB_PREFIX . "child_room WHERE parent_id =" . $id);
  909. if (empty($data)) {
  910. return;
  911. }
  912. $child_ids = implode(',', array_column($data, 'child_id'));
  913. $child_video = $GLOBALS['db']->getAll("SELECT id,user_id,max_watch_number,virtual_watch_number,robot_num,vote_number,group_id,room_type,begin_time,end_time,channelid,cate_id,video_vid FROM " . DB_PREFIX . "video WHERE id in (" . $child_ids . ")");
  914. foreach ($child_video as $value) {
  915. video_status($value['id'], 1);
  916. }
  917. }
  918. public function set_video_code(){
  919. if(!defined('CHILD_ROOM') || CHILD_ROOM != 1){
  920. $this->error ('功能未开启');
  921. }
  922. $room_id = intval($_REQUEST['id']);
  923. $data = M('EduVideoInfo')->where('video_id ='.$room_id)->find();
  924. $this->assign('room_id',$room_id);
  925. $this->assign('video',$data);
  926. $this->display();
  927. }
  928. public function modify_video_code(){
  929. if(!defined('CHILD_ROOM') || CHILD_ROOM != 1){
  930. $this->error ('功能未开启');
  931. }
  932. $room_id = intval($_REQUEST['id']);
  933. $video_code = strim($_REQUEST['video_code']);
  934. $is_verify = 0;
  935. //开始验证有效性
  936. $this->assign("jumpUrl", u(MODULE_NAME . "/online_index"));
  937. //判断是否是直播状态
  938. $is_live = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . DB_PREFIX . "video WHERE live_in in (1,3) AND id =" . $room_id);
  939. if(!$is_live){
  940. $this->error ('直播间状态不符');
  941. }
  942. //edu_video插入教育直播数据
  943. $edu_video_data['video_id'] = $room_id;
  944. $edu_video_data['deal_id'] = 0;
  945. $edu_video_data['edu_cate_id'] = 0;
  946. $edu_video_data['tags'] = '';
  947. $edu_video_data['video_code'] = $video_code;
  948. $edu_video_data['is_verify'] = $is_verify;
  949. $edu_video_data['booking_class_id'] = 0;
  950. $is_set = $GLOBALS['db']->getOne("SELECT COUNT(video_id) FROM " . DB_PREFIX . "edu_video_info WHERE video_id =" . $room_id);
  951. $data['title'] = '';
  952. if ($video_code != '') {
  953. if (!preg_match("/^[A-Za-z0-9]+$/", $video_code)) {
  954. $this->error('验证码只能是字母和数字');
  955. }
  956. $edu_video_data['is_verify'] = 1;
  957. $data['title'] = "验证码直播";
  958. $cate_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "video_cate where title='" . $data['title'] . "'",
  959. true, true);
  960. if ($cate_id) {
  961. $is_newtitle = 0;
  962. } else {
  963. $is_newtitle = 1;
  964. }
  965. if ($is_newtitle) {
  966. $data_cate = array();
  967. $data_cate['title'] = $data['title'];
  968. $data_cate['is_effect'] = 1;
  969. $data_cate['is_delete'] = 0;
  970. $data_cate['create_time'] = NOW_TIME;
  971. $GLOBALS['db']->autoExecute(DB_PREFIX . "video_cate", $data_cate, 'INSERT');
  972. $cate_id = $GLOBALS['db']->insert_id();
  973. }
  974. $data['cate_id'] = $cate_id;
  975. }
  976. if ($GLOBALS['db']->autoExecute(DB_PREFIX . "video", $data, 'UPDATE', 'id =' . $room_id)) {
  977. require_once APP_ROOT_PATH . "/mapi/lib/core/common.php";
  978. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  979. sync_video_to_redis($room_id, '*', false);
  980. }
  981. if ($is_set) {
  982. if ($GLOBALS['db']->autoExecute(DB_PREFIX . "edu_video_info", $edu_video_data, 'UPDATE',
  983. 'video_id =' . $room_id)
  984. ) {
  985. $this->success ('设置成功');
  986. }else{
  987. $this->error('设置失败');
  988. }
  989. } else {
  990. if ($GLOBALS['db']->autoExecute(DB_PREFIX . "edu_video_info", $edu_video_data, 'INSERT')) {
  991. $this->success ('设置成功');
  992. }else{
  993. $this->error('设置失败');
  994. }
  995. }
  996. }
  997. }
  998. ?>