2b004e1997-01-25Peter Bortas /* This is a roxen module. (c) Informationsvävarna AB 1997. * * Adds some java script that will prevent others from putting * your page in a frame. *
afbad21997-06-09Peter Bortas  * Will also remove occuranses of "index.html" at the end of the URL.
2b004e1997-01-25Peter Bortas  * * made by Peter Bortas <peter@infovav.se> Januari -97
aa899c1997-11-14Peter Bortas  * * Thanks to
2b004e1997-01-25Peter Bortas  */
aa899c1997-11-14Peter Bortas constant cvs_version = "$Id: killframe.pike,v 1.11 1997/11/14 01:00:02 peter Exp $";
07bf511997-08-31Peter Bortas constant thread_safe=1;
6677ac1997-08-31Peter Bortas 
2b004e1997-01-25Peter Bortas #include <module.h> inherit "module"; void create() { } mixed *register_module() { return ({ MODULE_PARSER, "Killframe tag", ("Makes pages frameproof." "<br>This module defines a tag," "<pre>" "&lt;killframe&gt;: Adds some java script that will prevent others\n" " from putting your page in a frame.\n\n"
aa899c1997-11-14Peter Bortas  /* " Will also strip any occurences of the string\n" " 'index.html' from the end of the URL." */
2b004e1997-01-25Peter Bortas  "</pre>" ), ({}), 1, }); }
aa899c1997-11-14Peter Bortas string newstyle_tag_killframe( string tag, mapping m, object id ) { /* Links to index.html are ugly. */ string my_url = id->conf->query("MyWorldLocation") + id->raw_url[1..]; int l=strlen(my_url); if( my_url[l-11..] == "/index.html" ) my_url = my_url[..l-11]; if (id->supports->javascript) return("<script language=javascript>\n" "<!--\n" // " if (self != top) top.location = self.location\n" " if (\""+ my_url +"\" != top.location) top.location = \"" + my_url +"\"\n" "//-->" "</script>\n"); return ""; } /* I liked this better, but it caused securityexceptions on newer browsers */
2b004e1997-01-25Peter Bortas string tag_killframe( string tag, mapping m, object id ) {
07bf511997-08-31Peter Bortas  /* Links to index.html are ugly. */
a211d91997-08-10Henrik Grubbström (Grubba)  string my_url = id->conf->query("MyWorldLocation") + id->raw_url[1..];
0cbd1a1997-08-12Peter Bortas  int l=strlen(my_url);
07bf511997-08-31Peter Bortas  if( my_url[l-11..] == "/index.html" )
0cbd1a1997-08-12Peter Bortas  my_url = my_url[..l-11];
07bf511997-08-31Peter Bortas 
2b004e1997-01-25Peter Bortas  if (id->supports->javascript)
1e84351997-08-27Henrik Grubbström (Grubba)  return("<script language=javascript>\n" "<!--\n"
aa899c1997-11-14Peter Bortas  " if(top.location != \""+ my_url +"\")\n" " top.location = \""+ my_url +"\";\n"
1e84351997-08-27Henrik Grubbström (Grubba)  "//-->" "</script>\n"); return "";
2b004e1997-01-25Peter Bortas } mapping query_tag_callers() { return ([ "killframe" : tag_killframe ]); }