@@ -310,10 +310,49 @@ function GetCertificate() {
310310 HTML ;
311311 }
312312
313- $ goaccess = GetGoaccess ();
314- $ status = GetHeader () . GetProxies () . GetF2B () . GetTemplates () . GetAnnouncements () . GetLinks () . "<div class='wrap-general'> " ;
315- $ page = str_replace ("<div class='wrap-general'> " , $ status , $ goaccess );
316- $ ssl = GetCertificate () . "<div class='pull-right hide'> " ;
317- $ page = str_replace ("<div class='pull-right'> " , $ ssl , $ page );
318- echo $ page ;
313+ function GetStats () {
314+ $ output = shell_exec ("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-f2b.py; else python3 /dashboard/swag-f2b.py; fi " );
315+ $ jails = json_decode ($ output , true );
316+ $ banned = 0 ;
317+ foreach ($ jails as $ jail ){
318+ $ banned = $ banned + $ jail ["bans " ];
319+ }
320+
321+ $ output = shell_exec ("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py fast; else python3 /dashboard/swag-proxies.py fast; fi " );
322+ $ results = json_decode ($ output );
323+ $ proxied = 0 ;
324+ $ auth = 0 ;
325+ foreach ($ results as $ result => $ data ){
326+ if (!empty ($ data ->locations )){
327+ $ proxied ++;
328+ if ($ data ->auth_status == 1 ) {
329+ $ auth ++;
330+ }
331+ }
332+ }
333+
334+ $ output = shell_exec ("/etc/s6-overlay/s6-rc.d/init-version-checks/run " );
335+ $ outdated = 0 ;
336+ foreach (explode (PHP_EOL , $ output ) as $ line ) {
337+ if (str_contains ($ line , "/config/ " )) {
338+ $ outdated ++;
339+ }
340+ }
341+
342+ return array ("proxied " => "$ proxied " , "auth " => "$ auth " , "outdated " => "$ outdated " , "banned " => "$ banned " );
343+ }
344+
345+ $ stats = $ _GET ['stats ' ] == 'true ' ? true : false ;
346+ if ($ stats ) {
347+ $ page = GetStats ();
348+ header ("Content-Type: application/json " );
349+ echo json_encode ($ page );
350+ } else {
351+ $ goaccess = GetGoaccess ();
352+ $ status = GetHeader () . GetProxies () . GetF2B () . GetTemplates () . GetAnnouncements () . GetLinks () . "<div class='wrap-general'> " ;
353+ $ page = str_replace ("<div class='wrap-general'> " , $ status , $ goaccess );
354+ $ ssl = GetCertificate () . "<div class='pull-right hide'> " ;
355+ $ page = str_replace ("<div class='pull-right'> " , $ ssl , $ page );
356+ echo $ page ;
357+ }
319358?>
0 commit comments