syn.action.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class synModule extends baseModule
  10. {
  11. public function index(){
  12. if(IS_DEBUG||1){
  13. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  14. <html>
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  17. <title>数据操作</title>
  18. </head>
  19. <body>
  20. <script type="text/javascript" src="'.SITE_DOMAIN.'/admin/Tpl/default/Common/js/jquery.js"></script>
  21. <div align="center" style="padding-top: 50px;">
  22. <form action="'.SITE_DOMAIN.'/syn/index.php?ctl=syn&act=do_action" method="get" id="form_type">
  23. 执行操作:<select name="type" id="type" onchange="change_type();">
  24. <option value="0">选择数据的操作方式</option>
  25. <option value="1">0-100的机器人同步到IM</option>
  26. <option value="13">100-200的机器人同步到IM</option>
  27. <option value="14">200-300的机器人同步到IM</option>
  28. <option value="15">300-392的机器人同步到IM</option>
  29. <option value="2">机器人同步到redis</option>
  30. <option value="7">模拟登录账号(手机号或是ID)</option>
  31. <option value="8">获取腾讯IM的AES</option>
  32. <option value="9">获取服务器的AES</option>
  33. <option value="10">获取缓存数据</option>
  34. <option value="11">删除定时器加入直播的机器人列表</option>
  35. <option value="12">同步指定用户信息到redis</option>
  36. </select>
  37. <br/>
  38. <div style="display: none;padding-top: 20px;" id="user_module">
  39. 主播ID:<input type = "text" value="" name="user_id" id="user_id"/>
  40. 主播手机号:<input type = "text" value="" name="mobile" id="mobile"/>
  41. </div>
  42. <div style="display: none;padding-top: 20px;" id="m_config">
  43. 缓存名称:<input type = "text" name="cache_name" id="cache_name" value = "m_config"/> 系统缓存:m_config
  44. 是否清除缓存:<input type = "text" name="rm_cache" id="rm_cache" value = "0" /> 0:不更新缓存;1:更新缓存
  45. </div>
  46. <br/>
  47. <input type="button" class="submit button" value="提交" onclick="submit_type();"/>
  48. </form>
  49. </div>
  50. <script type="text/javascript">
  51. $(function(){
  52. var type = $("#type option:selected") .val();
  53. if(type==7 || type==12){
  54. $("#user_module").show();
  55. }else if(type==10){
  56. $("#m_config").show();
  57. }else{
  58. $("#user_module").hide();
  59. $("#m_config").hide();
  60. $("#user_id").val("");
  61. }
  62. });
  63. function change_type(){
  64. var type = $("#type option:selected") .val();
  65. if(type==7 || type==12 ){
  66. $("#user_module").show();
  67. }else if(type==10){
  68. $("#m_config").show();
  69. }else{
  70. $("#user_module").hide();
  71. $("#m_config").hide();
  72. $("#user_id").val("");
  73. }
  74. }
  75. function submit_type(){
  76. var type = $("#type option:selected") .val();
  77. if(type>0){
  78. var confirm_str = "确定将";
  79. var user_id = $("#user_id").val();
  80. var user_str = "所有";
  81. if(user_id){
  82. user_str = user_id;
  83. }
  84. confirm_str = confirm_str+user_str+$("#type option:selected") .text() +"吗?";
  85. if(confirm(confirm_str)){
  86. var url = $("#form_type").attr("action");
  87. var query = $("#form_type").serialize();
  88. $.ajax({
  89. url:url,
  90. data:query,
  91. dataType:"json",
  92. type:"post",
  93. success:function(result){
  94. alert(result.error);
  95. func();
  96. function func(){
  97. if(result.status==1){
  98. location.href=location.href;
  99. }
  100. }
  101. }
  102. });
  103. }
  104. }else{
  105. alert("请选择数据的操作方式!!");
  106. }
  107. }
  108. </script>
  109. </body>
  110. </html>';
  111. echo $html;
  112. }else{
  113. print_r("请开启debug模式");exit;
  114. }
  115. }
  116. //1、2、7、8、9
  117. public function do_action(){
  118. $root = array('status'=>0,'error'=>'');
  119. if(IS_DEBUG){
  120. $type = $_REQUEST['type'];
  121. $root['error'] = '请选择数据的操作方式!!';
  122. if($type){
  123. $user_id = intval($_REQUEST['user_id']);
  124. if($type == 7 || $type==12){
  125. $user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where id = " . intval($user_id),true,true);
  126. if(intval($user_id)<=0){
  127. $root['error'] = '主播ID不存在';
  128. admin_ajax_return($root);
  129. }
  130. }
  131. if($type == 1){
  132. $res = $this->robot_im1(1);
  133. if($res['status']==0){
  134. admin_ajax_return($res);
  135. }else{
  136. $root['error'] =$res['error'];
  137. admin_ajax_return($root);
  138. }
  139. }elseif($type == 13){
  140. $res = $this->robot_im2(1);
  141. if($res['status']==0){
  142. admin_ajax_return($res);
  143. }else{
  144. $root['error'] =$res['error'];
  145. admin_ajax_return($root);
  146. }
  147. }elseif($type == 14){
  148. $res = $this->robot_im3(1);
  149. if($res['status']==0){
  150. admin_ajax_return($res);
  151. }else{
  152. $root['error'] =$res['error'];
  153. admin_ajax_return($root);
  154. }
  155. }elseif($type == 15){
  156. $res = $this->robot_im4(1);
  157. if($res['status']==0){
  158. admin_ajax_return($res);
  159. }else{
  160. $root['error'] =$res['error'];
  161. admin_ajax_return($root);
  162. }
  163. }elseif($type == 2){
  164. $this->robot(1);
  165. }elseif($type==7){
  166. $user_id = intval($_REQUEST['user_id']);
  167. $mobile = strim($_REQUEST['mobile']);
  168. $root['error'] = print_r($this->login(1,$user_id,$mobile),1) ;
  169. admin_ajax_return($root);
  170. }elseif($type==8){
  171. $get_aes_key = $this->get_aes_key();
  172. $root['error'] = print_r($get_aes_key,1);
  173. admin_ajax_return($root);
  174. }elseif($type==9){
  175. $get_privatekey = $this->get_privatekey();
  176. $root['error'] = print_r($get_privatekey,1);
  177. admin_ajax_return($root);
  178. }elseif($type==10){
  179. $cache_name = $_REQUEST['cache_name'];
  180. $rm_cache = intval($_REQUEST['rm_cache']);
  181. if($cache_name==''){
  182. $root['error'] = '缓存文件名称不能为空!';
  183. }else{
  184. $m_configs = $this->m_configs($cache_name,$rm_cache);
  185. $root['error'] = print_r($m_configs,1);
  186. }
  187. admin_ajax_return($root);
  188. }elseif($type==11){
  189. $d_user_robot = $this->del_user_robot();
  190. if(intval($d_user_robot)>0){
  191. $root['error'] = '删除成功!';
  192. }else{
  193. $root['error'] = '无数据!';
  194. }
  195. admin_ajax_return($root);
  196. }elseif($type==12){
  197. $id = intval($_REQUEST['user_id']);
  198. $mobile = strim($_REQUEST['mobile']);
  199. $update_user = $this-> update_user($id,$mobile);
  200. $root['error'] = print_r($update_user,1);
  201. admin_ajax_return($root);
  202. }
  203. }
  204. }else{
  205. $root['error'] = '请开启debug模式';
  206. admin_ajax_return($root);
  207. }
  208. }
  209. //同步机器人到im1
  210. public function robot_im1($json = 0){
  211. $root = array('status' => 0, 'error' => '');
  212. if(IS_DEBUG) {
  213. $user_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where is_robot = 1 limit 0,100");
  214. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  215. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  216. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  217. $user_redis = new UserRedisService();
  218. $api = createTimAPI();
  219. if (is_array($api)) {
  220. if ($json) {
  221. $res = json_decode($api);
  222. $root = array('status' => 0, 'error' => $res['ErrorInfo']);
  223. admin_ajax_return($root);
  224. }
  225. print_r($api,1);
  226. exit;
  227. }
  228. if (count($user_data)) {
  229. foreach ($user_data as $k => $v) {
  230. //添加成功,同步信息
  231. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  232. if ($ret['ErrorCode'] == 0) {
  233. $GLOBALS['db']->query("update " . DB_PREFIX . "user set synchronize = 1 where id =" . $v['id']);
  234. $data['synchronize'] = 1;
  235. $user_redis->update_db($v['id'], $data);
  236. $ret_im[] = $v['id'];
  237. } else {
  238. $root = array('status' => 0, 'error' => $ret['ErrorInfo']);
  239. }
  240. }
  241. if ($ret_im) {
  242. $root = array('status' => 1, 'error' => '第一次同步实际数量:' . count($user_data) . ' 同步数量:' . count($ret_im));
  243. }
  244. }else{
  245. $root['error'] = '机器人数量少于10';
  246. }
  247. }else{
  248. $root['error'] = 'IS_DEBUG参数未开启';
  249. }
  250. return $root;
  251. }
  252. //同步机器人到im2
  253. public function robot_im2($json = 0){
  254. $root = array('status' => 0, 'error' => '');
  255. if(IS_DEBUG) {
  256. $user_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where is_robot = 1 limit 100,100");
  257. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  258. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  259. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  260. $user_redis = new UserRedisService();
  261. $api = createTimAPI();
  262. if (is_array($api)) {
  263. if ($json) {
  264. admin_ajax_return($api);
  265. }
  266. print_r($api);
  267. exit;
  268. }
  269. if (count($user_data)) {
  270. foreach ($user_data as $k => $v) {
  271. //添加成功,同步信息
  272. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  273. if ($ret['ErrorCode'] == 0) {
  274. $GLOBALS['db']->query("update " . DB_PREFIX . "user set synchronize = 1 where id =" . $v['id']);
  275. $data['synchronize'] = 1;
  276. $user_redis->update_db($v['id'], $data);
  277. $ret_im[] = $v['id'];
  278. } else {
  279. $root = array('status' => 0, 'error' => $ret['ErrorInfo']);
  280. }
  281. }
  282. if ($ret_im) {
  283. $root = array('status' => 1, 'error' => '第二次同步实际数量:' . count($user_data) . ' 同步数量:' . count($ret_im));
  284. }
  285. }else{
  286. $root['error'] = '机器人数量少于100';
  287. }
  288. }else{
  289. $root['error'] = 'IS_DEBUG参数未开启';
  290. }
  291. return $root;
  292. }
  293. //同步机器人到im3
  294. public function robot_im3($json = 0){
  295. $root = array('status' => 0, 'error' => '');
  296. if(IS_DEBUG) {
  297. $user_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where is_robot = 1 limit 200,100");
  298. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  299. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  300. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  301. $user_redis = new UserRedisService();
  302. $api = createTimAPI();
  303. if (is_array($api)) {
  304. if ($json) {
  305. admin_ajax_return($api);
  306. }
  307. print_r($api);
  308. exit;
  309. }
  310. if (count($user_data)) {
  311. foreach ($user_data as $k => $v) {
  312. //添加成功,同步信息
  313. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  314. if ($ret['ErrorCode'] == 0) {
  315. $GLOBALS['db']->query("update " . DB_PREFIX . "user set synchronize = 1 where id =" . $v['id']);
  316. $data['synchronize'] = 1;
  317. $user_redis->update_db($v['id'], $data);
  318. $ret_im[] = $v['id'];
  319. } else {
  320. $root = array('status' => 0, 'error' => $ret['ErrorInfo']);
  321. }
  322. }
  323. if ($ret_im) {
  324. $root = array('status' => 1, 'error' => '第三次同步实际数量:' . count($user_data) . ' 同步数量:' . count($ret_im));
  325. }
  326. }else{
  327. $root['error'] = '机器人数量少于200';
  328. }
  329. }else{
  330. $root['error'] = 'IS_DEBUG参数未开启';
  331. }
  332. return $root;
  333. }
  334. //同步机器人到im4
  335. public function robot_im4($json = 0){
  336. $root = array('status' => 0, 'error' => '');
  337. if(IS_DEBUG) {
  338. $user_data = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where is_robot = 1 limit 300,100");
  339. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  340. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  341. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  342. $user_redis = new UserRedisService();
  343. $api = createTimAPI();
  344. if (is_array($api)) {
  345. if ($json) {
  346. admin_ajax_return($api);
  347. }
  348. print_r($api);
  349. exit;
  350. }
  351. if (count($user_data)) {
  352. foreach ($user_data as $k => $v) {
  353. //添加成功,同步信息
  354. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  355. if ($ret['ErrorCode'] == 0) {
  356. $GLOBALS['db']->query("update " . DB_PREFIX . "user set synchronize = 1 where id =" . $v['id']);
  357. $data['synchronize'] = 1;
  358. $user_redis->update_db($v['id'], $data);
  359. $ret_im[] = $v['id'];
  360. } else {
  361. $root = array('status' => 0, 'error' => $ret['ErrorInfo']);
  362. }
  363. }
  364. if ($ret_im) {
  365. $root = array('status' => 1, 'error' => '第四次同步实际数量:' . count($user_data) . ' 同步数量:' . count($ret_im));
  366. }
  367. }else{
  368. $root['error'] = '机器人数量少于300';
  369. }
  370. }else{
  371. $root['error'] = 'IS_DEBUG参数未开启';
  372. }
  373. return $root;
  374. }
  375. //同步机器人到redis
  376. public function robot($json = 0){
  377. if(IS_DEBUG){
  378. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user where is_robot = 1");
  379. if(count($user_data)>0){
  380. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  381. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  382. $user_redis = new UserRedisService();
  383. foreach($user_data as $k=>$v){
  384. $user_redis->insert_db($v['id'],$v);
  385. $ret[] = $v['id'];
  386. }
  387. }
  388. if($json){
  389. $root = array('status'=>1,'error'=>'实际数量:'.count($user_data).' 同步数量:'.count($ret));
  390. admin_ajax_return($root);
  391. }
  392. print_r($ret);exit;
  393. }
  394. }
  395. //登录 test
  396. public function login($json=0,$user_id=0,$mobile=0)
  397. {
  398. if(IS_DEBUG){
  399. $mobile = intval($mobile);
  400. $uid = intval($user_id);
  401. if($mobile){
  402. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where mobile =".$mobile);
  403. }else{
  404. if($uid){
  405. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id =".$uid);
  406. }else{
  407. return "请填写会员ID";
  408. }
  409. }
  410. es_session::set("user_info",$user_data);
  411. $GLOBALS['user_info'] = $user_data;
  412. es_cookie::set("client_ip",CLIENT_IP,3600*24*30);
  413. es_cookie::set("nick_name",$user_data['nick_name'],3600*24*30);
  414. es_cookie::set("user_id",$user_data['id'],3600*24*30);
  415. es_cookie::set("user_pwd",md5($user_data['user_pwd']."_EASE_COOKIE"),3600*24*30);
  416. es_cookie::set("is_agree",$user_data['is_agree'],3600*24*30);
  417. es_cookie::set("PHPSESSID2",es_session::id(),3600*24*30);
  418. return $user_data;
  419. }
  420. }
  421. //获取腾讯aeskey
  422. public function get_aes_key(){
  423. if(IS_DEBUG) {
  424. $m_config = load_auto_cache("m_config");//初始化手机端配置
  425. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  426. $api = createTimAPI();
  427. $group_id = strim($m_config['full_group_id']);
  428. $base_info_filter = array("Introduction");
  429. $ret = $api->group_get_group_info2(array('0' => $group_id), $base_info_filter);
  430. return $ret;
  431. }
  432. }
  433. //获取服务端key
  434. public function get_privatekey(){
  435. if(IS_DEBUG) {
  436. $key_list = get_privatekey();
  437. return $key_list;
  438. }
  439. }
  440. //测试读取缓存 load_auto_cache
  441. public function m_configs($cache_name,$rm_cache=0){
  442. if(IS_DEBUG){
  443. if($rm_cache){
  444. rm_auto_cache($cache_name);
  445. }
  446. $cache = load_auto_cache($cache_name);
  447. return $cache;
  448. }
  449. }
  450. //删除定时器加入直播的机器人列表
  451. public function del_user_robot(){
  452. if(IS_DEBUG){
  453. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  454. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  455. $user_redis = new UserRedisService();
  456. $video_con_keys = $user_redis->redis->keys($GLOBALS['distribution_cfg']['REDIS_PREFIX'].'user_robot');
  457. $video_con_count = $user_redis->redis->delete($video_con_keys);
  458. return $video_con_count;
  459. }
  460. }
  461. //同步某个用户信息到redis
  462. public function update_user($id,$mobile=''){
  463. if(IS_DEBUG){
  464. if($mobile!=''){
  465. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where mobile = ".$mobile);
  466. }else{
  467. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$id);
  468. }
  469. return $user_data;
  470. if($user_data){
  471. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$id);
  472. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  473. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  474. $user_redis = new UserRedisService();
  475. $user_redis->update_db($user_data['id'],$user_data);
  476. return $id;
  477. }else{
  478. return array('error'=>'用户不存在!');
  479. }
  480. }
  481. }
  482. //********************************
  483. public function index2(){
  484. if(IS_DEBUG||1){
  485. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  486. <html>
  487. <head>
  488. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  489. <title>数据操作</title>
  490. </head>
  491. <body>
  492. <script type="text/javascript" src="'.SITE_DOMAIN.'/admin/Tpl/default/Common/js/jquery.js"></script>
  493. <div align="center" style="padding-top: 50px;">
  494. <form action="'.SITE_DOMAIN.'/syn/index1.php?ctl=syn&act=do_action2" method="get" id="form_type">
  495. 清除信息:<select name="type" id="type" onchange="change_type();">
  496. <option value="0">选择数据的操作方式</option>
  497. <option value="3">修改等级为1(积分清零)</option>
  498. <option value="4">用户的钻石、消费钻石、印票、可用印票清零</option>
  499. <option value="5">用户的粉丝、关注数量清零</option>
  500. <option value="6">清空所有记录(包含用户、直播、提现、充值等除配置外所有数据,不含机器人)</option>
  501. </select>
  502. <br/>
  503. <div style="display: none;padding-top: 20px;" id="user_module">
  504. 主播ID:<input type = "text" value="" name="user_id" id="user_id"/>(不填则操作所有主播)
  505. </div>
  506. <br/>
  507. <input type="button" class="submit button" value="提交" onclick="submit_type();"/>
  508. </form>
  509. </div>
  510. <script type="text/javascript">
  511. $(function(){
  512. var type = $("#type option:selected") .val();
  513. if(type==3 || type==4 || type==5){
  514. $("#user_module").show();
  515. }else{
  516. $("#user_module").hide();
  517. $("#user_id").val("");
  518. }
  519. });
  520. function change_type(){
  521. var type = $("#type option:selected") .val();
  522. if(type==3 || type==4 || type==5){
  523. $("#user_module").show();
  524. }else{
  525. $("#user_module").hide();
  526. $("#user_id").val("");
  527. }
  528. }
  529. function submit_type(){
  530. var type = $("#type option:selected") .val();
  531. if(type>0){
  532. var confirm_str = "确定将";
  533. var user_id = $("#user_id").val();
  534. var user_str = "所有";
  535. if(user_id){
  536. user_str = user_id;
  537. }
  538. confirm_str = confirm_str+user_str+$("#type option:selected") .text() +"吗?";
  539. if(confirm(confirm_str)){
  540. var url = $("#form_type").attr("action");
  541. var query = $("#form_type").serialize();
  542. $.ajax({
  543. url:url,
  544. data:query,
  545. dataType:"json",
  546. type:"post",
  547. success:function(result){
  548. alert(result.error);
  549. func();
  550. function func(){
  551. if(result.status==1){
  552. location.href=location.href;
  553. }
  554. }
  555. }
  556. });
  557. }
  558. }else{
  559. alert("请选择数据的操作方式!!");
  560. }
  561. }
  562. </script>
  563. </body>
  564. </html>';
  565. echo $html;
  566. }else{
  567. print_r("请开启debug模式");exit;
  568. }
  569. }
  570. //3、4、5、6
  571. public function do_action2(){
  572. $root = array('status'=>0,'error'=>'');
  573. if(IS_DEBUG){
  574. $type = $_REQUEST['type'];
  575. $root['error'] = '请选择数据的操作方式!!';
  576. if($type){
  577. $user_id = intval($_REQUEST['user_id']);
  578. if($type == 3 || $type==4 || $type==5){
  579. $user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where id = " . intval($user_id),true,true);
  580. if(intval($user_id)<=0){
  581. $root['error'] = '主播ID不存在';
  582. admin_ajax_return($root);
  583. }
  584. }
  585. if($type == 3){
  586. $this->syn_user_level(1,$user_id);
  587. }elseif($type==4){
  588. $sql = "";
  589. if($user_id>0){
  590. $sql = " and id=".$user_id;
  591. }
  592. $GLOBALS['db']->query("update ".DB_PREFIX."user set diamonds=0,use_diamonds=0,ticket=0,refund_ticket=0 where is_robot = 0 ".$sql);
  593. $user_data = $GLOBALS['db']->getAll("select id,diamonds,use_diamonds,ticket,refund_ticket from ".DB_PREFIX."user where 1 = 1 ".$sql,true,true);
  594. if(count($user_data)>0){
  595. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  596. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  597. $user_redis = new UserRedisService();
  598. foreach($user_data as $k=>$v){
  599. $user_redis->update_db($v['id'],$v);
  600. $ret[] = $v['id'];
  601. }
  602. }
  603. $root = array('status'=>0,'error'=>'清除失败!');
  604. if(count($user_data) == count($ret)){
  605. $root['status'] = 1;
  606. $root['error'] = '清除成功!';
  607. }
  608. admin_ajax_return($root);
  609. }elseif($type==5){
  610. $sql = "";
  611. if($user_id>0){
  612. $sql = " and id=".$user_id;
  613. }
  614. $GLOBALS['db']->query("update ".DB_PREFIX."user set fans_count=0,focus_count=0 where is_robot = 0 ".$sql);
  615. $user_data = $GLOBALS['db']->getAll("select id,fans_count,focus_count from ".DB_PREFIX."user where is_robot = 0 ".$sql,true,true);
  616. if(count($user_data)>0){
  617. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  618. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  619. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  620. $user_redis = new UserRedisService();
  621. foreach($user_data as $k=>$v){
  622. $user_redis->update_db($v['id'],$v);
  623. $ret[] = $v['id'];
  624. $user_follow_redis = new UserFollwRedisService($user_id);
  625. $user_follow_redis->redis->delete($user_follow_redis->user_follow_db.$v['id']);
  626. $user_follow_redis->redis->delete($user_follow_redis->user_followed_by_db.$v['id']);
  627. }
  628. }
  629. $root = array('status'=>0,'error'=>'清除失败!');
  630. if(count($user_data) == count($ret)){
  631. $root['status'] = 1;
  632. $root['error'] = '清除成功!';
  633. }
  634. admin_ajax_return($root);
  635. }elseif($type==6){
  636. $root = $this->clear_all();
  637. admin_ajax_return($root);
  638. }
  639. }
  640. }else{
  641. $root['error'] = '请开启debug模式';
  642. }
  643. print_r($root);
  644. }
  645. //所有用户等级改为1,其他与等级相关字段清零
  646. public function syn_user_level($json =0,$user_id=0){
  647. if(IS_DEBUG){
  648. $sql = "";
  649. if($user_id>0){
  650. $sql = " and id=".$user_id;
  651. }
  652. $GLOBALS['db']->query("update ".DB_PREFIX."user set score=0,online_time=0,user_level=1 where is_robot = 0 ".$sql);
  653. $user_data = $GLOBALS['db']->getAll("select id,score,online_time,user_level from ".DB_PREFIX."user where is_robot = 0 ".$sql,true,true);
  654. if(count($user_data)>0){
  655. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  656. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  657. $user_redis = new UserRedisService();
  658. foreach($user_data as $k=>$v){
  659. $user_redis->update_db($v['id'],$v);
  660. $ret[] = $v['id'];
  661. }
  662. }
  663. if($json){
  664. $root = array('status'=>0,'error'=>'修改失败!');
  665. if(count($user_data) == count($ret)){
  666. $root['status'] = 1;
  667. $root['error'] = '修改成功!';
  668. }
  669. admin_ajax_return($root);
  670. }
  671. print_r($ret);exit;
  672. }
  673. }
  674. //清空用户数据
  675. public function clear_all(){
  676. $result = array();
  677. $result[DB_PREFIX.'api_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."api_log");
  678. $result[DB_PREFIX.'black'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."black");
  679. $result[DB_PREFIX.'deal_msg_list'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."deal_msg_list");
  680. $result[DB_PREFIX.'mobile_verify_code'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."mobile_verify_code");
  681. $result[DB_PREFIX.'exchange_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."exchange_log");
  682. $result[DB_PREFIX.'flow_statistics'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."flow_statistics");
  683. $result[DB_PREFIX.'log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."log");
  684. $result[DB_PREFIX.'payment_notice'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."payment_notice");
  685. $result[DB_PREFIX.'push_anchor'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."push_anchor");
  686. $result[DB_PREFIX.'slb_group'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."slb_group");
  687. $result[DB_PREFIX.'tipoff'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."tipoff");
  688. //清空主播
  689. $result[DB_PREFIX.'user'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user where is_robot = 0");
  690. $result[DB_PREFIX.'user_admin'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_admin");
  691. $result[DB_PREFIX.'user_id'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_id");
  692. $result[DB_PREFIX.'user_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_log");
  693. $result[DB_PREFIX.'user_music'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_music");
  694. $result[DB_PREFIX.'user_refund'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_refund");
  695. $result[DB_PREFIX.'login_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."login_log");
  696. //清空直播记录
  697. $result[DB_PREFIX.'room_id'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."room_id");
  698. $result[DB_PREFIX.'video'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video");
  699. $result[DB_PREFIX.'video_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_history");
  700. $result[DB_PREFIX.'video_cate'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_cate");
  701. $result[DB_PREFIX.'video_lianmai'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_lianmai");
  702. $result[DB_PREFIX.'video_lianmai_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_lianmai_history");
  703. $result[DB_PREFIX.'video_monitor'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_monitor");
  704. $result[DB_PREFIX.'video_monitor_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_monitor_history");
  705. $result[DB_PREFIX.'video_red'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_red");
  706. $result[DB_PREFIX.'video_share'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_share");
  707. $result[DB_PREFIX.'video_share_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_share_history");
  708. $result[DB_PREFIX.'video_prop'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_prop");
  709. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY){
  710. $result[DB_PREFIX.'live_pay_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."live_pay_log");
  711. $result[DB_PREFIX.'live_pay_log_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."live_pay_log_history");
  712. }
  713. //家族
  714. if(defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1){
  715. $result[DB_PREFIX.'family'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family");
  716. $result[DB_PREFIX.'family_join'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family_join");
  717. $result[DB_PREFIX.'family_level'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family_level");
  718. }
  719. if(defined('OPEN_GAME_MODULE')&&OPEN_GAME_MODULE==1){
  720. $result = array_merge($result,$this->clear_game_data());
  721. }
  722. if(defined('OPEN_GAME_MODULE')&&OPEN_PAI_MODULE==1){
  723. $result = array_merge($result,$this->pai_delete_data());
  724. }
  725. if(defined('OPEN_GAME_MODULE')&&SHOPPING_GOODS==1){
  726. $result = array_merge($result,$this->shop_delete_data());
  727. }
  728. if(defined('OPEN_GAME_MODULE')&&OPEN_PODCAST_GOODS==1){
  729. $result = array_merge($result,$this->podcast_goods_delete_data());
  730. }
  731. $root = array();
  732. $root['status'] = 1;
  733. $root['error'] = print_r($result,1);
  734. return $root;
  735. }
  736. public function clear_game_data()
  737. {
  738. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  739. Model::$lib = dirname(__FILE__);
  740. $result = array();
  741. $variable = [
  742. 'coin_log',
  743. 'game_log',
  744. 'game_log_history',
  745. 'user_game_log',
  746. 'user_game_log_history',
  747. 'banker_log',
  748. 'banker_log_history',
  749. 'game_distribution',
  750. ];
  751. foreach ($variable as $value) {
  752. $result[$value] = Model::build($value)->delete(['id' => ['>', 0]]);
  753. }
  754. return $result;
  755. }
  756. //清空竞拍数据
  757. public function pai_delete_data(){
  758. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  759. Model::$lib = dirname(__FILE__);
  760. $result = array();
  761. $variable = [
  762. 'pai_goods',
  763. 'pai_join',
  764. 'goods_order',
  765. 'user_address',
  766. 'user_notice',
  767. 'pai_tags',
  768. 'user_diamonds_log',
  769. 'pai_log',
  770. 'pai_violations',
  771. 'goods',
  772. 'user_goods',
  773. 'courier',
  774. 'goods_cate',
  775. 'goods_tags',
  776. ];
  777. foreach($variable as $key => $value){
  778. $result[$value] = Model::build($value)->delete(['id'=>['>',0]]);
  779. }
  780. return $result;
  781. }
  782. //清空购物数据
  783. public function shop_delete_data(){
  784. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  785. Model::$lib = dirname(__FILE__);
  786. $result = array();
  787. $variable = [
  788. 'goods_order',
  789. 'user_address',
  790. 'user_notice',
  791. 'pai_tags',
  792. 'user_diamonds_log',
  793. 'goods',
  794. 'user_goods',
  795. 'courier',
  796. 'shopping_cart',
  797. 'goods_cate',
  798. 'goods_tags',
  799. ];
  800. foreach($variable as $key => $value){
  801. $result[$value] = Model::build($value)->delete(['id'=>['>',0]]);
  802. }
  803. return $result;
  804. }
  805. //清空小店数据
  806. public function podcast_goods_delete_data(){
  807. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  808. Model::$lib = dirname(__FILE__);
  809. $result = array();
  810. $result['podcast_goods'] = Model::build('podcast_goods')->delete(['id'=>['>',0]]);
  811. return $result;
  812. }
  813. public function clearBmPromoter()
  814. {
  815. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  816. Model::$lib = dirname(__FILE__);
  817. $result = array();
  818. $result[] = Model::build('bm_config')->update(['val'=>0],['code'=>'bm_pid']);
  819. $variable = [
  820. 'bm_promoter',
  821. 'bm_promoter_game_log',
  822. 'bm_qrcode',
  823. ];
  824. foreach($variable as $key => $value){
  825. $result[$value] = Model::build($value)->delete(['id'=>['>',0]]);
  826. }
  827. return $result;
  828. }
  829. //更新2.5版本后,填充旧用户的认证图标
  830. public function modify_v_icon()
  831. {
  832. $authentication_list = $GLOBALS['db']->getAll("select name,icon from ".DB_PREFIX."authent_list");
  833. if ($authentication_list)
  834. {
  835. $sql = "UPDATE ".DB_PREFIX."user SET v_icon = CASE authentication_type ";
  836. foreach($authentication_list as $k => $v)
  837. {
  838. $sql .= "WHEN '{$v['name']}' THEN '{$v['icon']}' ";
  839. }
  840. $sql .= "END where is_authentication = 2";
  841. }
  842. $GLOBALS['db']->query($sql);
  843. }
  844. }