function get_filename($page) { if (MOD_PUKI_WIKI_VER == '1.3') { $page = PukiWikiFunc::add_bracket(PukiWikiFunc::strip_bracket($page)); } return MOD_PUKI_WIKI_DATA_DIR . PukiWikiFunc::encode($page) . '.txt'; }
function plugin_ref_body($name, $args, $params) { // $nameをもとに以下の変数を設定 // $url : URL // $title :タイトル // $ext : 拡張子判別用文字列 // $icon : アイコンのimgタグ // $size : 画像ファイルのときサイズ // $info : 画像ファイル以外のファイルの情報 // 添付ファイルのとき : ファイルの最終更新日とサイズ // URLのとき : URLそのもの $ret = ""; if (PukiWikiFunc::is_url($name)) { //URL $url = $ext = $info = htmlspecialchars($name); $icon = $size = ''; $l_url = $url; $icon = MOD_PUKI_REF_FILE_ICON; if (preg_match('/([^\\/]+)$/', $name, $match)) { $ext = $match[1]; } } else { $page = ''; if (count($args) > 0) { $_page = $args[0]; if (PukiWikiFunc::is_page($_page)) { $page = $_page; array_shift($args); } } //相対パスからフルパスを得る if (preg_match('/^(.+)\\/([^\\/]+)$/', $name, $matches)) { if ($matches[1] == '.' or $matches[1] == '..') { $matches[1] .= '/'; } $page = PukiWikiFunc::add_bracket($matches[1]); $name = $matches[2]; } $ext = $name; if (MOD_PUKI_WIKI_VER == '1.3') { $page = PukiWikiFunc::add_bracket(PukiWikiFunc::strip_bracket($page)); } $file = MOD_PUKI_WIKI_UPLOAD_DIR . PukiWikiFunc::encode($page) . '_' . PukiWikiFunc::encode($name); if (!is_file($file)) { if (!PukiWikiFunc::is_page($page)) { $rets['_error'] = 'page not found.'; return $rets; } else { $rets['_error'] = 'not found.'; return $rets; } } $l_url = MOD_PUKI_WIKI_URL . '?plugin=attach&openfile=' . rawurlencode($name) . '&refer=' . rawurlencode($page); $fsize = sprintf('%01.1f', round(filesize($file) / 1000, 1)) . 'KB'; $is_picture = is_picture($file, $page); $is_flash = $is_picture ? false : plugin_ref_is_flash($file); if ($is_picture) { $url = $file; $size = getimagesize($file); $org_w = $size[0]; $org_h = $size[1]; } else { $lastmod = date('Y/m/d H:i:s', filemtime($file)); $info = "{$lastmod} {$fsize}"; } } //タイトルを決定 if (!isset($title) or $title == '') { $title = $ext; } $title = htmlspecialchars($title); // ファイル種別判定 if (!isset($is_picture)) { $is_picture = is_picture($url); } if (!isset($is_flash)) { $is_flash = plugin_ref_is_flash($url); } if ($is_picture) { // 画像 $info = ""; $width = $height = 0; //URLの場合キャッシュ判定 if (PukiWikiFunc::is_url($url)) { $parse = parse_url($url); $name = $parse['host'] . "_" . basename($parse['path']); $filename = PukiWikiFunc::encode($name); if (!$params['nocache']) { //キャッシュする $size = plugin_ref_cache_image_fetch($filename, &$url); $fsize = sprintf('%01.1f', round(filesize(MOD_PUKI_UPLOAD_DIR . $filename) / 1000, 1)) . 'KB'; $l_url = $url; } else { //キャッシュしない $size = @getimagesize($url); $l_url = $url; $fsize = '?KB'; } $org_w = $size[0]; $org_h = $size[1]; } foreach ($params['_args'] as $arg) { if (preg_match("/^(m)?w:([0-9]+)\$/i", $arg, $m)) { $params['_size'] = TRUE; $params['_w'] = $m[2]; $max_flg = $m[1]; } if (preg_match("/^(m)?h:([0-9]+)\$/i", $arg, $m)) { $params['_size'] = TRUE; $params['_h'] = $m[2]; $max_flg = $m[1]; } if (preg_match("/^([0-9.]+)%\$/i", $arg, $m)) { $params['_%'] = $m[1]; } if (preg_match("/^t:(.*)\$/i", $arg, $m)) { $m[1] = htmlspecialchars(str_replace("&quot;", "", $m[1])); if ($m[1]) { $title = $m[1] . " " . $title; } } } // 指定されたサイズを使用する if ($params['_size']) { if ($params['_w'] > 0 && $params['_h'] > 0 && !$max_flg) { $width = $params['_w']; $height = $params['_h']; } else { $_w = $params['_w'] ? $org_w / $params['_w'] : 0; $_h = $params['_h'] ? $org_h / $params['_h'] : 0; $zoom = max($_w, $_h); if ($zoom) { if (!$max_flg || $zoom >= 1 && $max_flg) { $width = floor($org_w / $zoom); $height = floor($org_h / $zoom); } } } } if ($params['_%']) { $width = floor($org_w * $params['_%'] / 100); $height = floor($org_h * $params['_%'] / 100); } if ($org_w && $width && $org_h && $height) { $zoom = floor(max($width / $org_w, $height / $org_h) * 100); } $title .= " SIZE:{$org_w}x{$org_h}({$fsize})"; // &を変換 $title = str_replace("&", "&", $title); //IE以外は改行文字をスペースに変換 if (!strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) { $title = str_replace(" ", " ", $title); } if ($width && $height) { $s_file_base = PukiWikiFunc::encode($zoom . "%" . $name); $s_file = MOD_PUKI_UPLOAD_DIR . $s_file_base; if (!file_exists($s_file) && $zoom < 90 && !$params['nocache']) { //サムネイル作成 $url = plugin_ref_make_thumb($url, $s_file_base, $width, $height, $org_w, $org_h); } else { if (file_exists($s_file)) { //サムネイルがあればサムネイルを参照 $url = MOD_PUKI_UPLOAD_URL . $s_file_base; } } $info = "width=\"{$width}\" height=\"{$height}\" "; $ret .= "<a href=\"{$l_url}\" title=\"{$title}\"><img src=\"{$url}\" alt=\"{$title}\" title=\"{$title}\" {$info}/></a>"; } else { if ($org_w and $org_h) { $info = "width=\"{$org_w}\" height=\"{$org_h}\" "; } if (!$params['nocache']) { $ret .= "<img src=\"{$url}\" alt=\"{$title}\" title=\"{$title}\" {$info}/>"; } else { $ret .= "<img src=\"{$url}\" alt=\"{$title}\" title=\"{$title}\" {$info}/>"; } } } else { if ($is_flash) { // Flashファイル //初期化 $params['_qp'] = $params['_q'] = $params['_pp'] = $params['_p'] = $params['_lp'] = $params['_l'] = $params['_w'] = $params['_h'] = $params['_a'] = $params['_bp'] = $params['_b'] = $params['_scp'] = $params['_sc'] = $params['_sap'] = $params['_sa'] = $params['_mp'] = $params['_m'] = $params['_wmp'] = ""; foreach ($params['_args'] as $arg) { if (preg_match("/^q(?:uality)?:((auto)?(high|low|best|medium))\$/i", $arg, $m)) { $params['_qp'] = "<param name=\"quality\" value=\"{$m[1]}\">"; $params['_q'] = " quality=\"{$m[1]}\""; } if (preg_match("/^p(?:lay)?:(true|false)\$/i", $arg, $m)) { $params['_pp'] = "<param name=\"play\" value=\"{$m[1]}\">"; $params['_p'] = " play=\"{$m[1]}\""; } if (preg_match("/^l(?:oop)?:(true|false)\$/i", $arg, $m)) { $params['_lp'] = "<param name=\"loop\" value=\"{$m[1]}\">"; $params['_l'] = " loop=\"{$m[1]}\""; } if (preg_match("/^w(?:idth)?:([0-9]+)\$/i", $arg, $m)) { $params['_w'] = " width=" . $m[1]; } if (preg_match("/^h(?:eight)?:([0-9]+)\$/i", $arg, $m)) { $params['_h'] = " height=" . $m[1]; } if (preg_match("/^a(?:lign)?:(l|r|t|b)\$/i", $arg, $m)) { $params['_a'] = " align=\"{$m[1]}\""; } if (preg_match("/^b(?:gcolor)?:#?([abcdef\\d]{6,6})\$/i", $arg, $m)) { $params['_bp'] = "<param name=\"bgcolor\" value=\"{$m[1]}\">"; $params['_b'] = " bgcolor=\"#{$m[1]}\""; } if (preg_match("/^sc(?:ale)?:(showall|noborder|exactfit|noscale)\$/i", $arg, $m)) { $params['_scp'] = "<param name=\"scale\" value=\"{$m[1]}\">"; $params['_sc'] = " scale=\"{$m[1]}\""; } if (preg_match("/^sa(?:lign)?:(l|r|t|b|tl|tr|bl|br)\$/i", $arg, $m)) { $params['_sap'] = "<param name=\"salign\" value=\"{$m[1]}\">"; $params['_sa'] = " salign=\"{$m[1]}\""; } if (preg_match("/^m(?:enu)?:(true|false)\$/i", $arg, $m)) { $params['_mp'] = "<param name=\"menu\" value=\"{$m[1]}\">"; $params['_m'] = " menu=\"{$m[1]}\""; } if (preg_match("/^wm(?:ode)?:(window|opaque|transparent)\$/i", $arg, $m)) { $params['_wmp'] = "<param name=\"wmode\" value=\"{$m[1]}\">"; } } $ret .= <<<_HTML_ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0"{$params['_w']}{$params['_h']}{$params['_a']}> <param name="movie" value="{$file}"> {$params['_qp']}{$params['_lp']}{$params['_pp']}{$params['_scp']}{$params['_sap']}{$params['_mp']}{$params['_wmp']} <embed src="{$file}" pluginspage="http://www.macromedia.com/jp/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"{$params['_w']}{$params['_h']}{$params['_a']}{$params['_p']}{$params['_l']}{$params['_q']}{$params['_b']}{$params['_sc']}{$params['_sa']}{$params['_m']}> </embed> </object> _HTML_; } else { // 通常ファイル foreach ($params['_args'] as $arg) { if (preg_match("/^t:(.*)\$/i", $arg, $m)) { $m[1] = htmlspecialchars(str_replace("&quot;", "", $m[1])); if ($m[1]) { $info = $m[1] . " " . $info; } } } // &を変換 $info = str_replace("&", "&", $info); //IE以外は改行文字をスペースに変換 if (!strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) { $info = str_replace(" ", " ", $info); } $ret .= "<a href=\"{$l_url}\" title=\"{$info}\">{$icon}{$title}</a>"; } } $rets['_body'] = $ret; return $rets; }