• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンfd549e4343007a525b7e68d5227842c84888f0b8 (tree)
日時2016-11-15 02:40:00
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/2396 Redirect pages by Site Administrator

Add new property - $page_redirect_rules in pukiwiki.ini.php

変更サマリ

差分

--- a/lib/func.php
+++ b/lib/func.php
@@ -730,6 +730,29 @@ function htmlsc($string = '', $flags = ENT_COMPAT, $charset = CONTENT_CHARSET)
730730 return htmlspecialchars($string, $flags, $charset); // htmlsc()
731731 }
732732
733+// Redirect from an old page to new page
734+function manage_page_redirect() {
735+ global $page_redirect_rules, $vars;
736+ if (isset($vars['page'])) {
737+ $page = $vars['page'];
738+ foreach ($page_redirect_rules as $rule => $replace) {
739+ if (preg_match($rule, $page)) {
740+ if (is_string($replace)) {
741+ $new_page = preg_replace($rule, $replace, $page);
742+ } elseif (is_object($replace) && is_callable($replace)) {
743+ $new_page = preg_replace_callback($rule, $replace, $page);
744+ } else {
745+ die_message('Invalid redirect rule: ' . $rule . '=>' . $replace);
746+ }
747+ header('Location: ' . get_script_uri() . '?' .
748+ pagename_urlencode($new_page));
749+ return TRUE;
750+ }
751+ }
752+ }
753+ return FALSE;
754+}
755+
733756
734757 //// Compat ////
735758
--- a/lib/pukiwiki.php
+++ b/lib/pukiwiki.php
@@ -1,32 +1,12 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: pukiwiki.php,v 1.23 2011/01/25 15:01:01 henoheno Exp $
3+// pukiwiki.php
4+// Copyright
5+// 2002-2016 PukiWiki Development Team
6+// 2001-2002 Originally written by yu-ji
7+// License: GPL v2 or (at your option) any later version
48 //
5-// PukiWiki 1.4.*
6-// Copyright (C) 2002-2005 by PukiWiki Development Team
7-// http://pukiwiki.osdn.jp/
8-//
9-// PukiWiki 1.3.*
10-// Copyright (C) 2002-2004 by PukiWiki Development Team
11-// http://pukiwiki.osdn.jp/
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.
9+// PukiWiki main script
3010
3111 if (! defined('DATA_HOME')) define('DATA_HOME', '');
3212
@@ -65,7 +45,9 @@ if ($notify) {
6545
6646 /////////////////////////////////////////////////
6747 // Main
68-
48+if (manage_page_redirect()) {
49+ exit;
50+}
6951 $retvars = array();
7052 $is_cmd = FALSE;
7153 if (isset($vars['cmd'])) {
@@ -121,4 +103,3 @@ if (isset($retvars['body']) && $retvars['body'] != '') {
121103
122104 // Output
123105 catbody($title, $page, $body);
124-exit;
--- a/pukiwiki.ini.php
+++ b/pukiwiki.ini.php
@@ -419,6 +419,13 @@ $non_list = '^\:';
419419 // Search ignored pages
420420 $search_non_list = 1;
421421
422+
423+// Page redirect rules
424+$page_redirect_rules = array(
425+ //'#^FromProject($|(/(.+)$))#' => 'ToProject$1',
426+ //'#^FromProject($|(/(.+)$))#' => function($matches) { return 'ToProject' . $matches[1]; },
427+);
428+
422429 /////////////////////////////////////////////////
423430 // Template setting
424431