OSDN Git Service

Simplify
[pukiwiki/pukiwiki.git] / lib / pukiwiki.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: pukiwiki.php,v 1.6 2005/04/10 04:46:05 henoheno Exp $
4 // $Id: pukiwiki.php,v 1.6 2005/04/10 04:46:05 henoheno Exp $
5 //
6 // PukiWiki 1.4.*
7 //  Copyright (C) 2002-2005 by PukiWiki Developers Team
8 //  http://pukiwiki.org/
9 //
10 // PukiWiki 1.3.*
11 //  Copyright (C) 2002-2004 by PukiWiki Developers Team
12 //  http://pukiwiki.org/
13 //
14 // PukiWiki 1.3 (Base)
15 //  Copyright (C) 2001-2002 by yu-ji <sng@factage.com>
16 //  http://factage.com/sng/pukiwiki/
17 //
18 // Special thanks
19 //  YukiWiki by Hiroshi Yuki <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 if (! defined('DATA_HOME')) define('DATA_HOME', '');
33
34 /////////////////////////////////////////////////
35 // Include subroutines
36
37 if (! defined('LIB_DIR')) define('LIB_DIR', '');
38
39 require(LIB_DIR . 'func.php');
40 require(LIB_DIR . 'file.php');
41 require(LIB_DIR . 'plugin.php');
42 require(LIB_DIR . 'html.php');
43 require(LIB_DIR . 'backup.php');
44
45 require(LIB_DIR . 'convert_html.php');
46 require(LIB_DIR . 'make_link.php');
47 require(LIB_DIR . 'diff.php');
48 require(LIB_DIR . 'config.php');
49 require(LIB_DIR . 'link.php');
50 require(LIB_DIR . 'trackback.php');
51 require(LIB_DIR . 'auth.php');
52 require(LIB_DIR . 'proxy.php');
53 require(LIB_DIR . 'mail.php');
54 if (! extension_loaded('mbstring')) {
55         require(LIB_DIR . 'mbstring.php');
56 }
57
58 // Load *.ini.php files and init PukiWiki
59 require(LIB_DIR . 'init.php');
60
61 /////////////////////////////////////////////////
62 // Main
63
64 $retvars = array();
65 $is_cmd = FALSE;
66 if (isset($vars['cmd'])) {
67         $is_cmd  = TRUE;
68         $plugin = & $vars['cmd'];
69 } else if (isset($vars['plugin'])) {
70         $plugin = & $vars['plugin'];
71 } else {
72         $plugin = '';
73 }
74 if ($plugin != '') {
75         if (exist_plugin_action($plugin)) {
76                 // Found and exec
77                 $retvars = do_plugin_action($plugin);
78                 if ($retvars === FALSE) exit; // Done
79
80                 if ($is_cmd) {
81                         $base = isset($vars['page'])  ? $vars['page']  : '';
82                 } else {
83                         $base = isset($vars['refer']) ? $vars['refer'] : '';
84                 }
85         } else {
86                 // Not found
87                 $msg = 'plugin=' . htmlspecialchars($plugin) .
88                         ' is not implemented.';
89                 $retvars = array('msg'=>$msg,'body'=>$msg);
90                 $base    = & $defaultpage;
91         }
92 }
93
94 $title = htmlspecialchars(strip_bracket($base));
95 $page  = make_search($base);
96 if (isset($retvars['msg']) && $retvars['msg'] != '') {
97         $title = str_replace('$1', $title, $retvars['msg']);
98         $page  = str_replace('$1', $page,  $retvars['msg']);
99 }
100
101 if (isset($retvars['body']) && $retvars['body'] != '') {
102         $body = & $retvars['body'];
103 } else {
104         if ($base == '' || ! is_page($base)) {
105                 $base  = & $defaultpage;
106                 $title = htmlspecialchars(strip_bracket($base));
107                 $page  = make_search($base);
108         }
109
110         $vars['cmd']  = 'read';
111         $vars['page'] = & $base;
112
113         $body  = convert_html(get_source($base));
114         $body .= tb_get_rdf($base);
115         ref_save($base);
116 }
117
118 // Output
119 catbody($title, $page, $body);
120 exit;
121 ?>