first_login.php 3.6 KB

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