OSDN Git Service

Don't call tb_get_rdf() and/or ref_save() without clear reason
[pukiwiki/pukiwiki.git] / lib / pukiwiki.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: pukiwiki.php,v 1.8 2005/04/10 08:06:03 henoheno Exp $
4 //
5 // PukiWiki 1.4.*
6 //  Copyright (C) 2002-2005 by PukiWiki Developers Team
7 //  http://pukiwiki.org/
8 //
9 // PukiWiki 1.3.*
10 //  Copyright (C) 2002-2004 by PukiWiki Developers Team
11 //  http://pukiwiki.org/
12 //
13 // PukiWiki 1.3 (Base)
14 //  Copyright (C) 2001-2002 by yu-ji <sng@factage.com>
15 //  http://factage.com/sng/pukiwiki/
16 //
17 // Special thanks
18 //  YukiWiki by Hiroshi Yuki <hyuki@hyuki.com>
19 //  http://www.hyuki.com/yukiwiki/
20 //
21 // This program is free software; you can redistribute it and/or modify
22 // it under the terms of the GNU General Public License as published by
23 // the Free Software Foundation; either version 2 of the License, or
24 // (at your option) any later version.
25 //
26 // This program is distributed in the hope that it will be useful,
27 // but WITHOUT ANY WARRANTY; without even the implied warranty of
28 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 // GNU General Public License for more details.
30
31 if (! defined('DATA_HOME')) define('DATA_HOME', '');
32
33 /////////////////////////////////////////////////
34 // Include subroutines
35
36 if (! defined('LIB_DIR')) define('LIB_DIR', '');
37
38 require(LIB_DIR . 'func.php');
39 require(LIB_DIR . 'file.php');
40 require(LIB_DIR . 'plugin.php');
41 require(LIB_DIR . 'html.php');
42 require(LIB_DIR . 'backup.php');
43
44 require(LIB_DIR . 'convert_html.php');
45 require(LIB_DIR . 'make_link.php');
46 require(LIB_DIR . 'diff.php');
47 require(LIB_DIR . 'config.php');
48 require(LIB_DIR . 'link.php');
49 require(LIB_DIR . 'trackback.php');
50 require(LIB_DIR . 'auth.php');
51 require(LIB_DIR . 'proxy.php');
52 require(LIB_DIR . 'mail.php');
53 if (! extension_loaded('mbstring')) {
54         require(LIB_DIR . 'mbstring.php');
55 }
56
57 // Load *.ini.php files and init PukiWiki
58 require(LIB_DIR . 'init.php');
59
60 /////////////////////////////////////////////////
61 // Main
62
63 $retvars = array();
64 $is_cmd = FALSE;
65 if (isset($vars['cmd'])) {
66         $is_cmd  = TRUE;
67         $plugin = & $vars['cmd'];
68 } else if (isset($vars['plugin'])) {
69         $plugin = & $vars['plugin'];
70 } else {
71         $plugin = '';
72 }
73 if ($plugin != '') {
74         if (exist_plugin_action($plugin)) {
75                 // Found and exec
76                 $retvars = do_plugin_action($plugin);
77                 if ($retvars === FALSE) exit; // Done
78
79                 if ($is_cmd) {
80                         $base = isset($vars['page'])  ? $vars['page']  : '';
81                 } else {
82                         $base = isset($vars['refer']) ? $vars['refer'] : '';
83                 }
84         } else {
85                 // Not found
86                 $msg = 'plugin=' . htmlspecialchars($plugin) .
87                         ' is not implemented.';
88                 $retvars = array('msg'=>$msg,'body'=>$msg);
89                 $base    = & $defaultpage;
90         }
91 }
92
93 $title = htmlspecialchars(strip_bracket($base));
94 $page  = make_search($base);
95 if (isset($retvars['msg']) && $retvars['msg'] != '') {
96         $title = str_replace('$1', $title, $retvars['msg']);
97         $page  = str_replace('$1', $page,  $retvars['msg']);
98 }
99
100 if (isset($retvars['body']) && $retvars['body'] != '') {
101         $body = & $retvars['body'];
102 } else {
103         if ($base == '' || ! is_page($base)) {
104                 $base  = & $defaultpage;
105                 $title = htmlspecialchars(strip_bracket($base));
106                 $page  = make_search($base);
107         }
108
109         $vars['cmd']  = 'read';
110         $vars['page'] = & $base;
111
112         $body  = convert_html(get_source($base));
113
114         if ($trackback) $body .= tb_get_rdf($base); // Add TrackBack-Ping URI
115         if ($referer) ref_save($base);
116 }
117
118 // Output
119 catbody($title, $page, $body);
120 exit;
121 ?>