user.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. <?php
  2. if(!defined('InEmpireCMS'))
  3. {
  4. exit();
  5. }
  6. define('InEmpireCMSUser',TRUE);
  7. //--------------- 扩展函数 ---------------
  8. //登录附加cookie
  9. function AddLoginCookie($r){
  10. }
  11. //--------------- 会员表信息函数 ---------------
  12. //返回会员表
  13. function eReturnMemberTable(){
  14. global $ecms_config;
  15. return $ecms_config['member']['tablename'];
  16. }
  17. //返回默认会员组ID
  18. function eReturnMemberDefGroupid(){
  19. global $ecms_config,$public_r;
  20. $groupid=$ecms_config['member']['defgroupid']?$ecms_config['member']['defgroupid']:$public_r['defaultgroupid'];
  21. return intval($groupid);
  22. }
  23. //返回查询会员字段列表
  24. function eReturnSelectMemberF($f,$tb=''){
  25. global $ecms_config;
  26. if(empty($ecms_config['member']['chmember']))
  27. {
  28. if(!empty($tb))
  29. {
  30. $f=$f=='*'?$tb.$f:$tb.str_replace(',',','.$tb,$f);
  31. }
  32. return $f;
  33. }
  34. if($f=='*')
  35. {
  36. $f='userid,username,password,rnd,email,registertime,groupid,userfen,userdate,money,zgroupid,havemsg,checked,salt,userkey,ingid,agid,isern';
  37. }
  38. $r=explode(',',$f);
  39. $count=count($r);
  40. $selectf='';
  41. $dh='';
  42. for($i=0;$i<$count;$i++)
  43. {
  44. $truef=$r[$i];
  45. if($ecms_config['memberf'][$truef]==$truef)
  46. {
  47. $selectf.=$dh.$tb.$truef;
  48. }
  49. else
  50. {
  51. $selectf.=$dh.$tb.$ecms_config['memberf'][$truef].' as '.$truef;
  52. }
  53. $dh=',';
  54. }
  55. return $selectf;
  56. }
  57. //返回插入会员字段列表
  58. function eReturnInsertMemberF($f){
  59. global $ecms_config;
  60. if(empty($ecms_config['member']['chmember']))
  61. {
  62. return $f;
  63. }
  64. $r=explode(',',$f);
  65. $count=count($r);
  66. $insertf='';
  67. $dh='';
  68. for($i=0;$i<$count;$i++)
  69. {
  70. $truef=$r[$i];
  71. $insertf.=$dh.$ecms_config['memberf'][$truef];
  72. $dh=',';
  73. }
  74. return $insertf;
  75. }
  76. //取得实际会员字段
  77. function egetmf($f){
  78. global $ecms_config;
  79. if(empty($ecms_config['member']['chmember']))
  80. {
  81. return $f;
  82. }
  83. return $ecms_config['memberf'][$f]?$ecms_config['memberf'][$f]:$f;
  84. }
  85. //密码
  86. function eDoMemberPw($password,$salt){
  87. global $ecms_config;
  88. if($ecms_config['member']['pwtype']==0)//单重md5
  89. {
  90. $pw=md5($password);
  91. }
  92. elseif($ecms_config['member']['pwtype']==1)//明码
  93. {
  94. $pw=$password;
  95. }
  96. elseif($ecms_config['member']['pwtype']==3)//16位md5
  97. {
  98. $pw=substr(md5($password),8,16);
  99. }
  100. else//双重md5
  101. {
  102. $pw=md5(md5($password).$salt);
  103. }
  104. return $pw;
  105. }
  106. //验证密码
  107. function eDoCkMemberPw($oldpw,$pw,$salt){
  108. global $ecms_config;
  109. $istrue=0;
  110. if($ecms_config['member']['pwtype']==0)//单重md5
  111. {
  112. $oldpw=md5($oldpw);
  113. if('dg'.$oldpw=='dg'.$pw)
  114. {
  115. $istrue=1;
  116. }
  117. }
  118. elseif($ecms_config['member']['pwtype']==1)//明码
  119. {
  120. if('dg'.$oldpw=='dg'.$pw)
  121. {
  122. $istrue=1;
  123. }
  124. }
  125. elseif($ecms_config['member']['pwtype']==3)//16位md5
  126. {
  127. $oldpw=substr(md5($oldpw),8,16);
  128. if('dg'.$oldpw=='dg'.$pw)
  129. {
  130. $istrue=1;
  131. }
  132. }
  133. else//双重md5
  134. {
  135. $oldpw=md5(md5($oldpw).$salt);
  136. if('dg'.$oldpw=='dg'.$pw)
  137. {
  138. $istrue=1;
  139. }
  140. }
  141. return $istrue;
  142. }
  143. //返回注册时间
  144. function eReturnMemberRegtime($regtime,$format){
  145. global $ecms_config;
  146. return empty($ecms_config['member']['regtimetype'])?$regtime:date($format,$regtime);
  147. }
  148. //返回注册时间(int)
  149. function eReturnMemberIntRegtime($regtime){
  150. global $ecms_config;
  151. return empty($ecms_config['member']['regtimetype'])?to_time($regtime):$regtime;
  152. }
  153. //返回当前注册时间
  154. function eReturnAddMemberRegtime(){
  155. global $ecms_config;
  156. return empty($ecms_config['member']['regtimetype'])?date('Y-m-d H:i:s'):time();
  157. }
  158. //返回SALT
  159. function eReturnMemberSalt(){
  160. global $ecms_config;
  161. return make_password($ecms_config['member']['saltnum']);
  162. }
  163. //返回UserKey
  164. function eReturnMemberUserKey(){
  165. global $ecms_config;
  166. return make_password(12);
  167. }
  168. //启动易通行系统
  169. function DoEpassport($ecms,$userid,$username,$password,$salt,$email,$groupid,$retime){
  170. global $ecms_config;
  171. return '';
  172. if(!$ecms_config['epassport']['open'])
  173. {
  174. return '';
  175. }
  176. include_once ECMS_PATH.'e/epassport/epp_config.php';
  177. include_once ECMS_PATH.'e/epassport/epp_function.php';
  178. $r=DoEpassportVar($userid,$username,$password,$salt,$email,$groupid,$retime);
  179. epassport_doaction($r,$ecms);
  180. }
  181. //易通行系统变量
  182. function DoEpassportVar($userid,$username,$password,$salt,$email,$groupid,$retime){
  183. $r['userid']=$userid;
  184. $r['username']=$username;
  185. $r['password']=$password;
  186. $r['salt']=$salt;
  187. $r['email']=$email;
  188. $r['groupid']=$groupid;
  189. $r['retime']=$retime;
  190. return $r;
  191. }
  192. //--------------- 会员公共函数 ---------------
  193. //返回设置短消息
  194. function eReturnSetHavemsg($havemsg,$ecms=0){
  195. $newhavemsg=1;
  196. if($havemsg==3)//全部信息
  197. {
  198. $newhavemsg=3;
  199. }
  200. elseif($havemsg==2)//通知
  201. {
  202. $newhavemsg=$ecms==1?2:3;
  203. }
  204. elseif($havemsg==1)//消息
  205. {
  206. $newhavemsg=$ecms==1?3:1;
  207. }
  208. else //无状态
  209. {
  210. $newhavemsg=$ecms==1?2:1;
  211. }
  212. return $newhavemsg;
  213. }
  214. //取得表单id
  215. function GetMemberFormId($groupid){
  216. global $empire,$dbtbpre;
  217. $groupid=(int)$groupid;
  218. $r=$empire->fetch1("select formid from {$dbtbpre}enewsmembergroup where groupid='$groupid'");
  219. return $r['formid'];
  220. }
  221. //取得邮件地址
  222. function GetUserEmail($userid,$username){
  223. global $empire,$dbtbpre;
  224. $userid=(int)$userid;
  225. $r=$empire->fetch1("select ".eReturnSelectMemberF('email')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' limit 1");
  226. return $r['email'];
  227. }
  228. //返回修改资料
  229. function ReturnUserInfo($userid){
  230. global $empire,$dbtbpre;
  231. $userid=(int)$userid;
  232. $r=$empire->fetch1("select ".eReturnSelectMemberF('username,email,groupid,userfen,money,userdate,zgroupid,checked,registertime,ingid,agid,isern')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' limit 1");
  233. return $r;
  234. }
  235. //返回是否审核
  236. function ReturnGroupChecked($groupid){
  237. global $level_r;
  238. if($level_r[$groupid]['regchecked']==1)
  239. {
  240. $checked=0;
  241. }
  242. else
  243. {
  244. $checked=1;
  245. }
  246. return $checked;
  247. }
  248. //返回使用空间模板
  249. function ReturnGroupSpaceStyleid($groupid){
  250. global $level_r;
  251. $spacestyleid=$level_r[$groupid]['spacestyleid']?$level_r[$groupid]['spacestyleid']:0;
  252. return intval($spacestyleid);
  253. }
  254. //清空COOKIE
  255. function EmptyEcmsCookie(){
  256. $set1=esetcookie("mlusername","",0);
  257. $set2=esetcookie("mluserid","",0);
  258. $set3=esetcookie("mlgroupid","",0);
  259. $set4=esetcookie("mlrnd","",0);
  260. $set5=esetcookie("mlauth","",0);
  261. }
  262. //登录加密验证2
  263. function qReturnLoginPassNoCK($userid,$username,$rnd,$ecms=0){
  264. global $ecms_config;
  265. if(!$userid||!$rnd)
  266. {
  267. return '';
  268. }
  269. $checkpass=md5(md5($ecms_config['cks']['ckrndthree'].'e.c-m-s-'.$userid.'-(em!pi.re!-)'.$rnd.'-d-i-g.o*d').'-#em.pire.cms!-'.$ecms_config['cks']['ckrndthree']);
  270. return $checkpass;
  271. }
  272. //登录验证符
  273. function qGetLoginAuthstr($userid,$username,$rnd,$groupid,$cookietime=0){
  274. global $ecms_config;
  275. $checkpass=md5(md5($rnd.'--d-i!'.$userid.'-(g*od-'.$username.$ecms_config['cks']['ckrndtwo'].'-'.$groupid).'-#empire.cms!--p)h-o!me-'.$ecms_config['cks']['ckrndtwo']);
  276. esetcookie('mlauth',$checkpass,$cookietime);
  277. }
  278. //验证登录验证符
  279. function qCheckLoginAuthstr(){
  280. global $ecms_config;
  281. $re['userid']='';
  282. $re['username']='';
  283. $re['groupid']='';
  284. $re['rnd']='';
  285. $re['islogin']=0;
  286. $checkpass=getcvar('mlauth');
  287. if(!$checkpass)
  288. {
  289. return $re;
  290. }
  291. $re['userid']=(int)getcvar('mluserid');
  292. $re['username']=RepPostVar(getcvar('mlusername'));
  293. $re['rnd']=RepPostVar(getcvar('mlrnd'));
  294. $re['groupid']=(int)getcvar('mlgroupid');
  295. if(!$re['userid']||!$re['username']||!$re['rnd'])
  296. {
  297. return $re;
  298. }
  299. $pass=md5(md5($re['rnd'].'--d-i!'.$re['userid'].'-(g*od-'.$re['username'].$ecms_config['cks']['ckrndtwo'].'-'.$re['groupid']).'-#empire.cms!--p)h-o!me-'.$ecms_config['cks']['ckrndtwo']);
  300. if('dg'.$pass!='dg'.$checkpass)
  301. {
  302. return $re;
  303. }
  304. else
  305. {
  306. $re['islogin']=1;
  307. return $re;
  308. }
  309. }
  310. //是否登录
  311. function islogin($uid=0,$uname='',$urnd=''){
  312. global $empire,$dbtbpre,$public_r,$ecmsreurl,$ecms_config;
  313. if($uid)
  314. {$userid=(int)$uid;}
  315. else
  316. {$userid=(int)getcvar('mluserid');}
  317. if($uname)
  318. {$username=$uname;}
  319. else
  320. {$username=getcvar('mlusername');}
  321. $username=RepPostVar($username);
  322. if($urnd)
  323. {$rnd=$urnd;}
  324. else
  325. {$rnd=getcvar('mlrnd');}
  326. if($ecms_config['member']['loginurl'])
  327. {$gotourl=$ecms_config['member']['loginurl'];}
  328. else
  329. {$gotourl=$public_r['newsurl']."e/member/login/";}
  330. $petype=1;
  331. $rnd=RepPostVar($rnd);
  332. if(!$userid||!$username||!$rnd)
  333. {
  334. if(!getcvar('returnurl'))
  335. {
  336. esetcookie("returnurl",EcmsGetReturnUrl(),0);
  337. }
  338. if($ecmsreurl==1)
  339. {
  340. $gotourl="history.go(-1)";
  341. $petype=9;
  342. }
  343. elseif($ecmsreurl==2)
  344. {
  345. $phpmyself=urlencode(eReturnSelfPage(1));
  346. $gotourl=$public_r['newsurl']."e/member/login/login.php?prt=1&from=".$phpmyself;
  347. $petype=9;
  348. }
  349. printerror("NotLogin",$gotourl,$petype);
  350. }
  351. //cookie
  352. if(getcvar('mluserid'))
  353. {
  354. $qcklgr=qCheckLoginAuthstr();
  355. if(!$qcklgr['islogin'])
  356. {
  357. EmptyEcmsCookie();
  358. if(!getcvar('returnurl'))
  359. {
  360. esetcookie("returnurl",EcmsGetReturnUrl(),0);
  361. }
  362. if($ecmsreurl==1)
  363. {
  364. $gotourl="history.go(-1)";
  365. $petype=9;
  366. }
  367. elseif($ecmsreurl==2)
  368. {
  369. $phpmyself=urlencode(eReturnSelfPage(1));
  370. $gotourl=$public_r['newsurl']."e/member/login/login.php?prt=1&from=".$phpmyself;
  371. $petype=9;
  372. }
  373. printerror("NotSingleLogin",$gotourl,$petype);
  374. }
  375. }
  376. $cr=$empire->fetch1("select ".eReturnSelectMemberF('userid,username,email,groupid,userfen,money,userdate,zgroupid,havemsg,checked,registertime,ingid,agid,isern')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' and ".egetmf('username')."='$username' and ".egetmf('rnd')."='$rnd' limit 1");
  377. if(!$cr['userid'])
  378. {
  379. EmptyEcmsCookie();
  380. if(!getcvar('returnurl'))
  381. {
  382. esetcookie("returnurl",EcmsGetReturnUrl(),0);
  383. }
  384. if($ecmsreurl==1)
  385. {
  386. $gotourl="history.go(-1)";
  387. $petype=9;
  388. }
  389. elseif($ecmsreurl==2)
  390. {
  391. $phpmyself=urlencode(eReturnSelfPage(1));
  392. $gotourl=$public_r['newsurl']."e/member/login/login.php?prt=1&from=".$phpmyself;
  393. $petype=9;
  394. }
  395. printerror("NotSingleLogin",$gotourl,$petype);
  396. }
  397. if($cr['checked']==0)
  398. {
  399. EmptyEcmsCookie();
  400. if($ecmsreurl==1)
  401. {
  402. $gotourl="history.go(-1)";
  403. $petype=9;
  404. }
  405. elseif($ecmsreurl==2)
  406. {
  407. $phpmyself=urlencode(eReturnSelfPage(1));
  408. $gotourl=$public_r['newsurl']."e/member/login/login.php?prt=1&from=".$phpmyself;
  409. $petype=9;
  410. }
  411. printerror("NotCheckedUser",'',$petype);
  412. }
  413. //默认会员组
  414. if(empty($cr['groupid']))
  415. {
  416. $user_groupid=eReturnMemberDefGroupid();
  417. $usql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('groupid')."='$user_groupid' where ".egetmf('userid')."='".$cr[userid]."'");
  418. $cr['groupid']=$user_groupid;
  419. }
  420. //是否过期
  421. if($cr['userdate'])
  422. {
  423. if($cr['userdate']-time()<=0)
  424. {
  425. OutTimeZGroup($cr['userid'],$cr['zgroupid']);
  426. $cr['userdate']=0;
  427. if($cr['zgroupid'])
  428. {
  429. $cr['groupid']=$cr['zgroupid'];
  430. $cr['zgroupid']=0;
  431. }
  432. }
  433. }
  434. $re[userid]=$cr['userid'];
  435. $re[rnd]=$rnd;
  436. $re[username]=$cr['username'];
  437. $re[email]=$cr['email'];
  438. $re[userfen]=$cr['userfen'];
  439. $re[money]=$cr['money'];
  440. $re[groupid]=$cr['groupid'];
  441. $re[userdate]=$cr['userdate'];
  442. $re[zgroupid]=$cr['zgroupid'];
  443. $re[havemsg]=$cr['havemsg'];
  444. $re[registertime]=$cr['registertime'];
  445. $re[ingid]=$cr['ingid'];
  446. $re[agid]=$cr['agid'];
  447. $re[isern]=$cr['isern'];
  448. $re['checked']=$cr['checked'];
  449. return $re;
  450. }
  451. //会员登录
  452. function DoEcmsMemberLogin($r,$lifetime=0){
  453. global $empire,$dbtbpre,$ecms_config;
  454. $rnd=make_password(20);//取得随机密码
  455. //默认会员组
  456. if(empty($r['groupid']))
  457. {
  458. $r['groupid']=eReturnMemberDefGroupid();
  459. }
  460. $r['groupid']=(int)$r['groupid'];
  461. $empire->query("update ".eReturnMemberTable()." set ".egetmf('rnd')."='$rnd',".egetmf('groupid')."='$r[groupid]' where ".egetmf('userid')."='$r[userid]'");
  462. //设置cookie
  463. $lifetime=(int)$lifetime;
  464. $logincookie=0;
  465. if($lifetime)
  466. {
  467. $logincookie=time()+$lifetime;
  468. }
  469. esetcookie("mlusername",$r['username'],$logincookie);
  470. esetcookie("mluserid",$r['userid'],$logincookie);
  471. esetcookie("mlgroupid",$r['groupid'],$logincookie);
  472. esetcookie("mlrnd",$rnd,$logincookie);
  473. //验证符
  474. qGetLoginAuthstr($r['userid'],$r['username'],$rnd,$r['groupid'],$logincookie);
  475. //登录附加cookie
  476. AddLoginCookie($r);
  477. }
  478. //验证会员帐号和密码
  479. function DoEcmsMemberCheckUserPass($add){
  480. global $empire,$dbtbpre,$ecms_config;
  481. $dopr=1;
  482. if($_POST['prtype'])
  483. {
  484. $dopr=9;
  485. }
  486. $username=trim($add['username']);
  487. $password=trim($add['password']);
  488. if(!$username||!$password)
  489. {
  490. printerror("EmptyLogin","history.go(-1)",$dopr);
  491. }
  492. $username=RepPostVar($username);
  493. $password=RepPostVar($password);
  494. $num=0;
  495. $r=$empire->fetch1("select ".eReturnSelectMemberF('*')." from ".eReturnMemberTable()." where ".egetmf('username')."='$username' limit 1");
  496. if(!$r['userid'])
  497. {
  498. printerror("FailPassword","history.go(-1)",$dopr);
  499. }
  500. if(!eDoCkMemberPw($password,$r['password'],$r['salt']))
  501. {
  502. printerror("FailPassword","history.go(-1)",$dopr);
  503. }
  504. if($r['checked']==0)
  505. {
  506. printerror('NotCheckedUser','',$dopr);
  507. }
  508. return $r;
  509. }
  510. //返回管理组级别
  511. function eMember_ReturnAgidLevel($userid,$agid){
  512. global $empire,$dbtbpre,$public_r,$ecms_config,$aglevel_r;
  513. $userid=(int)$userid;
  514. $agid=(int)$agid;
  515. $glevel=0;
  516. $ckstr=','.$userid.',';
  517. if(!$agid)
  518. {
  519. return 0;
  520. }
  521. if(!$aglevel_r[$agid]['agid'])
  522. {
  523. return 0;
  524. }
  525. if(strstr($public_r['qmotheruids'],$ckstr))
  526. {
  527. $glevel=1;
  528. }
  529. elseif(strstr($public_r['qmforumuids'],$ckstr))
  530. {
  531. $glevel=5;
  532. }
  533. elseif(strstr($public_r['qmadminuids'],$ckstr))
  534. {
  535. $glevel=9;
  536. }
  537. else
  538. {
  539. $glevel=0;
  540. }
  541. if($aglevel_r[$agid]['isadmin']!=$glevel)
  542. {
  543. $glevel=0;
  544. }
  545. return $glevel;
  546. }
  547. //返回验证访问组权限
  548. function eMember_ReturnCheckViewGroup($ckuser,$vgid){
  549. global $empire,$dbtbpre,$public_r,$ecms_config,$class_r;
  550. $esuccess='empire.cms';
  551. $vgid=(int)$vgid;
  552. $ckuser['userid']=(int)$ckuser['userid'];
  553. if(!$vgid)
  554. {
  555. return 'NotVgid';
  556. }
  557. $vgr=$empire->fetch1("select * from {$dbtbpre}enewsvg where vgid='$vgid'");
  558. if(!$vgr['vgid'])
  559. {
  560. return 'NotVgid';
  561. }
  562. $thistime=time();
  563. //会员组验证
  564. if($vgr['gids'])
  565. {
  566. $ckuser['groupid']=(int)$ckuser['groupid'];
  567. if(strstr($vgr['gids'],','.$ckuser['groupid'].','))
  568. {
  569. return $esuccess;
  570. }
  571. }
  572. //内部组验证
  573. if($vgr['ingids'])
  574. {
  575. $ckuser['ingid']=(int)$ckuser['ingid'];
  576. if(strstr($vgr['ingids'],','.$ckuser['ingid'].','))
  577. {
  578. return $esuccess;
  579. }
  580. }
  581. //会员管理组验证
  582. if($vgr['agids'])
  583. {
  584. $ckuser['agid']=(int)$ckuser['agid'];
  585. if(strstr($vgr['agids'],','.$ckuser['agid'].','))
  586. {
  587. return $esuccess;
  588. }
  589. }
  590. //会员白名单
  591. if($vgr['mlist'])
  592. {
  593. $vgmember=$empire->fetch1("select userid,outtime from {$dbtbpre}enewsvglist where vgid='$vgid' and userid='".$ckuser['userid']."' limit 1");
  594. if(!$vgmember['userid'])
  595. {
  596. return 'NotUserid';
  597. }
  598. if(empty($vgmember['outtime']))
  599. {
  600. return $esuccess;
  601. }
  602. if($thistime<$vgmember['outtime'])
  603. {
  604. return $esuccess;
  605. }
  606. }
  607. return 'NotLevel';
  608. }
  609. //--------------- 会员实名函数 ---------------
  610. //实名验证
  611. function eCheckHaveTruename($mod,$userid,$username,$isern,$checked,$ecms=0){
  612. global $empire,$dbtbpre,$public_r,$ecms_config,$ecms_topagesetr,$enews;
  613. if(empty($public_r['openern']))
  614. {
  615. return '';
  616. }
  617. if(!strstr($public_r['openern'],','.$mod.','))
  618. {
  619. return '';
  620. }
  621. if($userid)
  622. {
  623. if($checked==0)
  624. {
  625. printerror("NotCheckedUser",'',1);
  626. }
  627. }
  628. if(!$isern)
  629. {
  630. printerror('NotHaveTrueName',$public_r['ernurl'],1);
  631. }
  632. }
  633. //实名验证2
  634. function eCheckHaveTruenameCK($mod,$ecms=0){
  635. global $empire,$dbtbpre,$public_r,$ecms_config,$ecms_topagesetr,$enews;
  636. if(empty($public_r['openern']))
  637. {
  638. return '';
  639. }
  640. if(!strstr($public_r['openern'],','.$mod.','))
  641. {
  642. return '';
  643. }
  644. $isern=0;
  645. $cklgr=qCheckLoginAuthstr();
  646. if($cklgr['islogin'])
  647. {
  648. $userid=(int)$cklgr['userid'];
  649. $ernr=eReturnHaveTruename($userid,'',1);
  650. $isern=$ernr['isern'];
  651. if($ernr['checked']==0)
  652. {
  653. printerror("NotCheckedUser",'',1);
  654. }
  655. }
  656. if(!$isern)
  657. {
  658. printerror('NotHaveTrueName',$public_r['ernurl'],1);
  659. }
  660. }
  661. //返回是否实名
  662. function eReturnHaveTruename($userid,$username='',$ecms=0){
  663. global $empire,$dbtbpre;
  664. $userid=(int)$userid;
  665. $r=$empire->fetch1("select ".eReturnSelectMemberF('userid,checked,isern')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' limit 1");
  666. if($ecms)
  667. {
  668. return $r;
  669. }
  670. else
  671. {
  672. return $r['isern'];
  673. }
  674. }
  675. //更新实名状态
  676. function eUpdateTruenameStatus($userid,$username,$checked,$isern,$ecms=0){
  677. global $empire,$dbtbpre;
  678. $userid=(int)$userid;
  679. $checked=(int)$checked;
  680. $isern=(int)$isern;
  681. $username=RepPostVar($username);
  682. //更新审核和实名状态
  683. $upstr='';
  684. if($ecms==2)
  685. {
  686. $upstr="".egetmf('checked')."='$checked',".egetmf('isern')."='$isern'";
  687. }
  688. elseif($ecms==1)//审核
  689. {
  690. $upstr="".egetmf('checked')."='$checked'";
  691. }
  692. else//实名
  693. {
  694. $upstr="".egetmf('isern')."='$isern'";
  695. }
  696. if($upstr)
  697. {
  698. $sql=$empire->query("update ".eReturnMemberTable()." set ".$upstr." where ".egetmf('userid')."='$userid'");
  699. return $sql;
  700. }
  701. return 0;
  702. }
  703. //--------------- 其他函数 ---------------
  704. //增加点数
  705. function AddInfoFen($cardfen,$userid,$checkfen=1){
  706. global $empire,$dbtbpre;
  707. $cardfen=(int)$cardfen;
  708. if(!$cardfen)
  709. {
  710. return '';
  711. }
  712. //checkfen
  713. if($checkfen==1)
  714. {
  715. if($cardfen<0)
  716. {
  717. $ur=$empire->fetch1("select ".eReturnSelectMemberF('userid,userdate,userfen')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' limit 1");
  718. if(!$ur['userid'])
  719. {
  720. return '';
  721. }
  722. if($ur['userdate']-time()>0)
  723. {
  724. return '';
  725. }
  726. if($cardfen+$ur['userfen']<0)
  727. {
  728. $cardfen=$ur['userfen']*-1;
  729. }
  730. }
  731. }
  732. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userfen')."=".egetmf('userfen')."+".$cardfen." where ".egetmf('userid')."='$userid'");
  733. }
  734. //转向会员组
  735. function OutTimeZGroup($userid,$zgroupid){
  736. global $empire,$dbtbpre;
  737. if($zgroupid)
  738. {
  739. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('groupid')."='".$zgroupid."',".egetmf('userdate')."=0 where ".egetmf('userid')."='$userid'");
  740. }
  741. else
  742. {
  743. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userdate')."=0 where ".egetmf('userid')."='$userid'");
  744. }
  745. }
  746. //充值有效期判断
  747. function eCardCheckUserdate($userdate,$usergroupid,$buygroupid){
  748. global $public_r;
  749. if($usergroupid==$buygroupid)
  750. {
  751. return $userdate;
  752. }
  753. //已有有效期
  754. if($userdate&&$userdate>=time())
  755. {
  756. if($public_r['mhavedatedo']==1)//覆盖
  757. {
  758. $userdate=0;
  759. }
  760. elseif($public_r['mhavedatedo']==2)//叠加
  761. {
  762. }
  763. else//不让充值
  764. {
  765. printerror('CardHaveUserdate','history.go(-1)',1);
  766. }
  767. }
  768. return $userdate;
  769. }
  770. //充值
  771. function eAddFenToUser($fen,$date,$groupid,$zgroupid,$user){
  772. global $empire,$dbtbpre,$public_r;
  773. if(!($fen||$date))
  774. {
  775. return '';
  776. }
  777. $update='';
  778. //积分
  779. if($fen)
  780. {
  781. $update.=egetmf('userfen')."=".egetmf('userfen')."+$fen";
  782. }
  783. //有效期
  784. if($date)
  785. {
  786. $user[userdate]=eCardCheckUserdate($user[userdate],$user[groupid],$groupid);//有效期验证
  787. $dh='';
  788. if($update)
  789. {
  790. $dh=',';
  791. }
  792. if($user[userdate]<time())
  793. {
  794. $userdate=time()+$date*24*3600;
  795. }
  796. else
  797. {
  798. $userdate=$user[userdate]+$date*24*3600;
  799. }
  800. $update.=$dh.egetmf('userdate')."='$userdate'";
  801. //转向会员组
  802. if($groupid)
  803. {
  804. $update.=",".egetmf('groupid')."='$groupid'";
  805. }
  806. if($zgroupid)
  807. {
  808. $update.=",".egetmf('zgroupid')."='$zgroupid'";
  809. }
  810. }
  811. $sql=$empire->query("update ".eReturnMemberTable()." set ".$update." where ".egetmf('userid')."='".$user[userid]."'");
  812. if(!$sql)
  813. {
  814. printerror('DbError',$public_r[newsurl],1);
  815. }
  816. }
  817. //检查下载数
  818. function DoCheckMDownNum($userid,$groupid,$ecms=0){
  819. global $empire,$dbtbpre,$level_r;
  820. $ur=$empire->fetch1("select userid,todaydate,todaydown from {$dbtbpre}enewsmemberpub where userid='$userid' limit 1");
  821. $thetoday=date("Y-m-d");
  822. if($ur['userid'])
  823. {
  824. if($thetoday!=$ur['todaydate'])
  825. {
  826. $query="update {$dbtbpre}enewsmemberpub set todaydate='$thetoday',todaydown=1 where userid='$userid'";
  827. }
  828. else
  829. {
  830. if($ur['todaydown']>=$level_r[$groupid]['daydown'])
  831. {
  832. if($ecms==1)
  833. {
  834. exit();
  835. }
  836. elseif($ecms==2)
  837. {
  838. return 'error';
  839. }
  840. else
  841. {
  842. printerror("CrossDaydown","history.go(-1)",1);
  843. }
  844. }
  845. $query="update {$dbtbpre}enewsmemberpub set todaydown=todaydown+1 where userid='$userid'";
  846. }
  847. }
  848. else
  849. {
  850. $query="replace into {$dbtbpre}enewsmemberpub(userid,todaydate,todaydown) values('$userid','$thetoday',1);";
  851. }
  852. return $query;
  853. }
  854. //更新激活认证码
  855. function DoUpdateMemberAuthstr($userid,$authstr){
  856. global $empire,$dbtbpre;
  857. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsmemberpub where userid='$userid' limit 1");
  858. if($num)
  859. {
  860. $sql=$empire->query("update {$dbtbpre}enewsmemberpub set authstr='$authstr' where userid='$userid'");
  861. }
  862. else
  863. {
  864. $sql=$empire->query("replace into {$dbtbpre}enewsmemberpub(userid,authstr) values('$userid','$authstr');");
  865. }
  866. return $sql;
  867. }
  868. ?>