Merge pull request #2131 from sjpadgett/portal-tables
[openemr.git] / interface / main / pwd_expires_alert.php
blobd31de8af7d3364f67309e670c0ccbfb8bb913f3b
1 <?php
2 /**
3 * Display a message indicating that the user's password has/will expire.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author ViCarePlus Team, Visolve <vicareplus_engg@visolve.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2010 ViCarePlus Team, Visolve <vicareplus_engg@visolve.com>
10 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
17 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
18 csrfNotVerified();
21 $pwd_expires = "";
22 $q = $_SESSION["authUserID"];
23 $result = sqlStatement("select username, pwd_expiration_date from users where id = ?", array($q));
24 if ($row = sqlFetchArray($result)) {
25 $pwd_expires = $row['pwd_expiration_date'];
26 $username = $row['username'];
29 $current_date = date("Y-m-d");
30 $grace_time = date("Y-m-d", strtotime($pwd_expires . "+" . $GLOBALS['password_grace_time'] . "days"));
31 $pwd_alert = date("Y-m-d", strtotime($pwd_expires . "-7 days"));
32 $msg_alert = "";
34 // Determine the expiration message to display
35 if (($pwd_expires == "0000-00-00") or ($pwd_expires == "")) {
36 $msg_alert = xl("Your Password Expired. Please change your password.");
37 $case="alertmsg1";
38 } else if ((strtotime($current_date) > strtotime($pwd_expires)) && ($grace_time != "") &&
39 ($pwd_expires != "") && (strtotime($current_date) < strtotime($grace_time))) {
40 //display warning if user is in grace period to change password
41 $msg_alert = xl("You are in Grace Login period. Change your password before")." ".$grace_time;
42 $case="alertmsg1";
43 } else if (strtotime($pwd_expires) == strtotime($current_date)) {
44 // Display warning if password expires on current day
45 $msg_alert = xl("Your Password Expires today. Please change your password.");
46 $case="alertmsg2";
47 } else if ((strtotime($current_date) >= strtotime($pwd_alert)) && strtotime($pwd_alert) != "") {
48 // Display a notice that password expires soon
49 $msg_alert = xl("Your Password Expires on")." ".$pwd_expires.". ".xl("Please change your password.");
50 $case="alertmsg3";
55 <html>
56 <head>
57 <meta http-equiv="Content-Language" content="en-us">
58 <?php html_header_show();?>
59 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
60 </head>
61 <body class="body_bottom">
63 <br/><br/><br/><span class="pwdalert <?php echo attr($case); ?>">
64 <table align="center" >
66 <tr valign="top">
67 <td>&nbsp;</td>
68 <td rowspan="3"><?php echo xlt("Welcome");
69 echo " ".text($username);?>,<br>
70 <br>
71 <?php echo text($msg_alert);?>
72 <br>
73 </td>
74 <td>&nbsp;</td>
75 </tr>
77 <tr>
78 <td>&nbsp;</td>
79 <td>&nbsp;</td>
80 </tr>
81 <tr>
82 <td>&nbsp;</td>
83 <td>&nbsp;</td>
84 </tr>
85 </table></span>
88 </body>
89 </html>