This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·280 lines (242 loc) · 12.9 KB
/
index.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?php
/*
* searx-stats is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* searx-stats is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with searx-stats. If not, see < http://www.gnu.org/licenses/ >.
*
* (C) 2014- by Thomas Pointhuber
*/
define('_SEARX_STATS', 1);
// check if config-file is available
if(!is_readable(realpath(dirname(__FILE__) . '/resources/config.inc.php')))
die("config-file not found!");
require_once(realpath(dirname(__FILE__) . '/resources/config.inc.php'));
require_once(LIBRARY_PATH . '/system/data/DatabaseManager.class.php');
require_once(LIBRARY_PATH . '/system/data/Input.class.php');
DatabaseManager::connect();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/img/favicon.png">
<title>searx-stats</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap theme -->
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/searx_stats.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="js/html5shiv.min.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">searx stats</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<!--<li><a href="#instances">Instances</a></li>-->
<!--<li><a href="#engines">Engines</a></li>-->
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container theme-showcase" role="main">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>Welcome</h1>
<p>This is a little website, to show up-to-date informations about searx-engines and public searx Instances.</p>
<p>searx is a privacy-respecting, hackable metasearch engine, which can everyone host by itself.</p>
<p><a href="https://github.com/asciimoo/searx" class="btn btn-primary btn-lg" role="button">View searx on Github »</a></p>
</div><!-- /.container -->
<div class="row">
<div class="col-md-7">
<h2>public searx Instances</h2>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>url</th>
<th>online-status</th>
<th>searx-version</th>
<th>last update</th>
</tr>
</thead>
<tbody>
<?php
require_once(LIBRARY_PATH . '/system/SearxInstances.class.php');
$SearxInstancesObject = new SearxInstances();
$instances = $SearxInstancesObject->GetInstances();
$instance_id = 0;
foreach ($instances as $single_instance) {
$instance_id ++;
echo '<tr>';
echo '<td>'.$instance_id.'</td>';
// print url of engine, and add http:// if not done yet
if(strpos($single_instance['url'], 'http') === 0 or strpos($single_instance['url'], 'https') === 0) {
echo '<td><a href="'.$single_instance['url'].'">'.$single_instance['url'].'</a></td>';
} else {
echo '<td><a href="http://'.$single_instance['url'].'">'.$single_instance['url'].'</a></td>';
}
// parse and show formated return-code
echo '<td>';
switch($single_instance['return_code']) {
case 0:
echo '<span class="label label-default">'.'unknow'.'</span>';
break;
case 200:
echo '<span class="label label-success">'.$single_instance['return_code'].' - OK'.'</span>';
break;
case 301:
echo '<span class="label label-warning">'.$single_instance['return_code'].' - Moved Permanently'.'</span>';
break;
case 302:
echo '<span class="label label-warning">'.$single_instance['return_code'].' - Found'.'</span>';
break;
case 303:
echo '<span class="label label-warning">'.$single_instance['return_code'].' - See Other'.'</span>';
break;
case 400:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Bad Request'.'</span>';
break;
case 401:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Unauthorized'.'</span>';
break;
case 403:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Forbidden'.'</span>';
break;
case 404:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Not Found'.'</span>';
break;
case 408:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Request Timeout'.'</span>';
break;
case 500:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Internal Server Error'.'</span>';
break;
case 501:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Not Implemented'.'</span>';
break;
case 502:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Bad Gateway'.'</span>';
break;
case 503:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Service Unavailable'.'</span>';
break;
case 504:
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Gateway Timeout'.'</span>';
break;
default:
if($single_instance['return_code'] >= 200 && $single_instance['return_code'] < 300)
echo '<span class="label label-success">'.$single_instance['return_code'].' - Success'.'</span>';
else if($single_instance['return_code'] >= 300 && $single_instance['return_code'] < 400)
echo '<span class="label label-warning">'.$single_instance['return_code'].' - Redirection'.'</span>';
else if($single_instance['return_code'] >= 400 && $single_instance['return_code'] < 500)
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Client Error'.'</span>';
else if($single_instance['return_code'] >= 500 && $single_instance['return_code'] < 600)
echo '<span class="label label-danger">'.$single_instance['return_code'].' - Server Error'.'</span>';
else
echo '<span class="label label-default">'.$single_instance['return_code'].'</span>';
break;
}
echo '</td>';
// show version of instance
if($single_instance['searx_version'] == '') {
echo '<td><em class="text-muted">unknow</em></td>';
} else {
echo '<td>'.$single_instance['searx_version'].'</td>';
}
// show last update-time
if($single_instance['last_update'] == 0) {
echo '<td><em class="text-muted">unknow</em></td>';
} else {
echo '<td>'.date("d.m.Y",$single_instance['last_update']).'</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div class="col-md-5">
<h2>Engines</h2>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>name</th>
<th>is working</th>
<th>last update</th>
</tr>
</thead>
<tbody>
<?php
require_once(LIBRARY_PATH . '/system/SearxEngines.class.php');
$SearxEnginesObject = new SearxEngines();
$engines = $SearxEnginesObject->GetEngines();
$engine_id = 0;
foreach ($engines as $single_engine) {
$engine_id ++;
echo '<tr>';
echo '<td>'.$engine_id.'</td>';
echo '<td>'.$single_engine['name'].'</td>';
// show, if engine provide results
if($single_engine['is_working'] == true) {
echo '<td><span class="label label-success">provide results</span></td>';
} else {
// if dataset has not update-time, show label in grey
if($single_engine['last_update'] == 0) {
echo '<td><span class="label label-default">no results!</span></td>';
} else {
echo '<td><span class="label label-danger">no results!</span></td>';
}
}
// show last update-time
if($single_engine['last_update'] == 0) {
echo '<td><em class="text-muted">unknow</em></td>';
} else {
echo '<td>'.date("d.m.Y",$single_engine['last_update']).'</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
DatabaseManager::disconnect();
?>