A
PPENDICES
S
ECTION
A
PPENDIX
B
438
M86 S
ECURITY
U
SER
G
UIDE
CGI written in C
/*
* cusc_block.c
* Description: sample C source code of CGI for customized block page
* Replace <Web Filter IP> with real IP and recompile before using
* Revision: 1
* Date: 03/08/2004
*/
#include <stdio.h>
struct {
char *name;
char *val;
} entries[20];
char szIP[16];
char szURL[1024];
char szUserName[1024];
char szCategory[8];
/*function prototypes*/
void printhtml();
void unescape_url(char *url);
char x2c(char *what);
char *makeword(char *line, char stop);
void plustospace(char *str);
char *fmakeword(FILE *f, char stop, int *cl);
int to_upper(char *string);
void getquery(char *paramd, char **paramv);
void getnextquery(char **paramv);
int main(int argc, char **argv)
{
int data_size; /* size (in bytes) of POST input */
int index;
char *paramd, *paramn, *paramv;
char step[120];
printf("content-type: text/html\n\n");
/* If using the GET method */
if (strcmp((char *)getenv("REQUEST_METHOD"), "GET") == 0)
{
paramd = (char *)strdup((char *)getenv("QUERY_STRING"));
getquery(paramd, ¶mv);
while (paramv)
{
plustospace(paramv);