bug 1394: applied text changes according to bug description
[cacert-devel.git] / tverify / index / 0.php
1 <? /*
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 $continue = 1;
19 //Checking for Thawte Freemail members, who aren´t notaries
20 if($_SERVER['SSL_CLIENT_S_DN_CN'] == 'Thawte Freemail Member')
21 {
22 $continue = 0;
23 echo _("I wasn't able to locate your name on your certificate, as such you can't continue with this process.");
24 }
25
26 //Extracting the Email address from the certificate that is presented, looking up the email in the database to find the user that has registered it.
27 if($continue == 1)
28 {
29 $addy = array();
30 $emails = explode("/", trim($_SERVER['SSL_CLIENT_S_DN']));
31 foreach($emails as $email)
32 {
33 $bits = explode("=", $email);
34 if($bits['0'] == "emailAddress")
35 {
36 $query = "select * from `email` where `email`='".$bits['1']."' and `deleted`=0 and hash=''";
37 $account = mysql_query($query);
38 if(mysql_num_rows($account))
39 $addy[] = $bits['1'];
40 }
41 }
42 }
43
44 //Verifying that we found a record with that email address
45 if(count($addy) <= 0 && $continue == 1)
46 {
47 $continue = 0;
48 echo _("I wasn't able to match any email accounts on your certificate to any accounts in our database, as such I can't continue with this process.");
49 }
50
51 //If we found one, we extract the member-id from the sql result of the query we did above, and fetch the name of that user
52 if($continue == 1)
53 {
54 $row = mysql_fetch_assoc($account);
55 $memid = $row['memid'];
56
57
58 //Fetching the name of the user we have in the database:
59 $query = "select `fname`, `mname`, `lname`, `suffix` from `users` where `id`='$memid' and `deleted`=0";
60 $res = mysql_query($query);
61 $row = mysql_fetch_assoc($res);
62
63 //Building the user´s name, and ignoring punctuation
64 $cacert_name=$row['fname']." ".$row['mname']." ".$row['lname']." ".$row['suffix'];
65 $cacert_name=strtr($cacert_name,",.","");
66 $cacert_name=trim(str_replace(" ", " ", $cacert_name));
67
68 //Generate a short name form without the middle name
69 $cacert_short_name=$row['fname']." ".$row['lname']." ".$row['suffix'];
70 $cacert_short_name=strtr($cacert_short_name,",.","");
71 $cacert_short_name=trim(str_replace(" ", " ", $cacert_short_name));
72
73
74 $tverifybits = explode(" ", trim($_SERVER['SSL_CLIENT_S_DN_G']), 2);
75 $firstname = trim($tverifybits['0']);
76 $givenname = trim($_SERVER['SSL_CLIENT_S_DN_G']);
77 $lastname = trim($_SERVER['SSL_CLIENT_S_DN_S']);
78 $tverify_name=strtr("$givenname $lastname",",.","");
79 $tverify_short_name=strtr("$firstname $lastname",",.","");
80
81 if(($cacert_name != $tverify_name) and ($cacert_short_name == $tverify_name))
82 {
83 $continue = 0;
84 printf(_("Your CAcert account contains a middle name (%s), but we cannot verify this middle name with the certificate."),$row['mname']);
85
86 }
87
88 if($continue and ($cacert_name != $tverify_name) and ($cacert_name == $tverify_short_name))
89 {
90 printf(_("Your certificate containes a middle name (%s) which isn´t listed in your CAcert account. In case you might want to get certificates with your middle name included in the future, you should add the middle name to your CAcert account before continueing."));
91 }
92
93 if($continue and ($cacert_name != $tverify_name) and ($cacert_name != $tverify_short_name) and ($cacert_short_name == $tverify_short_name))
94 {
95 printf(_("There is a problem with your middle name. You could remove the middle name in your CAcert account, which should help to continue with the TVerify process, but then you can´t use it in your certificates."));
96 }
97
98 if($continue and ($cacert_name != $tverify_name) and ($cacert_name != $tverify_short_name))
99 {
100 $continue = 0;
101 printf(_("The name and email address on your certificate (%s) could not be exactly matched to any stored in our database (%s), as such I'm not able to continue with this process."),$tverify_name,$cacert_name);
102 }
103 }
104
105 if($_SERVER['SSL_CLIENT_VERIFY'] == "SUCCESS" && $continue == 1)
106 {
107 $_SESSION['_config']['uid'] = $memid;
108 $_SESSION['_config']['CN'] = trim($_SERVER['SSL_CLIENT_S_DN']);
109 ?>
110 <p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;">
111 <?=_("By just submitting your Thawte certificate you can be issued 50 points automatically to any matching account in the system that you operate.")?><br>
112 <?=_("To receive an additional 40 points you must also include a valid link to your notary listing on the Thawte website.")?><br>
113 <?=_("If you meet the above criteria you are also elligible to receive an additional 60 points by submitting a legible government issued copy of your photo ID. If details on your photo ID aren't legible you may be excluded from receiving these points.")?></p>
114 <? if($_SESSION['_config']['errmsg'] != "") { ?><p>&nbsp;</p><p style="border:dotted 1px #900;padding:0.3em;background-color:#ffe;"><?
115 echo $_SESSION['_config']['errmsg']."</p>";
116 unset($_SESSION['_config']['errmsg']);
117 } ?>
118 <form method="post" action="index.php" enctype="multipart/form-data">
119 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
120 <tr>
121 <td colspan="2" class="title"><?=_("Points Transfer and Verification")?></td>
122 </tr>
123 <tr>
124 <td class="DataTD" width="125"><?=_("Email Address")?>: </td>
125 <td class="DataTD" width="125"><input type="text" name="email" value="<?=$row['email']?>"></td>
126 </tr>
127 <tr>
128 <td class="DataTD" width="125"><?=_("Notary URL")?>: </td>
129 <td class="DataTD" width="125"><input type="text" name="notaryURL" value="<?=htmlentities($_POST['notaryURL'])?>"></td>
130 </tr>
131 <tr>
132 <td class="DataTD" width="125"><?=_("Photo ID")?>: </td>
133 <td class="DataTD" width="125"><input type="file" name="photoid"></td>
134 </tr>
135 <tr>
136 <td class="DataTD"><?=_("Pass Phrase")?>: </td>
137 <td class="DataTD"><input type="password" name="pword"></td>
138 </tr>
139 <tr>
140 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Submit Application for Points Transfer")?>"></td>
141 </tr>
142
143 </table>
144 <input type="hidden" name="id" value="1">
145 </form>
146 <? } else if($continue == 1) {
147 echo _("1I'm sorry, I couldn't verify your certificate");
148 }
149 ?>