<?php
-// $Id: source.inc.php,v 1.6 2003/02/18 04:30:32 panda Exp $
+// PukiWiki - Yet another WikiWikiWeb clone
+// $Id: source.inc.php,v 1.14 2005/01/29 02:07:58 henoheno Exp $
+//
+// Source plugin
+// Output source text of the page
function plugin_source_action()
{
- global $vars;
-
- header('Content-type: text/plain; charset="'.SOURCE_ENCODING.'"');
- echo join('',get_source($vars['page']));
-
- die();
-}
+ global $vars, $_source_messages;
+
+ if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this');
+
+ $page = isset($vars['page']) ? $vars['page'] : '';
+ $vars['refer'] = $page;
+ if (! is_page($page) || ! check_readable($page, false, false))
+ return array('msg' => $_source_messages['msg_notfound'],
+ 'body' => $_source_messages['err_notfound']);
+
+ return array('msg' => $_source_messages['msg_title'],
+ 'body' => '<pre id="source">' .
+ htmlspecialchars(join('', get_source($page))) . '</pre>');
+}
?>