function plugin_tenki_inline() { $args = array(); $args = func_get_args(); //echo $args[0].":".$args[1]; if ($args[0] == "pic") { $url = "http://weather.is.kochi-u.ac.jp/FE/00Latest.jpg"; $alt = "日本付近赤外画像"; $picid = "pic"; $args[0] = $args[1]; $size[0] = 640; $size[1] = 480; } else { $url = "http://www.jma.go.jp/JMA_HP/jp/g3/latest/SPAS-GG.gif"; $alt = "気象庁発表天気図"; $picid = ""; $size[0] = 528; $size[1] = 512; } if ($args[0] == "now?") { $args[0] = ""; } if (!defined('MOD_PUKI_UPLOAD_DIR')) { $args[0] = ""; } //画像のキャッシュは使用出来ない。 if ($args[0]) { $id = $args[0] . $picid; $id = str_replace(" ", "", $id); $id = PukiWikiFunc::encode($id); $img_arg = plugin_tenki_cache_image_fetch($url, $id); $url = $img_arg[0]; $size = $img_arg[1]; // } else { // $size = @getimagesize($url); // if ($size[0] < 1) return false; } $v_width = 264; $v_height = floor($v_width * $size[1] / $size[0]); $body = "<a href=\"{$url}\"><img src=\"{$url}\" width=\"{$v_width}\" height=\"{$v_height}\" alt=\"{$alt}\" title=\"{$alt}\" /></a>\n"; return $body; }
function plugin_tenki_cache_image_fetch($target, $id) { $filename = MOD_PUKI_UPLOAD_DIR . $id . "_tenki.gif"; if (!is_readable($filename)) { $result = PukiWikiFunc::http_request($target); if ($result['rc'] == 200) { $data = $result['data']; plugin_tenki_cache_image_save($data, $filename); $size = @getimagesize($filename); $url = MOD_PUKI_UPLOAD_URL . $id . "_tenki.gif"; } else { $url = ''; $size = false; } } else { $url = MOD_PUKI_UPLOAD_URL . $id . "_tenki.gif"; $size = @getimagesize($filename); } return array($url, $size); }
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; }
function do_plugin_inline($name, $args, $body) { global $digest; // digestを退避 $_digest = $digest; $aryargs = $args !== '' ? PukiWikiFunc::csv_explode(',', $args) : array(); $aryargs[] =& $body; PukiWikiPlugin::do_plugin_init($name); $retvar = call_user_func_array('plugin_' . $name . '_inline', $aryargs); // digestを復元 $digest = $_digest; if ($retvar === FALSE) { return htmlspecialchars("&{$name}" . ($args ? "({$args})" : '') . ';'); } return $retvar; }
function get_pgid_by_name($page) { global $xoopsDB; static $page_id = array(); $page = addslashes(PukiWikiFunc::strip_bracket($page)); if (!empty($page_id[$page])) { return $page_id[$page]; } $query = "SELECT * FROM " . $xoopsDB->prefix("pukiwikimod_pginfo") . " WHERE name='{$page}' LIMIT 1;"; $res = $xoopsDB->query($query); if (!$res) { return 0; } $ret = mysql_fetch_row($res); $page_id[$page] = $ret[0]; return $ret[0]; }
function _init_PukiWiki_env() { //他のPukiWikiシステムとの連携時の初期化 Original By nao-pon // PukiWikiMod用共通リンクへの対応 // AutoLink有効時に、AutoLinkデータ読込と、AutoLinkデータ更新時のキャッシュクリア // PukiWikiMod 共通リンクディレクトリ読み込み by nao-pon $wiki_common_dirs = ""; if (defined('MOD_PUKI_WIKI_CACHE_DIR')) { if (MOD_PUKI_WIKI_VER == "1.3" && file_exists(MOD_PUKI_WIKI_CACHE_DIR . "config.php")) { include MOD_PUKI_WIKI_CACHE_DIR . "config.php"; } } // PukiWikiMod 共通リンクディレクトリ展開 $wiki_common_dirs = preg_split("/\\s+/", trim($wiki_common_dirs)); sort($wiki_common_dirs, SORT_STRING); PukiWikiConfig::setParam('wiki_common_dirs', $wiki_common_dirs); // AutoLinkデータ読み込みとチェック(AutoLink有効時のみ) $autolink_dat = array(); if (PukiWikiConfig::getParam('autolink') && defined('MOD_PUKI_WIKI_CACHE_DIR') && file_exists(MOD_PUKI_WIKI_CACHE_DIR . 'autolink.dat')) { $autolink_dat = file(MOD_PUKI_WIKI_CACHE_DIR . 'autolink.dat'); if (!file_exists(MOD_PUKI_CACHE_DIR . 'autolink.dat') || $autolink_dat != file(MOD_PUKI_CACHE_DIR . 'autolink.dat')) { // 比較用オートリンクデータを保存 @(list($pattern, $pattern_a, $forceignorelist) = $autolink_dat); if ($fp = fopen(MOD_PUKI_CACHE_DIR . 'autolink.dat', 'wb')) { set_file_buffer($fp, 0); flock($fp, LOCK_EX); rewind($fp); fputs($fp, trim($pattern) . "\n"); if (count($autolink_dat) == 3) { fputs($fp, trim($pattern_a) . "\n"); fputs($fp, trim($forceignorelist) . "\n"); } flock($fp, LOCK_UN); fclose($fp); } else { // die_message('Cannot write autolink file '. MOD_PUKI_CACHE_DIR . '/autolink.dat<br />Maybe permission is not writable'); } // オートリンクデータが更新されているのでキャッシュをクリア $dh = dir(MOD_PUKI_CACHE_DIR); while (($file = $dh->read()) !== FALSE) { if (substr($file, -6) != '.cache') { continue; } $file = MOD_PUKI_CACHE_DIR . $file; unlink($file); } $dh->close(); } } PukiWikiConfig::setParam('autolink_dat', $autolink_dat); // ページ名エイリアス取得 PukiWikiConfig::setParam('pagename_aliases', PukiWikiFunc::get_pagename_aliases()); }
function getLocalPage($page = NULL) { if (!PukiWikiFunc::is_local_page($page)) { return ""; } else { $source = str_replace("\r", '', file(PukiWikiFunc::get_local_filename($page))); return implode("", $source); } }
function plugin_ref_make_thumb($url, $s_file_base, $width, $height, $org_w, $org_h) { $s_file = MOD_PUKI_UPLOAD_DIR . $s_file_base; // GD fuction のチェック if (!function_exists("ImageCreate")) { return $url; } //GDをサポートしていない $gifread = ''; if (MOD_PUKI_REF_GD_VERSION == 2) { $imagecreate = "ImageCreateTrueColor"; $imageresize = "ImageCopyResampled"; } else { $imagecreate = "ImageCreate"; $imageresize = "ImageCopyResized"; } if (function_exists("ImageCreateFromGif")) { $gifread = "on"; } if (PukiWikiFunc::is_url($url)) { //URL $result = PukiWikiFunc::http_request($url); if ($result['rc'] !== 200) { return ''; } $orgimg = tempnam(MOD_PUKI_UPLOAD_DIR, 'mpw_thumb'); $fp = fopen($orgimg, 'w'); fwrite($fp, $result['data']); fclose($fp); $url = $orgimg; } $size = @GetImageSize($url); $dst_im = $imagecreate($width, $height); switch ($size[2]) { case "1": //gif形式 if ($gifread == "on") { $src_im = ImageCreateFromGif($url); $imageresize($dst_im, $src_im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); touch($s_file); ImageJpeg($dst_im, $s_file); $url = MOD_PUKI_UPLOAD_URL . $s_file_base; } break; case "2": //jpg形式 $src_im = ImageCreateFromJpeg($url); $imageresize($dst_im, $src_im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); touch($s_file); ImageJpeg($dst_im, $s_file); $url = MOD_PUKI_UPLOAD_URL . $s_file_base; break; case "3": //png形式 $src_im = ImageCreateFromPng($url); $imageresize($dst_im, $src_im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); touch($s_file); ImageJpeg($dst_im, $s_file); $url = MOD_PUKI_UPLOAD_URL . $s_file_base; break; default: break; } if (!empty($orgimg)) { unlink($orgimg); } return $url; }
function plugin_isbn_cache_save($data, $target) { $filename = MOD_PUKI_UPLOAD_DIR . PukiWikiFunc::encode("ISBN" . $target . ".dat"); $fp = fopen($filename, "w"); fwrite($fp, $data); fclose($fp); return $filename; }
function plugin_isbn_cache_image_save($data, $target, $dir) { $filename = $dir . PukiWikiFunc::encode("ISBN" . $target . ".jpg"); $fp = fopen($filename, "wb"); fwrite($fp, $data); fclose($fp); return $filename; }
function Contents_UList($text, $level, $id) { // テキストのリフォーム // 行頭\nで整形済みを表す ... X( PukiWikiFunc::make_heading($text); $text = "\n<a href=\"#{$id}\">{$text}</a>\n"; parent::PukiWikiListContainer('ul', 'li', '-', str_repeat('-', $level)); $this->insert(new PukiWikiInline($text)); }
function end_element($parser, $name) { if (!$this->is_item or $name != 'ITEM') { return; } $item = array_map(array(&$this, 'escape'), $this->item); $this->item = array(); if (array_key_exists('DC:DATE', $item)) { $time = plugin_showrss_get_timestamp($item['DC:DATE']); } else { if (array_key_exists('PUBDATE', $item)) { $time = plugin_showrss_get_timestamp($item['PUBDATE']); } else { $time = time() - MOD_PUKI_LOCALZONE; } } $item['_TIMESTAMP'] = $time; $date = PukiWikiFunc::get_date('Y-m-d', $item['_TIMESTAMP']); $this->items[$date][] = $item; $this->is_item = FALSE; }
function get_real_pagename($page) { static $real_pages = array(); $page = PukiWikiFunc::strip_bracket($page); if (isset($real_pages[$page])) { return $real_pages[$page]; } $real_pages[$page] = false; foreach (PukiWikiConfig::getParam('wiki_common_dirs') as $dir) { $check = $dir . $page; if (PukiWikiFunc::is_page($check)) { $real_pages[$page] = $check; break; } } return $real_pages[$page]; }
function set($arr, $page) { global $_PukiWikiFootExplain; static $note_id = 0; list(, $body) = $this->splice($arr); $id = ++$note_id; $note = PukiWikiFunc::make_link($body); $style_small = PukiWikiConfig::getParam('style_prefix') . "small"; $style_super = PukiWikiConfig::getParam('style_prefix') . "note_super"; $_PukiWikiFootExplain[$id] = <<<EOD <a id="notefoot_{$id}" href="#notetext_{$id}" class="{$style_super}">*{$id}</a> <span class="{$style_small}">{$note}</span> <br /> EOD; $name = "<a id=\"notetext_{$id}\" href=\"#notefoot_{$id}\" class=\"" . PukiWikiConfig::getParam('style_prefix') . "note_super\">*{$id}</a>"; return parent::setParam($page, $name, $body); }
function get_pagename_aliases() { $_aliases = array(); foreach (PukiWikiFunc::get_source(':config/aliases') as $_line) { if (preg_match("/\\[(.+?) (.+?)\\](.*)/", $_line, $_match) && PukiWikiFunc::is_page($_match[2])) { $_aliases[$_match[1]] = $_match[2]; if ($_match[3]) { $_aliases[$_match[1]] .= '!' . $_match[3]; } } } return $_aliases; }