国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
5.3KB

  1. <?php
  2. /**
  3. * 会员注册
  4. *
  5. * @version $id:reg_new.php 8:38 2010年7月9日 tianya $
  6. * @package DedeBIZ.User
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. if ($cfg_mb_allowreg == 'N') {
  13. ShowMsg('系统关闭了新会员注册', 'index.php');
  14. exit();
  15. }
  16. if (!isset($dopost)) $dopost = '';
  17. $step = empty($step) ? 1 : intval($step);
  18. if ($step == 1) {
  19. if ($cfg_ml->IsLogin()) {
  20. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  21. exit();
  22. }
  23. if ($dopost == 'regbase') {
  24. $svali = GetCkVdValue();
  25. if (strtolower($vdcode) != $svali || $svali == '') {
  26. ResetVdValue();
  27. ShowMsg('验证码不正确', '-1');
  28. exit();
  29. }
  30. $userid = $uname = trim($userid);
  31. $pid = HtmlReplace($pid, 1);
  32. //推广pid
  33. $pRow = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE userid LIKE '$pid'");
  34. $pMid = isset($pRow['mid'])? intval($pRow['mid']) : 0;
  35. $pwd = trim($userpwd);
  36. $pwdc = trim($userpwdok);
  37. $rs = CheckUserID($userid, '账号');
  38. if ($rs != 'ok') {
  39. ShowMsg($rs, '-1');
  40. exit();
  41. }
  42. if (strlen($userid) > 20 || strlen($uname) > 36) {
  43. ShowMsg('您的账号或账号过长,不允许注册', '-1');
  44. exit();
  45. }
  46. if (strlen($userid) < $cfg_mb_idmin || strlen($pwd) < $cfg_mb_pwdmin) {
  47. ShowMsg("您的账号或密码过短,不允许注册", "-1");
  48. exit();
  49. }
  50. if (preg_match("#[^0-9a-zA-Z_@!\.-]#", $userid)) {
  51. ShowMsg('账号不合法,仅限使用[0-9a-zA-Z_@!.-]', '-1');
  52. exit();
  53. }
  54. if ($pwdc != $pwd) {
  55. ShowMsg('您两次输入的密码不一致', '-1');
  56. exit();
  57. }
  58. $uname = HtmlReplace($uname, 1);
  59. $userid = HtmlReplace($userid, 1);
  60. //检测账号是否存在
  61. $row = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE userid LIKE '$userid' ");
  62. if (is_array($row)) {
  63. ShowMsg("您指定的账号{$userid}已存在,请使用别的账号", "-1");
  64. exit();
  65. }
  66. //会员的默认金币
  67. $dfscores = 0;
  68. $dfmoney = 0;
  69. $dfrank = $dsql->GetOne("SELECT `money`,scores FROM `#@__arcrank` WHERE `rank`='10' ");
  70. if (is_array($dfrank)) {
  71. $dfmoney = $dfrank['money'];
  72. $dfscores = $dfrank['scores'];
  73. }
  74. if ($pMid > 0) {
  75. $dfscores = $dfscores + $cfg_userad_adds;
  76. }
  77. $jointime = time();
  78. $logintime = time();
  79. $joinip = GetIP();
  80. $loginip = GetIP();
  81. $pp = "pwd";
  82. if (function_exists('password_hash')) {
  83. $pp = "pwd_new";
  84. $pwd = password_hash($userpwd, PASSWORD_BCRYPT);
  85. } else {
  86. $pwd = md5($userpwd);
  87. }
  88. $mtype = '个人';
  89. $space = 'person';
  90. $spaceSta = ($cfg_mb_spacesta < 0 ? $cfg_mb_spacesta : 0);
  91. $inQuery = "INSERT INTO `#@__member` (`mtype` ,`userid` ,`$pp`,`uname` ,`sex` ,`rank` ,`money` ,`email` ,`scores` ,`matt`, `spacesta` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip`, `pmid`) VALUES ('$mtype','$userid','$pwd','$uname','','10','$dfmoney','','$dfscores','0','$spaceSta','','','','$jointime','$joinip','$logintime','$loginip', '$pMid'); ";
  92. if ($dsql->ExecuteNoneQuery($inQuery)) {
  93. $mid = $dsql->GetLastID();
  94. //写入默认统计数据
  95. $membertjquery = "INSERT INTO `#@__member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`) VALUES ('$mid','0','0','0','0','0','0','0','0'); ";
  96. $dsql->ExecuteNoneQuery($membertjquery);
  97. //写入默认空间配置数据
  98. $spacequery = "INSERT INTO `#@__member_space` (`mid`,`pagesize`,`matt`,`spacename`,`spacelogo`,`spacestyle`,`sign`,`spacenews`) VALUES ('{$mid}','10','0','{$uname}的个人主页','','$space','',''); ";
  99. $dsql->ExecuteNoneQuery($spacequery);
  100. //写入其它默认数据
  101. $dsql->ExecuteNoneQuery("INSERT INTO `#@__member_flink`(mid,title,url) VALUES ('$mid','DedeBIZ','https://www.dedebiz.com');");
  102. //模拟登录
  103. $cfg_ml = new MemberLogin(7 * 3600);
  104. $rs = $cfg_ml->CheckUser($userid, $userpwd);
  105. if ($pMid > 0) {
  106. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_userad_adds} WHERE mid='$pMid'");
  107. }
  108. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  109. exit;
  110. } else {
  111. ShowMsg("注册失败,请检查资料是否有误或与管理员联系", "-1");
  112. exit();
  113. }
  114. }
  115. $pid = HtmlReplace($pid, 1);
  116. require_once(DEDEMEMBER."/templets/reg-new.htm");
  117. } else {
  118. if (!$cfg_ml->IsLogin()) {
  119. ShowMsg("您未填写基本信息,请填写基本信息", "index_do.php?fmdo=user&dopost=regnew");
  120. exit;
  121. } else {
  122. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  123. exit;
  124. }
  125. }
  126. ?>