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

227 lines
8.9KB

  1. <?php
  2. /**
  3. * @version $id:index_do.php 8:24 2010年7月9日 tianya $
  4. * @package DedeBIZ.User
  5. * @copyright Copyright (c) 2022 DedeBIZ.COM
  6. * @license https://www.dedebiz.com/license
  7. * @link https://www.dedebiz.com
  8. */
  9. require_once(dirname(__FILE__)."/config.php");
  10. if (empty($dopost)) $dopost = '';
  11. if (empty($fmdo)) $fmdo = '';
  12. /*********************
  13. function check_email()
  14. *******************/
  15. if ($fmdo == 'sendMail') {
  16. if (!CheckEmail($cfg_ml->fields['email'])) {
  17. ShowMsg('您的邮箱格式有错误', '-1');
  18. exit();
  19. }
  20. if ($cfg_ml->fields['spacesta'] != -10) {
  21. ShowMsg('您的帐号不在邮件验证状态,本操作无效', '-1');
  22. exit();
  23. }
  24. $userhash = md5($cfg_cookie_encode.'--'.$cfg_ml->fields['mid'].'--'.$cfg_ml->fields['email']);
  25. $url = $cfg_basehost.(empty($cfg_cmspath) ? '/' : $cfg_cmspath)."/user/index_do.php?fmdo=checkMail&mid={$cfg_ml->fields['mid']}&userhash={$userhash}&do=1";
  26. $url = preg_replace("#http:\/\/#i", '', $url);
  27. $proto = IsSSL()? "https://" : "http://";
  28. $url = $proto.preg_replace("#\/\/#i", '/', $url);
  29. $mailtitle = "{$cfg_webname},会员邮件验证通知";
  30. $mailbody = '';
  31. $mailbody .= "尊敬的用户<span class='text-primary'>{$cfg_ml->fields['uname']}</span>,您好:\r\n";
  32. $mailbody .= "欢迎注册成为<span class='text-primary'>{$cfg_webname}</span>会员\r\n";
  33. $mailbody .= "要通过注册,还必须进行最后一步操作,请点击或复制下面链接到地址栏浏览这地址:\r\n";
  34. $mailbody .= "{$url}\r\n";
  35. $mailbody .= "Powered by DedeBIZ开发团队\r\n";
  36. $headers = "From: ".$cfg_adminemail."\r\nReply-To: ".$cfg_adminemail;
  37. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  38. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  39. $client->appid = $cfg_bizcore_appid;
  40. $client->key = $cfg_bizcore_key;
  41. $client->MailSend($cfg_ml->fields['email'],$mailtitle,$mailtitle,$mailbody);
  42. $client->Close();
  43. } else {
  44. if ($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_server)) {
  45. $mailtype = 'TXT';
  46. require_once(DEDEINC.'/libraries/mail.class.php');
  47. $smtp = new smtp($cfg_smtp_server, $cfg_smtp_port, true, $cfg_smtp_usermail, $cfg_smtp_password);
  48. $smtp->debug = false;
  49. $smtp->sendmail($cfg_ml->fields['email'], $cfg_webname, $cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);
  50. } else {
  51. @mail($cfg_ml->fields['email'], $mailtitle, $mailbody, $headers);
  52. }
  53. }
  54. ShowMsg('成功发送邮件,请稍后登录您的邮箱进行接收', '/user');
  55. exit();
  56. } else if ($fmdo == 'checkMail') {
  57. $mid = intval($mid);
  58. if (empty($mid)) {
  59. ShowMsg('您的效验串不合法', '-1');
  60. exit();
  61. }
  62. $row = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='{$mid}' ");
  63. $needUserhash = md5($cfg_cookie_encode.'--'.$mid.'--'.$row['email']);
  64. if ($needUserhash != $userhash) {
  65. ShowMsg('您的效验串不合法', '-1');
  66. exit();
  67. }
  68. if ($row['spacesta'] != -10) {
  69. ShowMsg('您的帐号不在邮件验证状态,本操作无效', '-1');
  70. exit();
  71. }
  72. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET spacesta=0 WHERE mid='{$mid}' ");
  73. //清除会员缓存
  74. $cfg_ml->DelCache($mid);
  75. ShowMsg('操作成功,请重新登录系统', 'login.php');
  76. exit();
  77. }
  78. /*********************
  79. function Case_user()
  80. *******************/
  81. else if ($fmdo == 'user') {
  82. //检查用户名是否存在
  83. if ($dopost == "checkuser") {
  84. AjaxHead();
  85. $msg = '';
  86. $uid = trim($uid);
  87. if ($cktype == 0) {
  88. $msgtitle = '用户名称';
  89. } else {
  90. $msgtitle = '用户名';
  91. }
  92. if ($cktype != 0 || $cfg_mb_wnameone == 'N') {
  93. $msg = CheckUserID($uid, $msgtitle);
  94. } else {
  95. $msg = CheckUserID($uid, $msgtitle, false);
  96. }
  97. if ($msg == 'ok') {
  98. $msg = "<span class='text-dark'>√{$msgtitle}可以使用</span>";
  99. } else {
  100. $msg = "<span class='text-danger'>×{$msg}</span>";
  101. }
  102. echo $msg;
  103. exit();
  104. }
  105. //检查邮箱是否存在
  106. else if ($dopost == "checkmail") {
  107. AjaxHead();
  108. if ($cfg_md_mailtest == 'N') {
  109. $msg = "<span class='text-dark'>√可以使用</span>";
  110. } else {
  111. if (!CheckEmail($email)) {
  112. $msg = "<span class='text-dark'>×邮箱格式有误</span>";
  113. } else {
  114. $row = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE email LIKE '$email' LIMIT 1");
  115. if (!is_array($row)) {
  116. $msg = "<span class='text-dark'>√可以使用</span>";
  117. } else {
  118. $msg = "<span class='text-primary'>×邮箱已经被另一个帐号占用</span>";
  119. }
  120. }
  121. }
  122. echo $msg;
  123. exit();
  124. }
  125. //引入注册页面
  126. else if ($dopost == "regnew") {
  127. $step = empty($step) ? 1 : intval(preg_replace("/[^\d]/", '', $step));
  128. require_once(dirname(__FILE__)."/reg_new.php");
  129. exit();
  130. }
  131. /***************************
  132. //积分换金币
  133. function money2s() { }
  134. ***************************/
  135. else if ($dopost == "money2s") {
  136. CheckRank(0, 0);
  137. if ($cfg_money_scores == 0) {
  138. ShowMsg('系统禁用了积分与金币兑换功能', '-1');
  139. exit();
  140. }
  141. $money = empty($money) ? "" : abs(intval($money));
  142. if (empty($money)) {
  143. ShowMsg('您没指定要兑换多少金币', '-1');
  144. exit();
  145. }
  146. $needscores = $money * $cfg_money_scores;
  147. if ($cfg_ml->fields['scores'] < $needscores) {
  148. ShowMsg('您积分不足,不能换取这么多的金币', '-1');
  149. exit();
  150. }
  151. $litmitscores = $cfg_ml->fields['scores'] - $needscores;
  152. //保存记录
  153. $mtime = time();
  154. $inquery = "INSERT INTO `#@__member_operation` (`buyid`,`pname`,`product`,`money`,`mtime`,`pid`,`mid`,`sta` ,`oldinfo`) VALUES ('ScoresToMoney','积分换金币操作','stc' ,'0' ,'$mtime' ,'0' ,'{$cfg_ml->M_ID}','0' ,'用{$needscores}积分兑了换金币{$money}个'); ";
  155. $dsql->ExecuteNoneQuery($inquery);
  156. //修改积分与金币值
  157. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET `scores`=$litmitscores, money= money + $money WHERE mid='".$cfg_ml->M_ID."' ");
  158. //清除会员缓存
  159. $cfg_ml->DelCache($cfg_ml->M_ID);
  160. ShowMsg('成功兑换指定量的金币', 'operation.php');
  161. exit();
  162. }
  163. }
  164. /*********************
  165. function login()
  166. *******************/
  167. else if ($fmdo == 'login') {
  168. //用户登录
  169. if ($dopost == "login") {
  170. if (!isset($vdcode)) {
  171. $vdcode = '';
  172. }
  173. if (CheckUserID($userid, '', false) != 'ok') {
  174. ResetVdValue();
  175. ShowMsg("您输入的用户名<span class='text-primary'>{$userid}</span>不合法", "index.php");
  176. exit();
  177. }
  178. if ($pwd == '') {
  179. ResetVdValue();
  180. ShowMsg("密码不能为空", "-1", 0, 2000);
  181. exit();
  182. }
  183. $isNeed = $cfg_ml->isNeedCheckCode($userid);
  184. if ($isNeed) {
  185. $svali = GetCkVdValue();
  186. if (strtolower($vdcode) != $svali || $svali == '') {
  187. ResetVdValue();
  188. ShowMsg('验证码不正确', 'index.php');
  189. exit();
  190. }
  191. }
  192. //检查帐号
  193. $rs = $cfg_ml->CheckUser($userid, $pwd);
  194. if ($rs == 0) {
  195. ResetVdValue();
  196. ShowMsg("您的账号不存在", "index.php", 0, 2000);
  197. exit();
  198. } else if ($rs == -1) {
  199. ResetVdValue();
  200. ShowMsg("您的密码错误", "index.php", 0, 2000);
  201. exit();
  202. } else if ($rs == -2) {
  203. ResetVdValue();
  204. ShowMsg("管理员帐号不允许从前台登录", "index.php", 0, 2000);
  205. exit();
  206. } else {
  207. //清除会员缓存
  208. $cfg_ml->DelCache($cfg_ml->M_ID);
  209. if (empty($gourl) || preg_match("#action|_do#i", $gourl)) {
  210. ShowMsg("成功登录,正在跳转用户主页", "index.php", 0, 2000);
  211. } else {
  212. $gourl = str_replace('^', '&', $gourl);
  213. ShowMsg("成功登录,正在跳转指定页面", $gourl, 0, 2000);
  214. }
  215. exit();
  216. }
  217. }
  218. //退出登录
  219. else if ($dopost == "exit") {
  220. $cfg_ml->ExitCookie();
  221. ShowMsg("成功退出登录", "index.php", 0, 2000);
  222. exit();
  223. }
  224. } else {
  225. ShowMsg("本页面禁止返回", "index.php");
  226. }
  227. ?>