return htmlspecialchars($string, $flags, $charset); // htmlsc()
}
+// Redirect from an old page to new page
+function manage_page_redirect() {
+ global $page_redirect_rules, $vars;
+ if (isset($vars['page'])) {
+ $page = $vars['page'];
+ foreach ($page_redirect_rules as $rule => $replace) {
+ if (preg_match($rule, $page)) {
+ if (is_string($replace)) {
+ $new_page = preg_replace($rule, $replace, $page);
+ } elseif (is_object($replace) && is_callable($replace)) {
+ $new_page = preg_replace_callback($rule, $replace, $page);
+ } else {
+ die_message('Invalid redirect rule: ' . $rule . '=>' . $replace);
+ }
+ header('Location: ' . get_script_uri() . '?' .
+ pagename_urlencode($new_page));
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
//// Compat ////
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: pukiwiki.php,v 1.23 2011/01/25 15:01:01 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 Development Team
-// http://pukiwiki.osdn.jp/
-//
-// PukiWiki 1.3.*
-// Copyright (C) 2002-2004 by PukiWiki Development Team
-// http://pukiwiki.osdn.jp/
-//
-// 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', '');
/////////////////////////////////////////////////
// Main
-
+if (manage_page_redirect()) {
+ exit;
+}
$retvars = array();
$is_cmd = FALSE;
if (isset($vars['cmd'])) {
// Output
catbody($title, $page, $body);
-exit;
// Search ignored pages
$search_non_list = 1;
+
+// Page redirect rules
+$page_redirect_rules = array(
+ //'#^FromProject($|(/(.+)$))#' => 'ToProject$1',
+ //'#^FromProject($|(/(.+)$))#' => function($matches) { return 'ToProject' . $matches[1]; },
+);
+
/////////////////////////////////////////////////
// Template setting