]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RawHtml.php
Fix security bugs in the RawHtml plugin.
[SourceForge/phpwiki.git] / lib / plugin / RawHtml.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RawHtml.php,v 1.6 2003-03-17 21:24:53 dairiki Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
8  PhpWiki is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  PhpWiki is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with PhpWiki; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 // Define ENABLE_RAW_HTML to false (in index.php) to disable the RawHtml plugin.
24 //
25 if (!defined('ENABLE_RAW_HTML'))
26     define('ENABLE_RAW_HTML', true);
27
28 /**
29  * A plugin to provide for raw HTML within wiki pages.
30  */
31 class WikiPlugin_RawHtml
32 extends WikiPlugin
33 {
34     function getName () {
35         return "RawHtml";
36     }
37
38     function getDescription () {
39         return _("A plugin to provide for raw HTML within wiki pages.");
40     }
41
42     function getVersion() {
43         return preg_replace("/[Revision: $]/", '',
44                             "\$Revision: 1.6 $");
45     }
46
47     function run($dbi, $argstr, &$request, $basepage) {
48         if (!defined('ENABLE_RAW_HTML') || ! ENABLE_RAW_HTML) {
49             return $this->disabled(_("Raw HTML is disabled in this wiki."));
50         }
51         if (!$basepage) {
52             return $this->error("$basepage unset?");
53         }
54         
55         $page = $request->getPage($basepage);
56
57         if (! $page->get('locked')) {
58             return $this->disabled(fmt(_("%s is only allowed in locked pages."),
59                                        _("Raw HTML")));
60         }
61
62         return HTML::raw($argstr);
63     }
64 }
65
66 // $Log: not supported by cvs2svn $
67 // Revision 1.5  2003/01/18 22:01:43  carstenklapp
68 // Code cleanup:
69 // Reformatting & tabs to spaces;
70 // Added copyleft, getVersion, getDescription, rcs_id.
71 //
72
73 // For emacs users
74 // Local Variables:
75 // mode: php
76 // tab-width: 8
77 // c-basic-offset: 4
78 // c-hanging-comment-ender-p: nil
79 // indent-tabs-mode: nil
80 // End:
81 ?>