-
Notifications
You must be signed in to change notification settings - Fork 8
/
directory.php
193 lines (151 loc) · 6.04 KB
/
directory.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
include("common.php");
pg_prepare($dbconn, "list_server", "SELECT server_name, founded, country, url, description FROM public_servers ORDER BY server_name;");
pg_prepare($dbconn, "find_s2s", "SELECT test_id FROM test_results WHERE server_name = $1 AND type = 'server' ORDER BY test_date DESC LIMIT 1;");
pg_prepare($dbconn, "find_c2s", "SELECT test_id, version FROM test_results WHERE server_name = $1 AND type = 'client' ORDER BY test_date DESC LIMIT 1;");
pg_prepare($dbconn, "find_srvs", "SELECT grade, total_score, certificate_score, done, error, srv_result_id, certificate_score, warn_rc4_tls11, warn_no_fs FROM srv_results WHERE test_id = $1 ORDER BY priority ASC;");
pg_prepare($dbconn, "find_cert", "SELECT signed_by_id, certificates.certificate_id FROM srv_certificates, certificates WHERE srv_certificates.certificate_id = certificates.certificate_id AND srv_certificates.srv_result_id = $1;");
pg_prepare($dbconn, "find_cn", "SELECT value FROM certificate_subjects WHERE certificate_subjects.certificate_id = $1 AND (certificate_subjects.name = 'commonName' OR certificate_subjects.name = 'organizationName') ORDER BY certificate_subjects.name LIMIT 1;");
$res = pg_execute($dbconn, "list_server", array());
$list = pg_fetch_all($res);
common_header("");
?>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">IM Observatory</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="list.php">Test results</a></li>
<li class="active"><a href="#">Public server directory</a></li>
<li><a href="about.php">About</a></li>
<li><a href="reports.php">Stats</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<?php
if (!$list) {
?>
<h1>404</h1>
<div class="alert alert-block alert-error">
Test results could not be found.
</div>
<?php
} else {
?>
<h1>Public XMPP Server Directory</h1>
<p>This is a list of servers with public registration (i.e., anyone can sign up for free). Follow the links to the website to sign up, or use a client that supports in-band registration. Server administrators can register their servers by following the <a href="register.php">registration instructions</a>.</p>
<table class="table table-bordered table-striped sortable">
<thead>
<tr>
<th data-defaultsort="asc">Domain</th>
<th>Year founded</th>
<th>Country</th>
<th>Certificate Authority (untrusted certificates in red text)</th>
<th>Software</th>
<th>Software release date</th>
<th>Security grade client-to-server</th>
<th>Security grade server-to-server</th>
</tr>
</thead>
<tbody>
<?php
foreach ($list as $result) {
$issuer = NULL;
$res = pg_execute($dbconn, "find_s2s", array($result["server_name"]));
$s2s = pg_fetch_assoc($res);
$res = pg_execute($dbconn, "find_srvs", array($s2s["test_id"]));
$s2s_scores = pg_fetch_all($res);
$res = pg_execute($dbconn, "find_c2s", array($result["server_name"]));
$c2s = pg_fetch_assoc($res);
$res = pg_execute($dbconn, "find_srvs", array($c2s["test_id"]));
$c2s_scores = pg_fetch_all($res);
if (pg_num_rows($res) > 0) {
$res = pg_execute($dbconn, "find_cert", array($c2s_scores[0]["srv_result_id"]));
$cert = pg_fetch_assoc($res);
if ($cert["signed_by_id"] !== NULL) {
$res = pg_execute($dbconn, "find_cn", array($cert["signed_by_id"]));
$issuer = pg_fetch_assoc($res);
} else {
$res = pg_execute($dbconn, "find_cn", array($cert["certificate_id"]));
$issuer = pg_fetch_assoc($res);
}
}
$c2s_final_score = NULL;
$s2s_final_score = NULL;
if ($c2s_scores) {
foreach ($c2s_scores as $score) {
if (grade($score) && (!$c2s_final_score || grade($score) < $c2s_final_score)) {
$c2s_final_score = grade($score);
}
}
}
if ($s2s_scores) {
foreach ($s2s_scores as $score) {
if (grade($score) && (!$s2s_final_score || grade($score) < $s2s_final_score)) {
$s2s_final_score = grade($score);
}
}
}
?>
<tr>
<td>
<a class="my-popover" data-content="<?= $result["description"] ?>" data-toggle="popover" data-original-title="<?= htmlspecialchars($result["server_name"]) ?>" href="<?= $result["url"] ?>">
<?= htmlspecialchars($result["server_name"]) ?> <span class="glyphicon glyphicon-link"></span>
</a>
</td>
<td>
<?= $result["founded"] ?>
</td>
<td>
<?= $result["country"] ?>
</td>
<td>
<span<?= $c2s_scores[0]["certificate_score"] != 100 ? " class='text-danger'" : ""?>><?= htmlspecialchars($issuer["value"]) ?></span>
</td>
<td>
<?= htmlspecialchars($c2s["version"]) ?>
</td>
<td>
<?= released($c2s["version"]) ?>
</td>
<td data-value="<?= $c2s_final_score ? $c2s_final_score : "G" ?>">
<a class="label <?= color_label_text_grade($c2s_final_score) ?>" href="result.php?domain=<?= $result["server_name"] ?>&type=client">
<?= $c2s_final_score ? $c2s_final_score : "?" ?>
</a>
</td>
<td data-value="<?= $s2s_final_score ? $s2s_final_score : "G" ?>">
<a class="label <?= color_label_text_grade($s2s_final_score) ?>" href="result.php?domain=<?= $result["server_name"] ?>&type=server">
<?= $s2s_final_score ? $s2s_final_score : "?" ?>
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php } ?>
<div class="footer">
<p>Some rights reserved.</p>
</div>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./js/jquery.js"></script>
<script src="./js/jquery.timeago.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/bootstrap-sortable.js"></script>
<script src="./js/main.js"></script>
</body>
</html>