0e834c | 2000-02-24 | Martin Nilsson | | |
2b004e | 1997-01-25 | Peter Bortas | | *
* Adds some java script that will prevent others from putting
* your page in a frame.
|
30338e | 1999-11-29 | Martin Nilsson | | *
|
bd8fa3 | 1998-04-03 | Peter Bortas | | * Will also remove occuranses of "indexfiles" from the end of the URL.
|
30338e | 1999-11-29 | Martin Nilsson | | *
|
0e834c | 2000-02-24 | Martin Nilsson | | * made by Peter Bortas <peter@roxen.com> 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>
|
2b004e | 1997-01-25 | Peter Bortas | | */
|
b32070 | 2000-11-02 | Kenneth Johansson | | constant cvs_version = "$Id: killframe.pike,v 1.32 2000/11/02 13:12:17 kuntri 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()
{
|
59ae15 | 2000-04-06 | Mattias Wingstedt | | defvar( "killindex", 1, "Remove index files from the URL", TYPE_FLAG,
"If set, the module will remove occurrences of any index file from "
"the end of the URL, leaving only a slash. The index file "
"definition is taken from the active directory module." );
|
93f855 | 1998-04-03 | Peter Bortas | | }
|
2b004e | 1997-01-25 | Peter Bortas | |
|
b3281f | 2000-09-10 | Martin Nilsson | | constant module_type = MODULE_TAG;
|
59ae15 | 2000-04-06 | Mattias Wingstedt | | constant module_name = "Kill frame";
|
197355 | 2000-02-10 | Martin Nilsson | | constant module_doc = "This module defines a the tag <killframe> that "
|
59ae15 | 2000-04-06 | Mattias Wingstedt | | "adds some JavaScript that will prevent others "
"from putting the page in a frame. It can "
"also strip any occurrences of index files, like <tt>index.html</tt>, "
|
399fbc | 1999-12-08 | Martin Nilsson | | "from the end of the URL.";
TAGDOCUMENTATION
#ifdef manual
|
b32070 | 2000-11-02 | Kenneth Johansson | | constant tagdoc=(["killframe":#"<desc tag='tag'><p><short>
|
baf02c | 2000-04-15 | Per Hedbor | | This tag adds some JavaScript that will prevent others from putting
the page in a frame.</short> It can also strip any occurrences of
index files, like <ext>index.html</ext>, from the end of the
|
b32070 | 2000-11-02 | Kenneth Johansson | | URL.</p></desc>
|
baf02c | 2000-04-15 | Per Hedbor | |
<attr name=killindex>Removes trailing index.html from the URL</attr>",
]);
|
399fbc | 1999-12-08 | Martin Nilsson | | #endif
|
2b004e | 1997-01-25 | Peter Bortas | | string tag_killframe( string tag, mapping m, object id )
{
|
3f094d | 1998-08-10 | Per Hedbor | | NOCACHE();
|
6b56dc | 1998-06-06 | Peter Bortas | | if( !id->supports->javascript ) return "";
|
30338e | 1999-11-29 | Martin Nilsson | |
|
6b56dc | 1998-06-06 | Peter Bortas | | string javascript;
|
30338e | 1999-11-29 | Martin Nilsson | |
|
93f855 | 1998-04-03 | Peter Bortas | | while( id->misc->orig )
id = id->misc->orig;
|
30338e | 1999-11-29 | Martin Nilsson | |
|
6b56dc | 1998-06-06 | Peter Bortas | |
string tmp;
|
ceccc0 | 1998-08-01 | Peter Bortas | | string prestate;
|
6b56dc | 1998-06-06 | Peter Bortas | | string my_url = id->conf->query("MyWorldLocation");
|
ceccc0 | 1998-08-01 | Peter Bortas | |
if( sscanf(id->raw_url, "/(%s)", tmp) )
prestate = "("+ tmp +")/";
|
6b56dc | 1998-06-06 | Peter Bortas | | if( sscanf(my_url, "%s:80/", tmp ) )
|
ceccc0 | 1998-08-01 | Peter Bortas | | my_url = tmp +"/"+ (prestate?prestate:"") + id->not_query[1..];
|
6b56dc | 1998-06-06 | Peter Bortas | | else
|
ceccc0 | 1998-08-01 | Peter Bortas | | my_url += (prestate?prestate:"") + id->not_query[1..];
|
30338e | 1999-11-29 | Martin Nilsson | |
|
6b56dc | 1998-06-06 | Peter Bortas | |
|
485b56 | 1999-11-29 | Martin Nilsson | | if( query("killindex") || m->killindex )
|
93f855 | 1998-04-03 | Peter Bortas | | {
|
6b56dc | 1998-06-06 | Peter Bortas | |
array indexfiles = ({});
if( id->conf->dir_module )
indexfiles = id->conf->dir_module->query("indexfiles");
|
93f855 | 1998-04-03 | Peter Bortas | |
|
6b56dc | 1998-06-06 | Peter Bortas | | int l=strlen(my_url)-1;
|
30338e | 1999-11-29 | Martin Nilsson | |
|
6b56dc | 1998-06-06 | Peter Bortas | | foreach( indexfiles, string index )
if( my_url[l-strlen(index)..] == "/" +index )
my_url = my_url[..l-strlen(index)];
|
93f855 | 1998-04-03 | Peter Bortas | | }
|
6b56dc | 1998-06-06 | Peter Bortas | |
if(id->query)
my_url += "?"+ id->query;
|
93f855 | 1998-04-03 | Peter Bortas | |
|
ceccc0 | 1998-08-01 | Peter Bortas | |
if( id->client && id->client[0][..8] == "Mozilla/3" )
javascript = ( " if(top.location != \""+ my_url +"\")\n"
" top.location = \""+ my_url +"\";\n" );
else
javascript = ( " if(top.frames.length>1)\n"
" top.location = \""+ my_url +"\";\n" );
|
a4f2a4 | 1999-07-21 | Martin Nilsson | | return("<script language=\"javascript\"><!--\n"
|
6b56dc | 1998-06-06 | Peter Bortas | | + javascript
+ "//--></script>\n");
|
2b004e | 1997-01-25 | Peter Bortas | | }
|