BmUserCommonAction.class.php 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  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. //相同操作
  10. class BmUserCommon extends CommonAction{
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. require_once APP_ROOT_PATH."/system/libs/user.php";
  15. }
  16. public function index($date)
  17. {
  18. if(trim($date['nick_name'])!='')
  19. {
  20. $parameter.= "nick_name like " . urlencode ( '%'.trim($date['nick_name']).'%' ) . "&";
  21. $sql_w .= "nick_name like '%".trim($date['nick_name'])."%' and ";
  22. }
  23. if(trim($date['mobile'])!='')
  24. {
  25. $parameter.= "mobile like " . urlencode ( '%'.trim($date['mobile']).'%' ) . "&";
  26. $sql_w .= "mobile like '%".trim($date['mobile'])."%' and ";
  27. }
  28. $create_time_2=empty($_REQUEST['create_time_2'])?to_date(get_gmtime(),'Y-m-d'):strim($date['create_time_2']);
  29. $create_time_2=to_timespan($create_time_2)+24*3600;
  30. if(trim($date['create_time_1'])!='' )
  31. {
  32. $parameter.="create_time between '". to_timespan($date['create_time_1']) . "' and '". $create_time_2 ."'&";
  33. $sql_w .=" (create_time between '". to_timespan($date['create_time_1']). "' and '". $create_time_2 ."' ) and ";
  34. }
  35. if(intval($date['id'])>0)
  36. {
  37. $parameter.= "id=" . intval($date['id']). "&";
  38. $sql_w .= "id=".intval($date['id'])." and ";
  39. }
  40. if($date['is_effect']!=NULL){
  41. $parameter.= "is_effect=" . intval($date['is_effect']). "&";
  42. $sql_w .= "is_effect=".intval($date['is_effect'])." and ";
  43. }else{
  44. $parameter.= "is_effect=1&";
  45. $sql_w .= "is_effect=1 and ";
  46. }
  47. if($_REQUEST['is_admin']!='')
  48. {
  49. $parameter.= "is_admin=" . intval($date['is_admin']). "&";
  50. $sql_w .= "is_admin=".intval($date['is_admin'])." and ";
  51. }
  52. if (!isset($_REQUEST['is_authentication'])) {
  53. $_REQUEST['is_authentication'] = -1;
  54. }
  55. if($_REQUEST['is_authentication']!=-1) {
  56. if (isset($date['is_authentication'])) {
  57. $parameter .= "is_authentication in (" . $date['is_authentication'] . ")&";
  58. $sql_w .= "is_authentication in (" . $date['is_authentication'] . ") and ";
  59. }
  60. }
  61. if(isset($date['is_robot'])){
  62. $parameter.= "is_robot=" . intval($date['is_robot']). "&";
  63. $sql_w .= "is_robot=".intval($date['is_robot'])." and ";
  64. }else{
  65. $parameter.= "is_robot=0&";
  66. $sql_w .= "is_robot=0 and ";
  67. }
  68. $m_config = load_auto_cache("m_config");//初始化手机端配置
  69. if(defined('OPEN_VIP')&&OPEN_VIP==1){
  70. if($_REQUEST['is_vip']!='')
  71. {
  72. $parameter.= "is_vip=" . intval($date['is_vip']). "&";
  73. $sql_w .= "is_vip=".intval($date['is_vip'])." and ";
  74. }
  75. $this->assign ( 'open_vip', 1 );
  76. }
  77. $model = D ();
  78. $m_config = load_auto_cache("m_config");
  79. $ote = floatval($m_config['onlinetime_to_experience']);
  80. $sql_str = "SELECT *," .
  81. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  82. " FROM ".DB_PREFIX."user WHERE 1=1 ";
  83. $count_sql = "SELECT count(*) as tpcount" .
  84. " FROM ".DB_PREFIX."user WHERE (1=1 ";
  85. if(intval($date['id']) == 0){
  86. $sql_str .= " and ".$sql_w." 1=1 ";
  87. $count_sql .= " and ".$sql_w." 1=1) ";
  88. }else{
  89. $sql_str .= " and ".$sql_w." 1=1 union SELECT *," .
  90. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  91. " FROM ".DB_PREFIX."user WHERE luck_num=".$date['id'];
  92. $count_sql .= " and ".$sql_w." 1=1 ) or (luck_num=".$date['id'].")";
  93. }
  94. $distribution_log = 0;
  95. if(defined('OPEN_DISTRIBUTION') && OPEN_DISTRIBUTION==1){
  96. $distribution_log = 1;
  97. }
  98. $coins = 0;
  99. if(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE==1){
  100. $coins = 1;
  101. }
  102. $goods = 0;
  103. if((defined('SHOPPING_GOODS') && SHOPPING_GOODS==1) || (defined('PAI_REAL_BTN') && PAI_REAL_BTN==1)){
  104. $goods = 1;
  105. }
  106. $voList = $this->_Sql_list($model, $sql_str, "&".$parameter,'id',0,$count_sql);
  107. foreach($voList as $k=>$v){
  108. $voList[$k]['nick_name'] = emoji_decode($v['nick_name']);
  109. $voList[$k]['head_image'] = get_spec_image($v['head_image']);
  110. $voList[$k]['distribution_log'] = $distribution_log;
  111. $voList[$k]['coins'] = $coins;
  112. $voList[$k]['goods'] = $goods;
  113. $voList[$k]['ticket'] = $v['ticket']+$v['no_ticket'];
  114. }
  115. $this->assign ( 'list', $voList );
  116. $this->display ();
  117. }
  118. public function add(){
  119. $region_lv2 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where region_level = 2 order by py asc"); //二级地址
  120. $this->assign("region_lv2",$region_lv2);
  121. //会员等级信息
  122. $user_level = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_level order by level ASC");
  123. $this->assign("user_level",$user_level);
  124. //认证类型
  125. $authent_list = M("AuthentList")->findAll();
  126. $this->assign("authent_list",$authent_list);
  127. //分类
  128. $classifi_list = M("VideoClassified")->findAll();
  129. $this->assign("classifi_list",$classifi_list);
  130. $this->display ();
  131. }
  132. public function insert(){
  133. B('FilterString');
  134. $ajax = intval($_REQUEST['ajax']);
  135. $data = M(MODULE_NAME)->create ();
  136. //开始验证有效性
  137. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  138. if($_REQUEST['v_explain']==''){
  139. $_REQUEST['v_explain'] = $_REQUEST['authentication_type'];
  140. }
  141. $_REQUEST['v_icon'] = get_spec_image(M('AuthentList')->where("name='".trim($_REQUEST['authentication_type']."'"))->getField("icon"));
  142. $_REQUEST['score'] = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where `level`=".$_REQUEST['user_level'],true,true);
  143. $res = save_user($_REQUEST,'INSERT',$update_status=1);
  144. if($res['status']==0)
  145. {
  146. $error_field = $res['data'];
  147. if($error_field['error'] == EMPTY_ERROR)
  148. {
  149. if($error_field['field_name'] == 'user_name')
  150. {
  151. $this->error(L("USER_NAME_EMPTY_TIP"));
  152. }
  153. elseif($error_field['field_name'] == 'email')
  154. {
  155. $this->error(L("USER_EMAIL_EMPTY_TIP"));
  156. }
  157. else
  158. {
  159. $this->error(sprintf(L("USER_EMPTY_ERROR"),$error_field['field_show_name']));
  160. }
  161. }
  162. if($error_field['error'] == FORMAT_ERROR)
  163. {
  164. if($error_field['field_name'] == 'email')
  165. {
  166. $this->error(L("USER_EMAIL_FORMAT_TIP"));
  167. }
  168. elseif($error_field['field_name'] == 'mobile')
  169. {
  170. $this->error(L("USER_MOBILE_FORMAT_TIP"));
  171. }
  172. }
  173. if($error_field['error'] == EXIST_ERROR)
  174. {
  175. if($error_field['field_name'] == 'user_name')
  176. {
  177. $this->error(L("USER_NAME_EXIST_TIP"));
  178. }
  179. elseif($error_field['field_name'] == 'email')
  180. {
  181. $this->error(L("USER_EMAIL_EXIST_TIP"));
  182. }
  183. elseif($error_field['field_name'] == 'mobile')
  184. {
  185. $this->error(L("USER_MOBILE_EXIST_TIP"));
  186. }
  187. }
  188. }
  189. $user_id = intval($res['user_id']);
  190. // 更新数据
  191. $log_info = $_REQUEST['nick_name'];
  192. save_log($log_info.L("INSERT_SUCCESS"),1);
  193. $this->success(L("INSERT_SUCCESS"));
  194. }
  195. public function edit($date) {
  196. $id = intval($date['id']);
  197. $condition['id'] = $id;
  198. $vo = M('User')->where($condition)->find();
  199. $vo['ban_time'] = $vo['ban_time']>0?to_date($vo['ban_time']):'';
  200. $vo['create_time'] = $vo['create_time']>0?to_date($vo['create_time']):'';
  201. $vo['nick_name'] = emoji_decode($vo['nick_name']);
  202. $vo['signature'] = emoji_decode($vo['signature']);
  203. $m_config = load_auto_cache("m_config");//初始化手机端配置
  204. if(defined('OPEN_VIP')&&OPEN_VIP==1){
  205. $this->assign ( 'open_vip', 1 );
  206. $vip_expire_time = $vo['vip_expire_time'];
  207. $vo['vip_expire_time'] = '';
  208. if(intval($vo['is_vip'])==1){
  209. $vo['vip_expire_time'] = $vip_expire_time>0?to_date($vip_expire_time):'';
  210. if($vip_expire_time>0 && $vip_expire_time<NOW_TIME){
  211. $vo['is_vip'] = 0;
  212. $vo['vip_expire_time'] = '';
  213. $sql = "update ".DB_PREFIX."user set is_vip = 0 where id = ".$id;
  214. $GLOBALS['db']->query($sql);
  215. user_deal_to_reids(array($id));
  216. }
  217. }
  218. }
  219. if(defined('OPEN_DISTRIBUTION') && OPEN_DISTRIBUTION == 1){
  220. $this->assign('open_distribution',1);
  221. }
  222. $user_level = $GLOBALS['db']->getOne("select user_level from ".DB_PREFIX."user where id = ".$id); //二级地址
  223. $vo['user_level'] = $user_level>0?$user_level:1;
  224. //过滤头像是本地连接的问题
  225. $vo['head_image'] = get_spec_image($vo['head_image'],50,50);
  226. $this->assign ( 'vo', $vo );
  227. $region_pid = 0;
  228. $region_lv2 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where region_level = 2 order by py asc"); //二级地址
  229. foreach($region_lv2 as $k=>$v)
  230. {
  231. if($v['name'] == $vo['province'])
  232. {
  233. $region_lv2[$k]['selected'] = 1;
  234. $region_pid = $region_lv2[$k]['id'];
  235. break;
  236. }
  237. }
  238. $this->assign("region_lv2",$region_lv2);
  239. if($region_pid>0)
  240. {
  241. $region_lv3 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where pid = ".$region_pid." order by py asc"); //三级地址
  242. foreach($region_lv3 as $k=>$v)
  243. {
  244. if($v['name'] == $vo['city'])
  245. {
  246. $region_lv3[$k]['selected'] = 1;
  247. break;
  248. }
  249. }
  250. $this->assign("region_lv3",$region_lv3);
  251. }
  252. //会员等级信息
  253. $user_level = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_level where `level`>=".$user_level." order by level ASC");
  254. $this->assign("user_level",$user_level);
  255. //认证类型
  256. $authent_list = M("AuthentList")->findAll();
  257. $this->assign("authent_list",$authent_list);
  258. //分类
  259. $classifi_list = M("VideoClassified")->findAll();
  260. $this->assign("classified_id",$classifi_list);
  261. if (defined('OPEN_EDU_MODULE') && OPEN_EDU_MODULE == 1) {
  262. if ($vo['authentication_type'] == '教师') {
  263. $teacher = M('EduTeacher')->where(array('user_id' => $vo['id']))->find();
  264. $this->assign('teaching_certificate', get_spec_image($teacher['teaching_certificate']));
  265. $this->assign('education_certificate', get_spec_image($teacher['education_certificate']));
  266. } elseif ($vo['authentication_type'] == '机构') {
  267. $org = M('EduOrg')->where(array('user_id' => $vo['id']))->find();
  268. $this->assign('business_license', get_spec_image($org['business_license']));
  269. }
  270. }
  271. //是否显示身份证号码
  272. $show_identify_number = intval($m_config['is_show_identify_number']);
  273. $this->assign('show_identify_number',$show_identify_number);
  274. $this->display ();
  275. }
  276. //删除
  277. public function delete($data) {
  278. //彻底删除指定记录
  279. $ajax = intval($data['ajax']);
  280. $id = $data ['id'];
  281. if (isset ( $id )) {
  282. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  283. $rel_data = M('User')->where($condition)->findAll();
  284. foreach($rel_data as $data)
  285. {
  286. $info[] = $data['user_name'];
  287. }
  288. if($info) $info = implode(",",$info);
  289. $ids = explode ( ',', $id );
  290. foreach($ids as $uid)
  291. {
  292. delete_user($uid);
  293. }
  294. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  295. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  296. } else {
  297. $this->error (l("INVALID_OPERATION"),$ajax);
  298. }
  299. }
  300. public function update() {
  301. B('FilterString');
  302. $data = M('User')->create ();
  303. //开始验证有效性
  304. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  305. $old_user_info = M('User')->where("id=".$data['id'])->find();
  306. //app和admin共用user.php的save_user方法,后台update是没有验证码的,所以save_user设置标示字段$update_status
  307. $user_info=$GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".intval($data['id']));
  308. /*if($user_info['user_level'] != $data['user_level']){
  309. //require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  310. //require_once(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  311. //$user_redis = new UserRedisService();
  312. $score = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where `level` = ".$data['user_level']);
  313. //$online_time = $user_redis->getOne_db($data['id'],'online_time');
  314. //$online_time = intval($online_time)>0?intval($online_time):0;
  315. //$score = $score - floor($online_time/app_conf('ONLINETIME_TO_EXPERIENCE'));
  316. $user_info['score'] = $score;
  317. }*/
  318. if($user_info['login_type'] == 2 && empty($data['mobile'])){
  319. $this->error('手机注册用户,手机号不能为空');
  320. }else{
  321. $user_info['mobile'] = $data['mobile'];
  322. }
  323. $user_info['user_level'] = $data['user_level'];
  324. if($data['v_explain']==''){
  325. $data['v_explain'] = $data['authentication_type'];
  326. }
  327. $data['v_icon'] = get_spec_image(M('AuthentList')->where("name='".trim($data['authentication_type']."'"))->getField("icon"));
  328. $data['authent_list_id'] = get_spec_image(M('AuthentList')->where("name='".trim($data['authentication_type']."'"))->getField("id"));
  329. $data['nick_name'] = emoji_encode($data['nick_name'] );
  330. $data['signature'] = emoji_encode($data['signature'] );
  331. $user_info = array_merge($user_info,$data);
  332. if (defined('GAME_DISTRIBUTION') && GAME_DISTRIBUTION == 1) {
  333. if($user_info['id'] == $user_info['game_distribution_id']){
  334. $this->error('推荐人不能为自己');
  335. }
  336. if ($user_info['game_distribution_id']) {
  337. $distribution = M('User')->where(['id'=>$user_info['game_distribution_id']])->find();
  338. if (!$distribution) {
  339. $this->error('推荐人ID不存在');
  340. }
  341. }
  342. }
  343. $res = save_user($user_info,'UPDATE',$update_status=0);
  344. if($res['status']==0)
  345. {
  346. $error_field = $res['data'];
  347. if($error_field['error'] == EMPTY_ERROR)
  348. {
  349. if($error_field['field_name'] == 'user_name')
  350. {
  351. $this->error(L("USER_NAME_EMPTY_TIP"));
  352. }
  353. elseif($error_field['field_name'] == 'email')
  354. {
  355. $this->error(L("USER_EMAIL_EMPTY_TIP"));
  356. }
  357. else
  358. {
  359. $this->error(sprintf(L("USER_EMPTY_ERROR"),$error_field['field_show_name']));
  360. }
  361. }elseif($error_field['error'] == FORMAT_ERROR)
  362. {
  363. if($error_field['field_name'] == 'email')
  364. {
  365. $this->error(L("USER_EMAIL_FORMAT_TIP"));
  366. }
  367. if($error_field['field_name'] == 'mobile')
  368. {
  369. $this->error(L("USER_MOBILE_FORMAT_TIP"));
  370. }
  371. }elseif($error_field['error'] == EXIST_ERROR)
  372. {
  373. if($error_field['field_name'] == 'user_name')
  374. {
  375. $this->error(L("USER_NAME_EXIST_TIP"));
  376. }
  377. if($error_field['field_name'] == 'email')
  378. {
  379. $this->error(L("USER_EMAIL_EXIST_TIP"));
  380. }
  381. if($error_field['field_name'] == 'mobile')
  382. {
  383. $this->error(L("USER_MOBILE_EXIST_TIP"));
  384. }
  385. }else{
  386. $this->error($res['error']);
  387. }
  388. }
  389. //开始更新is_effect状态
  390. M("User")->where("id=".intval($data['id']))->setField("is_effect",intval($data['is_effect']));
  391. $user_id = intval($data['id']);
  392. $log_info = '';
  393. if($data['user_level']!=$old_user_info['user_level']){
  394. $log_info .=" 等级从".$old_user_info['user_level']."级变为".$data['user_level']."级";
  395. }
  396. if($data['is_authentication']!=$old_user_info['is_authentication']){
  397. $log_info .=" 认证状态从".$this->get_authentication($old_user_info['is_authentication'])."变为".$this->get_authentication($data['is_authentication']);
  398. }
  399. if (defined('OPEN_EDU_MODULE') && OPEN_EDU_MODULE == 1) {
  400. if ($data['authentication_type'] == '教师') {
  401. if ($old_user_info['authentication_type'] == '机构') {
  402. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", array('is_effect' => 0), "UPDATE", "user_id=" . $data['id']);
  403. }
  404. $teacher = M('EduTeacher')->create();
  405. $teacher_info = array_merge( array(
  406. 'user_id' => $data['id'],
  407. 'title' => $data['authentication_name'],
  408. 'teaching_certificate' => $teacher['teaching_certificate'],
  409. 'education_certificate' => $teacher['education_certificate'],
  410. ));
  411. if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "edu_teacher where user_id=" . $data['id']) > 0) {
  412. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", $teacher_info, "UPDATE", "user_id=" . $data['id']);
  413. } else {
  414. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", $teacher_info);
  415. }
  416. } elseif ($data['authentication_type'] == '机构') {
  417. if ($old_user_info['authentication_type'] == '教师') {
  418. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", array('is_effect' => 0), "UPDATE", "user_id=" . $data['id']);
  419. }
  420. $org = M('EduOrg')->create();
  421. $org_info = array_merge( array(
  422. 'user_id' => $data['id'],
  423. 'title' => $data['authentication_name'],
  424. 'business_license' => $org['business_license'],
  425. ));
  426. if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "edu_org where user_id=" . $data['id']) > 0) {
  427. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", $org_info, "UPDATE", "user_id=" . $data['id']);
  428. } else {
  429. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", $org_info);
  430. }
  431. }
  432. }
  433. save_log($user_id.L("UPDATE_SUCCESS").$log_info,1);
  434. $this->success(L("UPDATE_SUCCESS"));
  435. }
  436. public function get_authentication($is_authentication){
  437. switch($is_authentication){
  438. case 1:
  439. return "待审核";
  440. break;
  441. case 2:
  442. return "已认证";
  443. break;
  444. case 3:
  445. return "认证不通过";
  446. break;
  447. default:
  448. return "未认证";
  449. }
  450. }
  451. //设置状态
  452. public function set_effect($data)
  453. {
  454. $id = intval($data['id']);
  455. $ajax = intval($data['ajax']);
  456. $user_info = M("User")->getById($id);
  457. $c_is_effect = M("User")->where("id=".$id)->getField("is_effect"); //当前状态
  458. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  459. $result=M("User")->where("id=".$id)->setField("is_effect",$n_is_effect);
  460. $user_data = array();
  461. if($result){
  462. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  463. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  464. $user_redis = new UserRedisService();
  465. $user_data['is_effect'] = $n_is_effect;
  466. $user_redis->update_db($id, $user_data);
  467. }
  468. save_log($user_info['nick_name'].l("SET_EFFECT_".$n_is_effect),1);
  469. clear_auto_cache('charm_podcast');
  470. clear_auto_cache('newstar_rank');
  471. clear_auto_cache('rich_list');
  472. clear_auto_cache('rank_consumption');
  473. clear_auto_cache('rank_contribution');
  474. return $n_is_effect;
  475. }
  476. //设置永久禁播状态
  477. public function set_ban($data)
  478. {
  479. $id = intval($data['id']);
  480. $ajax = intval($data['ajax']);
  481. $user_info = M("User")->getById($id);
  482. $c_is_effect = M("User")->where("id=".$id)->getField("is_ban"); //当前状态
  483. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  484. $result=M("User")->where("id=".$id)->setField("is_ban",$n_is_effect);
  485. $user_data = array();
  486. if($result){
  487. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  488. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  489. $user_redis = new UserRedisService();
  490. $user_data['is_ban'] = $n_is_effect;
  491. $user_redis->update_db($id, $user_data);
  492. }
  493. save_log($user_info['nick_name'].l("SET_BAN_".$n_is_effect),1);
  494. return $n_is_effect;
  495. }
  496. //设置禁热门状态
  497. public function set_hot_on($data){
  498. $id = intval($data['id']);
  499. $ajax = intval($data['ajax']);
  500. $user_info = M("User")->getById($id);
  501. $c_is_effect = M("User")->where("id=".$id)->getField("is_hot_on"); //当前状态
  502. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  503. $result=M("User")->where("id=".$id)->setField("is_hot_on",$n_is_effect);
  504. $user_data = array();
  505. if($result){
  506. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  507. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  508. $user_redis = new UserRedisService();
  509. $user_data['is_hot_on'] = $n_is_effect;
  510. $user_redis->update_db($id, $user_data);
  511. }
  512. save_log($user_info['nick_name'].l("SET_HOT_ON_".$n_is_effect),1);
  513. return $n_is_effect;
  514. }
  515. //新增关注
  516. public function add_focus($data){
  517. $user_id = intval($data['user_id']);
  518. $user = M('User')->where("id=".$user_id)->find();
  519. $this->assign("user",$user);
  520. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  521. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  522. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  523. $now=get_gmtime();
  524. if(trim($data['nick_name'])!='')
  525. {
  526. $map[DB_PREFIX.'user.nick_name'] = array('like','%'.trim($data['nick_name']).'%');
  527. }
  528. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  529. $create_time_2=to_timespan($create_time_2)+24*3600;
  530. if(trim($data['create_time_1'])!='' )
  531. {
  532. $map[DB_PREFIX.'user.create_time'] = array('between',array(to_timespan($data['create_time_1']),$create_time_2));
  533. }
  534. if(intval($data['id'])>0)
  535. {
  536. $map[DB_PREFIX.'user.id'] = intval($data['id']);
  537. }else{
  538. $users = array();
  539. $user_redis = new UserFollwRedisService($user_id);
  540. $fans = $user_redis->get_follonging_user($user_id,1,100);
  541. foreach($fans as $k=>$v){
  542. $users[] = $v['user_id'];
  543. }
  544. $users[] = $user_id;
  545. if($users){
  546. $map[DB_PREFIX.'user.id'] = array('not in',$users);
  547. }
  548. }
  549. $map[DB_PREFIX.'user.is_effect'] = 1;
  550. if (method_exists ( $this, '_filter' )) {
  551. $this->_filter ( $map );
  552. }
  553. $model = D ('User');
  554. if (! empty ( $model )) {
  555. $this->_list ( $model, $map );
  556. }
  557. $list = $this->get("list");
  558. foreach($list as $k=>$v){
  559. $user_id = intval($v['id']);
  560. $user_redis = new UserRedisService();
  561. $user_info = $user_redis->getRow_db($user_id,array('diamonds','use_diamonds','ticket','score','user_level'));
  562. $list[$k]['diamonds'] = $user_info['diamonds']>0?$user_info['diamonds']:0;
  563. $list[$k]['use_diamonds'] = $user_info['use_diamonds']>0?$user_info['use_diamonds']:0;
  564. $list[$k]['ticket'] = $user_info['ticket']>0?$user_info['ticket']:0;
  565. $list[$k]['score'] = $user_info['score']>0?$user_info['score']:0;
  566. $list[$k]['user_level'] = $user_info['user_level']>0?$user_info['user_level']:1;
  567. $userfollw_redis = new UserFollwRedisService($user_id);
  568. $fans_count = $userfollw_redis->follower_count();
  569. $focus_count = $userfollw_redis->follow_count();
  570. $list[$k]['focus_count'] = $focus_count>0?$focus_count:0;
  571. $list[$k]['fans_count'] = $fans_count>0?$fans_count:0;
  572. }
  573. $this->assign ( 'list', $list );
  574. $this->assign ( 'module_name', MODULE_NAME );
  575. $this->display("UserCommon:add_focus");
  576. }
  577. //新增关注
  578. public function set_follow($data){
  579. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  580. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  581. $id = $data ['id'];
  582. $user_id = $data['user_id'];
  583. if (isset ( $id )) {
  584. $info_success = array();
  585. $focus_user = explode(',',$id);
  586. foreach($focus_user as $v)
  587. {
  588. $deal_id = $user_id;
  589. if($user_id!=$v){
  590. $root = redis_set_follow($user_id,$v);
  591. if($root['status']==1){
  592. $info_success[] = $v;
  593. }else{
  594. $info[] = $v;
  595. }
  596. }
  597. }
  598. if($info) $info = implode(",",$info);
  599. $info = "用户ID".$deal_id."新增关注:".$info;
  600. if($info_success) $success_str = implode(",",$info_success);
  601. $success_str = "用户ID".$deal_id."新增关注:".$success_str;
  602. if (sizeof($info_success)) {
  603. save_log($success_str.l("INSERT_SUCCESS"),1);
  604. $root['status'] = 1;
  605. $root['info'] = '新增成功!';
  606. admin_ajax_return($root);
  607. } else {
  608. save_log($info.l("INSERT_FAILED"),0);
  609. $root['status'] = 0;
  610. $root['info'] = '新增失败!';
  611. admin_ajax_return($root);
  612. }
  613. } else {
  614. return false;
  615. }
  616. }
  617. //关注列表
  618. public function focus_list($data,$page=0){
  619. $user_id = intval($data['id']);
  620. $user = M("User")->getById($user_id);
  621. $this->assign("user",$user);
  622. if($user)
  623. {
  624. $page = intval($_REQUEST['p']);
  625. if($page<=0)
  626. $page = 1;
  627. $map['user_id'] = $user['id'];
  628. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  629. $redisCommon = new Ridescommon();
  630. $redis = $redisCommon->video_follw_list($map['user_id'],0,$page);
  631. $model = D ("Focus");
  632. if (! empty ( $model )) {
  633. $this->_list ( $model, $map,'','',1,$redis);
  634. }
  635. }
  636. $this->display("UserCommon:focus_list");
  637. }
  638. //新增粉丝
  639. public function add_fans($data){
  640. $user_id = intval($data['user_id']);
  641. $user = M('User')->where("id=".$user_id)->find();
  642. $this->assign("user",$user);
  643. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  644. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  645. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  646. $now=get_gmtime();
  647. if(trim($data['nick_name'])!='')
  648. {
  649. $map[DB_PREFIX.'user.nick_name'] = array('like','%'.trim($data['nick_name']).'%');
  650. }
  651. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  652. $create_time_2=to_timespan($create_time_2)+24*3600;
  653. if(trim($data['create_time_1'])!='' )
  654. {
  655. $map[DB_PREFIX.'user.create_time'] = array('between',array(to_timespan($data['create_time_1']),$create_time_2));
  656. }
  657. if(intval($data['id'])>0)
  658. {
  659. $map[DB_PREFIX.'user.id'] = intval($data['id']);
  660. }else{
  661. $users = array();
  662. $user_redis = new UserFollwRedisService($user_id);
  663. $fans = $user_redis->get_follonging_by_user($user_id,1,100);
  664. foreach($fans as $k=>$v){
  665. $users[] = $v['user_id'];
  666. }
  667. $users[] = $user_id;
  668. if($users){
  669. $map[DB_PREFIX.'user.id'] = array('not in',$users);
  670. }
  671. }
  672. $map[DB_PREFIX.'user.is_effect'] = 1;
  673. if (method_exists ( $this, '_filter' )) {
  674. $this->_filter ( $map );
  675. }
  676. $model = D ('User');
  677. if (! empty ( $model )) {
  678. $this->_list ( $model, $map );
  679. }
  680. $list = $this->get("list");
  681. foreach($list as $k=>$v){
  682. $user_id = intval($v['id']);
  683. $user_redis = new UserRedisService();
  684. $user_info = $user_redis->getRow_db($user_id,array('diamonds','use_diamonds','ticket','score','user_level'));
  685. $list[$k]['diamonds'] = $user_info['diamonds']>0?$user_info['diamonds']:0;
  686. $list[$k]['use_diamonds'] = $user_info['use_diamonds']>0?$user_info['use_diamonds']:0;
  687. $list[$k]['ticket'] = $user_info['ticket']>0?$user_info['ticket']:0;
  688. $list[$k]['score'] = $user_info['score']>0?$user_info['score']:0;
  689. $list[$k]['user_level'] = $user_info['user_level']>0?$user_info['user_level']:1;
  690. $userfollw_redis = new UserFollwRedisService($user_id);
  691. $fans_count = $userfollw_redis->follower_count();
  692. $focus_count = $userfollw_redis->follow_count();
  693. $list[$k]['focus_count'] = $focus_count>0?$focus_count:0;
  694. $list[$k]['fans_count'] = $fans_count>0?$fans_count:0;
  695. }
  696. $this->assign ( 'list', $list );
  697. $this->assign ( 'module_name', MODULE_NAME );
  698. $this->display("UserCommon:add_fans");
  699. }
  700. //新增粉丝
  701. public function set_follower($data){
  702. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  703. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  704. $id = $data ['id'];
  705. $user_id = $data['user_id'];
  706. if (isset ( $id )) {
  707. $info_success = array();
  708. $focus_user = explode(',',$id);
  709. foreach($focus_user as $v)
  710. {
  711. $deal_id = $user_id;
  712. if($user_id!=$v){
  713. $root = redis_set_follow($v,$user_id);
  714. if($root['status']==1){
  715. $info_success[] = $v;
  716. }else{
  717. $info[] = $v;
  718. }
  719. }
  720. }
  721. if($info) $info = implode(",",$info);
  722. $info = "用户ID".$deal_id."新增粉丝:".$info;
  723. if($info_success) $success_str = implode(",",$info_success);
  724. $success_str = "用户ID".$deal_id."新增粉丝:".$success_str;
  725. if (sizeof($info_success)) {
  726. save_log($success_str.l("INSERT_SUCCESS"),1);
  727. $root['status'] = 1;
  728. $root['info'] = '新增成功!';
  729. admin_ajax_return($root);
  730. } else {
  731. save_log($info.l("INSERT_FAILED"),0);
  732. $root['status'] = 0;
  733. $root['info'] = '新增失败!';
  734. admin_ajax_return($root);
  735. }
  736. } else {
  737. return false;
  738. }
  739. }
  740. //粉丝列表
  741. public function fans_list($data,$page=0){
  742. $user_id = intval($data['id']);
  743. $user = M("User")->getById($user_id);
  744. $this->assign("user",$user);
  745. if($user)
  746. {
  747. $page = intval($_REQUEST['p']);
  748. if($page<=0)
  749. $page = 1;
  750. $map['user_id'] = $user['id'];
  751. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  752. $redisCommon = new Ridescommon();
  753. $redis = $redisCommon->video_follw_list($map['user_id'],1,$page);
  754. $model = D ("Focus");
  755. if (! empty ( $model )) {
  756. $this->_list ( $model, $map,'','',1,$redis);
  757. }
  758. }
  759. $this->display("UserCommon:fans_list");
  760. }
  761. //删除关注
  762. public function del_focus_list($data){
  763. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  764. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  765. $id = $data ['id'];
  766. $user_id = $data['user_id'];
  767. if (isset ( $id )) {
  768. $info_success = array();
  769. $focus_user = explode(',',$id);
  770. foreach($focus_user as $v)
  771. {
  772. $deal_id = $user_id;
  773. $info[] = $v;
  774. if($user_id!=$v){
  775. $root = redis_set_follow($user_id,$v);
  776. if($root['status']==1){
  777. $info_success[] = $v;
  778. }
  779. }
  780. }
  781. if($info) $info = implode(",",$info);
  782. $info = "用户ID".$deal_id."删除关注:".$info;
  783. if($info_success) $success_str = implode(",",$info_success);
  784. $success_str = "用户ID".$deal_id."删除关注:".$success_str;
  785. if (sizeof($info_success)) {
  786. save_log($info_success.l("FOREVER_DELETE_SUCCESS"),1);
  787. $root['status'] = 1;
  788. $root['info'] = '删除成功!';
  789. admin_ajax_return($root);
  790. } else {
  791. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  792. $root['status'] = 0;
  793. $root['info'] = '删除失败!';
  794. admin_ajax_return($root);
  795. }
  796. } else {
  797. $root['status'] = 0;
  798. $root['info'] = '删除失败!';
  799. admin_ajax_return($root);
  800. }
  801. }
  802. //删除粉丝
  803. public function del_fans_list($data){
  804. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  805. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  806. $id = $data ['id'];
  807. $user_id = $data['user_id'];
  808. if (isset ( $id )) {
  809. $info_success = array();
  810. $focus_user = explode(',',$id);
  811. foreach($focus_user as $v)
  812. {
  813. $deal_id = $user_id;
  814. $info[] = $v;
  815. if($user_id!=$v){
  816. $root = redis_set_follow($v,$user_id);
  817. if($root['status']==1){
  818. $info_success[] = $v;
  819. }
  820. }
  821. }
  822. if($info) $info = implode(",",$info);
  823. $info = "用户ID".$deal_id."删除粉丝:".$info;
  824. if($info_success) $success_str = implode(",",$info_success);
  825. $success_str = "用户ID".$deal_id."删除粉丝:".$success_str;
  826. if (sizeof($info_success)) {
  827. save_log($info_success.l("FOREVER_DELETE_SUCCESS"),1);
  828. $root['status'] = 1;
  829. $root['info'] = '删除成功!';
  830. admin_ajax_return($root);
  831. } else {
  832. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  833. $root['status'] = 0;
  834. $root['info'] = '删除失败!';
  835. admin_ajax_return($root);
  836. }
  837. } else {
  838. $root['status'] = 0;
  839. $root['info'] = '删除失败!';
  840. admin_ajax_return($root);
  841. }
  842. }
  843. //印票贡献榜
  844. public function contribution_list($data){
  845. $user_id = intval($data['id']);
  846. $user = M("User")->getById($user_id);
  847. $this->assign("user",$user);
  848. if($user)
  849. {
  850. $page = intval($_REQUEST['p']);
  851. if($page<=0)
  852. $page = 1;
  853. $map['podcast_id'] = $user['id'];
  854. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  855. $redisCommon = new Ridescommon();
  856. $redis = $redisCommon->video_contribute_list($map['podcast_id'],0,$map['podcast_id'],$page);
  857. $model = D ("UserContribution");
  858. if (! empty ( $model )) {
  859. $this->_list ( $model, $map,'','',1,$redis);
  860. }
  861. }
  862. $this->display();
  863. }
  864. /**
  865. * 删除印票贡献榜
  866. */
  867. /* public function del_contribution_list($data)
  868. {
  869. $id = $data['id'];
  870. if (isset ( $id )) {
  871. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  872. $rel_data = M("UserContribution")->where($condition)->findAll();
  873. foreach($rel_data as $data)
  874. {
  875. $deal_id = $data['podcast_id'];
  876. $info[] = $data['user_id'];
  877. }
  878. if($info) $info = implode(",",$info);
  879. $info = "用户ID".$deal_id."的印票贡献榜:".$info;
  880. $list = M("UserContribution")->where ( $condition )->delete();
  881. if ($list!==false) {
  882. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  883. return true;
  884. } else {
  885. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  886. return false;
  887. }
  888. } else {
  889. return false;
  890. }
  891. }*/
  892. //消息推送
  893. public function push($data){
  894. $user_id = intval($data['id']);
  895. $user = M("User")->getById($user_id);
  896. $this->assign("user",$user);
  897. if($user)
  898. {
  899. $map['user_id'] = $user['id'];
  900. $model = D ("PushAnchor");
  901. if (! empty ( $model )) {
  902. $this->_list ( $model, $map );
  903. }
  904. }
  905. $this->display();
  906. }
  907. /**
  908. * 删除推送消息
  909. */
  910. public function del_push($data)
  911. {
  912. $id = $data['id'];
  913. if (isset ( $id )) {
  914. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  915. $rel_data = M("PushAnchor")->where($condition)->findAll();
  916. foreach($rel_data as $data)
  917. {
  918. $deal_id = $data['user_id'];
  919. $info[] = $data['room_id'];
  920. }
  921. if($info) $info = implode(",",$info);
  922. $info = "用户ID".$deal_id."的直播推送消息:".$info;
  923. $list = M("PushAnchor")->where ( $condition )->delete();
  924. if ($list!==false) {
  925. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  926. return true;
  927. } else {
  928. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  929. return false;
  930. }
  931. } else {
  932. return false;
  933. }
  934. }
  935. public function account($data)
  936. {
  937. $user_id = intval($data['id']);
  938. $model = D ();
  939. $user_info = array();
  940. if($user_id){
  941. $sql_str = "select id,nick_name,diamonds,score,ticket from ".DB_PREFIX."user where id = ".$user_id;
  942. $user_info = $GLOBALS['db']->getRow($sql_str); //
  943. }
  944. $this->assign("user_info",$user_info);
  945. $this->display();
  946. }
  947. public function modify_account($data)
  948. {
  949. $data_arr = array();
  950. $user_id = intval($data['id']);
  951. $data_arr['diamonds'] = floatval($data['diamonds']);
  952. $sql_str = "select id,diamonds from ".DB_PREFIX."user where id = ".$user_id;
  953. $user_info = $GLOBALS['db']->getRow($sql_str); //
  954. if($data_arr['diamonds']+$user_info['diamonds']>2147483647||$data_arr['diamonds']+$user_info['diamonds']<0){
  955. return false;
  956. }
  957. //$data_arr['ticket'] = intval($data['ticket']);
  958. $msg = trim($data['msg'])==''?l("ADMIN_MODIFY_ACCOUNT"):trim($data['msg']);
  959. modify_account($data_arr,$user_id,$msg);
  960. if ($data_arr['diamonds'] >= 0)
  961. save_log("用户".$user_id."钻石增加".$data_arr['diamonds']."成功",1);
  962. elseif ($data_arr['diamonds'] < 0){
  963. save_log("用户".$user_id."钻石减少".(-$data_arr['diamonds'])."成功",1);
  964. }
  965. return true;
  966. }
  967. public function account_detail($data)
  968. {
  969. $user_id = intval($data['id']);
  970. $user_info = M("User")->getById($user_id);
  971. $this->assign("user_info",$user_info);
  972. $map['user_id'] = $user_id;
  973. if($data['type']!=''){
  974. $map['type'] = intval($data['type']);
  975. }
  976. if (method_exists ( $this, '_filter' )) {
  977. $this->_filter ( $map );
  978. }
  979. $types = array('0'=>'充值记录','1'=>'提现记录','3'=>'兑换记录');
  980. if(defined('OPEN_SHARE_EXPERIENCE')&&OPEN_SHARE_EXPERIENCE==1){
  981. $types[4] = '分享';
  982. }
  983. if(defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1){
  984. $types[4] = '家族收益';
  985. }
  986. if((defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1) && (defined('OPEN_SHARE_EXPERIENCE')&&OPEN_SHARE_EXPERIENCE==1)){
  987. $types[4] = '分享或家族收益';
  988. }
  989. if(defined('OPEN_LOGIN_SEND_SCORE')&&OPEN_LOGIN_SEND_SCORE==1){
  990. $types[5] = '每日首次登录送积分';
  991. }
  992. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  993. $types[6] = '付费直播消费记录';
  994. }
  995. if(defined('PAI_REAL_BTN')&&PAI_REAL_BTN==1 || defined('PAI_VIRTUAL_BTN')&&PAI_VIRTUAL_BTN==1){
  996. $types[8] = '竞拍记录';
  997. }
  998. $model = M ("UserLog");
  999. if (! empty ( $model )) {
  1000. $this->_list ( $model, $map );
  1001. }
  1002. $this->assign ( 'module_name', MODULE_NAME );
  1003. $this->assign("types",$types);
  1004. $this->display ();
  1005. return;
  1006. }
  1007. public function foreverdelete_account_detail()
  1008. {
  1009. //彻底删除指定记录
  1010. $ajax = intval($_REQUEST['ajax']);
  1011. $id = $_REQUEST ['id'];
  1012. if (isset ( $id )) {
  1013. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  1014. $rel_data = M("UserLog")->where($condition)->findAll();
  1015. foreach($rel_data as $data)
  1016. {
  1017. $info[] = $data['id'];
  1018. }
  1019. if($info) $info = implode(",",$info);
  1020. $list = M("UserLog")->where ( $condition )->delete();
  1021. if ($list!==false) {
  1022. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1023. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  1024. } else {
  1025. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1026. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  1027. }
  1028. } else {
  1029. $this->error (l("INVALID_OPERATION"),$ajax);
  1030. }
  1031. }
  1032. public function check_user($user_id){
  1033. if(intval($user_id)>0)
  1034. {
  1035. $uinfo = M("User")->getById(intval($user_id));
  1036. if($uinfo)
  1037. {
  1038. $result['status'] = true;
  1039. $result['user_info'] = $uinfo;
  1040. admin_ajax_return($result);
  1041. }
  1042. else
  1043. {
  1044. $result['status'] = false;
  1045. admin_ajax_return($result);
  1046. }
  1047. }
  1048. $result['status'] = false;
  1049. return($result);
  1050. }
  1051. //礼物日志
  1052. public function prop($data)
  1053. {
  1054. $now=get_gmtime();
  1055. $user_id = intval($_REQUEST['id']);
  1056. $user_info = M("User")->getById($user_id);
  1057. $prop_list = M("prop")->where("is_effect <>0")->findAll();
  1058. $where = "l.from_user_id=".$user_id ;
  1059. $model = D ("video_prop");
  1060. //赠送时间
  1061. $current_Year = date('Y');
  1062. $current_YM = date('Ym');
  1063. for ($i=0; $i<5; $i++)
  1064. {
  1065. $years[$i] = $current_Year - $i;
  1066. }
  1067. for ($i=01; $i<13; $i++)
  1068. {
  1069. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  1070. }
  1071. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  1072. $time=$data['years'].''.$data['month'];
  1073. }else{
  1074. $time=$current_YM;
  1075. }
  1076. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  1077. $this->error("请选择月份");
  1078. }
  1079. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  1080. $this->error("请选择年份");
  1081. }
  1082. //查询ID
  1083. if(strim($data['to_user_id'])!=''){
  1084. $parameter.= "l.to_user_id=".intval($data['to_user_id']). "&";
  1085. $sql_w .= "l.to_user_id=".intval($data['to_user_id'])." and ";
  1086. }
  1087. //查询昵称
  1088. if(trim($data['nick_name'])!='')
  1089. {
  1090. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  1091. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  1092. }
  1093. if (!isset($_REQUEST['prop_id'])) {
  1094. $_REQUEST['prop_id'] = -1;
  1095. }
  1096. //查询礼物
  1097. if($_REQUEST['prop_id']!=-1) {
  1098. if (isset($data['prop_id'])) {
  1099. $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
  1100. $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
  1101. }
  1102. }
  1103. // //查询时间
  1104. // $create_time_2=empty($data['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  1105. // $create_time_1=to_timespan($data['create_time_1'])+24*3600;
  1106. // $create_time_2=to_timespan($create_time_2)+24*3600;
  1107. //
  1108. //
  1109. // if(trim($data['create_time_1'])!='')
  1110. // {
  1111. // $parameter.="l.create_time between '".strtotime($data['create_time_1']) . "' and '". $create_time_2 ."'&";
  1112. // $sql_w .="l.create_time between '". strtotime($data['create_time_1']). "' and '". $create_time_2 ."' and ";
  1113. //
  1114. // }
  1115. // if(trim($data['create_time_2']))
  1116. // {
  1117. //
  1118. // $parameter.="l.create_time<=".$create_time_2. "&";
  1119. // $sql_w .="l.create_time<=". $create_time_2." and ";
  1120. //
  1121. //
  1122. // }
  1123. //
  1124. // //比较两个时间段的月份是否一致,如不一致,提示
  1125. // $create_time_1_m =date('m', $create_time_1);
  1126. // $create_time_2_m =date('m', $create_time_2);
  1127. // if(trim($data['create_time_1'])!=''&& trim($data['create_time_2'])!=''){
  1128. // if($create_time_2_m!=$create_time_1_m){
  1129. // $this->error("查询时间只能在当月内");
  1130. // }
  1131. // }
  1132. //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
  1133. if($data['years']!=''&&$data['month']!=''){
  1134. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name,l.from_ip,l.is_coin
  1135. FROM ".DB_PREFIX."video_prop_".$time." as l
  1136. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1137. WHERE $where "." and ".$sql_w." 1=1 ";
  1138. $count_sql = "SELECT count(l.id) as tpcount
  1139. FROM ".DB_PREFIX."video_prop_".$time." as l
  1140. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1141. WHERE $where "." and ".$sql_w." 1=1 ";
  1142. }else{
  1143. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name,l.from_ip,l.is_coin
  1144. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  1145. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1146. WHERE $where "." and ".$sql_w." 1=1 ";
  1147. $count_sql = "SELECT count(l.id) as tpcount
  1148. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  1149. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1150. WHERE $where "." and ".$sql_w." 1=1 ";
  1151. }
  1152. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  1153. foreach($volist as $k=>$v){
  1154. if($volist[$k]['prop_id']==12){
  1155. $volist[$k]['total_ticket']='';
  1156. }
  1157. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  1158. }
  1159. $this->assign("user_info",$user_info);
  1160. $this->assign("prop",$prop_list);
  1161. $this->assign("years",$years);
  1162. $this->assign("month",$month);
  1163. $this->assign("list", $volist);
  1164. $this->display ();
  1165. return;
  1166. }
  1167. /**
  1168. * 删除礼物日志
  1169. */
  1170. public function del_prop()
  1171. {
  1172. //彻底删除指定记录
  1173. $ajax = intval($_REQUEST['ajax']);
  1174. $id = intval($_REQUEST ['id']);
  1175. $create_ym = intval($_REQUEST ['create_ym']);
  1176. if (isset ( $id )) {
  1177. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  1178. //默认删除本月记录,如果用户进行时间搜索,通过ajax获取起始时间的年月用REQUEST获取,
  1179. //再与表名连接进行查询删除。
  1180. $rel_data = M("video_prop_".date('Ym',NOW_TIME))->where($condition)->findAll();
  1181. foreach($rel_data as $data)
  1182. {
  1183. $info[] = $data['id'];
  1184. }
  1185. if($info) $info = implode(",",$info);
  1186. $list = M("video_prop_".date('Ym',NOW_TIME))->where ( $condition )->delete();
  1187. if($create_ym!='NaNNaN' &&date('Ym',NOW_TIME)!=$create_ym) {
  1188. $rel_data = M("video_prop_".$create_ym)->where($condition)->findAll();
  1189. foreach($rel_data as $data)
  1190. {
  1191. $info[] = $data['id'];
  1192. }
  1193. if($info) $info = implode(",",$info);
  1194. $list = M("video_prop_".$create_ym)->where ( $condition )->delete();
  1195. }
  1196. if ($list!==false) {
  1197. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1198. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  1199. } else {
  1200. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1201. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  1202. }
  1203. } else {
  1204. $this->error (l("INVALID_OPERATION"),$ajax);
  1205. }
  1206. }
  1207. //分享奖励
  1208. public function distribution_log($data)
  1209. {
  1210. $now=get_gmtime();
  1211. $user_id = intval($_REQUEST['id']);
  1212. $user_info = M("User")->getById($user_id);
  1213. $where = "l.to_user_id=".$user_id ;
  1214. $model = D ("distribution_log");
  1215. //查询ID
  1216. if(strim($data['from_user_id'])!=''){
  1217. $parameter.= "l.from_user_id=".intval($data['from_user_id']). "&";
  1218. $sql_w .= "l.from_user_id=".intval($data['from_user_id'])." and ";
  1219. }
  1220. //查询昵称
  1221. if(trim($data['nick_name'])!='')
  1222. {
  1223. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  1224. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  1225. }
  1226. //查询时间
  1227. $create_time_2=empty($data['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  1228. $create_time_1=to_timespan($data['create_time_1'])+24*3600;
  1229. $create_time_2=to_timespan($create_time_2)+24*3600;
  1230. if(trim($data['create_time_1'])!='')
  1231. {
  1232. $parameter.="l.create_time between '".strtotime($data['create_time_1']) . "' and '". $create_time_2 ."'&";
  1233. $sql_w .="l.create_time between '". strtotime($data['create_time_1']). "' and '". $create_time_2 ."' and ";
  1234. }
  1235. if(trim($data['create_time_2']))
  1236. {
  1237. $parameter.="l.create_time<=".$create_time_2. "&";
  1238. $sql_w .="l.create_time<=". $create_time_2." and ";
  1239. }
  1240. //比较两个时间段的月份是否一致,如不一致,提示
  1241. $create_time_1_m =date('m', $create_time_1);
  1242. $create_time_2_m =date('m', $create_time_2);
  1243. if(trim($data['create_time_1'])!=''&& trim($data['create_time_2'])!=''){
  1244. if($create_time_2_m!=$create_time_1_m){
  1245. $this->error("查询时间只能在当月内");
  1246. }
  1247. }
  1248. $sql_str = "SELECT l.id,l.from_user_id,l.ticket, l.create_time,u.nick_name
  1249. FROM ".DB_PREFIX."distribution_log as l
  1250. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id
  1251. WHERE $where "." and ".$sql_w." 1=1 ";
  1252. $count_sql = "SELECT count(l.id) as tpcount
  1253. FROM ".DB_PREFIX."distribution_log as l
  1254. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id
  1255. WHERE $where "." and ".$sql_w." 1=1 ";
  1256. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,'id',0,$count_sql);
  1257. foreach($volist as $k=>$v){
  1258. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  1259. }
  1260. $this->assign("user_info",$user_info);
  1261. $this->assign("list", $volist);
  1262. $this->display ();
  1263. return;
  1264. }
  1265. //查询分销子成员
  1266. public function distribution_user($data)
  1267. {
  1268. $user_id = intval($data['id']);
  1269. $model = D("user");
  1270. $user_info = M("User")->getById($user_id);
  1271. $parameter = '';
  1272. $sql_w = '1=1';
  1273. //赠送时间
  1274. $current_Year = date('Y');
  1275. for ($i=0; $i<5; $i++)
  1276. {
  1277. $years[$i] = $current_Year - $i;
  1278. }
  1279. for ($i=01; $i<13; $i++)
  1280. {
  1281. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  1282. }
  1283. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  1284. $time=$data['years'].'-'.$data['month']."-01 00:00:00";
  1285. $s_month=to_timespan($time);
  1286. $e_month=to_timespan(date('Y-m-d', mktime(23, 59, 59, date('m', strtotime($time))+1, 00)));
  1287. $is_seslect = 1;
  1288. }
  1289. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  1290. $this->error("请选择月份");
  1291. }
  1292. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  1293. $this->error("请选择年份");
  1294. }
  1295. //查询注册时间
  1296. if ($is_seslect) {
  1297. $parameter .= "u.create_time>" . intval($s_month) . "&";
  1298. $parameter .= "u.create_time<" . intval($e_month) . "&";
  1299. $sql_w .= " and u.create_time>" . intval($s_month);
  1300. $sql_w .= " and u.create_time<" . intval($e_month);
  1301. }
  1302. //查询ID
  1303. if (strim($data['from_user_id']) != '') {
  1304. $parameter .= "u.id=" . intval($data['from_user_id']) . "&";
  1305. $sql_w .= " and u.id=" . intval($data['from_user_id']);
  1306. }
  1307. //查询昵称
  1308. if (trim($data['nick_name']) != '') {
  1309. $parameter .= "u.nick_name like " . urlencode('%' . trim($data['nick_name']) . '%') . "&";
  1310. $sql_w .= " and u.nick_name like '%" . trim($data['nick_name']) . "%'";
  1311. }
  1312. $field = "u.id,u.nick_name ";
  1313. $left_join_1 = ",(select sum(pn.money) from ".DB_PREFIX."payment_notice as pn where pn.user_id = u.id and pn.is_paid=1 ) as sum_money";
  1314. $left_join_2 = ", u.use_diamonds as sum_diamonds";
  1315. $where = " u.p_user_id=".$user_id." and ".$sql_w;
  1316. $sql_str = "select ".$field.$left_join_1.$left_join_2." from fanwe_user as u where ".$where." group by u.id";
  1317. $count_sql = "select count(u.id) as tpcount from ".DB_PREFIX."user as u where $where";
  1318. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,'id',0,$count_sql);
  1319. foreach($volist as $k=>$v){
  1320. if($v['sum_money']==''){
  1321. $volist[$k]['sum_money'] = 0;
  1322. }
  1323. if($v['sum_diamonds']==''){
  1324. $volist[$k]['sum_diamonds'] = 0;
  1325. }
  1326. }
  1327. $this->assign("user_info",$user_info);
  1328. $this->assign("list", $volist);
  1329. $this->assign("years",$years);
  1330. $this->assign("month",$month);
  1331. $this->display ();
  1332. }
  1333. /**
  1334. * @param $data
  1335. * @param bool $get_result 如果为true则函数return $result,如果为false则admin_ajax_return($result);
  1336. * @return mixed
  1337. */
  1338. public function forbid_msg($data,$get_result=false){
  1339. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  1340. $id = intval($data['user_id']);
  1341. $is_nospeaking = M("User")->where("id=".$id)->getField("is_nospeaking");
  1342. if($get_result && $is_nospeaking){
  1343. $result['status'] = 1;
  1344. $result['info'] = "已经全局禁言";
  1345. return $result;
  1346. }
  1347. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  1348. $api = createTimAPI();
  1349. $time = 4294967295;
  1350. $info = "im全局禁言";
  1351. $set_nospeaking = 1;
  1352. if($is_nospeaking){
  1353. $time = 0;
  1354. $set_nospeaking =0;
  1355. $info = "解除im全局禁言";
  1356. }
  1357. $ret = $api->set_no_speaking($id,$time);
  1358. if($ret['ErrorCode']){
  1359. $ret = $api->set_no_speaking($id,$time);
  1360. }
  1361. if($ret['ErrorCode']){
  1362. $result['status'] = 0;
  1363. $result['info'] = $info."失败";
  1364. save_log($id.$info."失败",0);
  1365. }else{
  1366. $result['status'] = 1;
  1367. $result['info'] = $info."成功";
  1368. M("User")->where("id=".$id)->setField("is_nospeaking",$set_nospeaking);
  1369. user_deal_to_reids(array($id));
  1370. save_log($id.$info."成功",1);
  1371. }
  1372. if($get_result){
  1373. return $result;
  1374. }
  1375. admin_ajax_return($result);
  1376. }
  1377. }