1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
/* This is a roxen module. Copyright © 1996 - 1998, Idonex AB. 
 * 
 * Adds some java script that will prevent others from putting 
 * your page in a frame. 
 *  
 * Will also remove occuranses of "index.html" at the end of the URL. 
 *  
 * made by Peter Bortas <peter@idonex.se> Januari -97 
 * 
 * Thanks to  
 */ 
 
constant cvs_version = "$Id: killframe.pike,v 1.14 1998/03/11 19:42:43 neotron Exp $"; 
constant thread_safe=1; 
 
#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" 
       /*       "             Will also strip any occurences of the string\n" 
                "             'index.html' from the end of the URL." */ 
       "</pre>" 
       ), ({}), 1, 
    }); 
} 
 
string tag_killframe( string tag, mapping m, object id ) 
{ 
  /* Links to index.html are ugly. */ 
  if(m->help) return register_module()[2]; 
 
  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(top.location != \""+ my_url  +"\")\n" 
           "     top.location = \""+ my_url  +"\";\n" 
           "//-->" 
           "</script>\n"); 
  return ""; 
} 
 
mapping query_tag_callers() 
{ 
  return ([ "killframe" : tag_killframe ]); 
}