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

118 lines
4.9KB

  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 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. $pwd = trim($userpwd);
  32. $pwdc = trim($userpwdok);
  33. $rs = CheckUserID($userid, '用户名');
  34. if ($rs != 'ok') {
  35. ShowMsg($rs, '-1');
  36. exit();
  37. }
  38. if (strlen($userid) > 20 || strlen($uname) > 36) {
  39. ShowMsg('您的用户名或用户名称过长,不允许注册', '-1');
  40. exit();
  41. }
  42. if (strlen($userid) < $cfg_mb_idmin || strlen($pwd) < $cfg_mb_pwdmin) {
  43. ShowMsg("您的用户名或密码过短,不允许注册", "-1");
  44. exit();
  45. }
  46. if ($pwdc != $pwd) {
  47. ShowMsg('您两次输入的密码不一致', '-1');
  48. exit();
  49. }
  50. $uname = HtmlReplace($uname, 1);
  51. $userid = HtmlReplace($userid, 1);
  52. //检测用户名是否存在
  53. $row = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE userid LIKE '$userid' ");
  54. if (is_array($row)) {
  55. ShowMsg("您指定的用户名<span class='text-primary'>{$userid}</span>已存在,请使用别的用户名", "-1");
  56. exit();
  57. }
  58. //会员的默认金币
  59. $dfscores = 0;
  60. $dfmoney = 0;
  61. $dfrank = $dsql->GetOne("SELECT `money`,scores FROM `#@__arcrank` WHERE `rank`='10' ");
  62. if (is_array($dfrank)) {
  63. $dfmoney = $dfrank['money'];
  64. $dfscores = $dfrank['scores'];
  65. }
  66. $jointime = time();
  67. $logintime = time();
  68. $joinip = GetIP();
  69. $loginip = GetIP();
  70. $pp = "pwd";
  71. if (function_exists('password_hash')) {
  72. $pp = "pwd_new";
  73. $pwd = password_hash($userpwd, PASSWORD_BCRYPT);
  74. } else {
  75. $pwd = md5($userpwd);
  76. }
  77. $mtype = '个人';
  78. $spaceSta = ($cfg_mb_spacesta < 0 ? $cfg_mb_spacesta : 0);
  79. $inQuery = "INSERT INTO `#@__member` (`mtype` ,`userid` ,`$pp`,`uname` ,`sex` ,`rank` ,`money` ,`email` ,`scores` ,`matt`, `spacesta` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip`) VALUES ('$mtype','$userid','$pwd','$uname','','10','$dfmoney','','$dfscores','0','$spaceSta','','','','$jointime','$joinip','$logintime','$loginip'); ";
  80. if ($dsql->ExecuteNoneQuery($inQuery)) {
  81. $mid = $dsql->GetLastID();
  82. //写入默认会员详细资料
  83. if ($mtype == '个人') {
  84. $space = 'person';
  85. } else if ($mtype == '企业') {
  86. $space = 'company';
  87. } else {
  88. $space = 'person';
  89. }
  90. //写入默认统计数据
  91. $membertjquery = "INSERT INTO `#@__member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`) VALUES ('$mid','0','0','0','0','0','0','0','0'); ";
  92. $dsql->ExecuteNoneQuery($membertjquery);
  93. //写入默认空间配置数据
  94. $spacequery = "INSERT INTO `#@__member_space` (`mid`,`pagesize`,`matt`,`spacename`,`spacelogo`,`spacestyle`,`sign`,`spacenews`) VALUES ('{$mid}','10','0','{$uname}的空间','','$space','',''); ";
  95. $dsql->ExecuteNoneQuery($spacequery);
  96. //写入其它默认数据
  97. $dsql->ExecuteNoneQuery("INSERT INTO `#@__member_flink`(mid,title,url) VALUES ('$mid','DedeBIZ','https://www.dedebiz.com'); ");
  98. //模拟登录
  99. $cfg_ml = new MemberLogin(7 * 3600);
  100. $rs = $cfg_ml->CheckUser($userid, $userpwd);
  101. ShowMsg('操作成功,请重新登录系统', 'index.php');
  102. exit;
  103. } else {
  104. ShowMsg("注册失败,请检查资料是否有误或与管理员联系", "-1");
  105. exit();
  106. }
  107. }
  108. require_once(DEDEMEMBER."/templets/reg-new.htm");
  109. } else {
  110. if (!$cfg_ml->IsLogin()) {
  111. ShowMsg("您未填写基本信息,请填写基本信息", "index_do.php?fmdo=user&dopost=regnew");
  112. exit;
  113. } else {
  114. ShowMsg('操作成功,请重新登录系统', 'index.php');
  115. exit;
  116. }
  117. }
  118. ?>