国内流行的内容管理系统(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.

130 lines
5.6KB

  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-9小写a-z大写A-Z符号_@!.-', '-1');
  52. exit();
  53. }
  54. if ($userpwd != '' && preg_match("#[^0-9a-zA-Z_@!\.-]#", $userpwd)) {
  55. ShowMsg('密码不合法,请使用数字0-9小写a-z大写A-Z符号_@!.-', '-1');
  56. exit();
  57. }
  58. if ($pwdc != $pwd) {
  59. ShowMsg('您两次输入的密码不一致,请重新输入', '-1');
  60. exit();
  61. }
  62. $uname = HtmlReplace($uname, 1);
  63. $userid = HtmlReplace($userid, 1);
  64. //检测账号是否存在
  65. $row = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE userid LIKE '$userid' ");
  66. if (is_array($row)) {
  67. ShowMsg("您指定的账号{$userid}已存在,请使用别的账号", "-1");
  68. exit();
  69. }
  70. //会员默认金币
  71. $dfscores = 0;
  72. $dfmoney = 0;
  73. $dfrank = $dsql->GetOne("SELECT `money`,scores FROM `#@__arcrank` WHERE `rank`='10' ");
  74. if (is_array($dfrank)) {
  75. $dfmoney = $dfrank['money'];
  76. $dfscores = $dfrank['scores'];
  77. }
  78. if ($pMid > 0) {
  79. $dfscores = $dfscores + $cfg_userad_adds;
  80. }
  81. $jointime = time();
  82. $logintime = time();
  83. $joinip = GetIP();
  84. $loginip = GetIP();
  85. $pp = "pwd";
  86. if (function_exists('password_hash')) {
  87. $pp = "pwd_new";
  88. $pwd = password_hash($userpwd, PASSWORD_BCRYPT);
  89. } else {
  90. $pwd = md5($userpwd);
  91. }
  92. $mtype = '个人';
  93. $space = 'person';
  94. $spaceSta = ($cfg_mb_spacesta < 0 ? $cfg_mb_spacesta : 0);
  95. $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'); ";
  96. if ($dsql->ExecuteNoneQuery($inQuery)) {
  97. $mid = $dsql->GetLastID();
  98. //写入默认统计数据
  99. $membertjquery = "INSERT INTO `#@__member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`) VALUES ('$mid','0','0','0','0','0','0','0','0'); ";
  100. $dsql->ExecuteNoneQuery($membertjquery);
  101. //写入默认空间配置数据
  102. $spacequery = "INSERT INTO `#@__member_space` (`mid`,`pagesize`,`matt`,`spacename`,`spacelogo`,`spacestyle`,`sign`,`spacenews`) VALUES ('{$mid}','10','0','{$uname}的个人主页','','$space','',''); ";
  103. $dsql->ExecuteNoneQuery($spacequery);
  104. //写入其它默认数据
  105. $dsql->ExecuteNoneQuery("INSERT INTO `#@__member_flink`(mid,title,url) VALUES ('$mid','DedeBIZ','https://www.dedebiz.com');");
  106. //模拟登录
  107. $cfg_ml = new MemberLogin(7 * 3600);
  108. $rs = $cfg_ml->CheckUser($userid, $userpwd);
  109. if ($pMid > 0) {
  110. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_userad_adds} WHERE mid='$pMid'");
  111. }
  112. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  113. exit;
  114. } else {
  115. ShowMsg("注册失败,请检查资料是否有误或与管理员联系", "-1");
  116. exit();
  117. }
  118. }
  119. $pid = HtmlReplace($pid, 1);
  120. require_once(DEDEMEMBER."/templets/reg-new.htm");
  121. } else {
  122. if (!$cfg_ml->IsLogin()) {
  123. ShowMsg("您未填写基本信息,请填写基本信息", "index_do.php?fmdo=user&dopost=regnew");
  124. exit;
  125. } else {
  126. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  127. exit;
  128. }
  129. }
  130. ?>