2 * mod_msff.c: Microsoft Free Fridays: reject MSIE on Friday.
4 * Michael Anthony <m@beanpod.net>
5 * You may use this software free for any purpose.
8 * You might find success by trying to build it like this:
10 * gcc -c -I<apache include dir> -fpic -DSHARED_MODULE mod_msff.c
11 * gcc -shared -o mod_msff.so mod_msff.o
13 * But you also might not. After you do that, you'll want the
14 * resulting .so file in your Apache installation's libexec directory.
16 * Enable the module by putting this line right around where the
17 * LoadModule line for mod_auth is:
19 * LoadModule msff_module libexec/mod_msff.so
21 * and put this line right around where the AddModule line for
24 * AddModule mod_msff.c
29 #include "http_core.h"
30 #include "http_config.h"
32 #include "http_request.h"
36 static void dump_message (request_rec *r)
38 r->content_type = "text/html";
39 r->status = FORBIDDEN;
40 ap_send_http_header (r);
46 "<html xml:lang=\"en\" lang=\"en\">\n"
48 "<title>Go home, Billy!</title>\n"
52 "<a href=\"http://davenet.userland.com/2001/06/13\">"
53 "Microsoft-Free Friday</a>!</h1></p>\n"
54 "<p>In support of freedom of choice in browser software, this"
55 " web site is Microsoft-Free on Fridays. Please use any"
56 " browser except MSIE to access this web site today.</p>\n"
62 static int msff (request_rec *r)
71 foo = ap_table_get (r->headers_in, "User-Agent");
74 agent = ap_pstrdup (r->pool, foo);
75 for (p = agent; *p; ++p)
85 && strstr (agent, "msie")
86 && ! strstr (agent, "opera")
87 && ! strstr (agent, "oregano"))
90 tmp = localtime (&now);
91 if (tmp->tm_wday == 5)
100 static int handle_msff (request_rec *r)
113 module MODULE_VAR_EXPORT msff_module;
115 static const command_rec msff_cmds[] =
120 static const handler_rec msff_handlers[] =
122 { "*/*", handle_msff },
126 module MODULE_VAR_EXPORT msff_module =
128 STANDARD_MODULE_STUFF,
129 NULL, /* initializer */
130 NULL, /* dir config creater */
131 NULL, /* dir merger --- default is to override */
132 NULL, /* server config */
133 NULL, /* merge server config */
134 msff_cmds, /* command table */
135 msff_handlers, /* handlers */
136 NULL, /* filename translation */
137 NULL, /* check_user_id */
138 NULL, /* check auth */
139 NULL, /* check access */
140 NULL, /* type_checker */
143 NULL, /* header parser */
144 NULL, /* child_init */
145 NULL, /* child_exit */
146 NULL /* post read-request */