OSDN Git Service

BugTrack/2561 Simpify English words - Page list / Page file list
[pukiwiki/pukiwiki.git] / lib / pukiwiki.php
index 168b41d..a784e3c 100644 (file)
@@ -1,32 +1,12 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: pukiwiki.php,v 1.9 2005/06/27 14:12:11 henoheno Exp $
+// pukiwiki.php
+// Copyright
+//   2002-2016 PukiWiki Development Team
+//   2001-2002 Originally written by yu-ji
+// License: GPL v2 or (at your option) any later version
 //
-// PukiWiki 1.4.*
-//  Copyright (C) 2002-2005 by PukiWiki Developers Team
-//  http://pukiwiki.org/
-//
-// PukiWiki 1.3.*
-//  Copyright (C) 2002-2004 by PukiWiki Developers Team
-//  http://pukiwiki.org/
-//
-// PukiWiki 1.3 (Base)
-//  Copyright (C) 2001-2002 by yu-ji <sng@factage.com>
-//  http://factage.com/sng/pukiwiki/
-//
-// Special thanks
-//  YukiWiki by Hiroshi Yuki <hyuki@hyuki.com>
-//  http://www.hyuki.com/yukiwiki/
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// PukiWiki main script
 
 if (! defined('DATA_HOME')) define('DATA_HOME', '');
 
@@ -48,24 +28,30 @@ require(LIB_DIR . 'config.php');
 require(LIB_DIR . 'link.php');
 require(LIB_DIR . 'auth.php');
 require(LIB_DIR . 'proxy.php');
-require(LIB_DIR . 'mail.php');
 if (! extension_loaded('mbstring')) {
        require(LIB_DIR . 'mbstring.php');
 }
 
+// Defaults
+$notify = 0;
+
 // Load *.ini.php files and init PukiWiki
 require(LIB_DIR . 'init.php');
 
 // Load optional libraries
-if ($trackback || $referer) {
-       // Referer functionality uses trackback functions
-       // without functional reason now
-       require(LIB_DIR . 'trackback.php');
+if ($notify) {
+       require(LIB_DIR . 'mail.php'); // Mail notification
 }
 
 /////////////////////////////////////////////////
 // Main
-
+if ($vars['page'] === FALSE) {
+       die_invalid_pagename();
+       exit;
+}
+if (manage_page_redirect()) {
+       exit;
+}
 $retvars = array();
 $is_cmd = FALSE;
 if (isset($vars['cmd'])) {
@@ -77,6 +63,7 @@ if (isset($vars['cmd'])) {
        $plugin = '';
 }
 if ($plugin != '') {
+       ensure_valid_auth_user();
        if (exist_plugin_action($plugin)) {
                // Found and exec
                $retvars = do_plugin_action($plugin);
@@ -89,14 +76,14 @@ if ($plugin != '') {
                }
        } else {
                // Not found
-               $msg = 'plugin=' . htmlspecialchars($plugin) .
+               $msg = 'plugin=' . htmlsc($plugin) .
                        ' is not implemented.';
                $retvars = array('msg'=>$msg,'body'=>$msg);
                $base    = & $defaultpage;
        }
 }
 
-$title = htmlspecialchars(strip_bracket($base));
+$title = htmlsc(strip_bracket($base));
 $page  = make_search($base);
 if (isset($retvars['msg']) && $retvars['msg'] != '') {
        $title = str_replace('$1', $title, $retvars['msg']);
@@ -107,21 +94,18 @@ if (isset($retvars['body']) && $retvars['body'] != '') {
        $body = & $retvars['body'];
 } else {
        if ($base == '' || ! is_page($base)) {
+               check_readable($defaultpage, true, true);
                $base  = & $defaultpage;
-               $title = htmlspecialchars(strip_bracket($base));
+               $title = htmlsc(strip_bracket($base));
                $page  = make_search($base);
        }
 
        $vars['cmd']  = 'read';
        $vars['page'] = & $base;
 
+       prepare_display_materials();
        $body  = convert_html(get_source($base));
-
-       if ($trackback) $body .= tb_get_rdf($base); // Add TrackBack-Ping URI
-       if ($referer) ref_save($base);
 }
 
 // Output
 catbody($title, $page, $body);
-exit;
-?>