-
Notifications
You must be signed in to change notification settings - Fork 2
/
search.php
148 lines (126 loc) · 5.64 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
include('./config.php');
include(STORE_DIR.'/config/config.php');
include('./include/common.php');
include('./include/my_functions.php');
include('./include/openssl_functions.php');
$stage = gpvar('stage');
$submit = gpvar('submit');
$search = gpvar('search');
$serial = gpvar('serial');
$show_valid = gpvar('show_valid');
$show_revoked = gpvar('show_revoked');
$show_expired = gpvar('show_expired');
# Force stage back to search form if search string is empty.
if ($stage == "search" && ! $search) $stage = "";
# Force filter to (V)alid certs if no search status is selected.
if ( !($show_valid.$show_revoked.$show_expired) ) $show_valid = 'V';
switch ($stage):
case 'display':
printHeader('about');
print "<div style='float:left; position: absolute'><a href='search.php'><button class='btn'>Back to Menu</button></a></div>";
print '
<div style="text-align:center"><h2>Certificate Details</h2></div>
<div style="text-align:center"><font color=#0000AA><h3>(#'.htvar($serial).')<br>'.htvar(CA_cert_cname($serial).' <'.CA_cert_email($serial).'>').'</h3></font></div>';
if ($revoke_date = CAdb_is_revoked($serial))
print '<div style="text-align:center"><font color="red"><h2>REVOKED '.htvar($revoke_date).'</h2></font></div>';
print '<pre>'.htvar(CA_cert_text($serial)).'</pre>';
break;
case 'download':
$rec = CAdb_get_entry($serial);
upload($config['cert_dir']."/$serial.der", $rec['common_name']." (".$rec['email'].").cer", 'application/pkix-cert');
break;
case 'search':
printHeader('public');
$db = CAdb_to_array("^[${show_valid}${show_revoked}${show_expired}].*$search");
print '<body onLoad="self.focus();document.form.submit.focus()">';
if (sizeof($db) == 0) {
?>
<div style="text-align:center">
<h2>Nothing Found</h2>
<form action="<?php print htvar($PHP_SELF)?>" method="post" name="form">
<input type="hidden" name="search" value="<?php print htvar($search)?>">
<input type="hidden" name="show_valid" value="<?php print htvar($show_valid)?>">
<input type="hidden" name="show_revoked" value="<?php print htvar($show_revoked)?>">
<input type="hidden" name="show_expired" value="<?php print htvar($show_expired)?>">
<input class="btn" type="submit" name="submit" value="Go Back">
</form>
</div>
<?php
printFooter();
break;
}
?>
<div style="width:80%; margin:0 auto">
<table>
<tr><th colspan="10"><h2>CERTIFICATE SEARCH RESULTS</h2></th></tr>
<tr>
<?php
$headings = array(
'status'=>"Status", 'issued'=>"Issued", 'expires'=>"Expires",
'common_name'=>"User's Name", 'email'=>"E-mail",
'organization'=>"Organization", 'unit'=>"Department",
'locality'=>"Locality", 'province'=>"State", 'action'=>'Action'
);
print '<tr>';
foreach($headings as $field=>$head) {
print '<th>'.htvar($head). '</th>';
}
print '</tr>';
foreach($db as $rec) {
$stcolor = array('Valid'=>'green', 'Revoked'=>'red', 'Expired'=>'orange');
?>
<tr style="font-size: 11px;">
<td style="color: <?php print $stcolor[$rec['status']]?>; font-weight: bold"><?php print htvar($rec['status'])?></td>
<td style="white-space: nowrap"><?php print htvar($rec['issued'])?></td>
<td style="white-space: nowrap"><?php print htvar($rec['expires'])?></td>
<td><?php print htvar($rec['common_name'])?></td>
<td style="white-space: nowrap">
<a href="mailto:<?php print htvar($rec['common_name']).' <'.htvar($rec['email']).'>' ?>">
<?php print htvar($rec['email']) ?>
</a>
</td>
<td><?php print htvar($rec['organization'])?></td>
<td><?php print htvar($rec['unit'])?></td>
<td><?php print htvar($rec['locality'])?></td>
<td><?php print htvar($rec['province'])?></td>
<td><a href="<?php print htvar($PHP_SELF)?>?stage=display&serial=<?php print htvar($rec['serial'])?>" target="_certdisp"><img src="images/display.png" alt="Display" title="Display the certificate in excruciating detail"></a>
<?php
if ($rec['status'] != 'Revoked') {
?>
<a href="<?php print htvar($PHP_SELF) ?>?stage=download&serial=<?php print htvar($rec['serial'])?>"><img src="images/download.png" alt="Download" title="Download the certificate so that you may send encrypted e-mail"></a>
<?php
}
print '</td></tr>';
}
?>
</table>
<form action="<?php print htvar($PHP_SELF) ?>" method="post" name="form">
<input class="btn" type="submit" name="submit" value="Another Search">
<input type="hidden" name="search" value="<?php print htvar($search) ?>">
<input type="hidden" name="show_valid" value="<?php print htvar($show_valid) ?>">
<input type="hidden" name="show_revoked" value="<?php print htvar($show_revoked) ?>">
<input type="hidden" name="show_expired" value="<?php print htvar($show_expired) ?>">
</form>
</div>
<?php
printFooter();
break;
default:
printHeader('public');
?>
<body onLoad="self.focus();document.search.search.focus()">
<div style="text-align:center"><h2>Certificate Search</h2>
<form action="<?php print htvar($PHP_SELF)?>" method="post" name="search">
<input class="inputbox" type="text" name="search" value="<?php print htvar($search)?>" maxlength="60" size="40">
<input class="btn" type="submit" name="submit" value="Find It!"><br>
<input type="checkbox" name="show_valid" value="V" <?php print ($show_valid?'checked':'')?>>Valid
<input type="checkbox" name="show_revoked" value="R" <?php print ($show_revoked?'checked':'')?>>Revoked
<input type="checkbox" name="show_expired" value="E" <?php print ($show_expired?'checked':'')?>>Expired
<input type="hidden" name="stage" value="search">
</form></div>
<br><br>
<?php
printFooter();
endswitch;
?>