Source code taken from cacert-20141124.tar.bz2
[cacert.git] / pages / account / 55.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 <?
19 if ($_SESSION['profile']['admin'] != 1 || !array_key_exists('userid',$_REQUEST) || intval($_REQUEST['userid']) < 1) {
20 $user_id = intval($_SESSION['profile']['id']);
21 ?>
22 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
23 <tr>
24 <td colspan="5" class="title"><?=_("Your passed Tests")?></td>
25 </tr>
26 <tr>
27 <td class="DataTD"><?=_("The list of tests you did pass at").' <a href="https://cats.cacert.org/">https://cats.cacert.org/</a>'?></td>
28 </tr>
29 </table>
30 <?
31 } else {
32 $user_id = intval($_REQUEST['userid']);
33 $query = "select * from `users` where `id`='$user_id' and `users`.`deleted`=0";
34 $res = mysql_query($query);
35 if(mysql_num_rows($res) <= 0)
36 {
37 echo _("I'm sorry, the user you were looking for seems to have disappeared! Bad things are afoot!");
38 } else {
39 $row = mysql_fetch_assoc($res);
40 }
41 ?>
42 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
43 <tr>
44 <td colspan="5" class="title"><?=_("Passed Tests of")." ".sanitizeHTML($row['fname'])." ".sanitizeHTML($row['mname'])." ".sanitizeHTML($row['lname'])?></td>
45 </tr>
46 </table>
47
48 <?
49 }
50 ?>
51 <br>
52 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
53 <tr>
54 <td class="DataTD"><b><?=_("Date")?></b></td>
55 <td class="DataTD"><b><?=_("Test")?></b></td>
56 <td class="DataTD"><b><?=_("Variant")?></b></td>
57 </tr>
58 <?
59 $query = "SELECT `CP`.`pass_date`, `CT`.`type_text`, `CV`.`test_text` ".
60 " FROM `cats_passed` AS CP, `cats_variant` AS CV, `cats_type` AS CT ".
61 " WHERE `CP`.`variant_id`=`CV`.`id` AND `CV`.`type_id`=`CT`.`id` AND `CP`.`user_id` ='".intval($user_id)."'".
62 " ORDER BY `CP`.`pass_date`";
63
64 $res = mysql_query($query);
65
66 $HaveTest=0;
67 while($row = mysql_fetch_array($res, MYSQL_NUM))
68 {
69 if ($row[1] == "Assurer Challenge") {
70 $HaveTest=1;
71 }
72 ?>
73 <tr>
74 <td class="DataTD"><?=sanitizeHTML($row[0])?></td>
75 <td class="DataTD"><?=sanitizeHTML($row[1])?></td>
76 <td class="DataTD"><?=sanitizeHTML($row[2])?></td>
77 </tr>
78 <? }
79 ?>
80 </table>
81 <br>
82 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
83 <tr>
84 <?
85 if ($_SESSION['profile']['admin'] == 1 && array_key_exists('userid',$_REQUEST) && intval($_REQUEST['userid']) > 0) {
86 ?>
87 <tr><td colspan="3" class="DataTD"><a href="account.php?id=43&amp;userid=<?=intval($user_id)?>">back</a></td></tr>
88 <?
89 } else {
90 $query = '
91 SELECT `u`.`id`,
92 `u`.`assurer`,
93 SUM(`points`)
94 FROM `users` AS `u`,
95 `notary` AS `n`
96 WHERE `u`.`id` = \''.intval($_SESSION['profile']['id']).'\'
97 AND `n`.`to` = `u`.`id`
98 AND `expire` < NOW()
99 AND `n`.`deleted` = 0
100 GROUP BY `u`.`id`, `u`.`assurer`
101 ';
102 $res = mysql_query($query);
103 if (!$res) {
104 print '<td colspan="3" class="DataTD">'._('Internal Error').'</td>'."\n";
105 } else {
106 $row = mysql_fetch_array($res, MYSQL_NUM);
107 if ($HaveTest && ($row[2]>=100)) {
108 if (!$row[1]) {
109 // This should not happen...
110 fix_assurer_flag($_SESSION['profile']['id']);
111 }
112 ?> <td colspan="3" class="DataTD"><?=_("You have passed the Assurer Challenge and collected at least 100 Assurance Points, you are an Assurer.")?></td>
113 <? } elseif (($row[2]>=100) && !$HaveTest) {
114 ?> <td colspan="3" class="DataTD"><?=_("You have at least 100 Assurance Points, if you want to become an assurer try the ").'<a href="https://cats.cacert.org">'._("Assurer Challenge").'</a>!'?></td>
115 <? } elseif ($HaveTest && ($row[2]<100)) {
116 ?> <td colspan="3" class="DataTD"><?=_("You have passed the Assurer Challenge, but to become an Assurer you still have to reach 100 Assurance Points!")?></td>
117 <? }
118 }
119 }
120 ?> </tr>
121 </table>
122