1 const char killpopup_rcs[] = "$Id: killpopup.c,v 1.2 2001/05/20 01:21:20 jongfoster Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/killpopup.c,v $
6 * Purpose : Handles the filtering of popups.
8 * Copyright : Written by and Copyright (C) 2001 the SourceForge
9 * IJBSWA team. http://ijbswa.sourceforge.net
11 * Based on the Internet Junkbuster originally written
12 * by and Copyright (C) 1997 Anonymous Coders and
13 * Junkbusters Corporation. http://www.junkbusters.com
15 * This program is free software; you can redistribute it
16 * and/or modify it under the terms of the GNU General
17 * Public License as published by the Free Software
18 * Foundation; either version 2 of the License, or (at
19 * your option) any later version.
21 * This program is distributed in the hope that it will
22 * be useful, but WITHOUT ANY WARRANTY; without even the
23 * implied warranty of MERCHANTABILITY or FITNESS FOR A
24 * PARTICULAR PURPOSE. See the GNU General Public
25 * License for more details.
27 * The GNU General Public License should be included with
28 * this file. If not, you can view it at
29 * http://www.gnu.org/copyleft/gpl.html
30 * or write to the Free Software Foundation, Inc., 59
31 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 * $Log: killpopup.c,v $
35 * Revision 1.2 2001/05/20 01:21:20 jongfoster
36 * Version 2.9.4 checkin.
37 * - Merged popupfile and cookiefile, and added control over PCRS
38 * filtering, in new "permissionsfile".
39 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
40 * file error you now get a message box (in the Win32 GUI) rather
41 * than the program exiting with no explanation.
42 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
44 * - Removed tabs from "config"
45 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
46 * - Bumped up version number.
48 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
49 * Initial import of version 2.9.3 source tree
52 *********************************************************************/
59 #include <sys/types.h>
71 #include "killpopup.h"
74 const char killpopup_h_rcs[] = KILLPOPUP_H_VERSION;
78 /* Change these for debug output. *lots*. */
79 /*#define POPUP_VERBOSE 1*/
83 /*********************************************************************
85 * Function : filter_popups
87 * Description : Filter the block of data that's been read from the server.
88 * Caller is responsible for checking permissons list
89 * to determine if this function should be called.
92 * 1 : buff = Buffer to scan and modify. Null terminated.
93 * 2 : size = Buffer size, excluding null terminator.
97 *********************************************************************/
98 void filter_popups(char *buff, int size)
103 char *q = NULL; /* by BREITENB NEW! */
105 while ((popup = strstr( buff, "window.open(" )) != NULL)
108 fprintf(logfp, "Found start of window open" );
110 close = strstr( popup+1, ");" );
114 fprintf(logfp, "Found end of window open" );
116 for ( p = popup; p != (close+1); p++ )
121 fprintf(logfp, "Blocked %s\n", host_name );
127 fprintf(logfp, "Couldn't find end, turned into comment. Read boundary?\n" );
135 q=popup; /* by BREITENB NEW! */
138 if (*q==' ' || *q=='\t')
144 if (*q=='=') *++q='1';
145 /* result of popup is assigned to a variable! ensure success. hehehe. */
149 /* Filter all other crap like onUnload onExit etc. (by BREITENB) NEW!*/
150 popup=strstr( buff, "<body");
151 if (!popup) popup=strstr( buff, "<BODY");
152 if (!popup) popup=strstr( buff, "<Body");
153 if (!popup) popup=strstr( buff, "<BOdy");
156 close=strchr(popup,'>');
159 /* we are now between <body and the ending > */
160 p=strstr(popup, "onUnload");
165 p=strstr(popup, "onExit");
175 #endif /* def KILLPOPUPS */