<?php
-/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
+// $Id: interwiki.inc.php,v 1.10 2004/12/04 14:48:32 henoheno Exp $
//
-// $Id: interwiki.inc.php,v 1.1 2003/01/27 05:38:46 panda Exp $
-//
-// InterWikiName¤ÎȽÊ̤ȥڡ¼¥¸¤Îɽ¼¨
+// InterWiki redirection plugin (OBSOLETE)
+
function plugin_interwiki_action()
{
- global $script,$vars,$interwiki,$WikiName,$InterWikiName;
- global $_title_invalidiwn,$_msg_invalidiwn;
-
- $retvars = array();
-
- if (!preg_match("/^$InterWikiName$/",$vars['page'],$match)) {
- $retvars['msg'] = $_title_invalidiwn;
- $retvars['body'] = str_replace('$1',htmlspecialchars($name),str_replace('$2',"<a href=\"$script?InterWikiName\">InterWikiName</a>",$_msg_invalidiwn));
- return $retvars;
- }
- $name = $match[2];
- $param = $match[3];
-
- $url = $opt = '';
- $source = get_source($interwiki);
- foreach($source as $line) {
- // <1 url --------------------------------------------------------------> <2 name> <3 opt >
- if (preg_match('/\[((?:https?|ftp|news)(?:\:\/\/[[:alnum:]\+\$\;\?\.%,!#~\*\/\:@&=_\-]+))\s([^\]]+)\]\s?([^\s]*)/',$line,$match) and $match[2] == $name) {
- $url = $match[1];
- $opt = $match[3];
- break;
- }
- }
-
- if ($url == '') {
- $retvars['msg'] = $_title_invalidiwn;
- $retvars['body'] = str_replace('$1',htmlspecialchars($name),str_replace('$2',"<a href=\"$script?InterWikiName\">InterWikiName</a>",$_msg_invalidiwn));
- return $retvars;
- }
-
- $b_mb = function_exists('mb_convert_encoding');
-
- // ʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
- if ($opt == 'yw')
- {
- // YukiWiki·Ï
- if (!preg_match("/$WikiName/",$param))
- $param = $b_mb ? '[['.mb_convert_encoding($param,'SJIS',ENCODING).']]' : FALSE;
- }
- else if ($opt == 'moin')
- {
- // moin·Ï
- $param = str_replace('%','_',rawurlencode($param));
- }
- else if ($opt == '' or $opt == 'std')
- {
- // ÆâÉôʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î¤Þ¤ÞURL¥¨¥ó¥³¡¼¥É
- $param = rawurlencode($param);
- }
- else if ($opt == 'asis' or $opt == 'raw')
- {
- // URL¥¨¥ó¥³¡¼¥É¤·¤Ê¤¤
-// $match[3] = $match[3];
- }
- else if ($opt != '')
- {
- // ¥¨¥¤¥ê¥¢¥¹¤ÎÊÑ´¹
- if ($opt == 'sjis')
- $opt = 'SJIS';
- else if ($opt == 'euc')
- $opt = 'EUC-JP';
- else if ($opt == 'utf8')
- $opt = 'UTF-8';
+ global $vars, $InterWikiName;
- // ¤½¤Î¾¡¢»ØÄꤵ¤ì¤¿Ê¸»ú¥³¡¼¥É¤Ø¥¨¥ó¥³¡¼¥É¤·¤ÆURL¥¨¥ó¥³¡¼¥É
- $param = $b_mb ? rawurlencode(mb_convert_encoding($param,$opt,'auto')) : FALSE;
- }
+ if (PKWK_SAFE_MODE) die_message('InterWiki plugin is not allowed');
- if ($param === FALSE)
- {
- $retvars['msg'] = 'Not support mb_convert_encoding.';
- $retvars['body'] = 'This server\'s PHP does not have "mb_jstring" module. Cannot convert encoding.';
- return $retvars;
- }
+ $match = array();
+ if (! preg_match("/^$InterWikiName$/", $vars['page'], $match))
+ return plugin_interwiki_invalid();
- if (strpos($url,'$1') !== FALSE)
- $url = str_replace('$1',$param,$url);
- else
- $url .= $param;
+ $url = get_interwiki_url($match[2], $match[3]);
+ if ($url === FALSE) return plugin_interwiki_invalid();
- header("Location: $url");
- die();
+ pkwk_headers_sent();
+ header('Location: ' . $url);
+ exit;
+}
+
+function plugin_interwiki_invalid()
+{
+ global $_title_invalidiwn, $_msg_invalidiwn;
+ return array(
+ 'msg' => $_title_invalidiwn,
+ 'body' => str_replace(array('$1', '$2'),
+ array(htmlspecialchars(''),
+ make_pagelink('InterWikiName')),
+ $_msg_invalidiwn));
}
-?>
\ No newline at end of file
+?>