2bedd4398919d1f07683b9cdc60086be2dedb74c
[cacert-devel.git] / pages / account / 13.php
1 <?php /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ ?>
18 <?php $query = "select * from `users` where `id`='".intval($_SESSION['profile']['id'])."' and `users`.`deleted`=0";
19 $res = mysql_query($query);
20 $user = mysql_fetch_assoc($res);
21
22 $year = intval(substr($user['dob'], 0, 4));
23 $month = intval(substr($user['dob'], 5, 2));
24 $day = intval(substr($user['dob'], 8, 2));
25 $showdetails = array_key_exists("showdetails",$_REQUEST) ? intval($_REQUEST['showdetails']) : 0;
26
27 if($showdetails){
28 $body = sprintf(_("Hi %s,"),$user['fname'])."\n\n";
29 $body .= _("You receive this automatic mail since you yourself or someone ".
30 "else looked up your secret questions and answers for a forgotten ".
31 "password.\n\n".
32 "If it was you who looked up or changed that data, or clicked ".
33 "through the menu in your account, everything is in best order ".
34 "and you can ignore this mail.\n\n".
35 "But if you received this mail without a recognisable reason, ".
36 "there is a danger that an unauthorised person accessed your ".
37 "account, and you should promptly change your password and your ".
38 "secret questions and answers.")."\n\n";
39
40 $body .= _("Best regards")."\n"._("CAcert Support");
41
42 sendmail($user['email'], "[CAcert.org] "._("Email Notification"), $body, "support@cacert.org", "", "", "CAcert Support");
43 }
44 ?>
45
46 <form method="post" action="account.php">
47 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="400">
48 <tr>
49 <td colspan="2" class="title"><?php echo _("My Details")?></td>
50 </tr>
51 <?php if($_SESSION['profile']['points'] == 0) { ?>
52 <tr>
53 <td class="DataTD" width="125"><?php echo _("First Name")?>: </td>
54 <td class="DataTD" width="125"><input type="text" name="fname" value="<?php echo sanitizeHTML($user['fname'])?>"></td>
55 </tr>
56 <tr>
57 <td class="DataTD" valign="top"><?php echo _("Middle Name(s)")?><br>
58 (<?php echo _("optional")?>)
59 </td>
60 <td class="DataTD"><input type="text" name="mname" value="<?php echo sanitizeHTML($user['mname'])?>"></td>
61 </tr>
62 <tr>
63 <td class="DataTD"><?php echo _("Last Name")?>: </td>
64 <td class="DataTD"><input type="text" name="lname" value="<?php echo sanitizeHTML($user['lname'])?>"></td>
65 </tr>
66 <tr>
67 <td class="DataTD"><?php echo _("Suffix")?><br>
68 (<?php echo _("optional")?>)</td>
69 <td class="DataTD"><input type="text" name="suffix" value="<?php echo sanitizeHTML($user['suffix'])?>"></td>
70 </tr>
71 <tr>
72 <td class="DataTD"><?php echo _("Date of Birth")?><br>
73 (<?php echo _("dd/mm/yyyy")?>)</td>
74 <td class="DataTD"><nobr><select name="day">
75 <?php for($i = 1; $i <= 31; $i++)
76 {
77 echo "<option";
78 if($day == $i)
79 echo " selected='selected'";
80 echo ">$i</option>";
81 }
82 ?>
83 </select>
84 <select name="month">
85 <?php for($i = 1; $i <= 12; $i++)
86 {
87 echo "<option value='$i'";
88 if($month == $i)
89 echo " selected='selected'";
90 echo ">".ucwords(recode("utf-8..html", strftime("%B", mktime(0,0,0,$i,1,date("Y")))))."</option>";
91 }
92 ?>
93 </select>
94 <input type="text" name="year" value="<?php echo $year?>" size="4"></nobr>
95 </td>
96 </tr>
97 <?php } else { ?>
98 <tr>
99 <td class="DataTD" width="125"><?php echo _("First Name")?>: </td>
100 <td class="DataTD" width="125"><?php echo sanitizeHTML($user['fname'])?></td>
101 </tr>
102 <tr>
103 <td class="DataTD" valign="top"><?php echo _("Middle Name(s)")?><br>
104 (<?php echo _("optional")?>)
105 </td>
106 <td class="DataTD"><?php echo sanitizeHTML($user['mname'])?></td>
107 </tr>
108 <tr>
109 <td class="DataTD"><?php echo _("Last Name")?>: </td>
110 <td class="DataTD"><?php echo sanitizeHTML($user['lname'])?></td>
111 </tr>
112 <tr>
113 <td class="DataTD"><?php echo _("Suffix")?><br>
114 (<?php echo _("optional")?>)</td>
115 <td class="DataTD"><?php echo sanitizeHTML($user['suffix'])?></td>
116 </tr>
117 <tr>
118 <td class="DataTD"><?php echo _("Date of Birth")?><br>
119 (<?php echo _("dd/mm/yyyy")?>)</td>
120 <td class="DataTD"><?php echo $day?> <?php echo ucwords(recode("utf-8..html", strftime("%B", mktime(0,0,0,$month,1,1))))?> <?php echo $year?></td>
121 </tr>
122 <?php } ?>
123 <tr>
124 <td colspan="2" class="title"><a href="account.php?id=59&amp;oldid=13&amp;userid=<?php echo intval($_SESSION['profile']['id'])?>"><?php echo _('Show account history')?></a></td>
125 </tr>
126 <tr>
127 <td colspan="2" class="title"><a href="account.php?id=13&amp;showdetails=<?php echo intval(!$showdetails)?>"><?php echo _("View secret question & answers")?></a></td>
128 </tr>
129 <?php if($showdetails){ ?>
130 <tr>
131 <td class="DataTD" colspan="2"><?php echo _("Lost Pass Phrase Questions")?></td>
132 </tr>
133 <tr>
134 <td class="DataTD">1)&nbsp;<input type="text" name="Q1" size="15" value="<?php echo sanitizeHTML($user['Q1'])?>"></td>
135 <td class="DataTD"><input type="text" name="A1" value="<?php echo sanitizeHTML($user['A1'])?>"></td>
136 </tr>
137 <tr>
138 <td class="DataTD">2)&nbsp;<input type="text" name="Q2" size="15" value="<?php echo sanitizeHTML($user['Q2'])?>"></td>
139 <td class="DataTD"><input type="text" name="A2" value="<?php echo sanitizeHTML($user['A2'])?>"></td>
140 </tr>
141 <tr>
142 <td class="DataTD">3)&nbsp;<input type="text" name="Q3" size="15" value="<?php echo sanitizeHTML($user['Q3'])?>"></td>
143 <td class="DataTD"><input type="text" name="A3" value="<?php echo sanitizeHTML($user['A3'])?>"></td>
144 </tr>
145 <tr>
146 <td class="DataTD">4)&nbsp;<input type="text" name="Q4" size="15" value="<?php echo sanitizeHTML($user['Q4'])?>"></td>
147 <td class="DataTD"><input type="text" name="A4" value="<?php echo sanitizeHTML($user['A4'])?>"></td>
148 </tr>
149 <tr>
150 <td class="DataTD">5)&nbsp;<input type="text" name="Q5" size="15" value="<?php echo sanitizeHTML($user['Q5'])?>"></td>
151 <td class="DataTD"><input type="text" name="A5" value="<?php echo sanitizeHTML($user['A5'])?>"></td>
152 </tr>
153 <tr>
154 <input type="hidden" name="showdetails" value="1" />
155 <?php } ?>
156 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?php echo _("Update")?>"></td>
157 </tr>
158 </table>
159 <input type="hidden" name="csrf" value="<?php echo make_csrf('perschange')?>" />
160 <input type="hidden" name="oldid" value="<?php echo intval($id)?>">
161 </form>