ConfAction.class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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 ConfAction extends CommonAction{
  10. //检查模块开关是否开启
  11. public function check_Module(){
  12. $m_config = load_auto_cache("m_config");
  13. if($m_config['has_dirty_words']==0){
  14. $this->redirect('APP_ROOT+'.get_manage_url_name().'?m=Conf&a=mobile&');
  15. }
  16. }
  17. public function index()
  18. {
  19. $conf_res = M("Conf")->where("is_effect = 1 and is_conf = 1")->order("group_id asc,sort asc")->findAll();
  20. foreach($conf_res as $k=>$v)
  21. {
  22. $v['value'] = htmlspecialchars($v['value']);
  23. /*if($v['name']=='TEMPLATE')
  24. {
  25. //输出现有模板文件夹
  26. $directory = APP_ROOT_PATH."admin/app/Tpl/";
  27. $dir = @opendir($directory);
  28. $tmpls = array();
  29. while (false !== ($file = @readdir($dir)))
  30. {
  31. if($file!='.'&&$file!='..')
  32. $tmpls[] = $file;
  33. }
  34. @closedir($dir);
  35. //end
  36. $v['input_type'] = 1;
  37. $v['value_scope'] = $tmpls;
  38. }
  39. elseif($v['name']=='SHOP_LANG')
  40. {
  41. //输出现有语言包文件夹
  42. $directory = APP_ROOT_PATH."app/Lang/";
  43. $dir = @opendir($directory);
  44. $tmpls = array();
  45. while (false !== ($file = @readdir($dir)))
  46. {
  47. if($file!='.'&&$file!='..')
  48. $tmpls[] = $file;
  49. }
  50. @closedir($dir);
  51. //end
  52. $v['input_type'] = 1;
  53. $v['value_scope'] = $tmpls;
  54. }
  55. else*/
  56. $v['value_scope'] = explode(",",$v['value_scope']);
  57. $conf[$v['group_id']][] = $v;
  58. }
  59. $ticke_name = M("MConfig")->where("code='ticket_name'")->getField("val");
  60. $this->assign("ticke_name",$ticke_name);
  61. $this->assign("conf",$conf);
  62. $this->display();
  63. }
  64. public function update()
  65. {
  66. $conf_res = M("Conf")->where("is_effect = 1 and is_conf = 1")->findAll();
  67. foreach($conf_res as $k=>$v)
  68. {
  69. conf($v['name'],$_REQUEST[$v['name']]);
  70. if($v['name']=='URL_MODEL'&&$v['value']!=$_REQUEST[$v['name']])
  71. {
  72. clear_dir_file(get_real_path()."public/runtime/app/data_caches/");
  73. clear_dir_file(get_real_path()."public/runtime/app/tpl_caches/");
  74. clear_dir_file(get_real_path()."public/runtime/app/tpl_compiled/");
  75. clear_dir_file(get_real_path()."public/runtime/app/data_caches/");
  76. clear_dir_file(get_real_path()."public/runtime/data/page_static_cache/");
  77. clear_dir_file(get_real_path()."public/runtime/data/dynamic_avatar_cache/");
  78. }
  79. }
  80. $sys_configs_array = array();
  81. //开始写入配置文件
  82. $sys_configs = M("Conf")->findAll();
  83. $config_str = "<?php\n";
  84. $config_str .= "return array(\n";
  85. foreach($sys_configs as $k=>$v)
  86. {
  87. $config_str.="'".$v['name']."'=>'".addslashes($v['value'])."',\n";
  88. $sys_configs_array[$v['name']] = addslashes($v['value']);
  89. }
  90. $config_str.=");\n ?>";
  91. $filename = get_real_path()."public/sys_config.php";
  92. if (!$handle = fopen($filename, 'w')) {
  93. $this->error(l("OPEN_FILE_ERROR").$filename);
  94. }
  95. if (fwrite($handle, $config_str) === FALSE) {
  96. $this->error(l("WRITE_FILE_ERROR").$filename);
  97. }
  98. fclose($handle);
  99. save_log(l("CONF_UPDATED"),1);
  100. //clear_cache();
  101. write_timezone();
  102. //var_dump($sys_configs_array);exit;
  103. create_app_js($sys_configs_array);
  104. $this->success(L("UPDATE_SUCCESS"));
  105. }
  106. public function mobile()
  107. {
  108. $config = M("MConfig")->order("sort asc")->findAll();
  109. static $society_pattern ;//记录公会模式 ljz
  110. foreach($config as $k=>$v){
  111. /*if($v['code']=='wx_appid'){
  112. $wx_appid=$v['val'];
  113. continue;
  114. }
  115. if($v['code']=='wx_secrit'){
  116. $wx_secrit=$v['val'];
  117. continue;
  118. }*/
  119. if($v['group_id'] == '鲜肉设置'){
  120. unset($config[$k]);
  121. continue;
  122. }
  123. if(!defined('OPEN_PC') || OPEN_PC != 1) {
  124. /*if(in_array($v['code'], array(
  125. 'rank_cache_time',
  126. 'videotime_to_experience',
  127. 'contribution_to_experience',
  128. 'wx_web_appid',
  129. 'wx_web_secrit',
  130. 'sina_web_app_key',
  131. 'sina_web_app_secret',
  132. 'qq_web_app_id',
  133. 'qq_web_app_key',
  134. 'qq_wpa_key',
  135. 'pc_logo',
  136. ))){
  137. unset($config[$k]);
  138. continue;
  139. }*/
  140. if($v['group_id'] == 'PC端设置'){
  141. unset($config[$k]);
  142. continue;
  143. }
  144. } else if (defined('ONLY_PC') && ONLY_PC == 1) {
  145. if(!in_array($v['code'], array(
  146. 'rank_cache_time',
  147. 'videotime_to_experience',
  148. 'contribution_to_experience',
  149. 'wx_web_appid',
  150. 'wx_web_secrit',
  151. 'sina_web_app_key',
  152. 'sina_web_app_secret',
  153. 'qq_web_app_id',
  154. 'qq_web_app_key',
  155. 'qq_wpa_key',
  156. 'pc_logo',
  157. 'short_name',
  158. 'share_title',
  159. 'short_video_time',
  160. 'monitor_overtime',
  161. 'robot_num',
  162. 'virtual_number',
  163. 'tim_sdkappid',
  164. 'tim_identifier',
  165. 'tim_account_type',
  166. 'qcloud_secret_id',
  167. 'qcloud_secret_key',
  168. 'diamonds_rate',
  169. 'exchange_rate',
  170. 'kf_phone',
  171. 'ticket_name',
  172. 'profit_ratio',
  173. 'has_is_authentication',
  174. // 2.1
  175. 'has_dirty_words',
  176. 'must_authentication',
  177. ))){
  178. unset($config[$k]);
  179. continue;
  180. }
  181. }
  182. //声网
  183. if((!defined('SOUND_NETWORK')||SOUND_NETWORK!=1)&&$v['code']=='agora_app_id'){
  184. unset($config[$k]);
  185. continue;
  186. }
  187. if((!defined('SOUND_NETWORK')||SOUND_NETWORK!=1)&&$v['code']=='agora_app_certificate'){
  188. unset($config[$k]);
  189. continue;
  190. }
  191. if((!defined('SOUND_NETWORK')||SOUND_NETWORK!=1)&&$v['code']=='agora_anchor_resolution'){
  192. unset($config[$k]);
  193. continue;
  194. }
  195. if((!defined('SOUND_NETWORK')||SOUND_NETWORK!=1)&&$v['code']=='agora_audience_resolution'){
  196. unset($config[$k]);
  197. continue;
  198. }
  199. //发言等级
  200. if((!defined('OPEN_SPEAK_LEVEL')||OPEN_SPEAK_LEVEL!=1)&&$v['code']=='speak_level'){
  201. unset($config[$k]);
  202. continue;
  203. }
  204. if(!(defined('OPEN_MISSION') && OPEN_MISSION == 1) && in_array(['mission_switch','mission_money','mission_max_times','mission_time','mission_name','mission_desc'], $v['code'])){
  205. unset($config[$k]);
  206. continue;
  207. }
  208. //置顶权重
  209. if((!defined('OPEN_STICK')||OPEN_STICK!=1)&&$v['code']=='top_weight'){
  210. unset($config[$k]);
  211. continue;
  212. }
  213. //审核时间
  214. if((!defined('EXAMINE_TIME')||EXAMINE_TIME!=1)&&$v['code']=='attestation_time'){
  215. unset($config[$k]);
  216. continue;
  217. }
  218. //家族
  219. if(!defined('OPEN_FAMILY_MODULE')||OPEN_FAMILY_MODULE!=1){
  220. if($v['code']=='profit_ratio'||$v['code']=='family_profit_platform'||$v['code']=='videotime_to_experience'||$v['code']=='contribution_to_experience') {
  221. unset($config[$k]);
  222. continue;
  223. }
  224. }
  225. //登录送积分
  226. if((!defined('OPEN_LOGIN_SEND_SCORE')||OPEN_LOGIN_SEND_SCORE!=1)&&$v['code']=='login_send_score'){
  227. unset($config[$k]);
  228. continue;
  229. }
  230. //升级提升
  231. if((!defined('OPEN_UPGRADE_PROMPT')||OPEN_UPGRADE_PROMPT!=1)&&$v['code']=='upgrade_level'){
  232. unset($config[$k]);
  233. continue;
  234. }
  235. //付费
  236. if((!defined('OPEN_LIVE_PAY')||OPEN_LIVE_PAY!=1)&&$v['group_id']=='付费直播配置'){
  237. unset($config[$k]);
  238. continue;
  239. }
  240. //分销
  241. if((!defined('OPEN_DISTRIBUTION')||OPEN_DISTRIBUTION!=1)&&$v['group_id']=='分销模块'){
  242. unset($config[$k]);
  243. continue;
  244. }
  245. //PC端
  246. if((!defined('OPEN_PC')||OPEN_PC!=1)&&$v['group_id']=='PC端设置'){
  247. unset($config[$k]);
  248. continue;
  249. }
  250. //分享收益
  251. if((!defined('OPEN_SHARE_EXPERIENCE')||OPEN_SHARE_EXPERIENCE!=1)){
  252. if($v['code']=='open_share_ticket' || $v['code']=='share_ticket'){
  253. unset($config[$k]);
  254. continue;
  255. }
  256. }
  257. if((!defined('OPEN_PAI_MODULE')||OPEN_PAI_MODULE!=1)){
  258. if($v['code']=='ticket_exchange_rate'){
  259. unset($config[$k]);
  260. continue;
  261. }
  262. }
  263. //游客
  264. if((!defined('VISITORS')||VISITORS!=1)){
  265. if($v['code']=='open_visitors_login'){
  266. unset($config[$k]);
  267. continue;
  268. }
  269. }
  270. //支付宝认证
  271. if((!defined('OPEN_AUTHENT_ALIPAY')||OPEN_AUTHENT_ALIPAY!=1)){
  272. if($v['code']=='authent_alipay'||$v['code']=='alipay_partner'||$v['code']=='alipay_key'){
  273. unset($config[$k]);
  274. continue;
  275. }
  276. }
  277. //分销
  278. if((!defined('OPEN_DISTRIBUTION')||OPEN_DISTRIBUTION!=1)){
  279. if($v['code']=='distribution'||$v['code']=='distribution_rate'){
  280. unset($config[$k]);
  281. continue;
  282. }
  283. }
  284. //VIP
  285. if((!defined('OPEN_VIP')||OPEN_VIP!=1)&&$v['code']=='open_vip'){
  286. unset($config[$k]);
  287. continue;
  288. }
  289. //房间隐藏
  290. if((!defined('OPEN_ROOM_HIDE')||OPEN_ROOM_HIDE!=1)&&$v['code']=='open_room_hide'){
  291. unset($config[$k]);
  292. continue;
  293. }
  294. //公会模式开关ljz
  295. if((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1)){
  296. if($v['code']=='society_pattern' || $v['code']=='society_platform_earnings'){
  297. unset($config[$k]);
  298. continue;
  299. }
  300. }
  301. if($v['code']=='society_pattern' && $v['val']==1){//有抽成模式下才显示 (是否平台支付公会收益)(公会收益比例)
  302. $society_pattern = 1;
  303. }elseif ($v['code']=='society_pattern' && $v['val']==2){//(对公结算比例)(主播对公结算比例)
  304. $society_pattern = 2;
  305. }elseif ($v['code']=='society_pattern' && $v['val']==0){//关闭上面四个
  306. $society_pattern = 0;
  307. }
  308. //对公结算比例
  309. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && $v['code']=='society_public_rate'){
  310. unset($config[$k]);
  311. continue;
  312. }
  313. //主播对公结算比例
  314. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_user_rate')){
  315. unset($config[$k]);
  316. continue;
  317. }
  318. //是否平台支付公会收益
  319. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_profit_platform')){
  320. unset($config[$k]);
  321. continue;
  322. }
  323. //公会收益比例
  324. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_profit_ratio')){
  325. unset($config[$k]);
  326. continue;
  327. }
  328. //直播时长积分转化比
  329. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_lv_videotime')){
  330. unset($config[$k]);
  331. continue;
  332. }
  333. //成员贡献积分转化比
  334. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_lv_contribution')){
  335. unset($config[$k]);
  336. continue;
  337. }
  338. //公会邀请码
  339. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='open_society_code')){
  340. unset($config[$k]);
  341. continue;
  342. }
  343. //公会名称
  344. if( ((!defined('OPEN_SOCIETY_MODULE')||OPEN_SOCIETY_MODULE!=1) ) && ($v['code']=='society_list_name')){
  345. unset($config[$k]);
  346. continue;
  347. }
  348. if(!(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE && !(defined('OPEN_DIAMOND_GAME_MODULE') && OPEN_DIAMOND_GAME_MODULE)) && $v['code']=='coin_exchange_rate'){
  349. unset($config[$k]);
  350. continue;
  351. }
  352. if (!(defined('GAME_GAIN_FOR_ALERT') && GAME_GAIN_FOR_ALERT) && $v['code']=='game_gain_for_alert') {
  353. unset($config[$k]);
  354. continue;
  355. }
  356. if (!(defined('GAME_COMMISSION') && GAME_COMMISSION) && $v['code']=='game_commission') {
  357. unset($config[$k]);
  358. continue;
  359. }
  360. if (!(defined('GAME_DISTRIBUTION') && GAME_DISTRIBUTION) && $v['code']=='game_distribution1') {
  361. unset($config[$k]);
  362. continue;
  363. }
  364. if (!(defined('GAME_DISTRIBUTION') && GAME_DISTRIBUTION) && $v['code']=='game_distribution2') {
  365. unset($config[$k]);
  366. continue;
  367. }
  368. if (!(defined('WEIXIN_DISTRIBUTION') && WEIXIN_DISTRIBUTION) && $v['code']=='weixin_first_rate') {
  369. unset($config[$k]);
  370. continue;
  371. }
  372. if (!(defined('WEIXIN_DISTRIBUTION') && WEIXIN_DISTRIBUTION) && $v['code']=='weixin_second_rate') {
  373. unset($config[$k]);
  374. continue;
  375. }
  376. if (!(defined('ENTER_INVITATION_CODE') && ENTER_INVITATION_CODE) && $v['code']=='enter_invitation_code') {
  377. unset($config[$k]);
  378. continue;
  379. }
  380. if (!(defined('ENTER_INVITATION_CODE') && ENTER_INVITATION_CODE) && $v['code']=='enter_invitation_code_tip') {
  381. unset($config[$k]);
  382. continue;
  383. }
  384. if (!(defined('OPEN_INVITE_CODE') && OPEN_INVITE_CODE) && $v['code']=='invite_ratio') {
  385. unset($config[$k]);
  386. continue;
  387. }
  388. if (!(defined('GAME_AUTO_START') && GAME_AUTO_START) && $v['code']=='auto_time') {
  389. unset($config[$k]);
  390. continue;
  391. }
  392. if (!defined('ROBOT_PROP') && ROBOT_PROP && in_array($v['code'], 'robot_prop_num','robot_prop_diamonds','robot_prop_total_diamonds','robot_prop_interval','robot_prop_real_interval')) {
  393. unset($config[$k]);
  394. continue;
  395. }
  396. if($v['code']=='full_group_id'|| $v['code']=='on_line_group_id'){
  397. unset($config[$k]);
  398. continue;
  399. }
  400. //付费 按时
  401. if(intval(LIVE_PAY_TIME)==0){
  402. if($v['code']=='live_pay_max' || $v['code']=='live_pay_min'|| $v['code']=='live_count_down'|| $v['code']=='live_pay_rule'|| $v['code']=='live_pay_fee'|| $v['code']=='is_only_play_video'|| $v['code']=='live_pay_num'|| $v['code']=='countdown'){
  403. unset($config[$k]);
  404. continue;
  405. }
  406. }
  407. //付费 按场
  408. if(intval(LIVE_PAY_SCENE)==0){
  409. if($v['code']=='live_pay_scene_max' || $v['code']=='live_pay_scene_min' || $v['code'] == 'pc_live_fee'){
  410. unset($config[$k]);
  411. continue;
  412. }
  413. }
  414. //后台短信验证
  415. if(intval(OPEN_CHECK_ACCOUNT)==0){
  416. if($v['code']=='account_ip' || $v['code']=='account_mobile'){
  417. unset($config[$k]);
  418. continue;
  419. }
  420. }
  421. //多支付宝账号功能
  422. if(intval(MORE_ALIPAY)==0){
  423. if($v['code']=='alipay_cache_time'){
  424. unset($config[$k]);
  425. continue;
  426. }
  427. }
  428. //隐藏客户端不许自义美颜度
  429. if($v['code']=='beauty_close'){
  430. unset($config[$k]);
  431. continue;
  432. }
  433. /*if($v['code']=='mic_max_num'){
  434. unset($config[$k]);
  435. continue;
  436. }*/
  437. //隐藏直播类型: 默认为 云直播 video_type=1
  438. /*if ($v['code'] == 'video_type' || $v['group_id'] == '方维云') {
  439. if(!defined('OPEN_FWYUN') || OPEN_FWYUN != 1){
  440. unset($config[$k]);
  441. continue;
  442. }
  443. }*/
  444. //隐藏注册礼物配置
  445. if ($v['code'] == 'register_gift' || $v['code'] == 'register_gift_diamonds'|| $v['code'] == 'register_gift_coins') {
  446. if(!defined('OPEN_REGISTER_GIFT') || OPEN_REGISTER_GIFT != 1){
  447. unset($config[$k]);
  448. continue;
  449. }
  450. }
  451. //大型礼物赠送的全服通告开关
  452. if((!defined('PROP_NOTIFY')||PROP_NOTIFY!=1))
  453. {
  454. if($v['code']=='is_prop_notify')
  455. {
  456. unset($config[$k]);
  457. continue;
  458. }
  459. }
  460. //PC端
  461. if((!defined('QK_TREE')||QK_TREE!=1)&&$v['group_id']=='树苗配置'){
  462. unset($config[$k]);
  463. continue;
  464. }
  465. //移除苹果价格是否与其他支付一致
  466. if($v['code']=='iap_recharge'){
  467. unset($config[$k]);
  468. continue;
  469. }
  470. //移除旧的发言等级
  471. if($v['code']=='speak_level'){
  472. unset($config[$k]);
  473. continue;
  474. }
  475. //移除邀请奖励
  476. if(intval(OPEN_REWARD_POINT)==0&&$v['code']=='reward_point_diamonds'){
  477. unset($config[$k]);
  478. continue;
  479. }
  480. if($v['type']==2){
  481. $v['val'] =get_spec_image($v['val']);
  482. }
  483. if($v['type']==4){
  484. $v['value_scope']=explode(',',$v['value_scope']);
  485. $v['title_scope']=explode(',',$v['title_scope']);
  486. }else{
  487. $v['value_scope']='';
  488. }
  489. $conf[$v['group_id']][] = $v;
  490. }
  491. /*if(!empty($wx_appid)&&!empty($wx_secrit)){
  492. require APP_ROOT_PATH."system/utils/weixin.php";
  493. $weixin=new weixin($wx_appid,$wx_secrit,get_domain().APP_ROOT."/wap");
  494. $wx_url=$weixin->scope_get_code();
  495. }
  496. $this->assign('wx_url',$wx_url);*/
  497. $is_limit_time_h = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24");
  498. $this->assign("is_limit_time_h",$is_limit_time_h);
  499. $this->assign("conf",$conf);
  500. $this->assign("domain_url",get_domain());
  501. $this->display();
  502. }
  503. public function savemobile()
  504. {
  505. foreach($_POST as $k=>$v)
  506. {
  507. /* if($k=='app_logo'&&$v!=''){
  508. $index = strpos($v,"/public/");
  509. $v = ".".substr($v,$index);
  510. syn_to_remote_image_server($v);
  511. }*/
  512. if($k=='rank_day'||$k=='rank_month'||$k=='rank_all'||$k=='rank_day_user'){
  513. $result = $this->check_rank_time(array('name'=>$k,'value'=>strim($v)));
  514. if($result['status']==0){
  515. $this->error($result['error']);
  516. }
  517. }
  518. if((defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1)&&($k=='live_pay_num'||$k=='pc_live_fee'||$k=='live_pay_rule'||$k=='live_pay_fee'||$k=='live_count_down'||$k=='ticket_to_rate'||$k=='uesddiamonds_to_score')){
  519. if(floor($v)!=$v){
  520. $this->error("付费直播的参数必须为整数");
  521. }
  522. }
  523. if((defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1)&&($k=='live_pay_max'||$k=='live_pay_min'||$k=='live_pay_scene_max'||$k=='live_pay_scene_min')){
  524. if(floor($v)!=$v){
  525. $this->error("付费直播的收费参数必须为整数");
  526. }
  527. }
  528. if(defined('OPEN_STICK')&&OPEN_STICK==1){
  529. if(intval($_POST['top_weight'])<1){
  530. $this->error("置顶权重值不能小于1");
  531. }
  532. }
  533. //公会配置添加限制ljz
  534. if(defined('OPEN_SOCIETY_MODULE') && OPEN_SOCIETY_MODULE){
  535. if($k=='society_public_rate'){
  536. if(floatval($v) <= 0 || floatval($v) >= 1){
  537. $this->error("对公结算比例方维0~1之间");
  538. }
  539. }
  540. if($k=='society_user_rate'){
  541. if(floatval($v) <= 0 || floatval($v) >= 1){
  542. $this->error("主播对公结算比例方维0~1之间");
  543. }
  544. }
  545. }
  546. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  547. if(intval(LIVE_PAY_TIME)==1){
  548. if(intval($_POST['live_pay_min'])<1){
  549. $this->error("按时收费最低收费参数不能小于1");
  550. }
  551. if(intval($_POST['live_pay_max'])!=0&&intval($_POST['live_pay_max'])<intval($_POST['live_pay_min'])){
  552. $this->error("按时收费最低收费参数必须小于按时收费最高收费参数");
  553. }
  554. }
  555. if(intval(LIVE_PAY_SCENE)==1){
  556. if(intval($_POST['live_pay_scene_min'])<1){
  557. $this->error("按场收费最低收费参数不能小于1");
  558. }
  559. if(intval($_POST['live_pay_scene_max'])!=0&&intval($_POST['live_pay_scene_max'])<intval($_POST['live_pay_scene_min'])){
  560. $this->error("按场收费最低收费参数必须小于按场收费最高收费参数");
  561. }
  562. if(intval($_POST['pc_live_fee']) > 0){
  563. if(intval($_POST['pc_live_fee']) < intval($_POST['live_pay_scene_min'])){
  564. $this->error("PC端付费直播费率不能小于按场收费最低收费");
  565. }
  566. if(intval($_POST['live_pay_scene_max']) < intval($_POST['pc_live_fee'])){
  567. $this->error("PC端付费直播费率必须小于按场收费最高收费参数");
  568. }
  569. }
  570. }
  571. }
  572. if($_POST['qcloud_secret_id']==''||$_POST['qcloud_secret_key']==''){
  573. if($_POST['has_dirty_words']==1){
  574. $this->error("腾讯云API账号或腾讯云API密钥未填写,无法启用脏字库");
  575. }
  576. }
  577. $res = M("MConfig")->where("code='".$k."'")->setField("val",trim($v));
  578. if($res)
  579. {
  580. $this->addself_init_version();
  581. }
  582. }
  583. $tourist_chat = $_POST['tourist_chat'];
  584. if($tourist_chat != ''){
  585. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  586. $api = createTimAPI();
  587. $id = 0;
  588. if($tourist_chat){
  589. $time = 0;
  590. }else{
  591. $time = 4294967295;
  592. }
  593. $ret = $api->set_no_speaking($id,$time);
  594. if($ret['ErrorCode']){
  595. $ret = $api->set_no_speaking($id,$time);
  596. }
  597. if($ret['ErrorCode']) {
  598. $this->error("开启游客发言失败");
  599. }
  600. }
  601. clear_auto_cache("m_config");
  602. $log_info = "手机端配置";
  603. save_log($log_info.L("UPDATE_SUCCESS"),1);
  604. $this->success("保存成功");
  605. }
  606. //脏字库
  607. public function dirty_words(){
  608. $this->check_Module();
  609. //调用tim
  610. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  611. $api = createTimAPI();
  612. $ret = $api->openim_dirty_words_get();
  613. $vo = array();
  614. $vo['title'] = '脏字库';
  615. $vo['content'] = implode(',',$ret['DirtyWordsList']);
  616. $this->assign ( 'vo', $vo );
  617. $this->display ();
  618. }
  619. //保存脏字库
  620. public function save_dirty_words(){
  621. $this->check_Module();
  622. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  623. $api = createTimAPI();
  624. $content = trim($_REQUEST['content']);
  625. //开始验证有效性
  626. if(!check_empty($content))
  627. {
  628. $this->error("脏字库内容不能为空");
  629. }
  630. if(count(explode(',',$content))>50)
  631. {
  632. $this->error("脏字库词数量不能大于50");
  633. }
  634. if($this->arrayHasOnlyInts(explode(',',$content)))
  635. {
  636. $this->error("数字不能添加到脏字库");
  637. }
  638. $ret = $api->openim_dirty_words_get();
  639. $old_words =array();
  640. $old_words = $ret['DirtyWordsList'];
  641. $new_words = array();
  642. $new_words = explode(',',$content);
  643. //未修改
  644. if(count($old_words)==count($new_words)){
  645. $this->error("未修改脏字库");die;
  646. }
  647. //添加OR删除
  648. if(count($old_words)>count($new_words)){
  649. $dirty_words_list = array_values(array_diff($old_words,$new_words));
  650. $ret = $api->openim_dirty_words_delete($dirty_words_list);
  651. $act = '更新';
  652. }else{
  653. $dirty_words_list = array_values(array_diff($new_words,$old_words));
  654. $ret = $api->openim_dirty_words_add($dirty_words_list);
  655. $act = '追加';
  656. }
  657. $log_info = '脏字库';
  658. if($ret['ErrorCode']==0) {
  659. //成功提示
  660. save_log($log_info.$act.'成功!',1);
  661. $this->success($log_info.$act.'成功!');
  662. } else {
  663. //错误提示
  664. save_log($log_info.$act.'失败!',0);
  665. $this->error($log_info.$act.'失败!');
  666. }
  667. }
  668. //判断数组是否包含数字
  669. function arrayHasOnlyInts($array)
  670. {
  671. $this->check_Module();
  672. foreach ($array as $value)
  673. {
  674. if($value!="0"){
  675. $value = intval($value);
  676. if (is_int($value)&&$value>0)
  677. {
  678. return true;
  679. }
  680. }else{
  681. return true;
  682. }
  683. }
  684. return false;
  685. }
  686. //检查排行榜缓存时间
  687. function check_rank_time($data){
  688. $result = array('status'=>1,'error'=>'');
  689. //日榜
  690. if($data['name']=='rank_day'&&$data['value'] <1){
  691. $result['status'] = 0;
  692. $result['error'] = '总排行日榜缓存时间,不得低1800秒';
  693. }
  694. //总排行月榜
  695. if($data['name']=='rank_month'&&$data['value'] <28800){
  696. $result['status'] = 0;
  697. $result['error'] = '总排行月榜缓存时间,不得低28800秒';
  698. }
  699. //总排行总榜
  700. if($data['name']=='rank_all'&&$data['value'] <86400){
  701. $result['status'] = 0;
  702. $result['error'] = '总排行总榜缓存时间,不得低86400秒';
  703. }
  704. //主播日排行榜
  705. if($data['name']=='rank_day_user'&&$data['value'] <300){
  706. $result['status'] = 0;
  707. $result['error'] = '主播日排行榜缓存时间,不得低300秒';
  708. }
  709. return $result;
  710. }
  711. function addself_init_version()
  712. {
  713. //更新初始化版本号
  714. $sql = "update ".DB_PREFIX."m_config set val = val + 1 where code = 'init_version'";
  715. $GLOBALS['db']->query($sql);
  716. }
  717. }
  718. ?>