first_login-dist.php 3.7 KB

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