OSDN Git Service

BugTrack/2418 Delete blank page even if it has only small changes
[pukiwiki/pukiwiki.git] / plugin / source.inc.php
index f6cdf01..f213dfc 100644 (file)
@@ -1,32 +1,25 @@
 <?php
-/////////////////////////////////////////////////
-// PukiWiki - Yet another WikiWikiWeb clone.
+// PukiWiki - Yet another WikiWikiWeb clone
+// $Id: source.inc.php,v 1.16 2011/01/25 15:01:01 henoheno Exp $
 //
-// $Id: source.inc.php,v 1.7 2003/03/13 05:31:16 panda Exp $
-//
-// ¥Ú¡¼¥¸¥½¡¼¥¹¤òɽ¼¨
-
-function plugin_source_init()
-{
-       $messages = array(
-               '_source_messages'=>array(
-               'msg_title' => '$1¤Î¥½¡¼¥¹'
-               )
-       );
-       set_plugin_messages($messages);
-}
+// Source plugin
 
+// Output source text of the page
 function plugin_source_action()
 {
-       global $vars;
-       global $_source_messages;
-       
-       return array(
-               'msg'=>$_source_messages['msg_title'],
-               'body' =>
-                       '<pre id="source">'.
-                       htmlspecialchars(join('',get_source($vars['page']))).
-                       '</pre>'
-       );
+       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">' .
+               htmlsc(join('', get_source($page))) . '</pre>');
 }
 ?>