OSDN Git Service

Cleanup.
[pukiwiki/pukiwiki.git] / lib / pukiwiki.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 //
4 // PukiWiki 1.4.*
5 //  Copyright (C) 2002 by PukiWiki Developers Team
6 //  http://pukiwiki.org/
7 //
8 // PukiWiki 1.3.*
9 //  Copyright (C) 2002 by PukiWiki Developers Team
10 //  http://pukiwiki.org/
11 //
12 // PukiWiki 1.3 (Base)
13 //  Copyright (C) 2001,2002 by sng.
14 //  <sng@factage.com>
15 //  http://factage.com/sng/pukiwiki/
16 //
17 // Special thanks
18 //  YukiWiki by Hiroshi Yuki
19 //  <hyuki@hyuki.com>
20 //  http://www.hyuki.com/yukiwiki/
21 //
22 // This program is free software; you can redistribute it and/or modify
23 // it under the terms of the GNU General Public License as published by
24 // the Free Software Foundation; either version 2 of the License, or
25 // (at your option) any later version.
26 //
27 // This program is distributed in the hope that it will be useful,
28 // but WITHOUT ANY WARRANTY; without even the implied warranty of
29 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30 // GNU General Public License for more details.
31 //
32 // $Id: pukiwiki.php,v 1.4 2004/10/10 12:58:30 henoheno Exp $
33 /////////////////////////////////////////////////
34
35 /////////////////////////////////////////////////
36 // ¥Ç¡¼¥¿¤ò³ÊǼ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤äÀßÄê¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê
37
38 if (! defined('DATA_HOME')) define('DATA_HOME', '');
39
40 /////////////////////////////////////////////////
41 // ¥µ¥Ö¥ë¡¼¥Á¥ó¤Î³ÊǼÀè¥Ç¥£¥ì¥¯¥È¥ê (¾¤Î *.php¥Õ¥¡¥¤¥ë)
42
43 if (! defined('LIB_DIR')) define('LIB_DIR', '');
44
45 /////////////////////////////////////////////////
46 // Include subroutines
47
48 require(LIB_DIR . 'func.php');
49 require(LIB_DIR . 'file.php');
50 require(LIB_DIR . 'plugin.php');
51 require(LIB_DIR . 'html.php');
52 require(LIB_DIR . 'backup.php');
53
54 require(LIB_DIR . 'convert_html.php');
55 require(LIB_DIR . 'make_link.php');
56 require(LIB_DIR . 'diff.php');
57 require(LIB_DIR . 'config.php');
58 require(LIB_DIR . 'link.php');
59 require(LIB_DIR . 'trackback.php');
60 require(LIB_DIR . 'auth.php');
61 require(LIB_DIR . 'proxy.php');
62 require(LIB_DIR . 'mail.php');
63 if (! extension_loaded('mbstring')) {
64         require(LIB_DIR . 'mbstring.php');
65 }
66
67 // ½é´ü²½: ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß
68 require(LIB_DIR . 'init.php');
69
70 /////////////////////////////////////////////////
71 // Main
72
73 $base    = $defaultpage;
74 $retvars = array();
75
76 if (isset($vars['plugin'])) {
77         // Plug-in action
78         if (! exist_plugin_action($vars['plugin'])) {
79                 $s_plugin = htmlspecialchars($vars['plugin']);
80                 $msg      = "plugin=$s_plugin is not implemented.";
81                 $retvars  = array('msg'=>$msg,'body'=>$msg);
82         } else {
83                 $retvars  = do_plugin_action($vars['plugin']);
84                 if ($retvars !== FALSE)
85                         $base = isset($vars['refer']) ? $vars['refer'] : '';
86         }
87
88 } else if (isset($vars['cmd'])) {
89         // Command action
90         if (! exist_plugin_action($vars['cmd'])) {
91                 $s_cmd   = htmlspecialchars($vars['cmd']);
92                 $msg     = "cmd=$s_cmd is not implemented.";
93                 $retvars = array('msg'=>$msg,'body'=>$msg);
94         } else {
95                 $retvars = do_plugin_action($vars['cmd']);
96                 $base    = $vars['page'];
97         }
98 }
99
100 if ($retvars !== FALSE) {
101         $title = htmlspecialchars(strip_bracket($base));
102         $page  = make_search($base);
103
104         if (isset($retvars['msg']) && $retvars['msg'] != '') {
105                 $title = str_replace('$1', $title, $retvars['msg']);
106                 $page  = str_replace('$1', $page,  $retvars['msg']);
107         }
108
109         if (isset($retvars['body']) && $retvars['body'] != '') {
110                 $body = $retvars['body'];
111         } else {
112                 if ($base == '' || ! is_page($base)) {
113                         $base  = $defaultpage;
114                         $title = htmlspecialchars(strip_bracket($base));
115                         $page  = make_search($base);
116                 }
117
118                 $vars['cmd']  = 'read';
119                 $vars['page'] = $base;
120                 $body  = convert_html(get_source($base));
121                 $body .= tb_get_rdf($vars['page']);
122                 ref_save($vars['page']);
123         }
124
125         // Output
126         catbody($title, $page, $body);
127 }
128 // End
129 ?>