member_adminfun.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <?php
  2. //--------------- 后台管理会员函数 ---------------
  3. //后台修改资料
  4. function admin_EditMember($add,$logininid,$loginin){
  5. global $empire,$dbtbpre;
  6. if(!trim($add[userid])||!trim($add[email])||!trim($add[username])||!$add[groupid])
  7. {
  8. printerror("EmptyEmail","history.go(-1)");
  9. }
  10. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  11. //变量
  12. $add[userid]=(int)$add[userid];
  13. $add[checked]=(int)$add[checked];
  14. $add[username]=RepPostVar($add[username]);
  15. $add[oldusername]=RepPostVar($add[oldusername]);
  16. $add[password]=RepPostVar($add[password]);
  17. $add[email]=RepPostStr($add[email]);
  18. $add[email]=RepPostVar($add[email]);
  19. $dousername=$add[username];
  20. $dooldusername=$add[oldusername];
  21. //修改密码
  22. $add1='';
  23. if($add[password])
  24. {
  25. $salt=eReturnMemberSalt();
  26. $add[password]=eDoMemberPw($add[password],$salt);
  27. $add1=",".egetmf('password')."='$add[password]',".egetmf('salt')."='$salt'";
  28. }
  29. //修改用户名
  30. if($add[oldusername]<>$add[username])
  31. {
  32. $num=$empire->gettotal("select count(*) as total from ".eReturnMemberTable()." where ".egetmf('username')."='$add[username]' and ".egetmf('userid')."<>".$add[userid]." limit 1");
  33. $add1.=",".egetmf('username')."='$add[username]'";
  34. if($num)
  35. {
  36. printerror("ReUsername","history.go(-1)");
  37. }
  38. }
  39. //包月
  40. $add[zgroupid]=(int)$add[zgroupid];
  41. if($add[userdate]>0)
  42. {
  43. $userdate=time()+$add[userdate]*24*3600;
  44. }
  45. else
  46. {
  47. $add[zgroupid]=0;
  48. }
  49. //变量
  50. $add[groupid]=(int)$add[groupid];
  51. $add[userfen]=(int)$add[userfen];
  52. $userdate=(int)$userdate;
  53. $add[money]=(float)$add[money];
  54. $add[spacestyleid]=(int)$add[spacestyleid];
  55. $add[ingid]=(int)$add[ingid];
  56. $isern=(int)$add['isern'];
  57. $spacename=dgdb_tosave($add['spacename']);
  58. $spacegg=dgdb_tosave($add['spacegg']);
  59. //验证附加表必填项
  60. $addr=$empire->fetch1("select * from {$dbtbpre}enewsmemberadd where userid='$add[userid]'");
  61. $fid=GetMemberFormId($add[groupid]);
  62. if(empty($addr[userid]))
  63. {
  64. $mr['add_filepass']=$add['userid'];
  65. $member_r=ReturnDoMemberF($fid,$_POST,$mr,0,$dousername,1);
  66. }
  67. else
  68. {
  69. $addr['add_filepass']=$add['userid'];
  70. $member_r=ReturnDoMemberF($fid,$_POST,$addr,1,$dousername,1);
  71. }
  72. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('email')."='$add[email]',".egetmf('groupid')."='$add[groupid]',".egetmf('userfen')."='$add[userfen]',".egetmf('money')."='$add[money]',".egetmf('userdate')."='$userdate',".egetmf('zgroupid')."='$add[zgroupid]',".egetmf('checked')."='$add[checked]',".egetmf('ingid')."='$add[ingid]',".egetmf('isern')."='$isern'".$add1." where ".egetmf('userid')."='$add[userid]'");
  73. //更改用户名
  74. if($add[oldusername]<>$add[username])
  75. {
  76. //短消息
  77. $empire->query("update {$dbtbpre}enewsqmsg set to_username='$dousername' where to_username='$dooldusername'");
  78. $empire->query("update {$dbtbpre}enewsqmsg set from_username='$dousername' where from_username='$dooldusername'");
  79. //收藏
  80. $empire->query("update {$dbtbpre}enewsfava set username='$dousername' where userid='$add[userid]'");
  81. //购买记录
  82. $empire->query("update {$dbtbpre}enewsbuybak set username='$dousername' where userid='$add[userid]'");
  83. //下载记录
  84. $empire->query("update {$dbtbpre}enewsdownrecord set username='$dousername' where userid='$add[userid]'");
  85. //信息表
  86. $tbsql=$empire->query("select tbname from {$dbtbpre}enewstable");
  87. while($tbr=$empire->fetch($tbsql))
  88. {
  89. $empire->query("update {$dbtbpre}ecms_".$tbr['tbname']." set username='$dousername' where userid='$add[userid]' and ismember=1");
  90. $empire->query("update {$dbtbpre}ecms_".$tbr['tbname']."_check set username='$dousername' where userid='$add[userid]' and ismember=1");
  91. }
  92. }
  93. //附加表
  94. if(empty($addr[userid]))
  95. {
  96. $sql1=$empire->query("insert into {$dbtbpre}enewsmemberadd(userid,spacestyleid,spacename,spacegg".$member_r[0].") values($add[userid],$add[spacestyleid],'$spacename','$spacegg'".$member_r[1].");");
  97. }
  98. else
  99. {
  100. $sql1=$empire->query("update {$dbtbpre}enewsmemberadd set spacestyleid=$add[spacestyleid],spacename='$spacename',spacegg='$spacegg'".$member_r[0]." where userid='$add[userid]'");
  101. }
  102. //更新附件
  103. UpdateTheFileEditOther(6,$add['userid'],'member');
  104. if($sql)
  105. {
  106. insert_dolog("userid=".$add[userid]."<br>username=".$dousername);//操作日志
  107. printerror("EditMemberSuccess","ListMember.php".hReturnEcmsHashStrHref2(1));
  108. }
  109. else
  110. {
  111. printerror("DbError","history.go(-1)");
  112. }
  113. }
  114. //后台删除会员
  115. function admin_DelMember($userid,$loginuserid,$loginusername){
  116. global $empire,$dbtbpre;
  117. $userid=(int)$userid;
  118. if(empty($userid))
  119. {
  120. printerror("NotDelMemberid","history.go(-1)");
  121. }
  122. CheckLevel($loginuserid,$loginusername,$classid,"member");//验证权限
  123. $r=$empire->fetch1("select ".eReturnSelectMemberF('username,groupid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
  124. if(empty($r['username']))
  125. {
  126. printerror("NotDelMemberid","history.go(-1)");
  127. }
  128. $sql=$empire->query("delete from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
  129. $dousername=$r['username'];
  130. //删除附加表
  131. $fid=GetMemberFormId($r['groupid']);
  132. DoDelMemberF($fid,$userid,$dousername);
  133. //删除收藏
  134. $del=$empire->query("delete from {$dbtbpre}enewsfava where userid='$userid'");
  135. $del=$empire->query("delete from {$dbtbpre}enewsfavaclass where userid='$userid'");
  136. //删除短消息
  137. $del=$empire->query("delete from {$dbtbpre}enewsqmsg where to_username='".$dousername."'");
  138. //删除购买记录
  139. $del=$empire->query("delete from {$dbtbpre}enewsbuybak where userid='$userid'");
  140. //删除下载记录
  141. $del=$empire->query("delete from {$dbtbpre}enewsdownrecord where userid='$userid'");
  142. //删除好友记录
  143. $del=$empire->query("delete from {$dbtbpre}enewshy where userid='$userid'");
  144. $del=$empire->query("delete from {$dbtbpre}enewshyclass where userid='$userid'");
  145. //删除留言
  146. $del=$empire->query("delete from {$dbtbpre}enewsmembergbook where userid='$userid'");
  147. //删除反馈
  148. $del=$empire->query("delete from {$dbtbpre}enewsmemberfeedback where userid='$userid'");
  149. //删除绑定
  150. $del=$empire->query("delete from {$dbtbpre}enewsmember_connect where userid='$userid';");
  151. if($sql)
  152. {
  153. insert_dolog("userid=".$userid."<br>username=".$dousername);//操作日志
  154. printerror("DelMemberSuccess",EcmsGetReturnUrl());
  155. }
  156. else
  157. {
  158. printerror("DbError","history.go(-1)");
  159. }
  160. }
  161. //后台批量删除会员
  162. function admin_DelMember_all($userid,$logininid,$loginin){
  163. global $empire,$dbtbpre;
  164. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  165. $count=count($userid);
  166. if(!$count)
  167. {
  168. printerror("NotDelMemberid","history.go(-1)");
  169. }
  170. $dh="";
  171. for($i=0;$i<$count;$i++)
  172. {
  173. $euid=(int)$userid[$i];
  174. //删除短消息
  175. $ur=$empire->fetch1("select ".eReturnSelectMemberF('username,groupid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='".$euid."'");
  176. if(empty($ur['username']))
  177. {
  178. continue;
  179. }
  180. $dousername=$ur['username'];
  181. //删除附加表
  182. $fid=GetMemberFormId($ur['groupid']);
  183. DoDelMemberF($fid,$euid,$dousername);
  184. $del=$empire->query("delete from {$dbtbpre}enewsqmsg where to_username='".$dousername."'");
  185. //集合
  186. $inid.=$dh.$euid;
  187. $dh=",";
  188. }
  189. if(empty($inid))
  190. {
  191. printerror("NotDelMemberid","history.go(-1)");
  192. }
  193. $add=egetmf('userid')." in (".$inid.")";
  194. $adda="userid in (".$inid.")";
  195. $sql=$empire->query("delete from ".eReturnMemberTable()." where ".$add);
  196. //删除收藏
  197. $del=$empire->query("delete from {$dbtbpre}enewsfava where ".$adda);
  198. $del=$empire->query("delete from {$dbtbpre}enewsfavaclass where ".$adda);
  199. //删除购买记录
  200. $del=$empire->query("delete from {$dbtbpre}enewsbuybak where ".$adda);
  201. //删除下载记录
  202. $del=$empire->query("delete from {$dbtbpre}enewsdownrecord where ".$adda);
  203. //删除好友记录
  204. $del=$empire->query("delete from {$dbtbpre}enewshy where ".$adda);
  205. $del=$empire->query("delete from {$dbtbpre}enewshyclass where ".$adda);
  206. //删除留言
  207. $del=$empire->query("delete from {$dbtbpre}enewsmembergbook where ".$adda);
  208. //删除反馈
  209. $del=$empire->query("delete from {$dbtbpre}enewsmemberfeedback where ".$adda);
  210. //删除绑定
  211. $del=$empire->query("delete from {$dbtbpre}enewsmember_connect where ".$adda);
  212. if($sql)
  213. {
  214. insert_dolog("");//操作日志
  215. printerror("DelMemberSuccess",EcmsGetReturnUrl());
  216. }
  217. else
  218. {
  219. printerror("DbError","history.go(-1)");
  220. }
  221. }
  222. //审核会员
  223. function admin_DoCheckMember_all($add,$logininid,$loginin){
  224. global $empire,$dbtbpre;
  225. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  226. $userid=$add['userid'];
  227. $docheck=(int)$add['docheck'];
  228. $count=count($userid);
  229. if(!$count)
  230. {
  231. printerror("NotChangeDoCheckMember","history.go(-1)");
  232. }
  233. $inid='';
  234. for($i=0;$i<$count;$i++)
  235. {
  236. $dh=",";
  237. if($i==0)
  238. {
  239. $dh="";
  240. }
  241. //集合
  242. $inid.=$dh.intval($userid[$i]);
  243. }
  244. $checked=$docheck?1:0;
  245. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('checked')."='$checked' where ".egetmf('userid')." in (".$inid.")");
  246. if($sql)
  247. {
  248. insert_dolog("");//操作日志
  249. printerror("DoCheckMemberSuccess",EcmsGetReturnUrl());
  250. }
  251. else
  252. {
  253. printerror("DbError","history.go(-1)");
  254. }
  255. }
  256. //转移至内部会员组
  257. function admin_DoMoveInGroupMember_all($add,$logininid,$loginin){
  258. global $empire,$dbtbpre;
  259. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  260. $userid=$add['userid'];
  261. $toingid=(int)$add['toingid'];
  262. $count=count($userid);
  263. if(!$count)
  264. {
  265. printerror("NotChangeDoMoveMember","history.go(-1)");
  266. }
  267. $inid='';
  268. for($i=0;$i<$count;$i++)
  269. {
  270. $dh=",";
  271. if($i==0)
  272. {
  273. $dh="";
  274. }
  275. //集合
  276. $inid.=$dh.intval($userid[$i]);
  277. }
  278. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('ingid')."='$toingid' where ".egetmf('userid')." in (".$inid.")");
  279. if($sql)
  280. {
  281. insert_dolog("");//操作日志
  282. printerror("DoMoveInGroupMemberSuccess",EcmsGetReturnUrl());
  283. }
  284. else
  285. {
  286. printerror("DbError","history.go(-1)");
  287. }
  288. }
  289. //后台清理会员
  290. function admin_ClearMember($add,$logininid,$loginin){
  291. global $empire,$dbtbpre,$level_r;
  292. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  293. //变量处理
  294. $username=RepPostVar($add['username']);
  295. $email=RepPostStr($add['email']);
  296. $email=RepPostVar($email);
  297. $startuserid=(int)$add['startuserid'];
  298. $enduserid=(int)$add['enduserid'];
  299. $groupid=(int)$add['groupid'];
  300. $startregtime=RepPostVar($add['startregtime']);
  301. $endregtime=RepPostVar($add['endregtime']);
  302. $startuserfen=(int)$add['startuserfen'];
  303. $enduserfen=(int)$add['enduserfen'];
  304. $startmoney=(int)$add['startmoney'];
  305. $endmoney=(int)$add['endmoney'];
  306. $checked=(int)$add['checked'];
  307. $where='';
  308. if($username)
  309. {
  310. $where.=" and ".egetmf('username')." like '%$username%'";
  311. }
  312. if($email)
  313. {
  314. $where.=" and ".egetmf('email')." like '%$email%'";
  315. }
  316. if($enduserid)
  317. {
  318. $where.=' and '.egetmf('userid').' BETWEEN '.$startuserid.' and '.$enduserid;
  319. }
  320. if($groupid)
  321. {
  322. $where.=" and ".egetmf('groupid')."='$groupid'";
  323. }
  324. if($startregtime&&$endregtime)
  325. {
  326. $startregtime=to_time($startregtime);
  327. $endregtime=to_time($endregtime);
  328. $where.=" and ".egetmf('registertime').">='$startregtime' and ".egetmf('registertime')."<='$endregtime'";
  329. }
  330. if($enduserfen)
  331. {
  332. $where.=' and '.egetmf('userfen').' BETWEEN '.$startuserfen.' and '.$enduserfen;
  333. }
  334. if($endmoney)
  335. {
  336. $where.=' and '.egetmf('money').' BETWEEN '.$startmoney.' and '.$endmoney;
  337. }
  338. if($checked)
  339. {
  340. $checkval=$checked==1?1:0;
  341. $where.=" and ".egetmf('checked')."='$checkval'";
  342. }
  343. if(!$where)
  344. {
  345. printerror("EmptyClearMember","history.go(-1)");
  346. }
  347. $where=substr($where,5);
  348. $sql=$empire->query("select ".eReturnSelectMemberF('userid,username,groupid')." from ".eReturnMemberTable()." where ".$where);
  349. $dh='';
  350. $inid='';
  351. while($r=$empire->fetch($sql))
  352. {
  353. $euid=$r['userid'];
  354. //删除短消息
  355. $dousername=$r['username'];
  356. //删除附加表
  357. $fid=GetMemberFormId($r['groupid']);
  358. DoDelMemberF($fid,$euid,$dousername);
  359. $empire->query("delete from {$dbtbpre}enewsqmsg where to_username='".$dousername."'");
  360. //集合
  361. $inid.=$dh.$euid;
  362. $dh=',';
  363. }
  364. if($inid)
  365. {
  366. $addw=egetmf('userid')." in (".$inid.")";
  367. $addaw="userid in (".$inid.")";
  368. $sql=$empire->query("delete from ".eReturnMemberTable()." where ".$addw);
  369. //删除收藏
  370. $del=$empire->query("delete from {$dbtbpre}enewsfava where ".$addaw);
  371. $del=$empire->query("delete from {$dbtbpre}enewsfavaclass where ".$addaw);
  372. //删除购买记录
  373. $del=$empire->query("delete from {$dbtbpre}enewsbuybak where ".$addaw);
  374. //删除下载记录
  375. $del=$empire->query("delete from {$dbtbpre}enewsdownrecord where ".$addaw);
  376. //删除好友记录
  377. $del=$empire->query("delete from {$dbtbpre}enewshy where ".$addaw);
  378. $del=$empire->query("delete from {$dbtbpre}enewshyclass where ".$addaw);
  379. //删除留言
  380. $del=$empire->query("delete from {$dbtbpre}enewsmembergbook where ".$addaw);
  381. //删除反馈
  382. $del=$empire->query("delete from {$dbtbpre}enewsmemberfeedback where ".$addaw);
  383. //删除绑定
  384. $del=$empire->query("delete from {$dbtbpre}enewsmember_connect where ".$addaw);
  385. }
  386. insert_dolog("");//操作日志
  387. printerror("DelMemberSuccess","ClearMember.php".hReturnEcmsHashStrHref2(1));
  388. }
  389. //批量赠送点数
  390. function GetFen_all($cardfen,$userid,$username){
  391. global $empire,$dbtbpre;
  392. $cardfen=(int)$cardfen;
  393. if(!$cardfen)
  394. {printerror("EmptyGetFen","history.go(-1)");}
  395. //验证权限
  396. CheckLevel($userid,$username,$classid,"card");
  397. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userfen')."=".egetmf('userfen')."+$cardfen");
  398. if($sql)
  399. {
  400. //操作日志
  401. insert_dolog("cardfen=$cardfen");
  402. printerror("GetFenSuccess","GetFen.php".hReturnEcmsHashStrHref2(1));
  403. }
  404. else
  405. {printerror("DbError","history.go(-1)");}
  406. }
  407. //批量更新到期会员组
  408. function admin_MemberChangeTimeGroup($add,$logininid,$loginin){
  409. global $empire,$dbtbpre;
  410. CheckLevel($logininid,$loginin,$classid,"member");//验证权限
  411. $dotime=time();
  412. //更新到期会员组
  413. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('groupid')."=".egetmf('zgroupid').",".egetmf('userdate')."=0 where ".egetmf('zgroupid')."<>0 and ".egetmf('userdate').">0 and ".egetmf('userdate')."<=".$dotime);
  414. //更新到期时间
  415. $sql1=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userdate')."=0 where ".egetmf('userdate').">0 and ".egetmf('userdate')."<=".$dotime);
  416. if($sql)
  417. {
  418. //操作日志
  419. insert_dolog("");
  420. printerror("MemberChangeTimeGroupSuccess","ListMember.php".hReturnEcmsHashStrHref2(1));
  421. }
  422. else
  423. {printerror("DbError","history.go(-1)");}
  424. }
  425. ?>