OSDN Git Service

BugTrack2/139: Correct. Deleted a first space at preview.
[pukiwiki/pukiwiki.git] / plugin / source.inc.php
index 63e3658..9223da0 100644 (file)
@@ -1,31 +1,25 @@
 <?php
-/////////////////////////////////////////////////
-// PukiWiki - Yet another WikiWikiWeb clone.
+// PukiWiki - Yet another WikiWikiWeb clone
+// $Id: source.inc.php,v 1.14 2005/01/29 02:07:58 henoheno Exp $
 //
-// $Id: source.inc.php,v 1.9 2003/07/03 05:25:53 arino Exp $
-//
-// ¥Ú¡¼¥¸¥½¡¼¥¹¤òɽ¼¨
+// Source plugin
 
+// Output source text of the page
 function plugin_source_action()
 {
-       global $vars;
-       global $_source_messages;
-       
-       $vars['refer'] = $vars['page'];
-       
-       if (!is_page($vars['page']))
-       {
-               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($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">' .
+               htmlspecialchars(join('', get_source($page))) . '</pre>');
 }
 ?>