.status-div { display: inline-block; padding-right: 20px; text-align: center; vertical-align: top; } .status-text { font-size: 15px; } .link-text { font-weight: bold; } .left-text { text-align: left; } td { padding-right: 20px; } .green-circle { padding: 2px 10px; border-radius: 100%; background-color: green; border: 1px solid black; } .red-circle { padding: 2px 10px; border-radius: 50%; background-color: red; border: 1px solid black; } HTML; } function GetProxies() { $output = shell_exec("python3 /dashboard/swag-proxies.py"); $results = json_decode($output); $status = ""; $index = 0; foreach($results as $result => $data){ $tr_class = ($index % 2 == 0) ? 'shaded' : ''; $status .= ''.$result.''; if ($data->status == 1) { $status .= ''; } else { $status .= ''; } $status .= ''; if (!empty($data->locations)) { $locations = $data->locations; $location = implode(",", $locations); $status .= ''.$location.''; } else { $status .= ''; } $status .= ''; $index++; } return <<

Proxies

{$status}

Application

Available

Proxied

Location



HTML; } function GetF2B() { $output = exec("python3 /dashboard/swag-f2b.py"); $jails = json_decode($output, true); $status = ""; $index = 0; foreach($jails as $jail){ $tr_class = ($index % 2 == 0) ? 'shaded' : ''; $status .= ''.$jail["name"].''; $status .= ''.$jail["bans"].''; $status .= ''.$jail["last_ban"].''; $index++; } return <<

Fail2Ban

{$status}

Jail

Bans

Last



HTML; } function GetAnnouncements() { $feed_url = 'https://info.linuxserver.io/index.xml'; $max_entries = 8; $xml = simplexml_load_string(file_get_contents($feed_url)); $output = ""; $entries = $xml->channel->item; $counter = 1; foreach($entries as $root) { $date = date('Y-m-d', strtotime($root->pubDate)); $output .= ''.htmlspecialchars($date).''; $output .= ''.htmlspecialchars($root->title).''; if($counter >= $max_entries) { break; } $counter++; } return <<

Announcements

{$output}


HTML; } function GetLinks() { return <<

Useful Links



HTML; } $geodb = file_exists('/config/geoip2db/GeoLite2-City.mmdb') ? '--geoip-database=/config/geoip2db/GeoLite2-City.mmdb' : ''; $goaccess = shell_exec("goaccess -a -o html --config-file=/dashboard/goaccess.conf ".$geodb); $status = GetHeader() . GetProxies() . GetF2B() . GetAnnouncements() . GetLinks() . '
'; $page = str_replace("
", $status, $goaccess); $page = str_replace("Server Statistics", "<title>SWAG Dashboard", $page); $page = str_replace("<h1 class='h-dashboard'>", "<h1>", $page); $page = str_replace("<i class='fa fa-tachometer'></i>", "<img src='/icon.svg' width='32' height='32'> SWAG ", $page); $page = preg_replace("/(<link rel='icon' )(.*?)(>)/", "<link rel='icon' type='image/svg+xml' href='/icon.svg'>", $page); echo $page; ?>