• R/O
  • SSH
  • HTTPS

ogup: 提交


Commit MetaInfo

修訂38 (tree)
時間2021-12-07 06:21:49
作者mateuszviste

Log Message

improved db archies menu look and added a new live view of the database

Change Summary

差異

--- trunk/frontend/dbdump/gophermap.php (nonexistent)
+++ trunk/frontend/dbdump/gophermap.php (revision 38)
@@ -0,0 +1,43 @@
1+<?php
2+
3+// db dump screen
4+
5+include '../db.php';
6+
7+$db = db_load('../ogupdb.dat', true, true, true);
8+$cnt = db_counters('../ogupdb.cnt');
9+
10+$dbtimestamp = gmdate("Y-m-d H:i", $cnt['timestamp']);
11+
12+echo "i\n";
13+echo "i >>> OGUP live database dump (as of {$dbtimestamp} UTC) <<<\n";
14+echo "i\n";
15+echo "i ### | HOSTNAME | STATUS | NEXT CHECK\n";
16+echo "i-----+---------------------------------+-----------------------+-----------------\n";
17+
18+$i = 1;
19+foreach ($db as $item) {
20+ $host = str_pad($item['host'] . ' ', 32, '.', STR_PAD_RIGHT);
21+ $port = $item['port'];
22+ if ($item['failedsince'] == 0) {
23+ $status = 'OK';
24+ } else if ($item['failedsince'] == 1) {
25+ $status = 'pending verification';
26+ } else {
27+ $status = 'down ' . gmdate("Y-m-d H:i", $item['failedsince']);
28+ }
29+ if ($item['nextcheck'] == 0) {
30+ $nextcheck = "ASAP";
31+ } else {
32+ $nextcheck = gmdate("Y-m-d H:i", $item['nextcheck']);
33+ }
34+ $status = str_pad($status, 22);
35+ $nextcheck = str_pad($nextcheck, 16);
36+ $id = str_pad($i, 4, ' ', STR_PAD_LEFT);
37+ echo "i{$id} | {$host}| {$status}| {$nextcheck}\n";
38+ $i++;
39+}
40+
41+echo "i-----+---------------------------------+-----------------------+-----------------\n";
42+
43+?>
--- trunk/frontend/db.php (revision 37)
+++ trunk/frontend/db.php (revision 38)
@@ -28,11 +28,12 @@
2828 // ['host']
2929 // ['port']
3030 // ['failedsince'] => timestamp since failure (0=up, 1=pending)
31+// ['nextcheck'] => time when server should be checked again
3132 function db_load($f, $include_up, $include_pending, $include_down) {
3233 $fh = fopen('../ogupdb.dat', 'r');
3334 if (! $fh) return(FALSE);
3435
35- // srv,port,downsince
36+ // srv,port,downsince,nextcheck
3637 $res = array();
3738 while (($lin = fgetcsv($fh)) !== FALSE) {
3839 // include down?
@@ -46,6 +47,7 @@
4647 $item['host'] = $lin[0];
4748 $item['port'] = intval($lin[1]);
4849 $item['failedsince'] = intval($lin[2]);
50+ $item['nextcheck'] = intval($lin[3]);
4951 $res[] = $item;
5052 }
5153 fclose($fh);
Show on old repository browser