X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=plugin%2Finterwiki.inc.php;h=02ba97b850eb447eb9a86f45d3d1c3ef651c0ba7;hb=e856ef40a5b38d8dc3e482d962c911563d84f131;hp=675c098d5bf9e17cf809c5f33fab9b7020a93468;hpb=1766d38bbdc7f2c6d4934300d58ea3ae81b0dfee;p=pukiwiki%2Fpukiwiki.git diff --git a/plugin/interwiki.inc.php b/plugin/interwiki.inc.php index 675c098..02ba97b 100644 --- a/plugin/interwiki.inc.php +++ b/plugin/interwiki.inc.php @@ -1,93 +1,35 @@ InterWikiName",$_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',"InterWikiName",$_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',SOURCE_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 +?>