@import url("https://use.fontawesome.com/releases/v5.15.0/css/all.css");
.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;
}
.far, .fas {
font-family: "Font Awesome 5 Free" !important;
}
.fa-exclamation-circle,.fa-check-circle, .fa-info-circle, .fa-edit {
font-size:20px;
padding: 2px;
}
.fa-check-circle {
color: #5DB56A;
}
.fa-exclamation-circle {
color: #FF303E;
}
.fa-info-circle:hover{
color: gray;
cursor: help;
}
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
Application |
Available |
Proxied |
Location |
{$status}
HTML;
}
function GetF2B() {
$output = shell_exec("python3 /dashboard/swag-f2b.py");
$jails = json_decode($output, true);
$status = "";
$index = 0;
foreach($jails as $jail){
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
$data = ($jail["data"]) ? ' ' : '';
$status .= '| '.$jail["name"].' | ';
$status .= ''.$jail["bans"].' | ';
$status .= ''.$jail["last_ban"].''.$data.' |
';
$index++;
}
return <<
HTML;
}
function GetTemplates() {
$tooltip = "";
$files = "";
$counter = 1;
$output = shell_exec("/etc/cont-init.d/70-templates");
foreach(explode(PHP_EOL, $output) as $line) {
if(substr($line, 0, 1) === "*"){
$tooltip .= str_replace("*", "", $line)."
";
} elseif(substr($line, 0, 1) === "/") {
$tr_class = ($counter % 2 == 0) ? 'shaded' : '';
$files .= '| '.htmlspecialchars($line).' | ';
$file_name = substr($line, strrpos($line, '/') + 1);
$files .= ' |
';
$counter++;
}
}
if(empty($files)) {
return "";
}
return <<
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 <<
HTML;
}
function GetLinks() {
return <<
HTML;
}
function GetGoaccess() {
$dbip = '/config/geoip2db/dbip-country-lite.mmdb';
$maxmind = '/config/geoip2db/GeoLite2-City.mmdb';
if (file_exists($dbip) and file_exists($maxmind)):
$geodb = (filemtime($dbip) > filemtime($maxmind)) ? '--geoip-database='.$dbip : '--geoip-database='.$maxmind;
elseif (file_exists($dbip)):
$geodb = '--geoip-database='.$dbip;
elseif (file_exists($maxmind)):
$geodb = '--geoip-database='.$maxmind;
else:
$geodb = '';
endif;
$goaccess = shell_exec("/usr/local/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf ".$geodb);
$goaccess = str_replace("Server Statistics", "SWAG Dashboard", $goaccess);
$goaccess = str_replace("", "", $goaccess);
$goaccess = str_replace("", "
SWAG ", $goaccess);
$goaccess = preg_replace("/()/", "", $goaccess);
return $goaccess;
}
$goaccess = GetGoaccess();
$status = GetHeader() . GetProxies() . GetF2B() . GetTemplates() . GetAnnouncements() . GetLinks() . '';
$page = str_replace("
", $status, $goaccess);
echo $page;
?>