-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_rules_list.c
More file actions
41 lines (28 loc) · 792 Bytes
/
show_rules_list.c
File metadata and controls
41 lines (28 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char *data = malloc(200);
data = getenv("QUERY_STRING");
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<body>\n");
printf("<h1>Rules list %s</h1>\n", data);
DIR *dir;
struct dirent *ent;
if ((dir = opendir ("/usr/lib/nagios/plugins/firewall")) != NULL) {
while ((ent = readdir (dir)) != NULL) {
const char *ext = strrchr(ent->d_name, '.');
if(strstr(ent->d_name, data) != NULL && strcmp(ext, ".txt") == 0)
printf ("<li><a href='show.cgi?plik=%s'>%s</a></li><br>", ent->d_name, ent->d_name);
}
closedir (dir);
} else {
perror ("Problem with open file");
}
printf("</body>\n");
printf("</html>\n");
return 0;
}