first_login-dist.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Quick page to react to first login cases
  5. * @package chamilo.custompages
  6. */
  7. /**
  8. * Initialization
  9. */
  10. require_once('language.php');
  11. require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
  12. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  13. /**
  14. * Security checks
  15. */
  16. if (! isset($_SESSION['conditional_login']['uid']))
  17. die("Not Authorised");
  18. if (isset($_POST['password'])) {
  19. $u = api_get_user_info($_SESSION['conditional_login']['uid']);
  20. if ($_POST['password'] != $_POST['password2']) {
  21. header('Location: '. api_get_self().'?invalid=2');
  22. exit();
  23. }
  24. if (empty($_POST['password'])){ //|| !api_check_password($password)) { //Pass must be at least 5 char long with 2 digits and 3 letters
  25. header('Location: '. api_get_self().'?invalid=1');
  26. exit();
  27. }
  28. $password = $_POST['password'];
  29. $updated = UserManager::update_user(
  30. $u['user_id'],
  31. $u['firstname'],
  32. $u['lastname'],
  33. $u['username'],
  34. $password,
  35. $u['auth_source'],
  36. $u['email'],
  37. $u['status'],
  38. $u['official_code'],
  39. $u['phone'],
  40. $u['picture_uri'],
  41. $u['expiration_date'],
  42. $u['active'],
  43. $u['creator_id'],
  44. $u['hr_dept_id'],
  45. null,
  46. $u['language'],
  47. ''
  48. );
  49. if ($updated) {
  50. UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');
  51. ConditionalLogin::login();
  52. }
  53. }
  54. if ($_GET['invalid'] == 1) {
  55. $error_message = get_lang('CurrentPasswordEmptyOrIncorrect');
  56. }
  57. if ($_GET['invalid'] == 2) {
  58. $error_message = get_lang('PassTwo');
  59. }
  60. /**
  61. * HTML output
  62. */
  63. ?>
  64. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  65. <html>
  66. <head>
  67. <title>Custompage - login</title>
  68. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  69. <!--[if !IE 6]><!-->
  70. <link rel="stylesheet" type="text/css" href="/custompages/style.css" />
  71. <!--<![endif]-->
  72. <!--[if IE 6]>
  73. <link rel="stylesheet" type="text/css" href="/custompages/style-ie6.css" />
  74. <![endif]-->
  75. <script type="text/javascript" src="/main/inc/lib/javascript/jquery.min.js"></script>
  76. <script type="text/javascript">
  77. $(document).ready(function() {
  78. if (top.location != location)
  79. top.location.href = document.location.href ;
  80. // Handler pour la touche retour
  81. $('input').keyup(function(e) {
  82. if (e.keyCode == 13) {
  83. $('#changepassword-form').submit();
  84. }
  85. });
  86. });
  87. </script>
  88. </head>
  89. <body>
  90. <div id="backgroundimage">
  91. <img src="/custompages/images/page-background.png" class="backgroundimage" />
  92. </div>
  93. <div id="wrapper">
  94. <div id="header">
  95. <img src="/custompages/images/header.png" alt="Logo" />
  96. </div> <!-- #header -->
  97. <h2> <?php echo custompages_get_lang('FirstLogin');?> </h2>
  98. <div id="changepassword-form-box" class="form-box">
  99. <div class="info"> <?php echo custompages_get_lang('FirstLoginChangePassword');?> </div>
  100. <?php if (isset($error_message)) {
  101. echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>';
  102. }?>
  103. <form id="changepassword-form" class="form" method="post">
  104. <div>
  105. <label for="password">*<?php echo custompages_get_lang('Password');?></label>
  106. <input name="password" type="password" /><br />
  107. <label for="password2">*<?php echo custompages_get_lang('Password');?></label>
  108. <input name="password2" type="password" /><br />
  109. </div>
  110. </form>
  111. <div id="changepassword-form-submit" class="form-submit" onclick="document.forms['changepassword-form'].submit();">
  112. <span><?php echo custompages_get_lang('LoginEnter');?></span>
  113. </div> <!-- #form-submit -->
  114. </div> <!-- #form -->
  115. <div id="footer">
  116. <img src="/custompages/images/footer.png" />
  117. </div> <!-- #footer -->
  118. </div> <!-- #wrapper -->
  119. </body>
  120. </html>