<?php
-/////////////////////////////////////////////////
-// PukiWiki - Yet another WikiWikiWeb clone.
-//
-// $Id: ref.inc.php,v 1.41 2004/09/21 11:57:23 henoheno Exp $
+// PukiWiki - Yet another WikiWikiWeb clone
+// $Id: ref.inc.php,v 1.51 2011/01/25 15:01:01 henoheno Exp $
+// Copyright (C)
+// 2002-2006 PukiWiki Developers Team
+// 2001-2002 Originally written by yu-ji
+// License: GPL v2 or (at your option) any later version
//
+// Image refernce plugin
// Include an attached image-file as an inline-image
+// File icon image
+if (! defined('FILE_ICON'))
+ define('FILE_ICON',
+ '<img src="' . IMAGE_DIR . 'file.png" width="20" height="20"' .
+ ' alt="file" style="border-width:0px" />');
+
+/////////////////////////////////////////////////
+// Default settings
+
+// Horizontal alignment
+define('PLUGIN_REF_DEFAULT_ALIGN', 'left'); // 'left', 'center', 'right'
+
+// Text wrapping
+define('PLUGIN_REF_WRAP_TABLE', FALSE); // TRUE, FALSE
+
+// URL»ØÄê»þ¤Ë²èÁü¥µ¥¤¥º¤ò¼èÆÀ¤¹¤ë¤«
+define('PLUGIN_REF_URL_GET_IMAGE_SIZE', FALSE); // FALSE, TRUE
+
// UPLOAD_DIR ¤Î¥Ç¡¼¥¿(²èÁü¥Õ¥¡¥¤¥ë¤Î¤ß)¤ËľÀÜ¥¢¥¯¥»¥¹¤µ¤»¤ë
define('PLUGIN_REF_DIRECT_ACCESS', FALSE); // FALSE or TRUE
// - ¤³¤ì¤Ï½¾Íè¤Î¥¤¥ó¥é¥¤¥ó¥¤¥á¡¼¥¸½èÍý¤ò¸ß´¹¤Î¤¿¤á¤Ë»Ä¤¹¤â¤Î¤Ç
// - ¥Ö¥é¥¦¥¶¤Ë¤è¤Ã¤Æ¤Ï¥¤¥ó¥é¥¤¥ó¥¤¥á¡¼¥¸¤Îɽ¼¨¤ä¡¢¡Ö¥¤¥ó¥é¥¤¥ó
// ¥¤¥á¡¼¥¸¤À¤±¤òɽ¼¨¡×¤µ¤»¤¿»þ¤Ê¤É¤ËÉÔ¶ñ¹ç¤¬½Ð¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹
-// Usage
-define('PLUGIN_REF_USAGE', "([pagename/]attached-file-name[,parameters, ... ][,title])");
+/////////////////////////////////////////////////
-// Image suffixes
+// Image suffixes allowed
define('PLUGIN_REF_IMAGE', '/\.(gif|png|jpe?g)$/i');
-// File icon image
-if (! defined('FILE_ICON')) {
- define('FILE_ICON',
- '<img src="' . IMAGE_DIR . 'file.png" width="20" height="20"' .
- ' alt="file" style="border-width:0px" />');
-}
-
-// Default alignment
-define('PLUGIN_REF_DEFAULT_ALIGN', 'left'); // 'left', 'center', 'right'
-
-// Force wrap on default
-define('PLUGIN_REF_WRAP_TABLE', FALSE); // TRUE, FALSE
-
-// URL»ØÄê»þ¤Ë²èÁü¥µ¥¤¥º¤ò¼èÆÀ¤¹¤ë¤«
-define('PLUGIN_REF_URL_GET_IMAGE_SIZE', FALSE); // FALSE, TRUE
+// Usage (a part of)
+define('PLUGIN_REF_USAGE', "([pagename/]attached-file-name[,parameters, ... ][,title])");
function plugin_ref_inline()
{
// Promote new design
if ($is_file_default && $is_file_second) {
// Because of race condition NOW
- $params['_error'] = htmlspecialchars('The same file name "' .
+ $params['_error'] = htmlsc('The same file name "' .
$name . '" at both page: "' . $page . '" and "' . $_arg .
- '". Try ref(pagename/filname) to specify one of them');
+ '". Try ref(pagename/filename) to specify one of them');
} else {
// Because of possibility of race condition, in the future
$params['_error'] = 'The style ref(filename,pagename) is ambiguous ' .
'and become obsolete. ' .
- 'Please try ref(pagename/filname)';
+ 'Please try ref(pagename/filename)';
}
return $params;
}
$is_file = is_file($file);
}
if (! $is_file) {
- $params['_error'] = htmlspecialchars('File not found: "' .
+ $params['_error'] = htmlsc('File not found: "' .
$name . '" at page "' . $page . '"');
return $params;
}
$matches = array();
if ($is_url) { // URL
- $url = $url2 = htmlspecialchars($name);
- $title = htmlspecialchars(preg_match('/([^\/]+)$/', $name, $matches) ? $matches[1] : $url);
+ if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI) {
+ //$params['_error'] = 'PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this';
+ //return $params;
+ $url = htmlsc($name);
+ $params['_body'] = '<a href="' . $url . '">' . $url . '</a>';
+ return $params;
+ }
+
+ $url = $url2 = htmlsc($name);
+ $title = htmlsc(preg_match('/([^\/]+)$/', $name, $matches) ? $matches[1] : $url);
$is_image = (! $params['noimg'] && preg_match(PLUGIN_REF_IMAGE, $name));
} else { // źÉÕ¥Õ¥¡¥¤¥ë
- $title = htmlspecialchars($name);
+ $title = htmlsc($name);
$is_image = (! $params['noimg'] && preg_match(PLUGIN_REF_IMAGE, $name));
}
if (! empty($_title)) {
- $title = htmlspecialchars(join(',', $_title));
+ $title = htmlsc(join(',', $_title));
if ($is_image) $title = make_line_rules($title);
}
}
if (! isset($vars['page']) || ! isset($vars['src']))
return array('msg'=>'Invalid argument', 'body'=>$usage);
- $page = $vars['page'];
- $file = $vars['src'];
+ $page = $vars['page'];
+ $filename = $vars['src'] ;
- $ref = UPLOAD_DIR . encode($page) . '_' . encode(preg_replace('#^.*/#','',$file));
+ $ref = UPLOAD_DIR . encode($page) . '_' . encode(preg_replace('#^.*/#', '', $filename));
if(! file_exists($ref))
return array('msg'=>'Attach file not found', 'body'=>$usage);
return array('msg'=>'Seems not an image', 'body'=>$usage);
}
- // Output
- $file = htmlspecialchars($file);
+ // Care for Japanese-character-included file name
+ if (LANG == 'ja') {
+ switch(UA_NAME . '/' . UA_PROFILE){
+ case 'Opera/default':
+ // Care for using _auto-encode-detecting_ function
+ $filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
+ break;
+ case 'MSIE/default':
+ $filename = mb_convert_encoding($filename, 'SJIS', 'auto');
+ break;
+ }
+ }
+ $file = htmlsc($filename);
$size = filesize($ref);
- header('Content-Disposition: inline; filename="' . $file . '"');
+
+ // Output
+ pkwk_common_headers();
+ header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Length: ' . $size);
header('Content-Type: ' . $type);
@readfile($ref);
-
exit;
}
?>