auth.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. $do_auth = true;
  23. require dirname(__FILE__).'/inc/prepend.php';
  24. if(!empty($_POST['user_id']) && !empty($_POST['user_pwd']))
  25. {
  26. $user_id = $_POST['user_id'];
  27. $user_remember = !empty($_POST['user_remember']) ? true : false;
  28. if($auth->perform($user_id,$_POST['user_pwd'],1,true,$user_remember))
  29. {
  30. $_SESSION['sess_user_id'] = $user_id;
  31. $redir = 'index.php';
  32. if (!empty($_SESSION['sess_auth_from']))
  33. {
  34. if ($_SESSION['sess_auth_from'] != $_SERVER['REQUEST_URI']) {
  35. $redir = $_SESSION['sess_auth_from'];
  36. }
  37. unset($_SESSION['sess_auth_from']);
  38. }
  39. header('Location: '.$redir);
  40. exit;
  41. }
  42. else
  43. {
  44. $err = __('Login failed. Please try again.');
  45. }
  46. }
  47. else
  48. {
  49. $user_id = '';
  50. }
  51. header('Content-Type: text/html; charset='.dc_encoding);
  52. ?>
  53. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  54. <html xmlns="http://www.w3.org/1999/xhtml"
  55. xml:lang="<?php echo DC_LANG; ?>" lang="<?php echo DC_LANG; ?>">
  56. <head>
  57. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo dc_encoding; ?>" />
  58. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  59. <meta http-equiv="Content-Style-Type" content="text/css" />
  60. <meta http-equiv="Content-Language" content="<?php echo DC_LANG; ?>" />
  61. <title><?php echo dc_blog_name; ?> - DotClear</title>
  62. <style type="text/css">
  63. @import url(style/default.css);
  64. </style>
  65. </head>
  66. <body>
  67. <div style="text-align:center;">
  68. <h1><img src="images/logo.png" alt="dotclear" /></h1>
  69. <form action="auth.php" method="post">
  70. <div class="login">
  71. <?php
  72. if(!empty($err))
  73. {
  74. echo '<p><strong>'.$err.'</strong></p>';
  75. }
  76. ?>
  77. <p><label for="user_id"><strong><?php echo __('Login'); ?> :</strong></label>
  78. <input name="user_id" id="user_id" type="text" maxlength="32"
  79. value="<?php echo $user_id; ?>" tabindex="1"/></p>
  80. <p><label for="user_pwd"><strong><?php echo __('Password'); ?> :</strong></label>
  81. <input name="user_pwd" id="user_pwd" type="password" tabindex="2" /></p>
  82. <p><input type="checkbox" id="user_remember" name="user_remember" value="1" />
  83. <label class="inline" for="user_remember"><?php echo __('Remember me'); ?></label></p>
  84. <p><input class="submit" type="submit" value="<?php echo __('ok'); ?>" /></p>
  85. <p><?php echo __('You must accept cookies in order to use the private area.'); ?></p>
  86. </div>
  87. </form>
  88. </div>
  89. <script type="text/javascript">
  90. document.forms[0]['user_id'].focus();
  91. </script>
  92. </body>
  93. </html>