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

259 lines
11KB

  1. <?php
  2. /**
  3. * 会员登录
  4. *
  5. * @version $id:login.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 (empty($dopost)) $dopost = '';
  13. if (empty($fmdo)) $fmdo = '';
  14. if ($fmdo == 'sendMail') {
  15. if (!CheckEmail($cfg_ml->fields['email'])) {
  16. ShowMsg('邮箱格式有错误', 'index.php');
  17. exit();
  18. }
  19. if ($cfg_ml->fields['spacesta'] != -10) {
  20. ShowMsg('帐号不在邮件验证状态,本操作无效', 'index.php');
  21. exit();
  22. }
  23. $userhash = md5($cfg_cookie_encode.'--'.$cfg_ml->fields['mid'].'--'.$cfg_ml->fields['email']);
  24. $url = $cfg_basehost.(empty($cfg_cmspath) ? '/' : $cfg_cmspath)."/user/index_do.php?fmdo=checkMail&mid={$cfg_ml->fields['mid']}&userhash={$userhash}&do=1";
  25. $mailtitle = "来自{$cfg_webname}:邮件验证通知";
  26. $mailbody = '';
  27. $mailbody .= "尊敬的{$cfg_ml->fields['uname']}会员,欢迎成为{$cfg_webname}会员!\r\n通过注册还须进行最后一步操作,请点击链接或复制链接到地址栏访问:{$url}";
  28. $headers = "From: ".$cfg_adminemail."\r\nReply-To: ".$cfg_adminemail;
  29. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  30. $client = new DedeBizClient();
  31. $client->MailSend($cfg_ml->fields['email'],$mailtitle,$mailtitle,$mailbody);
  32. $client->Close();
  33. } else {
  34. if ($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_server)) {
  35. $mailtype = 'HTML';
  36. require_once(DEDEINC.'/libraries/mail.class.php');
  37. $smtp = new smtp($cfg_smtp_server, $cfg_smtp_port, true, $cfg_smtp_usermail, $cfg_smtp_password);
  38. $smtp->debug = false;
  39. $smtp->sendmail($cfg_ml->fields['email'], $cfg_webname, $cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);
  40. } else {
  41. @mail($cfg_ml->fields['email'], $mailtitle, $mailbody, $headers);
  42. }
  43. }
  44. ShowMsg('成功发送邮件,请稍后登录邮箱进行接收', 'index.php');
  45. exit();
  46. } else if ($fmdo == 'checkMail') {
  47. $mid = intval($mid);
  48. if (empty($mid)) {
  49. ShowMsg('效验串不合法', 'index.php');
  50. exit();
  51. }
  52. $row = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='{$mid}' ");
  53. $needUserhash = md5($cfg_cookie_encode.'--'.$mid.'--'.$row['email']);
  54. if ($needUserhash != $userhash) {
  55. ShowMsg('效验串不合法', 'index.php');
  56. exit();
  57. }
  58. if ($row['spacesta'] != -10) {
  59. ShowMsg('操作无效,帐号不在邮件验证状态', 'index.php');
  60. exit();
  61. }
  62. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET spacesta=0 WHERE mid='{$mid}' ");
  63. //清除会员缓存
  64. $cfg_ml->DelCache($mid);
  65. ShowMsg('正在验证中', 'login.php');
  66. exit();
  67. } else if ($fmdo == 'user') {
  68. //检查账号是否存在
  69. if ($dopost == "checkuser") {
  70. AjaxHead();
  71. $msg = '';
  72. $uid = trim($uid);
  73. if ($cktype == 0) {
  74. $msgtitle = '账号';
  75. } else {
  76. $msgtitle = '账号';
  77. }
  78. if ($cktype != 0 || $cfg_mb_wnameone == 'N') {
  79. $msg = CheckUserID($uid, $msgtitle);
  80. } else {
  81. $msg = CheckUserID($uid, $msgtitle, false);
  82. }
  83. if ($msg == 'ok') {
  84. $msg = "{$msgtitle}可以使用";
  85. } else {
  86. $msg = "{$msg}";
  87. }
  88. echo $msg;
  89. exit();
  90. }
  91. //检查邮箱是否存在
  92. else if ($dopost == "checkmail") {
  93. AjaxHead();
  94. if ($cfg_md_mailtest == 'N') {
  95. $msg = "可以使用";
  96. } else {
  97. if (!CheckEmail($email)) {
  98. $msg = "邮箱格式有误";
  99. } else {
  100. $row = $dsql->GetOne("SELECT mid FROM `#@__member` WHERE email LIKE '$email' LIMIT 1");
  101. if (!is_array($row)) {
  102. $msg = "可以使用";
  103. } else {
  104. $msg = "邮箱已经被另一个账号占用";
  105. }
  106. }
  107. }
  108. echo $msg;
  109. exit();
  110. }
  111. //引入注册页面
  112. else if ($dopost == "regnew") {
  113. $step = empty($step) ? 1 : intval(preg_replace("/[^\d]/", '', $step));
  114. require_once(dirname(__FILE__)."/reg_new.php");
  115. exit();
  116. }
  117. //积分换金币
  118. else if ($dopost == "money2s") {
  119. CheckRank(0, 0);//禁止游客操作
  120. if ($cfg_money_scores == 0) {
  121. ShowMsg('系统禁用了积分与金币兑换功能', 'index.php');
  122. exit();
  123. }
  124. $money = empty($money) ? "" : abs(intval($money));
  125. if (empty($money)) {
  126. ShowMsg('您没指定要兑换多少金币', 'index.php');
  127. exit();
  128. }
  129. $needscores = $money * $cfg_money_scores;
  130. if ($cfg_ml->fields['scores'] < $needscores) {
  131. ShowMsg('您积分不足,不能换取这么多的金币', 'index.php');
  132. exit();
  133. }
  134. $litmitscores = $cfg_ml->fields['scores'] - $needscores;
  135. //保存记录
  136. $mtime = time();
  137. $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}个'); ";
  138. $dsql->ExecuteNoneQuery($inquery);
  139. //修改积分与金币值
  140. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET `scores`=$litmitscores, money= money + $money WHERE mid='".$cfg_ml->M_ID."' ");
  141. //清除会员缓存
  142. $cfg_ml->DelCache($cfg_ml->M_ID);
  143. ShowMsg('成功兑换指定量的金币', 'operation.php');
  144. exit();
  145. }
  146. } else if ($fmdo == 'login') {
  147. //会员登录
  148. if ($dopost == "login") {
  149. if (!isset($vdcode)) {
  150. $vdcode = '';
  151. }
  152. if (CheckUserID($userid, '', false) != 'ok') {
  153. ResetVdValue();
  154. ShowMsg("您输入的账号{$userid}已禁止", "index.php");
  155. exit();
  156. }
  157. if ($pwd == '') {
  158. ResetVdValue();
  159. ShowMsg('密码不能为空', 'index.php');
  160. exit();
  161. }
  162. $isNeed = $cfg_ml->isNeedCheckCode($userid);
  163. if ($isNeed) {
  164. $svali = GetCkVdValue();
  165. if (strtolower($vdcode) != $svali || $svali == '') {
  166. ResetVdValue();
  167. ShowMsg('验证码不正确', 'index.php');
  168. exit();
  169. }
  170. }
  171. //检查帐号
  172. $rs = $cfg_ml->CheckUser($userid, $pwd);
  173. if ($rs == 0) {
  174. ResetVdValue();
  175. ShowMsg('账号输入错误', 'index.php');
  176. exit();
  177. } else if ($rs == -1) {
  178. ResetVdValue();
  179. ShowMsg('密码输入错误', 'index.php');
  180. exit();
  181. } else if ($rs == -2) {
  182. ResetVdValue();
  183. ShowMsg('管理员帐号不允许从前台登录', 'index.php');
  184. exit();
  185. } else {
  186. //清除会员缓存
  187. $cfg_ml->DelCache($cfg_ml->M_ID);
  188. if (empty($gourl) || preg_match("#action|_do#i", $gourl)) {
  189. ShowMsg('正在登录会员中心,请稍等', 'index.php');
  190. } else {
  191. $gourl = str_replace('^', '&', $gourl);
  192. ShowMsg('正在前往指定页面,请稍等', $gourl);
  193. }
  194. exit();
  195. }
  196. }
  197. //退出登录
  198. else if ($dopost == "exit") {
  199. $cfg_ml->ExitCookie();
  200. ShowMsg('已退出会员中心', 'index.php');
  201. exit();
  202. }
  203. } else if ($fmdo == 'purl'){
  204. require_once(DEDEINC.'/libraries/webwindow.class.php');
  205. CheckRank(0, 0);//禁止游客操作
  206. $row = $dsql->GetOne("SELECT count(*) as dd FROM `#@__member` WHERE `pmid`='{$cfg_ml->M_ID}' ");
  207. $msg = "<p>您已经邀请了{$row['dd']}人:</p>
  208. <div class='media mb-3'>
  209. <span class='btn btn-primary btn-sm mr-3'>链</span>
  210. <div class='media-body pb-3 border-bottom border-gray'>
  211. <div class='d-flex justify-content-between align-items-center'>
  212. <h4>链接邀请</h4>
  213. <a href='javascript:Copylink()' class='btn btn-outline-primary btn-sm'>复制链接</a>
  214. </div>
  215. <span class='d-block'>复制链接分享给其他人,对方通过链接注册后双方均可获得{$cfg_userad_adds}积分<span id='text' style='font-size:0'>{$cfg_basehost}{$cfg_memberurl}/index_do.php?fmdo=user&dopost=regnew&pid={$cfg_ml->M_LoginID}</span>
  216. </div>
  217. </div>
  218. <div class='media mb-3'>
  219. <span class='btn btn-success btn-sm mr-3'>码</span>
  220. <div class='media-body pb-3 border-bottom border-gray'>
  221. <div class='d-flex justify-content-between align-items-center'>
  222. <h4>二维码邀请</h4>
  223. <a href='javascript:ShowQrcode()' class='btn btn-outline-success btn-sm'>查看二维码</a>
  224. </div>
  225. <span class='d-block'>分享二维码到移动设备,通过二维码扫码注册,双方均可获得{$cfg_userad_adds}积分</span>
  226. </div>
  227. </div>
  228. <div id='qrcode'></div>
  229. <div class='text-center'><a href='index.php' class='btn btn-success btn-sm'>返回</a></div>
  230. <style>.modal-body img{margin:0 auto}#qrcode{display:none;margin:15px auto;width:200px;height:200px}</style>
  231. <script>
  232. var qrcode = new QRCode(document.getElementById(\"qrcode\"), {
  233. width : 200,
  234. height : 200,
  235. correctLevel : 3
  236. });
  237. qrcode.makeCode('{$cfg_basehost}{$cfg_memberurl}/index_do.php?fmdo=user&dopost=regnew&pid={$cfg_ml->M_LoginID}');
  238. </script>
  239. <script>
  240. function Copylink() {
  241. var val = document.getElementById('text');
  242. window.getSelection().selectAllChildren(val);
  243. document.execCommand(\"Copy\");
  244. ShowMsg(\"复制推广链接成功\");
  245. }
  246. function ShowQrcode(){
  247. ShowMsg(document.getElementById('qrcode').innerHTML);
  248. }
  249. </script>";
  250. $wintitle = "邀请好友赚积分";
  251. $win = new WebWindow();
  252. $win->AddMsgItem($msg);
  253. $winform = $win->GetWindow("hand", false);
  254. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  255. exit;
  256. } else {
  257. ShowMsg('操作失败', 'index.php');
  258. }
  259. ?>