admincp_login.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_login.php 36284 2016-12-12 00:47:50Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. if($this->core->var['inajax']) {
  12. ajaxshowheader();
  13. ajaxshowfooter();
  14. }
  15. if($this->cpaccess == -3) {
  16. html_login_header(false);
  17. } else {
  18. html_login_header();
  19. }
  20. if($this->cpaccess == -3) {
  21. echo '<p class="logintips">'.lang('admincp_login', 'login_cp_noaccess').'</p>';
  22. }elseif($this->cpaccess == -1) {
  23. $ltime = $this->sessionlife - (TIMESTAMP - $this->adminsession['dateline']);
  24. echo '<p class="logintips">'.lang('admincp_login', 'login_cplock', array('ltime' => $ltime)).'</p>';
  25. }elseif($this->cpaccess == -4) {
  26. $ltime = $this->sessionlife - (TIMESTAMP - $this->adminsession['dateline']);
  27. echo '<p class="logintips">'.lang('admincp_login', 'login_user_lock').'</p>';
  28. } else {
  29. html_login_form();
  30. }
  31. html_login_footer();
  32. function html_login_header($form = true) {
  33. $charset = CHARSET;
  34. $title = lang('admincp_login', 'login_title');
  35. $tips = lang('admincp_login', 'login_tips');
  36. echo <<<EOT
  37. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  38. <html xmlns="http://www.w3.org/1999/xhtml">
  39. <head>
  40. <meta http-equiv="Content-Type" content="text/html;charset=$charset" />
  41. <title>$title</title>
  42. <link rel="stylesheet" href="static/image/admincp/admincp.css?{$_G[style][verhash]}" type="text/css" media="all" />
  43. </head>
  44. <body>
  45. EOT;
  46. if($form) {
  47. echo <<<EOT
  48. <script language="JavaScript">
  49. if(self.parent.frames.length != 0) {
  50. self.parent.location=document.location;
  51. }
  52. </script>
  53. <table class="logintb">
  54. <tr>
  55. <td>
  56. EOT;
  57. }
  58. }
  59. function html_login_footer($halt = true) {
  60. $version = getglobal('setting/version');
  61. echo <<<EOT
  62. </td>
  63. </tr>
  64. </table>
  65. <table class="logintb">
  66. <tr>
  67. </tr>
  68. </table>
  69. </body>
  70. </html>
  71. EOT;
  72. $halt && exit();
  73. }
  74. function html_login_form() {
  75. global $_G;
  76. $isguest = !getglobal('uid');
  77. $lang = lang('admincp_login');
  78. $loginuser = $isguest ? '<input name="admin_username" tabindex="1" type="text" class="txt" autocomplete="off" />' : getglobal('member/username');
  79. $sid = getglobal('sid');
  80. $_SERVER['QUERY_STRING'] = str_replace('&amp;', '&', dhtmlspecialchars($_SERVER['QUERY_STRING']));
  81. $extra = ADMINSCRIPT.'?'.(getgpc('action') && getgpc('frames') ? 'frames=yes&' : '').$_SERVER['QUERY_STRING'];
  82. $forcesecques = '<option value="0">'.($_G['config']['admincp']['forcesecques'] || $_G['group']['forcesecques'] ? $lang['forcesecques'] : $lang['security_question_0']).'</option>';
  83. echo <<<EOT
  84. <form method="post" autocomplete="off" name="login" id="loginform" action="$extra">
  85. <input type="hidden" name="sid" value="$sid">
  86. <input type="hidden" name="frames" value="yes">
  87. <p class="logintitle">$lang[login_username]: </p>
  88. <p class="loginform">$loginuser</p>
  89. <p class="logintitle">$lang[login_password]:</p>
  90. <p class="loginform"><input name="admin_password" tabindex="1" type="password" class="txt" autocomplete="off" /></p>
  91. <p class="logintitle">$lang[security_question]:</p>
  92. <p class="loginform">
  93. <select id="questionid" name="admin_questionid" tabindex="2">
  94. $forcesecques
  95. <option value="1">$lang[security_question_1]</option>
  96. <option value="2">$lang[security_question_2]</option>
  97. <option value="3">$lang[security_question_3]</option>
  98. <option value="4">$lang[security_question_4]</option>
  99. <option value="5">$lang[security_question_5]</option>
  100. <option value="6">$lang[security_question_6]</option>
  101. <option value="7">$lang[security_question_7]</option>
  102. </select>
  103. </p>
  104. <p class="logintitle">$lang[security_answer]:</p>
  105. <p class="loginform"><input name="admin_answer" tabindex="3" type="text" class="txt" autocomplete="off" /></p>
  106. <p class="loginnofloat"><input name="submit" value="$lang[submit]" tabindex="3" type="submit" class="btn" /></p>
  107. </form>
  108. EOT;
  109. echo '<script type="text/JavaScript">document.getElementById(\'loginform\').admin_'.($isguest ? 'username' : 'password').'.focus();</script>';
  110. }
  111. ?>