app.action.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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 appModule extends baseModule
  10. {
  11. /**
  12. * 初始化接口
  13. */
  14. public function init()
  15. {
  16. //客服端手机类型dev_type=android;dev_type=ios
  17. $dev_type = strim($_REQUEST['sdk_type']);
  18. //开始定义IOS/android的客户端版本号
  19. //define("IOS_CLIENT_VERSION","3.03.01");
  20. //define("ANDROID_CLIENT_VERSION","4.5.2") ;
  21. $sdk_version_name = strim($_REQUEST['sdk_version_name']);
  22. $sdk_version = strim($_REQUEST['sdk_version']);//升级版本号yyyymmddnn: 2016021601
  23. //es_session::set("dev_type",$dev_type);
  24. //es_session::set("dev_version",$version);
  25. $root = array();
  26. $root['status'] = 1;
  27. $m_config = load_auto_cache("m_config");//初始化手机端配置
  28. //直播公告消息
  29. $root['listmsg'] = load_auto_cache("article_notice");
  30. //API接口地址
  31. $root['api_link'] = load_auto_cache("api_list");
  32. $root['sina_app_api'] = intval($m_config['sina_app_api']);
  33. $root['wx_app_api'] = intval($m_config['wx_app_api']);
  34. $root['qq_app_api'] = intval($m_config['qq_app_api']);
  35. $root['selected_app_api'] = 0;//创建直播时 默认选中分享按钮,0:不选中;1:微信;2:微信朋友圈;3:QQ;4:微博;
  36. $root['has_sdk_login'] = 1;//使用sdk登陆,如果使用sdk登陆时,在访问webveiw时,需要传输session_id参数;
  37. $root['has_sina_login'] = intval($m_config['has_sina_login']);//支持新浪登陆
  38. $root['has_wx_login'] = intval($m_config['has_wx_login']);//支持微信登陆
  39. $root['has_qq_login'] = intval($m_config['has_qq_login']);//支持qq登陆
  40. $root['has_mobile_login'] = intval($m_config['has_mobile_login']);//支持手机登陆(注册)
  41. //兼容分销屏蔽登录功能
  42. if(intval('OPEN_DISTRIBUTION')==1&&intval($m_config['distribution'])==1){
  43. $root['has_wx_login'] = intval($m_config['distribution_wx']);//支持微信登陆
  44. $root['has_sina_login'] = intval($m_config['distribution_sina']);//支持新浪登陆
  45. $root['has_qq_login'] = intval($m_config['distribution_qq']);//支持qq登陆
  46. }
  47. $root['statusbar_hide'] = 0;//0:显示状态栏;1隐藏状态栏
  48. $theme = intval($m_config['app_theme']);
  49. if($theme == 1){//1: green #1cd39b
  50. $color_code = '#1cd39b';
  51. if (defined('QK_TREE') && QK_TREE) {
  52. $color_code = '#ffffff';
  53. }
  54. }else {//0或其他: default #ff7551
  55. $color_code = '#ff7551';
  56. }
  57. $root['statusbar_color'] = $color_code;// '#55ACEF';//状态栏,颜色
  58. $root['topnav_color'] = $color_code;//'#55ACEF';//顶部导航栏,颜色
  59. $root['ad_img'] = '';//启动时的广告图
  60. $root['ad_http'] = '';//启动时的广告连接内容
  61. $root['ad_open'] = 0;//点击广告内容,打开方式:0:在第一个webveiw中打开;1:新建一个webview打开连接
  62. $root['site_url'] = SITE_DOMAIN;//.'/theme/index.php';//h5首页地址
  63. //$root['api'] = SITE_DOMAIN.APP_ROOT.'/service/index.php';//api地址
  64. $root['reload_time'] = 60;//秒;程序暂停,超过 60 秒,再进去时,需要重新清空程序加载
  65. $root['monitor_second'] = 10;//主播心跳监听,每10秒监听一次;监听数据:时间点,印票数,房间人数
  66. $root['jr_user_level'] = intval($m_config['jr_user_level']);//加入房间时,如果用户等级超过或等于jr_user_level时,有用户进入房间提醒操作
  67. $root['bullet_screen_diamond'] = 1;//弹幕一次消费的金币
  68. //SPEAR引擎配置
  69. $root['spear_live'] = 'LiveHost';//主播
  70. $root['spear_normal'] = 'NormalGuest';//观众
  71. $root['spear_interact'] = 'InteractUser';//连麦
  72. $root['privacy_title'] = "《用户隐私政策》";
  73. $root['privacy_link'] = SITE_DOMAIN.APP_ROOT.'/mapi/index.php?ctl=app&act=privacy';
  74. //$root['agreement_title'] = "主播协议";
  75. $root['agreement_link'] = SITE_DOMAIN.APP_ROOT.'/mapi/index.php?ctl=app&act=agreement';
  76. $root['short_name'] =strim($m_config['short_name']);
  77. $root['ticket_name'] =strim($m_config['ticket_name']);
  78. $root['diamonds_name'] =strim($m_config['diamonds_name']);
  79. $root['beauty_ios'] =intval($m_config['beauty_ios']);//IOS美颜度,默认值
  80. $root['beauty_android'] =intval($m_config['beauty_android']);//ANDROID美颜度,默认值
  81. $root['beauty_close'] =intval($m_config['beauty_close']);//4、客户端不许自义美颜度; 0:开;1:关; 当beauty_close=1时,美颜功能只有 开/关;美颜值直接取:服务端返回的值
  82. $root['beauty_close'] = 0;
  83. //$root['service_push'] =intval($m_config['service_push']);//是否开启全服推送 0: 不开启 推送给粉丝 1:开启
  84. $root['app_name'] =strim($m_config['app_name']);//app名称 方维直播
  85. $root['share_title'] =strim($m_config['share_title']);//分享标题 你丑你先睡,我美我直播
  86. $root['has_save_video'] = intval($m_config['has_save_video']);//保存视频(可用于回播)
  87. $root['account_name'] =strim($m_config['account_name']);//app账号名称 账号
  88. /*
  89. fanwe_require(APP_ROOT_PATH . "system/extend/ip.php");
  90. $ip = new iplocate ();
  91. $area = $ip->getaddress ( CLIENT_IP );
  92. $root['city'] = $area ['area1'];
  93. */
  94. $root['ip_info'] = get_ip_info();
  95. $root['city'] = $root['ip_info']['city'];
  96. /*
  97. $province = $ipinfo['province'];
  98. $city = $ipinfo['city'];
  99. */
  100. //地区列表版本号
  101. $root['region_versions'] =intval($m_config['region_versions']);
  102. //$root['request'] = print_r($_SERVER['HTTP_USER_AGENT'],1);
  103. //$root['ios_check_version'] = $m_config['ios_check_version'];
  104. //正在审核的版本,只显示:苹果支付
  105. if ($dev_type == 'ios' && $m_config['ios_check_version'] != '' && $m_config['ios_check_version'] == $sdk_version_name){
  106. $root['auto_login'] = 0;//自动创建帐户登陆;苹果审核跟云测试时使用
  107. $root['sina_app_api'] = 0;
  108. $root['wx_app_api'] = 0;
  109. $root['qq_app_api'] = 0;
  110. $root['selected_app_api'] = 0;//创建直播时 默认选中分享按钮,0:不选中;1:微信;2:微信朋友圈;3:QQ;4:微博;
  111. $root['has_sdk_login'] = 1;//使用sdk登陆,如果使用sdk登陆时,在访问webveiw时,需要传输session_id参数;
  112. $root['has_sina_login'] = 0;//支持新浪登陆
  113. $root['has_wx_login'] = 0;//支持微信登陆
  114. $root['has_qq_login'] = 0;//支持qq登陆
  115. $root['has_mobile_login'] = 1;//intval($m_config['has_mobile_login']);//支持手机登陆(注册)
  116. //1:可升级;0:不可升级
  117. $root['version'] = $this->version2($dev_type,$sdk_version,$sdk_version_name);//版本升级检查
  118. //购物竞拍配置开关
  119. $root['pai_real_btn']= 0;
  120. $root['pai_virtual_btn']= 0;
  121. $root['shopping_goods']= 0;
  122. $root['open_pai_module']= 0;
  123. $root['shop_shopping_cart']= 0;
  124. $root['open_podcast_goods']= 0;
  125. //是否开启游戏字段
  126. $root['open_game_module']= 0;
  127. //是否开启上庄模块
  128. $root['open_banker_module']= 0;
  129. //是否开启赠送游戏币模块
  130. $root['open_send_coins_module']= 0;
  131. // 游戏分销
  132. $root['game_distribution']= 0;
  133. $root['open_send_diamonds_module']= 0;
  134. //是否开启钻石游戏
  135. /**
  136. * 未开启游戏默认为1
  137. */
  138. $root['open_diamond_game_module']= 1;
  139. // 是否加载首页假数据
  140. $root['fake_index'] = 1;
  141. /*
  142. * 版本审核中
  143. */
  144. $ios_check_version = 1;
  145. }else{
  146. $root['auto_login'] = 0;
  147. $root['version'] = $this->version2($dev_type,$sdk_version);//版本升级检查
  148. //购物竞拍配置开关
  149. $root['pai_real_btn']= intval(PAI_REAL_BTN);
  150. $root['pai_virtual_btn']= intval(PAI_VIRTUAL_BTN);
  151. $root['shopping_goods']= intval(SHOPPING_GOODS);
  152. $root['open_pai_module']= intval(OPEN_PAI_MODULE);
  153. $root['shop_shopping_cart']= intval(SHOP_SHOPPING_CART);
  154. $root['open_podcast_goods']= intval(OPEN_PODCAST_GOODS);
  155. //是否开启游戏字段
  156. $root['open_game_module']= intval(OPEN_GAME_MODULE);
  157. //是否开启上庄模块
  158. $root['open_banker_module']= intval(OPEN_BANKER_MODULE) ? 1 : 0;
  159. //是否开启赠送游戏币模块
  160. $root['open_send_coins_module']= intval(OPEN_SEND_COINS_MODULE);
  161. $root['open_send_diamonds_module']= intval(OPEN_SEND_DIAMONDS_MODULE);
  162. //是否开启钻石游戏
  163. /**
  164. * 未开启游戏默认为1
  165. */
  166. $root['open_diamond_game_module']= intval(intval(OPEN_DIAMOND_GAME_MODULE) || !intval(OPEN_GAME_MODULE));
  167. // 游戏分销
  168. $root['game_distribution']= intval(GAME_DISTRIBUTION);
  169. // 是否加载首页假数据
  170. $root['fake_index'] = 0;
  171. }
  172. //$root['auto_login'] = 1;
  173. //苹果审核版本号
  174. $root['ios_check_version']=$m_config['ios_check_version'];
  175. //家族开关
  176. $root['open_family_module']= intval(OPEN_FAMILY_MODULE);
  177. //公会开关ljz
  178. //$root['open_society_module']= intval(OPEN_SOCIETY_MODULE);
  179. if(defined("OPEN_SOCIETY_MODULE") && OPEN_SOCIETY_MODULE==1){
  180. $m_config = load_auto_cache("m_config");//初始化手机端配置
  181. if($m_config['society_pattern'] == 0){
  182. $root['open_society_module'] = 0;
  183. }else{
  184. $root['open_society_module'] = 1;
  185. if($m_config['society_list_name'] == ''){
  186. $root['society_list_name'] = '公会';
  187. }else{
  188. $root['society_list_name'] = $m_config['society_list_name'];
  189. }
  190. }
  191. }else{
  192. $root['open_society_module'] = 0;
  193. }
  194. //APP端公会开关
  195. $root['open_society_app']= intval(OPEN_SOCIETY_APP)?intval(OPEN_SOCIETY_APP):0;
  196. //每日首次登录赠送积分开关
  197. $root['open_login_send_score']= intval(OPEN_LOGIN_SEND_SCORE);
  198. //开启O2O开关
  199. $root['o2o_open_goods'] = intval(O2O_OPEN_GOODS);
  200. //登录赠送积分值
  201. $root['login_send_score']= intval($m_config['login_send_score']);
  202. //是否首次登录
  203. $root['first_login']= es_session::get("first_login")?es_session::get("first_login"):0;
  204. es_session::set("first_login",0);
  205. //每次登录时升级提示
  206. $root['open_upgrade_prompt']= intval(OPEN_UPGRADE_PROMPT);
  207. $root['new_level']= es_session::get("new_level")?es_session::get("new_level"):0;
  208. es_session::set("new_level",0);
  209. //排行榜开关,审核期间不开
  210. $root['open_ranking_list'] = 0;
  211. if(trim($m_config['ios_check_version'] == '')){
  212. $root['open_ranking_list']= intval(OPEN_RANKING_LIST);
  213. }
  214. //启动广告
  215. if(!$root['open_ranking_list']){
  216. //未开启排行榜,去除指向排行榜
  217. $root['start_diagram'] = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."index_image where show_position = 4 and `type`<>2 ",true,true);
  218. }else{
  219. $root['start_diagram'] = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."index_image where show_position = 4 ",true,true);
  220. }
  221. if(!$root['start_diagram']){
  222. $root['start_diagram'] = array();
  223. }
  224. foreach($root['start_diagram'] as $k=>$v){
  225. if($v['image'] != ''){
  226. $root['start_diagram'][$k]['image'] = get_spec_image($v['image']);
  227. }
  228. }
  229. //H5链接
  230. $h5_url = array(
  231. 'url_my_grades' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=user_center&act=grade',
  232. 'url_about_we' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=settings&act=article_cate',
  233. 'url_help_feedback' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=settings&act=help',
  234. 'url_auction_record' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=pai_user&act=pailogs',
  235. 'url_user_order' => '', // 我的订单(暂无)
  236. 'url_user_pai' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=pai_user&act=goods',
  237. 'url_podcast_order' => '', // 星级订单(暂无)
  238. 'url_podcast_pai' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=pai_podcast&act=goods',
  239. 'url_podcast_goods' => '', //暂无(原生)
  240. 'url_auction_agreement' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=settings&act=article_show&cate_id=18', //竞拍协议
  241. 'url_pai_income' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=user_center&act=income', //竞拍收益h5
  242. 'url_goods_income' => SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=user_center&act=income&details=1', //商品收益h5
  243. 'url_tree_index' => SITE_DOMAIN.APP_ROOT.'/mapi/index.php?ctl=tree&act=index', // 西藏青稞秀h5
  244. );
  245. if(SHOPPING_GOODS == 1){
  246. $h5_url['url_podcast_goods'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=shop&act=podcasr_goods_management&state=1&page=1'; //商城h5链接(主播)
  247. $h5_url['url_user_goods'] =''; //进入第三方商城h5链接(观众)
  248. $h5_url['url_user_order'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=shop&act=shop_order&page=1'; //商城h5订单链接(观众)
  249. $h5_url['url_goods_income'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=user_center&act=goods_income_details'; //商品收益h5
  250. $h5_url['url_shopping_cart'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=shop&act=shop_shopping_cart&page=1'; //购物车
  251. }
  252. if((defined('PAI_REAL_BTN') && PAI_REAL_BTN == 1) && (defined('PAI_VIRTUAL_BTN') && PAI_VIRTUAL_BTN == 0)){
  253. $h5_url['url_user_pai'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=pai_user&act=goods&is_true=1';
  254. $h5_url['url_podcast_pai'] = SITE_DOMAIN.APP_ROOT.'/wap/index.php?ctl=pai_podcast&act=goods&is_true=1';
  255. }
  256. $root['h5_url']= $h5_url;
  257. $root['has_dirty_words'] = intval($m_config['has_dirty_words']);//当为1时,启用脏子过滤;默认0时不过滤, 即:0时不发送组合消息即可; 接收还是要处理组合消息; 主要是为了跟旧版本兼容过度一下,过度完后,这个参数将去掉;
  258. //将图片直接上传到OSS上,不中转;https://help.aliyun.com/document_detail/31920.html?spm=5176.doc31931.6.206.OEtePt
  259. $root['open_sts'] = intval($m_config['open_sts']);
  260. $root['sts_video_limit'] = intval($m_config['sts_video_limit']) ?: 60;
  261. //是否开启 强制输入话题 功能 1是 0否
  262. $root['must_cate'] = intval($m_config['must_cate']);
  263. //付费总开关
  264. $root['live_pay']=0;
  265. //按时付费
  266. $root['live_pay_time']=0;
  267. //按场付费
  268. $root['live_pay_scene']=0;
  269. if((defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1)&&intval($ios_check_version)==0){
  270. $live_pay_info= $GLOBALS['db']->getAll("SELECT id,class FROM ".DB_PREFIX."plugin WHERE is_effect=1 and type =1");
  271. if($live_pay_info){
  272. foreach($live_pay_info as $item){
  273. $live_pay[$item['id']] = $item['class'];
  274. }
  275. $root['live_pay'] =intval(OPEN_LIVE_PAY);
  276. }
  277. //按时付费
  278. if(intval(LIVE_PAY_TIME)==1) {
  279. if (in_array('live_pay',$live_pay)) {
  280. $root['live_pay_time'] = 1;
  281. $root['live_pay_count_down'] = intval($m_config['live_count_down']);//进入付费模式倒计时时间
  282. }
  283. }
  284. //按场付费
  285. if(intval(LIVE_PAY_SCENE)==1){
  286. if (in_array('live_pay_scene',$live_pay)) {
  287. $root['live_pay_scene'] = 1;
  288. }
  289. }
  290. }
  291. $pay_interval = intval($m_config['pay_interval'])*60;//(分钟)扣费间隔
  292. $root['pay_interval'] = $pay_interval>0?$pay_interval:60;
  293. //最大连麦数量
  294. $root['mic_max_num'] = intval($m_config['mic_max_num'])>3?3:intval($m_config['mic_max_num']);
  295. //分销功能
  296. //邀请奖励功能 依赖分销功能 分享收益开关
  297. if((defined('OPEN_DISTRIBUTION')&&OPEN_DISTRIBUTION==1)){
  298. $root['distribution'] =intval($m_config['distribution'])?1:0;
  299. }else if(intval(OPEN_REWARD_POINT)==1){
  300. $root['distribution'] =intval(OPEN_REWARD_POINT)?1:0;
  301. }
  302. //审核版本关闭分享功能
  303. if ($dev_type == 'ios' && $m_config['ios_check_version'] != '' && $m_config['ios_check_version'] == $sdk_version_name){
  304. $root['distribution'] = 0 ;
  305. }
  306. //分销类型
  307. if(defined('distribution_module')){
  308. $root['distribution_module'] =intval(DISTRIBUTION_MODULE);
  309. }else{
  310. $root['distribution_module'] =0;
  311. }
  312. $root['full_group_id'] = '';//全员广播大群群组id
  313. $root['on_line_group_id'] = '';//在线用户大群id
  314. $group_id = strim($m_config['full_group_id']);
  315. $online_group_id = strim($m_config['on_line_group_id']);
  316. if($group_id || $online_group_id){
  317. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  318. $api = createTimAPI();
  319. $api_arr = (array)$api;
  320. if(intval($api_arr['status'])==0&&$api_arr['error']!=''){
  321. log_err_file(array(__FILE__,__LINE__,__METHOD__,$api_arr['error']));
  322. echo "IM错误,请检查ec_key.pem 或 腾讯sdkAppid";exit;
  323. }
  324. if($group_id){
  325. $aes_key_info = get_privatekey();
  326. if(is_array($aes_key_info[0]['aes_key'])){
  327. $aes_key = $aes_key_info[0]['aes_key'][0];
  328. }else{
  329. $aes_key = $aes_key_info[0]['aes_key'];
  330. }
  331. $ret = $api->group_get_group_info2(array('0'=>$group_id));
  332. $root['full_group_id'] = $ret['GroupInfo'][0]['GroupId'];
  333. if($ret['GroupInfo'][0]['ErrorCode']){
  334. $ret = $api->full_group_create($group_id,$aes_key);
  335. if($ret['ActionStatus']!='OK'){
  336. log_err_file(array(__FILE__,__LINE__,__METHOD__,$ret));
  337. $ret = $api->full_group_create($group_id,$aes_key);
  338. }
  339. $root['full_group_id'] = $ret['GroupId'];
  340. }
  341. }
  342. if($online_group_id){
  343. $ret = $api->group_get_group_info2(array('0'=>$online_group_id));
  344. $root['on_line_group_id'] = $ret['GroupInfo'][0]['GroupId'];
  345. if($ret['GroupInfo'][0]['ErrorCode']){
  346. $ret = $api->full_group_create($online_group_id);
  347. if($ret['ActionStatus']!='OK'){
  348. log_err_file(array(__FILE__,__LINE__,__METHOD__,$ret));
  349. $ret = $api->full_group_create($online_group_id);
  350. }
  351. $root['on_line_group_id'] = $ret['GroupId'];
  352. }
  353. }
  354. }
  355. if(OPEN_X){
  356. $root['weibo_red_price'] =floatval($m_config['weibo_red_price']);//红包单张价格
  357. $root['weibo_photo_price'] =$m_config['weibo_photo_price'];//写真单张价格限制
  358. if($m_config['weibo_photo_price']){
  359. $weibo_photo_price = explode('-',$m_config['weibo_photo_price']);
  360. $root['weibo_photo_price_1'] =$weibo_photo_price[0];
  361. $root['weibo_photo_price_2'] =$weibo_photo_price[1];
  362. }
  363. $root['weibo_weixin_price'] = $m_config['weibo_weixin_price'];//微信价格限制
  364. if($m_config['weibo_weixin_price']){
  365. $weibo_weixin_price = explode('-',$m_config['weibo_weixin_price']);
  366. $root['weibo_weixin_price_1'] =$weibo_weixin_price[0];
  367. $root['weibo_weixin_price_2'] =$weibo_weixin_price[1];
  368. }
  369. $root['weibo_goods_price'] = $m_config['weibo_goods_price'];//微信价格限制
  370. if($m_config['weibo_goods_price']){
  371. $weibo_goods_price = explode('-',$m_config['weibo_goods_price']);
  372. $root['weibo_goods_price_1'] =$weibo_goods_price[0];
  373. $root['weibo_goods_price_2'] =$weibo_goods_price[1];
  374. }
  375. }
  376. $root['open_xr'] = intval(OPEN_XR);
  377. //按场付费直播最高最低限制
  378. $root['live_pay_max'] = intval($m_config['live_pay_max']);//付费直播收费最高
  379. $root['live_pay_min'] = intval($m_config['live_pay_min']);//付费直播收费最低
  380. //按场付费直播最高最低限制
  381. $root['live_pay_scene_max'] = intval($m_config['live_pay_scene_max']);//付费直播收费最高
  382. $root['live_pay_scene_min'] = intval($m_config['live_pay_scene_min']);//付费直播收费最低
  383. //开启vip会员
  384. $root['open_vip'] = 0;
  385. if(defined('OPEN_VIP')&&intval($m_config['open_vip'])==1){
  386. $root['open_vip'] = intval(OPEN_VIP);
  387. }
  388. $root['init_version'] = intval($m_config['init_version']);//手机端配置版本号
  389. //是否开启私信
  390. $root['has_private_chat'] = intval($m_config['has_private_chat']);//开启私信 1开启 0关闭
  391. //视频清晰度:0标清(360*640),1高清(540*960),2超清(720*1280)
  392. $root['video_resolution_type'] = intval($m_config['video_resolution_type']);
  393. //备用域名 列表
  394. $domain_list = array();
  395. $domain_arr = explode("<br />",nl2br($m_config['domain_list']));
  396. foreach($domain_arr as $k=>$v){
  397. $v = ltrim(rtrim(trim($v)));
  398. if($v!=''){
  399. $domain_list[]=$v;
  400. }
  401. }
  402. $root['domain_list']=$domain_list;
  403. //首页其他分类
  404. $root['video_classified'] = array();
  405. $video_classified = load_auto_cache("video_classified");
  406. if($video_classified){
  407. $root['video_classified'] = $video_classified;
  408. }
  409. //发言等级
  410. $root['speak_level']=intval($m_config['speak_level']);
  411. //用户开启发言功能的最低等级
  412. $root['send_msg_lv'] = intval($m_config['send_msg_lv']);
  413. //用户开启私信功能的最低等级
  414. $root['private_letter_lv'] = intval($m_config['private_letter_lv']);
  415. //声网AppID
  416. $root['agora_app_id'] = trim($m_config['agora_app_id']);
  417. //手机端配置,腾讯云 账号信息
  418. $root['sdkappid'] = trim($m_config['tim_sdkappid']);
  419. $root['accountType'] = trim($m_config['tim_account_type']);
  420. //游客登录
  421. $root['has_visitors_login'] = intval($m_config['open_visitors_login']);
  422. $root['family_join'] = 1;//开启加入家族的按钮
  423. //家族加入按钮 是否显示ljz
  424. if ((defined('OPEN_FAMILY_JOIN')&&OPEN_FAMILY_JOIN==1)){
  425. $root['family_join'] = 0;//关闭加入家族的按钮
  426. }
  427. //直播页面取消点赞功能 1.取消点赞 0.不取消
  428. $root['is_no_light'] = intval($m_config['is_no_light']);
  429. if (defined('OPEN_PAI_MODULE') && OPEN_PAI_MODULE) {
  430. $root['itype'] = 'shop';
  431. } elseif (defined('SHOPPING_GOODS') && SHOPPING_GOODS) {
  432. $root['itype'] = 'shop';
  433. } elseif (defined('OPEN_PODCAST_GOODS') && OPEN_PODCAST_GOODS) {
  434. $root['itype'] = 'shop';
  435. }
  436. /*$root['diamond_name'] = '钻石';*/
  437. $root['diamond_name'] = strim($m_config['diamonds_name']);
  438. //创建直播时是否需要强制选择分类 1.需要 0.不需要
  439. $root['is_classify'] = intval($m_config['is_classify']);
  440. ajax_return($root);
  441. }
  442. /**
  443. * 用户隐私政策
  444. */
  445. function privacy(){
  446. header("Content-Type:text/html; charset=utf-8");
  447. $content = load_auto_cache("article_privacy");
  448. echo $content;
  449. exit;
  450. }
  451. /**
  452. * 主播协议
  453. */
  454. function agreement(){
  455. header("Content-Type:text/html; charset=utf-8");
  456. $content = load_auto_cache("article_agreement");
  457. echo $content;
  458. exit;
  459. }
  460. /**
  461. * 版本管理
  462. * @param $dev_type
  463. * @param $version
  464. * @param $sdk_version_name
  465. * @return array
  466. */
  467. function version2($dev_type,$version,$sdk_version_name)
  468. {
  469. $m_config = load_auto_cache("m_config");//初始化手机端配置
  470. $site_url = SITE_DOMAIN.APP_ROOT."/";//站点域名;
  471. $root = array();
  472. if ($dev_type == 'android'){
  473. $root['serverVersion'] = $m_config['android_version'];//android版本号
  474. if ($version < $root['serverVersion'] && $m_config['android_filename'] != ''){
  475. $root['filename'] = $m_config['android_filename'];//android下载包名
  476. $root['android_upgrade'] = $m_config['android_upgrade'];//android版本升级内容
  477. $root['forced_upgrade'] = intval($m_config['android_forced_upgrade']);//强制升级
  478. $root['hasfile'] = 1;
  479. $root['has_upgrade'] = 1;//1:可升级;0:不可升级
  480. }else{
  481. $root['hasfile'] = 0;
  482. $root['has_upgrade'] = 0;//1:可升级;0:不可升级
  483. }
  484. }else if ($dev_type == 'ios'){
  485. $root['serverVersion'] = $m_config['ios_version'];//IOS版本号
  486. if ($version < $root['serverVersion']&&$m_config['ios_down_url']!=''){
  487. $root['ios_down_url'] = $m_config['ios_down_url'];//ios下载地址
  488. $root['ios_upgrade'] = $m_config['ios_upgrade'];//ios版本升级内容
  489. $root['has_upgrade'] = 1;//1:可升级;0:不可升级
  490. $root['forced_upgrade'] = intval($m_config['ios_forced_upgrade']);//0:非强制升级;1:强制升级
  491. }else{
  492. $root['has_upgrade'] = 0;//1:可升级;0:不可升级
  493. }
  494. }else{
  495. $root['hasfile'] = 0;
  496. $root['has_upgrade'] = 0;//1:可升级;0:不可升级
  497. }
  498. return $root;
  499. }
  500. /**
  501. * 将图片直接上传到OSS上,不中转;
  502. * 参考网址:https://help.aliyun.com/document_detail/31920.html?spm=5176.doc31931.6.206.OEtePt
  503. * status: 1,
  504. //上传文件时,必要的3个参数
  505. AccessKeyId: "",
  506. AccessKeySecret: "",
  507. SecurityToken: "",
  508. //过期时间,客户端不关心
  509. Expiration: "2016-09-28T10:30:02Z",
  510. //出错时,返回下面3个参数
  511. RequestId: "",
  512. Code: "",
  513. Message: "",
  514. //回调地址
  515. callbackUrl: "",
  516. callbackBody: "",
  517. //文件存放目录
  518. dir: ""
  519. */
  520. function aliyun_sts(){
  521. $root = array();
  522. $root['status'] = 1;
  523. //$GLOBALS['user_info']['id'] = 1;
  524. if(!$GLOBALS['user_info']){
  525. $root['error'] = "用户未登陆,请先登陆.";
  526. $root['status'] = 0;
  527. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  528. }else{
  529. $root = load_auto_cache("aliyun_sts");
  530. if ($root['status'] == 200){
  531. $root['status'] = 1;
  532. //回调说明https://help.aliyun.com/document_detail/31922.html?spm=5176.doc31921.6.208.xZgpik
  533. $root['callbackUrl'] = '';
  534. $root['callbackBody'] = '';
  535. //上传的目录是由服务端(即PHP)指定的,这样的好处就是安全。 这样就能控制每个客户端只能上传指定到指定的目录,做到安全隔离, 想要修改上传目录地址成abc/(必须以'/'结尾)
  536. $dir_name = to_date(get_gmtime(),"Ym");
  537. $root['dir'] = 'public/attachment/'.$dir_name.'/'.intval($GLOBALS['user_info']['id'])."/";
  538. }else{
  539. //$sts['status'] = 0;
  540. }
  541. }
  542. ajax_return($root);
  543. }
  544. /**
  545. * 调试接口
  546. */
  547. public function test()
  548. {
  549. header("Content-Type:text/html; charset=utf-8");
  550. }
  551. /**
  552. * 获得举报类型列表
  553. */
  554. public function tipoff_type(){
  555. $root = array();
  556. $root['status'] = 1;
  557. $list = load_auto_cache("tipoff_type_list");
  558. $root['list'] = $list;
  559. ajax_return($root);
  560. }
  561. /**
  562. * 获得礼物列表
  563. */
  564. public function prop(){
  565. $root = array();
  566. $root['status'] = 1;
  567. $root['list'] = load_auto_cache("prop_list");
  568. foreach($root['list'] as $k=>$v){
  569. $root['list'][$k]['ticket']=intval($v['ticket']);
  570. }
  571. //游戏币送礼物
  572. if(PROP_COINS == 1){
  573. $coins_list = array();
  574. foreach($root['list'] as $k=>$v){
  575. if(intval($v['coins'])>0){
  576. $v['ticket']=intval($v['ticket']);
  577. $v['coins']=intval($v['coins']);
  578. $coins_list[]=$v;
  579. }
  580. }
  581. $root['coins_list'] = $coins_list;
  582. }
  583. ajax_return($root);
  584. }
  585. /**
  586. *插件列表接口
  587. *
  588. */
  589. public function plugin_init()
  590. {
  591. $user_id = intval($GLOBALS['user_info']['id']);
  592. if ($user_id == 0) {
  593. api_ajax_return(array(
  594. 'status' => 10007,
  595. 'error' => "请先登录",
  596. ));
  597. }
  598. $m_config = load_auto_cache("m_config"); //初始化手机端配置
  599. //审核版本
  600. $ios_check = 0;
  601. $dev_type = strim($_REQUEST['sdk_type']);
  602. $sdk_version_name = strim($_REQUEST['sdk_version_name']);
  603. if ($dev_type == 'ios' && $m_config['ios_check_version'] != '' && $m_config['ios_check_version'] == $sdk_version_name&&$GLOBALS['user_info']['mobile']=='13888888888') {
  604. $ios_check = 1;
  605. }
  606. if ($ios_check) {
  607. ajax_return(array(
  608. 'status' => 1,
  609. 'list' => array(),
  610. 'rs_count' => 0,
  611. ));
  612. }
  613. $plugin = $GLOBALS['db']->getALL("SELECT id,child_id,name,image,type,class as class_name FROM " . DB_PREFIX . "plugin WHERE is_effect=1", true, true);
  614. $table = DB_PREFIX . 'video';
  615. $video = $GLOBALS['db']->getRow("SELECT `id` FROM $table WHERE user_id=$user_id and live_in=1");
  616. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/VideoRedisService.php');
  617. $video_redis = new VideoRedisService();
  618. $fields = array('live_pay_time', 'live_fee', 'live_pay_type', 'is_live_pay', 'game_log_id');
  619. $video_info = $video_redis->getRow_db($video['id'], $fields);
  620. foreach ($plugin as $key => $value) {
  621. $plugin[$key]['is_active'] = 0;
  622. switch ($value['class_name']) {
  623. case 'game':
  624. if (defined('GAME_PLUGIN_MANAGE') && GAME_PLUGIN_MANAGE == 1) {
  625. $allow_game_plugin = $GLOBALS['db']->getOne("select allow_game_plugin from " . DB_PREFIX . "user where id = " . $user_id);
  626. if (!$allow_game_plugin) {
  627. unset($plugin[$key]);
  628. continue 2;
  629. }
  630. }
  631. if (defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE == 1) {
  632. if ($value['type'] == 2) {
  633. $game_id = 0;
  634. $is_enable = 1;
  635. if ($video['id']) {
  636. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/GamesRedisService.php');
  637. $redis = new GamesRedisService();
  638. $last_game = $video_info['game_log_id'];
  639. if ($last_game) {
  640. $last_game = $redis->get($last_game, 'game_id,create_time,long_time');
  641. if (NOW_TIME < $last_game['create_time'] + $last_game['long_time']) {
  642. $game_id = $last_game['game_id'];
  643. $is_enable = 0;
  644. }
  645. }
  646. }
  647. $plugin[$key]['is_active'] = intval($value['id'] == $game_id);
  648. $plugin[$key]['is_enable'] = $is_enable;
  649. }
  650. } else {
  651. unset($plugin[$key]);
  652. continue 2;
  653. }
  654. break;
  655. case 'pai':
  656. if (defined('OPEN_PAI_MODULE') && OPEN_PAI_MODULE == 1) {
  657. if ($value['type'] == 1) {
  658. if ($video['pai_id'] != 0) {
  659. $pai_goods = $GLOBALS['db']->getRow("SELECT create_time,pai_time FROM " . DB_PREFIX . "pai_goods WHERE id=" . $video['pai_id'] . " ");
  660. if ($pai_goods) {
  661. if (NOW_TIME < strtotime($pai_goods['create_time']) + $pai_goods['pai_time'] * 3600) {
  662. $is_enable = 0;
  663. }
  664. }
  665. }
  666. $plugin[$key]['is_enable'] = $is_enable;
  667. }
  668. } else {
  669. unset($plugin[$key]);
  670. continue 2;
  671. }
  672. break;
  673. case 'shop':
  674. if (!defined('SHOPPING_GOODS') || SHOPPING_GOODS == 0) {
  675. unset($plugin[$key]);
  676. continue 2;
  677. } else {
  678. $plugin[$key]['is_enable'] = 1;
  679. }
  680. break;
  681. case 'podcast_goods':
  682. if (!defined('OPEN_PODCAST_GOODS') || OPEN_PODCAST_GOODS == 0) {
  683. unset($plugin[$key]);
  684. continue 2;
  685. } else {
  686. $plugin[$key]['is_enable'] = 1;
  687. }
  688. break;
  689. case 'live_pay':
  690. case 'live_pay_scene':
  691. default:
  692. if (defined('OPEN_LIVE_PAY') && OPEN_LIVE_PAY == 1) {
  693. $is_nospeaking = $GLOBALS['db']->getOne("SELECT is_nospeaking FROM ".DB_PREFIX."user WHERE id=".$user_id,true,true);
  694. if($is_nospeaking){
  695. unset($plugin[$key]);
  696. continue 2;
  697. }
  698. $live_pay_time = $video_info['live_pay_time']; //开始收费时间
  699. $live_fee = intval($video_info['live_fee']); //付费直播 收费多少
  700. $is_live_pay = intval($video_info['is_live_pay']);
  701. $live_pay_type = intval($video_info['live_pay_type']);
  702. $is_active = 0;
  703. if ($live_pay_time != '' && $live_fee > 0) {
  704. if (($is_live_pay == 1 && $live_pay_type == 0 && $value['class_name'] == 'live_pay') || ($is_live_pay == 1 && $live_pay_type == 1 && $value['class_name'] == 'live_pay_scene')) {
  705. $is_active = 1;
  706. $is_enable = 0;
  707. } else {
  708. $is_enable = 0;
  709. }
  710. }
  711. $plugin[$key]['is_active'] = $is_active;
  712. $plugin[$key]['is_enable'] = $is_enable;
  713. } else {
  714. unset($plugin[$key]);
  715. continue 2;
  716. }
  717. break;
  718. }
  719. $plugin[$key]['image'] = get_spec_image($value['image']);
  720. }
  721. api_ajax_return(array(
  722. 'status' => 1,
  723. 'list' => array_values($plugin),
  724. 'rs_count' => sizeof($plugin),
  725. 'test' => __FILE__.__LINE__,
  726. ));
  727. }
  728. /**
  729. * 插件接口状态
  730. */
  731. public function plugin_status(){
  732. $root = array('status' =>1,'error'=>'');
  733. $user_id = intval($GLOBALS['user_info']['id']);
  734. if($user_id == 0){
  735. $root['status']=10007;
  736. $root['error']="请先登录";
  737. ajax_return($root);
  738. }else{
  739. $plugin_id = intval($_REQUEST['plugin_id']);//插件id,fanwe_plugin.id
  740. $table = DB_PREFIX . 'video';
  741. $video = $GLOBALS['db']->getRow("SELECT `id`,pai_id FROM $table WHERE user_id=" . $user_id . " and live_in=1");
  742. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  743. $video_redis = new VideoRedisService();
  744. $fields = array('live_pay_time','live_fee','live_pay_type','is_live_pay','game_log_id');
  745. $video_info = $video_redis->getRow_db($video['id'],$fields);
  746. $is_enable = 1;
  747. $is_active = 0;
  748. $plugin = $GLOBALS['db']->getRow("SELECT id,child_id,name,image,type,class as class_name FROM ".DB_PREFIX."plugin WHERE is_effect=1 and id=".$plugin_id,true,true);
  749. $plugin['is_active'] = $is_active;
  750. $plugin['is_enable'] = $is_enable;
  751. if(defined('OPEN_PLUGIN')&&OPEN_PLUGIN) {
  752. $open_plugin= $GLOBALS['db']->getRow("select open_game,open_pay,open_auction from ".DB_PREFIX."user where id = $user_id");
  753. if($plugin['class_name'] == 'game'){
  754. if ($open_plugin['open_game']==1) {
  755. $root['error'] = "您无法开启游戏,请联系客服";
  756. $root['status'] = 0;
  757. ajax_return($root);
  758. }
  759. }
  760. if($plugin['class_name'] =='pai'){
  761. if ($open_plugin['open_auction']==1) {
  762. $root['error'] = "您无法开启竞拍,请联系客服";
  763. $root['status'] = 0;
  764. ajax_return($root);
  765. }
  766. }
  767. if($plugin['class_name'] =='live_pay'||$plugin['class_name']=='live_pay_scene'){
  768. if ($open_plugin['open_pay']==1) {
  769. $root['error'] = "您无法开启付费,请联系客服";
  770. $root['status'] = 0;
  771. ajax_return($root);
  772. }
  773. }
  774. }
  775. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  776. $live_pay_time = $video_info['live_pay_time'];//开始收费时间
  777. $live_fee = intval($video_info['live_fee']);//付费直播 收费多少
  778. $is_live_pay = intval($video_info['is_live_pay']);
  779. $live_pay_type = intval($video_info['live_pay_type']);
  780. if($live_pay_time!=''&&$live_fee>0) {
  781. //$is_enable = 0;
  782. if (($is_live_pay == 1 && $live_pay_type == 1 && $plugin['class_name'] == 'live_pay_scene') || ($is_live_pay == 1 && $live_pay_type == 0 && $plugin['class_name'] == 'live_pay')) {
  783. $is_active = 1;
  784. }
  785. if ($video['public_screen']==0) {
  786. if ($plugin['class_name'] == 'live_pay') {
  787. $is_enable = 0;
  788. if ($is_active) {
  789. $error = '按时付费直播正在使用中...';
  790. } else {
  791. $error = '按场付费直播正在使用中...';
  792. }
  793. } else if ($plugin['class_name'] == 'live_pay_scene') {
  794. $is_enable = 0;
  795. if ($is_active) {
  796. $error = '按场付费直播正在使用中...';
  797. } else {
  798. $error = '按时付费直播正在使用中...';
  799. }
  800. }
  801. }
  802. }
  803. $plugin['is_active'] = $is_active;
  804. $plugin['is_enable'] = $is_enable;
  805. }
  806. if(defined('OPEN_PAI_MODULE') && OPEN_PAI_MODULE==1){
  807. if($plugin['class_name'] == 'pai'){
  808. if($video['pai_id'] != 0) {
  809. $pai_goods = $GLOBALS['db']->getRow("SELECT create_time,pai_time,status FROM ".DB_PREFIX."pai_goods WHERE id=".$video['pai_id']." ");
  810. if ($pai_goods) {
  811. if(NOW_TIME < $pai_goods['create_time'] + $pai_goods['pai_time']*3600 || $pai_goods['status'] < 2){
  812. $is_enable = 0;
  813. $error ='竞拍正在使用中...';
  814. }
  815. }
  816. }
  817. if(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE==1){
  818. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/GamesRedisService.php');
  819. $redis = new GamesRedisService();
  820. $last_game = $video_info['game_log_id'];
  821. if ($last_game) {
  822. $last_game = $redis->get($last_game, 'game_id,create_time,long_time');
  823. $game_id = $last_game['game_id'];
  824. $is_enable = $game_id ? intval($plugin_id == $game_id) : 1;
  825. if ($game_id) {
  826. $error = $plugin_id == $game_id ? '游戏正在使用中...' : '请先关闭当前游戏再切换...';
  827. }
  828. }
  829. }
  830. $plugin['is_enable'] = $is_enable;
  831. }
  832. }
  833. if(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE==1){
  834. if($plugin['type'] == 2){
  835. $game_id = 0;
  836. if($video['id']) {
  837. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/GamesRedisService.php');
  838. $redis = new GamesRedisService();
  839. $last_game = $video_info['game_log_id'];
  840. if ($last_game) {
  841. $last_game = $redis->get($last_game, 'game_id,create_time,long_time');
  842. $game_id = $last_game['game_id'];
  843. $is_enable = $game_id ? intval($plugin_id == $game_id) : 1;
  844. if ($game_id) {
  845. $error = $plugin_id == $game_id ? '游戏正在使用中...' : '请先关闭当前游戏再切换...';
  846. }
  847. }
  848. if(defined('OPEN_PAI_MODULE') && OPEN_PAI_MODULE==1){
  849. $pai_goods = $GLOBALS['db']->getRow("SELECT create_time,pai_time FROM ".DB_PREFIX."pai_goods WHERE id=".$video['pai_id']." ");
  850. if ($pai_goods) {
  851. $is_enable = 0;
  852. $error ='竞拍正在使用中...';
  853. }
  854. }
  855. }
  856. $plugin['is_enable'] = $is_enable;
  857. }
  858. }
  859. $root['class_name'] = $plugin['class_name'];
  860. $root['is_enable'] = $plugin['is_enable'];
  861. if($error!='')$root['error'] = $error;
  862. ajax_return($root);
  863. }
  864. }
  865. /**
  866. * 接收APP端错误日志
  867. */
  868. public function log_err()
  869. {
  870. $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
  871. $dev_type = strim($_REQUEST['sdk_type']);
  872. $sdk_version_name = strim($_REQUEST['sdk_version_name']);
  873. $sdk_version = strim($_REQUEST['sdk_version']);//升级版本号yyyymmddnn: 2016021601
  874. $err = trim($_REQUEST['desc']);
  875. if($err!=''){
  876. log_err_file(array($dev_type,$sdk_version_name,$sdk_version,$agent,$err));
  877. }
  878. }
  879. }