Show client status on our basic presentation page.
This commit is contained in:
parent
eeffcf47dd
commit
a75bdadce1
77
upnphttp.c
77
upnphttp.c
@ -577,31 +577,68 @@ sendXMLdesc(struct upnphttp * h, char * (f)(int *))
|
||||
free(desc);
|
||||
}
|
||||
|
||||
#ifdef READYNAS
|
||||
static void
|
||||
SendResp_readynas_admin(struct upnphttp * h)
|
||||
{
|
||||
char body[128];
|
||||
int l;
|
||||
|
||||
h->respflags = FLAG_HTML;
|
||||
l = snprintf(body, sizeof(body), "<meta http-equiv=\"refresh\" content=\"0; url=https://%s/admin/\">",
|
||||
lan_addr[h->iface].str);
|
||||
|
||||
BuildResp_upnphttp(h, body, l);
|
||||
SendResp_upnphttp(h);
|
||||
CloseSocket_upnphttp(h);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
SendResp_presentation(struct upnphttp * h)
|
||||
{
|
||||
char body[1024];
|
||||
int l;
|
||||
struct string_s str;
|
||||
char body[4096];
|
||||
int a, v, p, i;
|
||||
|
||||
str.data = body;
|
||||
str.size = sizeof(body);
|
||||
str.off = 0;
|
||||
|
||||
h->respflags = FLAG_HTML;
|
||||
|
||||
#ifdef READYNAS
|
||||
l = snprintf(body, sizeof(body), "<meta http-equiv=\"refresh\" content=\"0; url=https://%s/admin/\">",
|
||||
lan_addr[h->iface].str);
|
||||
#else
|
||||
int a, v, p;
|
||||
a = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'a*'");
|
||||
v = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'v*'");
|
||||
p = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'i*'");
|
||||
l = snprintf(body, sizeof(body),
|
||||
strcatf(&str,
|
||||
"<HTML><HEAD><TITLE>" SERVER_NAME " " MINIDLNA_VERSION "</TITLE></HEAD>"
|
||||
"<BODY><div style=\"text-align: center\">"
|
||||
"<h3>" SERVER_NAME " status</h3>"
|
||||
"Audio files: %d<br>"
|
||||
"Video files: %d<br>"
|
||||
"Image files: %d</div>"
|
||||
"</BODY></HTML>\r\n", a, v, p);
|
||||
#endif
|
||||
BuildResp_upnphttp(h, body, l);
|
||||
"<h2>" SERVER_NAME " status</h2></div>");
|
||||
|
||||
strcatf(&str,
|
||||
"<h3>Media library</h3>"
|
||||
"<table border=1 cellpadding=10>"
|
||||
"<tr><td>Audio files</td><td>%d</td></tr>"
|
||||
"<tr><td>Video files</td><td>%d</td></tr>"
|
||||
"<tr><td>Image files</td><td>%d</td></tr>"
|
||||
"</table>", a, v, p);
|
||||
|
||||
strcatf(&str,
|
||||
"<h3>Connected clients</h3>"
|
||||
"<table border=1 cellpadding=10>"
|
||||
"<tr><td>ID</td><td>Type</td><td>IP Address</td><td>HW Address</td></tr>");
|
||||
for (i = 0; i < CLIENT_CACHE_SLOTS; i++)
|
||||
{
|
||||
if (!clients[i].addr.s_addr)
|
||||
continue;
|
||||
strcatf(&str, "<tr><td>%d</td><td>%s</td><td>%s</td><td>%02X:%02X:%02X:%02X:%02X:%02X</td></tr>",
|
||||
i, client_types[clients[i].type].name, inet_ntoa(clients[i].addr),
|
||||
clients[i].mac[0], clients[i].mac[1], clients[i].mac[2],
|
||||
clients[i].mac[3], clients[i].mac[4], clients[i].mac[5]);
|
||||
}
|
||||
strcatf(&str, "</table></BODY></HTML>\r\n");
|
||||
|
||||
BuildResp_upnphttp(h, str.data, str.off);
|
||||
SendResp_upnphttp(h);
|
||||
CloseSocket_upnphttp(h);
|
||||
}
|
||||
@ -954,10 +991,18 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
||||
{
|
||||
SendResp_caption(h, HttpUrl+10);
|
||||
}
|
||||
else if(strcmp(HttpUrl, "/") == 0)
|
||||
else if(strcmp(HttpUrl, "/status/") == 0)
|
||||
{
|
||||
SendResp_presentation(h);
|
||||
}
|
||||
else if(strcmp(HttpUrl, "/") == 0)
|
||||
{
|
||||
#ifdef READYNAS
|
||||
SendResp_readynas_admin(h);
|
||||
#else
|
||||
SendResp_presentation(h);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINTF(E_WARN, L_HTTP, "%s not found, responding ERROR 404\n", HttpUrl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user