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

81 lines
2.9KB

  1. <?php
  2. /**
  3. * 后台登录
  4. *
  5. * @version $Id: login.php 1 8:48 2010年7月13日Z tianya $
  6. * @package DedeBIZ.Administrator
  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__).'/../system/common.inc.php');
  12. require_once(DEDEINC.'/userlogin.class.php');
  13. if (empty($dopost)) $dopost = '';
  14. if (empty($gotopage)) $gotopage = '';
  15. $gotopage = RemoveXSS($gotopage);
  16. //检测安装目录安全性
  17. if (is_dir(dirname(__FILE__).'/../install')) {
  18. if (!file_exists(dirname(__FILE__).'/../install/install_lock.txt')) {
  19. $fp = fopen(dirname(__FILE__).'/../install/install_lock.txt', 'w') or die('安装目录无写入权限,无法进行写入锁定文件,请安装完毕删除安装目录');
  20. fwrite($fp, 'ok');
  21. fclose($fp);
  22. }
  23. $fileindex = "../install/index.html";
  24. if (!file_exists($fileindex)) {
  25. $fp = @fopen($fileindex, 'w');
  26. fwrite($fp, 'dir');
  27. fclose($fp);
  28. }
  29. }
  30. //检测后台目录是否更名
  31. $cururl = GetCurUrl();
  32. if (preg_match('/admin\/login/i', $cururl)) {
  33. $redmsg = '<div class="alert alert-warning"><div class=\"safe-tips\">您的管理目录的名称中包含默认名称admin,建议在FTP里把它修改为其它名称,那样会更安全</div></div>';
  34. } else {
  35. $redmsg = '';
  36. }
  37. //登录检测
  38. $admindirs = explode('/', str_replace("\\", '/', dirname(__FILE__)));
  39. $admindir = $admindirs[count($admindirs) - 1];
  40. if ($dopost == 'login') {
  41. $validate = empty($validate) ? '' : strtolower(trim($validate));
  42. $svali = strtolower(GetCkVdValue());
  43. if (($validate == '' || $validate != $svali) && preg_match("/6/", $safe_gdopen)) {
  44. ResetVdValue();
  45. ShowMsg('验证码不正确', 'login.php', 0, 1000);
  46. exit;
  47. } else {
  48. $cuserLogin = new userLogin($admindir);
  49. if (!empty($userid) && !empty($pwd)) {
  50. $res = $cuserLogin->checkUser($userid, $pwd);
  51. //success
  52. if ($res == 1) {
  53. $cuserLogin->keepUser();
  54. if (!empty($gotopage)) {
  55. ShowMsg('成功登录,正在转向管理管理主页', $gotopage);
  56. exit();
  57. } else {
  58. ShowMsg('成功登录,正在转向管理管理主页', "index.php");
  59. exit();
  60. }
  61. }
  62. //error
  63. else if ($res == -1) {
  64. ResetVdValue();
  65. ShowMsg('您的用户名不存在', 'login.php', 0, 1000);
  66. exit;
  67. } else {
  68. ResetVdValue();
  69. ShowMsg('您的密码错误', 'login.php', 0, 1000);
  70. exit;
  71. }
  72. }
  73. //password empty
  74. else {
  75. ResetVdValue();
  76. ShowMsg('用户和密码没填写完整', 'login.php', 0, 1000);
  77. exit;
  78. }
  79. }
  80. }
  81. include('templets/login.htm');