app.action.php 38 KB

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