bd8fa3 | 1998-04-03 | Peter Bortas | | |
2b004e | 1997-01-25 | Peter Bortas | | *
* Adds some java script that will prevent others from putting
* your page in a frame.
*
|
bd8fa3 | 1998-04-03 | Peter Bortas | | * Will also remove occuranses of "indexfiles" from the end of the URL.
|
2b004e | 1997-01-25 | Peter Bortas | | *
|
0247a3 | 1998-03-11 | David Hedbor | | * made by Peter Bortas <peter@idonex.se> Januari -97
|
aa899c | 1997-11-14 | Peter Bortas | | *
|
bd8fa3 | 1998-04-03 | Peter Bortas | | * Thanks for suggestions and bugreports:
* Barry Treahy <treahy@allianceelec.com>
* Chris Burgess <chris@ibex.co.nz>
|
40b0cf | 1998-04-15 | Peter Bortas | | *
* BUGS:
* Removes document-internal links. (gazink.html#foo)
|
2b004e | 1997-01-25 | Peter Bortas | | */
|
40b0cf | 1998-04-15 | Peter Bortas | | constant cvs_version = "$Id: killframe.pike,v 1.18 1998/04/15 12:00:45 peter Exp $";
|
07bf51 | 1997-08-31 | Peter Bortas | | constant thread_safe=1;
|
6677ac | 1997-08-31 | Peter Bortas | |
|
2b004e | 1997-01-25 | Peter Bortas | | #include <module.h>
inherit "module";
|
93f855 | 1998-04-03 | Peter Bortas | | void create()
{
defvar( "killindex", 1, "Kill trailing 'indexfiles'?", TYPE_FLAG|VAR_MORE,
|
e859de | 1998-04-03 | Peter Bortas | | "When set, the killframe module will remove occurrences of "
|
93f855 | 1998-04-03 | Peter Bortas | | "'indexfiles' (as set in the active directory module) from "
"the end of the URL, leaving only a slash." );
}
|
2b004e | 1997-01-25 | Peter Bortas | |
|
e859de | 1998-04-03 | Peter Bortas | | mixed register_module()
|
2b004e | 1997-01-25 | Peter Bortas | | {
return ({
MODULE_PARSER,
"Killframe tag",
("Makes pages frameproof."
"<br>This module defines a tag,"
"<pre>"
"<killframe>: Adds some java script that will prevent others\n"
" from putting your page in a frame.\n\n"
|
e859de | 1998-04-03 | Peter Bortas | | " Will also strip any occurrences of 'indexfiles'\n"
" from the end of the URL."
|
2b004e | 1997-01-25 | Peter Bortas | | "</pre>"
), ({}), 1,
});
}
string tag_killframe( string tag, mapping m, object id )
{
|
93f855 | 1998-04-03 | Peter Bortas | | string javascript;
|
8756ae | 1998-03-08 | Per Hedbor | | if(m->help) return register_module()[2];
|
93f855 | 1998-04-03 | Peter Bortas | | array indexfiles;
if( id->conf->dir_module )
indexfiles = id->conf->dir_module->query("indexfiles");
|
0cbd1a | 1997-08-12 | Peter Bortas | |
|
93f855 | 1998-04-03 | Peter Bortas | | while( id->misc->orig )
id = id->misc->orig;
|
07bf51 | 1997-08-31 | Peter Bortas | |
|
93f855 | 1998-04-03 | Peter Bortas | | if( query("killindex") )
{
string tmp;
string my_url = id->conf->query("MyWorldLocation");
if( sscanf(my_url, "%s:80/", tmp ) )
my_url = tmp +"/"+ id->not_query[1..];
else
my_url += id->not_query[1..];
|
40b0cf | 1998-04-15 | Peter Bortas | | if(id->query)
my_url += "?"+ id->query;
else
{
int l=strlen(my_url)-1;
foreach( indexfiles, string index )
if( my_url[l-strlen(index)..] == "/" +index )
my_url = my_url[..l-strlen(index)];
}
|
93f855 | 1998-04-03 | Peter Bortas | |
javascript = ( " if(top.location != \""+ my_url +"\")\n"
" top.location = \""+ my_url +"\";\n" );
}
else
javascript = ( " if (self != top) top.location = self.location;\n" );
|
2b004e | 1997-01-25 | Peter Bortas | | if (id->supports->javascript)
|
93f855 | 1998-04-03 | Peter Bortas | | return("<script language=javascript><!--\n"
+ javascript
+ "//--></script>\n");
|
1e8435 | 1997-08-27 | Henrik Grubbström (Grubba) | | return "";
|
2b004e | 1997-01-25 | Peter Bortas | | }
mapping query_tag_callers()
{
return ([ "killframe" : tag_killframe ]);
}
|