function plugin_show_convert() { $qm = get_qm(); $qt = get_qt(); if (!func_num_args()) { return $qm->m['plg_show']['err_usage']; } $args = func_get_args(); $args[] = '_block'; $params = plugin_show_body($args); if (isset($params['_error']) && $params['_error'] != '') { return "<p>#show(): {$params['_error']}</p>\n"; } if (PLUGIN_SHOW_WRAP_TABLE && !$params['nowrap'] || $params['wrap']) { // 枠で包む // margin:auto // Mozilla 1.x = x (wrap,aroundが効かない) // Opera 6 = o // Netscape 6 = x (wrap,aroundが効かない) // IE 6 = x (wrap,aroundが効かない) // margin:0px // Mozilla 1.x = x (wrapで寄せが効かない) // Opera 6 = x (wrapで寄せが効かない) // Netscape 6 = x (wrapで寄せが効かない) // IE6 = o $margin = $params['around'] ? '0px' : 'auto'; $margin_align = $params['_align'] == 'center' ? '' : ";margin-{$params['_align']}:0px"; $params['_body'] = <<<EOD <table class="style_table" style="margin:{$margin}{$margin_align}"> <tr> <td class="style_td">{$params['_body']}</td> </tr> </table> EOD; } $style_ard = ''; $style = ''; if ($params['around']) { $param_ard = $params['_align'] == 'right' ? 'right' : 'left'; $style_ard = "_" . $param_ard; } else { $style = "text-align:{$params['_align']}"; } $add_style = <<<EOD <style> .img_margin_left { float: left; margin: 0 1em 0 0; } .img_margin_right { float: right; margin: 0 0 0 1em; } </style> EOD; if ($is_bootstrap_skin) { $add_style .= <<<EOD <script> \$(function(){ if (\$("[class^=img_margin_]").length) { \$("[class^=img_margin_]").each(function(){ var prevMarginBottom = 0; var nextMarginTop = 0; if (\$(this).prev().length) { prevMarginBottom = parseInt(\$(this).prev().css("margin-bottom").replace("px", ""), 10); } else { \$(this).css({marginTop: 0}); } if (\$(this).next().length) { nextMarginTop = parseInt(\$(this).next().css("margin-top").replace("px", ""), 10); } var marginTop = nextMarginTop - prevMarginBottom; marginTop = (marginTop < 0) ? 0 : marginTop; \$(this).css({marginTop: marginTop}); }); } }); </script> EOD; } $qt->appendv_once("plugin_show_convert_style", "beforescript", $add_style); // divで包む return "<div class=\"img_margin{$style_ard}\" style=\"{$style}\">{$params['_body']}</div>\n"; }
function plugin_attachref_inline() { global $script, $vars, $digest, $username; static $numbers = array(); static $no_flag = 0; $qm = get_qm(); if (!array_key_exists($vars['page'], $numbers)) { $numbers[$vars['page']] = 0; } $attachref_no = $numbers[$vars['page']]++; //戻り値 $ret = ''; $dispattach = 1; $button = 0; $args = func_get_args(); $btn_text = array_pop($args); $btn_text = $btn_text ? $btn_text : $qm->m['plg_attachref']['btn_submit']; //SWFUを持っている人用 if ($username == $_SESSION['usr'] && has_swfu()) { $btn_text = '(swfu' . $btn_text . ')'; } $options = array(); foreach ($args as $opt) { if ($opt === 'button') { $button = 1; } else { if ($opt === 'number') { $no_flag = 1; } else { if ($opt === 'nonumber') { $no_flag = 0; } else { array_push($options, $opt); } } } } if ($no_flag == 1) { $btn_text .= "[{$attachref_no}]"; } $args = $options; if (count($args) and $args[0] != '') { // if( fopen($args[0], 'r') ){ // http:..., swfu/d/hogehoge.png.. などなど if (!is_url($args[0]) && file_exists($args[0])) { // http:..., swfu/d/hogehoge.png.. などなど require_once PLUGIN_DIR . "show.inc.php"; $params = plugin_show_body($args, $vars['page']); } else { require_once PLUGIN_DIR . "ref.inc.php"; $params = plugin_ref_body($args, $vars['page']); } if ($params['_error'] != '') { $ret = $params['_error']; $dispattach = 1; } else { $ret = $params['_body']; $dispattach = 0; } } if ($dispattach) { //XSS脆弱性問題 - 外部から来た変数をエスケープ $s_args = trim(join(",", $args)); if ($button) { $s_args .= ",button"; $f_page = htmlspecialchars($vars['page']); $f_args = htmlspecialchars($s_args); $ret = <<<EOD <form action="{$script}" method="post"> <div> <input type="hidden" name="encode_hint" value="ぷ" /> <input type="hidden" name="attachref_no" value="{$attachref_no}" /> <input type="hidden" name="attachref_opt" value="{$f_args}" /> <input type="hidden" name="digest" value="{$digest}" /> <input type="hidden" name="plugin" value="attachref" /> <input type="hidden" name="refer" value="{$f_page}" /> {$ret} <input type="submit" value="{$btn_text}" /> </div> </form> EOD; } else { $f_btn_text = preg_replace('/<[^<>]+>/', '', $btn_text); // echo '[debug]btn=',$f_btn_text; $f_page = rawurlencode($vars['page']); $f_args = rawurlencode($s_args); $ret = <<<EOD {$ret}<a href="{$script}?plugin=attachref&attachref_no={$attachref_no}&attachref_opt={$f_args}&refer={$f_page}&digest={$digest}" title="{$f_btn_text}">{$btn_text}</a> EOD; } } return $ret; }