function plugin_edit_action() { global $vars, $_title_edit, $load_template_func; if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); if (isset($vars['preview']) || $load_template_func && isset($vars['template'])) { return plugin_edit_preview(); } else { if (isset($vars['write'])) { return plugin_edit_write(); } else { if (isset($vars['cancel'])) { return plugin_edit_cancel(); } } } $postdata = @join('', get_source($page)); if ($postdata == '') { $postdata = auto_template($page); } return array('msg' => $_title_edit, 'body' => edit_form($page, $postdata)); }
function plugin_add_action() { global $get, $post, $vars, $_title_add, $_msg_add; if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page); $get['add'] = $post['add'] = $vars['add'] = TRUE; return array('msg' => $_title_add, 'body' => '<ul>' . "\n" . ' <li>' . $_msg_add . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, '')); }
function plugin_add_action() { global $get, $post, $vars; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); if (auth::check_role('readonly')) { die_message('PKWK_READONLY prohibits editing'); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page); $get['add'] = $post['add'] = $vars['add'] = TRUE; return array('msg' => _("Add to \$1"), 'body' => '<ul>' . "\n" . ' <li>' . _('Two and the contents of an input are added for a new-line to the contents of a page of present addition.') . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, '')); }
function plugin_add_action() { global $get, $post, $vars; $qm = get_qm(); if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page); $get['add'] = $post['add'] = $vars['add'] = TRUE; return array('msg' => $qm->m['plg_add']['title'], 'body' => '<ul>' . "\n" . ' <li>' . $qm->m['plg_add']['note'] . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, '')); }
function check() { if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } check_editable($this->page, true, true); if (!is_page($this->page)) { die_message('No such page'); } if (!$this->sections->is_valid_id($this->id)) { die_message('Invalid id'); } }
function plugin_blog_edit_action() { global $vars, $load_template_func; $qm = get_qm(); if (PKWK_READONLY) { die_message($qm->m['fmt_err_pkwk_readonly']); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); if (isset($vars['preview']) || $load_template_func && isset($vars['template'])) { return plugin_edit_preview(); } else { if (isset($vars['write'])) { return plugin_edit_write(); } else { if (isset($vars['cancel'])) { return plugin_edit_cancel(); } } } $postdata = @join('', get_source($page)); if ($postdata == '') { $postdata = auto_template($page); } if ($postdata == '') { $postdata = <<<EOD //--------- {$qm->m['plg_blog_edit']['ntc_post_conf']} -------------- #topicpath // {$qm->m['plg_blog_edit']['ntc_post_tag']} //---------- {$qm->m['plg_blog_edit']['ntc_post_body']} ------------- #blog_body {$qm->m['plg_blog_edit']['post_body']} //--------- {$qm->m['plg_blog_edit']['ntc_post_more']} ------------------ {$qm->m['plg_blog_edit']['post_more']} //------- {$qm->m['plg_blog_edit']['ntc_post_comment']} -------- &br; #blog_comment ---- {$qm->m['plg_blog_edit']['post_comment']} #comment2(textarea,10) EOD; } return array('msg' => $qm->m['fmt_title_edit'], 'body' => edit_form($page, $postdata)); }
function check() { $qm = get_qm(); if (PKWK_READONLY) { die_message($qm->m['fmt_err_pkwk_readonly']); } check_editable($this->page, true, true); if (!is_page($this->page)) { die_message($qm->m['plg_secedit']['err_nopage']); } if (!$this->sections->is_valid_id($this->id)) { die_message($qm->m['plg_secedit']['err_invalid_id']); } }
function plugin_edit_action() { // global $vars, $_title_edit, $load_template_func; global $vars, $load_template_func; // if (PKWK_READONLY) die_message( _('PKWK_READONLY prohibits editing') ); if (auth::check_role('readonly')) { die_message(_('PKWK_READONLY prohibits editing')); } if (PKWK_READONLY == ROLE_AUTH && auth::get_role_level() > ROLE_AUTH) { die_message(_('PKWK_READONLY prohibits editing')); } if (isset($vars['realview'])) { return plugin_edit_realview(); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); if (!is_page($page) && auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(_('PKWK_CREATE_PAGE prohibits editing')); } if (isset($vars['preview']) || $load_template_func && isset($vars['template'])) { return plugin_edit_preview(); } else { if (isset($vars['write'])) { return plugin_edit_write(); } else { if (isset($vars['cancel'])) { return plugin_edit_cancel(); } } } $source = get_source($page); auth::is_role_page($source); $postdata = $vars['original'] = join('', $source); if (!empty($vars['id'])) { $postdata = plugin_edit_parts($vars['id'], $source); if ($postdata === FALSE) { unset($vars['id']); // なかったことに :) $postdata = $vars['original']; } } if ($postdata == '') { $postdata = auto_template($page); } return array('msg' => _('Edit of $1'), 'body' => edit_form($page, $postdata)); }
function plugin_delete_action() { global $vars, $script, $load_template_func, $style_name, $layout_pages; global $defaultpage; $qm = get_qm(); $qt = get_qt(); if (PKWK_READONLY) { die_message($qm->m['fmt_err_pkwk_readonly']); } $page = isset($vars['page']) ? $vars['page'] : $defaultpage; $s_page = h($page); $digest = md5(join('', get_source($page))); check_editable($page, true, true); if ($page === $defaultpage) { $body = <<<EOD <p> {$page}は削除できません。 </p> EOD; return array('msg' => '$1の削除', 'body' => $body); } $body = <<<EOD <p> {$page}を削除しますか? </p> <form method="POST" action="{$script}"> <div> <p><input type="hidden" name="plugin" value="delete" /> <input type="hidden" name="write" value="1" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="hidden" name="digest" value="{$digest}" /> <input type="submit" value="実行する" /> </p> </div> </form> EOD; $body .= '<hr />' . convert_html(get_source($page)); if (isset($vars['write'])) { plugin_delete_write(); redirect($defaultpage, $page . 'を削除しました'); } return array('msg' => '$1の削除', 'body' => $body); }
/** * * */ function plugin_ssl_convert() { global $script, $script_ssl, $vars, $reg_exp_host; //------------ [重要かつ複雑なロジック] ---------------------------------- // #sslと記述されたページのみ、ssl通信の対象としたいため以下のような処理をする // (ナビ、メニュー、ナビ2などは、通常のURLにリンクさせたい) // // 0. lib/init.php で、$script_ssl が未設定なら生成される // 2. 入れ替えた後は、$script_ssl によって、コンテンツ部分の様々なURLが作られる // 3. lib/html.php 内で、元に戻す // 4. naviや、menuや、pukiwiki.skin.phpで呼び出すところでは、元の$scriptが使われる // // なるべく、ドメインを含めないURL指定を心掛けるとよいかも // // lib/html.php でSSL用の処理(HTMLコードの書き換えを実行)をするためのフラグ $qt = get_qt(); $qt->setv('plugin_ssl_flag', TRUE); $go_ssl_url = $script_ssl . '?' . rawurlencode($vars['page']); // 移動を促すメッセージ $args = func_get_args(); $msg = isset($args[0]) ? h($args[0]) : '暗号化されたページへ移動してください'; // javascriptで判定して、https:に移動させる(PHPのSERVER変数が信用できないから) $qt->setv('jquery_include', true); $js_co = check_editable($vars['page'], false, false) ? '//' : ''; $js = <<<EOD <script type="text/javascript"> if( document.location.protocol != 'https:' ){ \t{$js_co}location.href = '{$go_ssl_url}'; \t\$(function(){ \t\t\$('div#plugin_ssl_msg').html('<a href="{$go_ssl_url}" data-target="nowin">{$msg}</a>'); \t}); } </script> EOD; $qt->appendv_once('plugin_ssl', 'beforescript', $js); // 外部ウインドウで開くリストから、通常ページへのURLを除外 $p_url = parse_url(is_https() ? $script_ssl : $script); $reg_exp_host .= ($reg_exp_host == '' ? '' : '|') . $p_url['host']; return <<<EOD <div id="plugin_ssl_msg"></div> EOD; }
function plugin_gmapfun_convert() { static $s_gmapfun_cnt = 0; global $script, $googlemaps_apikey; global $vars; $qt = get_qt(); $qt->setv('jquery_include', true); $args = func_get_args(); $last = func_num_args() - 1; $datalist = ''; if (strpos($args[$last], ',') !== FALSE) { $datalist = array_pop($args); } list($type, $w, $h, $zoom, $addr, $lat, $lng) = array_pad($args, 7, ''); $type = $type == '' ? 'default' : $type; $addr = trim($addr) == '' ? '' : trim($addr); $lat = $lat == '' ? '35.658613' : $lat; $lng = $lng == '' ? '139.745525' : $lng; $zoom = $zoom == '' ? '15' : $zoom; $w = preg_match('/^[0-9]+$/', $w) ? $w . 'px' : $w; $h = preg_match('/^[0-9]+$/', $h) ? $h . 'px' : $h; switch ($type) { case 'top': $gmap_width = $w == '' ? '' : $w; $gmap_height = $h == '' ? '300px' : $h; $gmap_disp = PLUGIN_GMAPFUN_TYPE1; break; case 'side': $gmap_height = $h == '' ? '450px' : $h; if (is_bootstrap_skin()) { $gmap_width = '100%'; $gmap_disp = PLUGIN_GMAPFUN_TYPE2_BOOTSTRAP; } else { $gmap_width = $w == '' ? '220px' : $w; $gmap_disp = PLUGIN_GMAPFUN_TYPE2; } break; default: $gmap_width = $w == '' ? '' : $w; $gmap_height = $h == '' ? '500px' : $h; $gmap_disp = PLUGIN_GMAPFUN_DEFAULT; } if ($addr != '') { $geoobj = plugin_gmapfun_getGeocoding($addr); if ($geoobj) { $lng = $geoobj['lng']; $lat = $geoobj['lat']; } } if (isset($datalist)) { $flist = plugin_gmapfun_makelist($datalist); } $addscript = ''; if ($s_gmapfun_cnt == 0) { list($icon_width, $icon_height) = getimagesize(PLUGIN_GMAPFUN_ICON_PATH . 'pin.png'); list($icon_sh_width, $icon_sh_height) = getimagesize(PLUGIN_GMAPFUN_ICON_PATH . 'pin_shadow.png'); $addscript = ' <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script> <script src="js/infobox.js" type="text/javascript"></script> <script type="text/javascript"> <!-- $(function(){ // マップ処理 function gmap_initialize(){ var ibopts = { content: "", disableAutoPan: false, maxWidth: "200px", pixelOffset: new google.maps.Size(-100, 10), zIndex: null, boxStyle: { backgroundColor: "#333", opacity: 0.85, color:"#fff", borderRadius: "10px", MozBorderRadius: "10px", WebkitBorderRadius: "10px", position:"relative", width: "200px" }, closeBoxMargin: "5px 5px 2px 2px", closeBoxURL: "//www.google.com/intl/en_us/mapfiles/close.gif", infoBoxClearance: new google.maps.Size(1, 1), isHidden: false, pane: "floatPane", enableEventPropagation: false, }; var ib = new InfoBox(ibopts); // マップデータを読み込み表示 var firstData = []; if ($(".mapmk").length) { firstData = $(".mapmk:first").attr("longdesc").split(","); } else { firstData.push(""); firstData.push(' . $lat . '); firstData.push(' . $lng . '); } var latlng = new google.maps.LatLng(parseFloat(firstData[1]),parseFloat(firstData[2])); var gmap_opts = { backgroundColor:"#fff", noCler: true, zoom:' . $zoom . ', center:latlng, mapTypeId:google.maps.MapTypeId.ROADMAP }; var gmap = new google.maps.Map(document.getElementById("gmap"), gmap_opts); if ($(".mapmk").length) { gmap.setCenter(latlng); } var flgSize = new google.maps.Size(' . $icon_width . ', ' . $icon_height . '); var flgOrigin = new google.maps.Point(0, 0); var flgAnchor = new google.maps.Point(0, ' . $icon_height . '); var flgImage = "' . PLUGIN_GMAPFUN_ICON_PATH . 'pin.png"; var flgIcon = new google.maps.MarkerImage(flgImage, flgSize, flgOrigin, flgAnchor); var flgShadowSize = new google.maps.Size(' . $icon_sh_width . ', ' . $icon_sh_height . '); var flgShadowOrigin = new google.maps.Point(0, 0); var flgShadowAnchor = new google.maps.Point(0, ' . $icon_sh_height . '); var flgShadowImage = "' . PLUGIN_GMAPFUN_ICON_PATH . 'pin_shadow.png"; var flgShadowIcon = new google.maps.MarkerImage(flgShadowImage, flgShadowSize, flgShadowOrigin, flgShadowAnchor); var markeropts = { position:"", map: gmap, icon: flgIcon, shadow: flgShadowIcon }; $("div.mapmk").each(function(){ var pobj = $(this); var shopdata = ($(this).attr("longdesc")).split(","); var makertitle = $(this).attr("title"); var pos = new google.maps.LatLng(parseFloat(shopdata[1]), parseFloat(shopdata[2])); markeropts.position = pos; var marker = new google.maps.Marker(markeropts); google.maps.event.addListener(marker, "click", function(){ focus_listitem(pobj); show_infobox(gmap, pos, ib, shopdata[0], makertitle); }); marker.setMap(gmap); if (shopdata[0].length > 0){ $(this).css({color:"#336699"}); } }).hover(function(e){$(this).addClass("titlehover");}, function(e){$(this).removeClass("titlehover"); }).click(function(){ focus_listitem($(this)); var shopdata = ($(this).attr("longdesc")).split(","); var pos = new google.maps.LatLng(parseFloat(shopdata[1]),parseFloat(shopdata[2])); show_infobox(gmap, pos, ib, shopdata[0], $(this).attr("title")); show_marker_info($(this), shopdata[0]); gmap.setCenter(pos); return false; }).mouseover(function(){ var shopdata = ($(this).attr("longdesc")).split(","); var pos = new google.maps.LatLng(parseFloat(shopdata[1]),parseFloat(shopdata[2])); show_infobox(gmap, pos, ib, shopdata[0], $(this).attr("title")); focus_listitem($(this)); if ($(this).hasClass("gmap_mklist_fm")) { show_marker_info($(this), shopdata[0]); } gmap.setCenter(pos); }); if ($(".mapmk:first").length) { show_infobox(gmap, latlng, ib, firstData[0], $(".mapmk:first").attr("title")); } show_marker_info($(".mapmk:first"), firstData[0]); } function focus_listitem(obj) { if (obj.hasClass("gmap_mklist_fm")) { $("div.gmap_mklist_fm").css("background-image", "url(' . PLUGIN_GMAPFUN_ICON_PATH . 'listframebg.png)"); obj.css("background-image", "url(' . PLUGIN_GMAPFUN_ICON_PATH . 'listframebg_h.png)"); } } function show_infobox(gmap, pos, ib, url, str) { ib.close(); if (str.length > 0) { ib.setPosition(pos); ib.setContent(\'<p style="padding:0 1em;">\'+str+\'</p><div class="marker_info_balloon"></div>\'); ib.open(gmap); } } function show_marker_info(obj, url) { var fVisible = true; if (url.length == 0) { if ($("#marker_info").children("div.body").length) { $("#marker_info").children("div.body").children("div").html("").closest("#marker_info").fadeOut("fast"); } else { $("#marker_info").children("div").html(""); } $("#marker_info").find("input:hidden[name=pagename]").remove(); } else { if ($("#marker_info").hasClass("marker_info_insert")) { if (obj.parent().find("#marker_info:visible").length) { $("#marker_info").fadeOut("fast"); } else{ $("#marker_info").fadeIn(); obj.after($("#marker_info")); $("#marker_info").children("div.body").children("div").load(url,function(e){ $(window).unbind("load"); $(e).filter("script").each(function(){ document.getElementsByTagName("head")[0].appendChild(this); }); $(window).load(); }); } } else { $("#marker_info").children("div").load(url); } var tmpurl = url.split("?"); var page = tmpurl[1].match(/.*page=(.*)/)[1]; $("#marker_info input:hidden[name=pagename]").remove(); $("#marker_info").append("<input type=\\"hidden\\" name=\\"pagename\\" value=\\""+page+"\\" />"); } } google.maps.event.addDomListener(window,"load",gmap_initialize); if ($("div.gmap_box_right").length){ var padding = parseInt($("div.gmap_box_right").css("padding-left").split("px")[0]) + parseInt($("div.gmap_box_right").css("padding-right").split("px")[0]); var w = $("#body").width() - ($("div.gmap_box_right").width() + padding); $("div.gmap_info_left").width(w); } }); // --> </script> <style type="text/css"> div.gmap_box,div.gmap_box_right{ background:transparent; padding-left:15px; } div.gmap_box_right{ background:transparent url(' . PLUGIN_GMAPFUN_ICON_PATH . 'vline.png) no-repeat 0 0; float:right; } div#gmap{ width:' . $gmap_width . '; height:' . $gmap_height . '; background:transparent url(image/loading.gif) 50% 50% no-repeat; } div.gmap_info, div.gmap_info_left{ width:100%; margin:0; overflow:hidden; } div.gmap_info_left{ width:290px; float:left; } #marker_info{ position:relative; } div.marker_list, div.marker_list_left{ background:transparent url(' . PLUGIN_GMAPFUN_ICON_PATH . 'hline.png) repeat-x 0 100%; padding-top:10px; padding-bottom:10px; } div.marker_list_left{ background:transparent url(' . PLUGIN_GMAPFUN_ICON_PATH . 'hline.png) repeat-x 0 0; } div.marker_info_left{ height:290px; overflow:auto; margin-bottom:10px; } div.marker_info_insert{ margin-bottom:10px; } div.marker_info_balloon { background:transparent url(' . PLUGIN_GMAPFUN_ICON_PATH . 'sankaku.png) no-repeat; width:10px; height:10px; top:-10px; left:' . (95 + $icon_width / 2) . 'px; position:absolute; } div.gmap_mklist_dump { cursor:pointer; } div.mapmk{ color:#333; margin:10px 0 0 0; font-weight:bold; background:url(' . PLUGIN_GMAPFUN_ICON_PATH . 'pin.png) no-repeat 0 0; padding-left:' . ($icon_width + 5) . 'px; line-height:' . $icon_height . 'px; cursor:pointer; } div.gmap_mklist_fm { width:94px; height:114px; float:left; background:transparent url(' . PLUGIN_GMAPFUN_ICON_PATH . 'listframebg.png) no-repeat; position:relative; cursor:pointer; padding-left:0; } div.gmap_mklist_fm img{ top:7px; left:7px; position:absolute; cursor:pointer; } div.pola_title{ bottom:5px; left:7px; position:absolute; width:80px; height:1.5em; line-height:1.5em; font-size:10px; overflow:hidden; } div.bubble { margin:0 0 0 30px; border-left: 7px solid #6699CC; border-top: 7px solid transparent; -border-top-color: white; opacity:0.9; } div.bubble div.body { margin: 0 0 0 -30px; border-radius: 10px; border: 3px solid #6699CC; background: white; } div.bubble div.body div { margin:5px; overflow:auto; height:200px; } div.titlehover{ color:#0066CC; } [data-style="bootstrap"] .gmapfun-marker-info { background: transparent url(image/gmap/vline.png) no-repeat 100% 0; } @media (max-width: 768px) { [data-style="bootstrap"] #gmap { height: 250px; } [data-style="bootstrap"] #marker_info { padding: 15px 0; height: 150px; } [data-style="bootstrap"] .gmapfun-marker-info { background: none; } } </style> '; } $s_gmapfun_cnt++; $list_str = ''; foreach ($flist as $f) { if ($f != '') { if (trim($f['address']) != '') { $geoobj = plugin_gmapfun_getGeocoding(trim($f['address'])); if ($geoobj) { $f['lng'] = $geoobj['lng']; $f['lat'] = $geoobj['lat']; } } $f['lat'] = $f['lat'] == '' ? '35.658613' : $f['lat']; $f['lng'] = $f['lng'] == '' ? '139.745525' : $f['lng']; if ($type == 'default') { $list_str .= '<div class="gmap_mklist_dump">'; $list_str .= '<div class="mapmk" longdesc="' . $f['link'] . ',' . $f['lat'] . ',' . $f['lng'] . '" title="' . $f['title'] . '">' . $f['title'] . '</div> </div>'; } else { $list_str .= '<div class="gmap_mklist_fm mapmk" longdesc="' . $f['link'] . ',' . $f['lat'] . ',' . $f['lng'] . '" title="' . $f['title'] . '">'; if ($f['img'] != '') { $size = ""; $position = ""; list($width, $height) = getimagesize($f['img']); $sz = PLUGIN_GMAPFUN_MARK_IMAGE_SIZE; if ($width > $height) { $size = ' width="' . PLUGIN_GMAPFUN_MARK_IMAGE_SIZE . '"'; if (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE > $width) { $size = ' width="' . $width . '"'; } $position = 'top:' . (7 + (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE - $height * (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE / $width)) / 2) . 'px;'; } else { $size = ' height="' . PLUGIN_GMAPFUN_MARK_IMAGE_SIZE . '"'; if (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE > $height) { $size = ' height="' . $height . '"'; } $position = 'left:' . (7 + (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE - $width * (PLUGIN_GMAPFUN_MARK_IMAGE_SIZE / $height)) / 2) . 'px;'; } $list_str .= '<img src="' . $f['img'] . '" class="mapmk" ' . $size . ' style="' . $position . '" />'; } $list_str .= '<div class="pola_title">' . $f['title'] . '</div></div>'; } } } $list_str .= '<div style="clear:both;"></div>'; $body = str_replace('<%markerlist%>', $list_str, $gmap_disp); if (check_editable($vars['page'], false, false)) { $addscript .= ' <style type="text/css"> .gmap_edit_page { border-radius:7px; -ms-filter: "alpha( opacity=60 )";/* IE8 */ filter: alpha( opacity=60 );/* IE6-7 */ opacity: 0.6; background-color: #333; position: absolute; bottom:5px; left:0px; width:90%; padding:10px; text-align:center; color:#fff; cursor:pointer; } </style> <script type="text/javascript"> <!-- $(function(){ $("div#marker_info").click(function(){ var url = page_exists($(this)); if (url) { location.href = url; } return false; }) .hover( function(){ var url = page_exists($(this)); if (url) { $(this).append("<div class=\\"gmap_edit_page\\">クリックするとこのページの編集ができます</div>"); } }, function(){ $(this).children("div.gmap_edit_page").remove(); } ); function page_exists(obj) { var pageobj = obj.find("input:hidden[name=pagename]"); if (pageobj.length) { var tmpurl = location.href.split("?"); return tmpurl[0]+"?cmd=edit&page="+pageobj.val(); } return false; } }); // --> </script> '; } $qt->appendv_once('plugin_gmapfun' + $s_gmapfun_cnt, 'beforescript', $addscript); return $body; }
function plugin_list_get_commands($page) { $retarr = array('read' => array('format' => '%s?%s', 'label' => '表示'), 'edit' => array('format' => '%s?cmd=edit&page=%s', 'label' => '編集'), 'diff' => array('format' => '%s?cmd=diff&page=%s', 'label' => '差分'), 'backup' => array('format' => '%s?cmd=backup&page=%s', 'label' => 'バックアップ'), 'rename' => array('format' => '%s?cmd=rename&refer=%s', 'label' => '名前変更'), 'delete' => array('format' => '%s?cmd=delete&page=%s', 'label' => '削除'), 'map' => array('format' => '%s?cmd=map&refer=%s', 'label' => 'マップ'), 'template' => array('format' => '%s?cmd=template&refer=%s', 'label' => '複製')); if (PKWK_READONLY) { return array('read' => $retarr['read']); } if (!ss_admin_check()) { unset($retarr['diff'], $retarr['backup'], $retarr['rename'], $retarr['map'], $retarr['template']); if (!check_editable($page, FALSE, FALSE)) { unset($retarr['edit']); } } return $retarr; }
function plugin_qblog_comment_convert() { global $script, $vars, $digest, $username; global $qblog_defaultpage, $qblog_comment_check, $qblog_enable_comment; static $called = FALSE; $page = $vars['page']; if (PKWK_READONLY) { return ''; } // Show nothing if ($called) { return ''; } // Only once $called = TRUE; //QBlog ページ以外設置不可 if ($page === $qblog_defaultpage or !is_qblog()) { return ''; } if (isset($qblog_enable_comment) && !$qblog_enable_comment) { return ''; } $editable = check_editable($qblog_defaultpage, FALSE, FALSE); $qt = get_qt(); $qt->setv('jquery_include', TRUE); $qm = get_qm(); // TODO: remove // !既存のコメントを出力 $comments = array(); if (file_exists(CACHEQBLOG_DIR . encode($page) . '.qbcm.dat')) { $comments = unserialize(file_get_contents(CACHEQBLOG_DIR . encode($page) . '.qbcm.dat')); } if (count($comments) > 0) { foreach ($comments as $i => $comment) { if (!$comment['show']) { unset($comments[$i]); continue; } $cnt = $i + 1; if ($editable or $comment['accepted']) { $comment['msg'] = h($comment['msg']); //他のコメントにレスができる $comment['msg'] = preg_replace('/(>>|※)(\\d+)/', '<a href="#qbcomment_$2">$1$2</a>', $comment['msg']); $comment['msg'] = nl2br($comment['msg']); //URLをリンクに $ptns = array('/(?:https?|ftp)(?::\\/\\/[-_.!~*\'()a-zA-Z0-9;\\/?:\\@&=+\\$,%#]+)/'); $rpls = array('<a href="$0">$0</a>'); $comment['msg'] = preg_replace($ptns, $rpls, $comment['msg']); $comments[$i]['msg'] = $comment['msg']; } } } //認証コード生成 $authcode = '' . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9); $action = $script . '?' . rawurlencode($page); $name = ''; if ($editable) { $name = $username === $_SESSION['usr'] ? '管理人' : $_SESSION['usr']; } $name = isset($vars['name']) ? $vars['name'] : $name; $title = isset($vars['title']) ? $vars['title'] : ''; $msg = isset($vars['msg']) ? $vars['msg'] : ''; // !エラー処理 $auth_err = $title_err = $name_err = FALSE; if (isset($vars['qblog_comment_auth_error'])) { $auth_err = $vars['qblog_comment_auth_error']; } if (isset($vars['qblog_comment_title_error'])) { $title_err = $vars['qblog_comment_title_error']; } if (isset($vars['qblog_comment_name_error'])) { $name_err = $vars['qblog_comment_name_error']; } ob_start(); include PLUGIN_DIR . 'qblog/comment_template.html'; $html = ob_get_clean(); return $html; }
function plugin_qblog_list_convert() { global $vars, $qblog_date_format, $show_passage; global $qblog_page_prefix, $qblog_defaultpage, $qblog_page_format, $qblog_close; global $style_name; //閉鎖中は何も表示しない if ($qblog_close && !ss_admin_check()) { return ''; } static $exec_count = 1; $qm = get_qm(); $qt = get_qt(); $qt->setv('jquery_include', TRUE); $list_type = PLUGIN_QBLOG_LIST_TYPE; $recent_posts = PLUGIN_QBLOG_LIST_DEFAULT_POSTS; if (func_num_args()) { $args = func_get_args(); if (count($args) > 2) { return '#qblog_list([line or table], [number])'; } foreach ($args as $arg) { if (is_numeric($arg)) { $recent_posts = (int) $arg; } if ($arg == 'line') { $list_type = $arg; } } } //表示モード //recent, archives, category $mode = isset($vars['mode']) ? $vars['mode'] : 'recent'; //表示ページ:ページネーション //表示ページは必ず 1以上の整数 $page_num = isset($vars['p']) ? (int) $vars['p'] : 1; $page_num = $page_num <= 0 ? 1 : $page_num; // !前処理 if (!is_bootstrap_skin()) { $include_bs = ' <link rel="stylesheet" href="skin/bootstrap/css/bootstrap-custom.min.css" /> <script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>'; $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs); } //qblog.css を読み込む $head = ' <link rel="stylesheet" href="plugin/qblog/qblog.css" />'; $qt->appendv_once('qblog_beforescript', 'beforescript', $head); //---- キャッシュのための処理を登録 ----- $qt->enable_cache = FALSE; //------------------------------------ if (!file_exists(PLUGIN_QBLOG_LIST_CACHE)) { return $qm->m['plg_recent']['err_file_notfound'] . '<br />'; } $script = get_script_uri(); $date = $items = ''; //h2.title 前に挿入するHTML $pre_title_html = ''; // !新規記事追加リンクを表示 // デフォルトブログページが編集できるユーザー $editable = FALSE; if (check_editable($qblog_defaultpage, FALSE, FALSE) === TRUE) { $editable = TRUE; $search_replace = array('YYYY' => date('Y'), 'MM' => date('m'), 'DD' => date('d')); $newpage = str_replace(array_keys($search_replace), array_values($search_replace), $qblog_page_format); $number_holder_pos = strpos($newpage, '#'); if ($number_holder_pos !== FALSE) { $filename_prefix = encode(substr($newpage, 0, $number_holder_pos)); $files = glob(DATA_DIR . $filename_prefix . '*'); $pattern = '/^(' . str_replace('#', '(\\d+)', preg_quote($newpage)) . ')$/'; $max = 1; foreach ($files as $file) { $pagename = decode(basename($file, '.txt')); if (preg_match($pattern, $pagename, $mts)) { $max = max($mts[2], $max); } } $newpage = str_replace('#', $max + 1, $newpage); } $addpostlink = $script . '?cmd=qblog&mode=addpost'; $pre_title_html .= '<a href="' . h($addpostlink) . '" class="badge badge-info" style="color:#fff"><i class="icon-white icon-edit" style="vertical-align:text-bottom;"></i> 記事の追加</a> '; } // !モードによって、読み込むキャッシュを替える $pages = array(); $start = ($page_num - 1) * $recent_posts; $addquery = ''; switch ($mode) { case 'archives': $date = $vars['date']; $addquery = '&mode=archives&date=' . rawurlencode($date); if (preg_match('/^(\\d{4})(\\d{2})$/', $date, $mts)) { $year = $mts[1]; $month = $mts[2]; } else { $year = date('Y'); $month = date('m'); } $date = $year . $month; $files = glob(DATA_DIR . encode($qblog_page_prefix . $date) . '*'); foreach ($files as $file) { $pages[] = decode(basename($file, '.txt')); } $count_pages = count($pages); natsort($pages); $pages = array_reverse($pages); $pages = array_slice($pages, $start, $recent_posts); $subtitle = "{$year}年{$month}月"; $pre_title_html .= '<span class="badge">' . h($subtitle) . '</span> '; break; case 'category': $cat = isset($vars['catname']) ? $vars['catname'] : $qblog_default_cat; $addquery = '&mode=category&catname=' . rawurlencode($cat); $pages = explode("\n", trim(file_get_contents(CACHEQBLOG_DIR . encode($cat) . '.qbc.dat'))); $count_pages = count($pages); $pages = array_slice($pages, $start, $recent_posts); $pre_title_html .= '<span class="badge">カテゴリ:' . h($cat) . '</span> '; break; default: //recent mode // Get latest N changes $count_pages = (int) array_pop(file_head(PLUGIN_QBLOG_LIST_CACHE, 1)); $lines = file_slice(PLUGIN_QBLOG_LIST_CACHE, $start + 1, $recent_posts); foreach ($lines as $line) { $pages[] = rtrim($line); } } //! 記事毎のデータをまとめる $posts = array(); foreach ($pages as $i => $page) { //キャッシュファイルを読み込む $data = get_qblog_post_data($page); if ($data === FALSE) { continue; } $r_page = rawurlencode($page); if (is_file(SWFU_IMAGE_DIR . $data['image'])) { $data['image'] = SWFU_IMAGE_DIR . $data['image']; } if (trim($data['image']) === '') { $data['image'] = PLUGIN_DIR . 'qblog/qblog_thumbnail.png'; } if (trim($data['image']) === '') { $data['image'] = PLUGIN_DIR . 'qblog/qblog_thumbnail.png'; } $posts[$i] = array('page' => $page, 'title' => $data['title'], 'abstract' => $data['abstract'], 'image' => $data['image'], 'category' => $data['category'], 'url' => $script . '?' . $r_page . $addquery, 'date' => get_qblog_date($qblog_date_format, $page)); } // !ページネーションリンクを足す $paginates = array(); if ($count_pages > $recent_posts) { if ($page_num > 1) { $paginates[PLUGIN_QBLOG_LIST_PAGINATE_LAST_NAV] = $script . '?' . $qblog_defaultpage . '&p=1' . $addquery; } $paginate_length = ceil($count_pages / $recent_posts); if (PLUGIN_QBLOG_LIST_PAGINATE_NUM < $paginate_length) { } $range = (int) floor(PLUGIN_QBLOG_LIST_PAGINATE_NUM / 2); $start = (int) max(1, $page_num - $range); $end = (int) min($paginate_length + 1, $start + PLUGIN_QBLOG_LIST_PAGINATE_NUM); // 最初<<< 1 | 2 | 3 | 4 | 5 >>>最後 // 最初<<< 5 | 6 | 7 | 8 | 9 >>>最後 for ($i = $start; $i < $end; $i++) { $paginates[$i] = $script . '?' . $qblog_defaultpage . '&p=' . $i . $addquery; if ($page_num == $i) { $paginates[$i] = ''; } } if ($page_num < $paginate_length) { $paginates[PLUGIN_QBLOG_LIST_PAGINATE_FIRST_NAV] = $script . '?' . $qblog_defaultpage . '&p=' . $paginate_length . $addquery; } } $template_name = 'qblog_list_template.html'; if (file_exists(SKIN_DIR . $style_name . '/' . $template_name)) { $template_path = SKIN_DIR . $style_name . '/' . $template_name; } else { $template_path = PLUGIN_DIR . 'qblog/list_template.html'; } //! テンプレートを読み込む ob_start(); include $template_path; $items .= ob_get_clean(); //! h2.title にbadge を挿入 if ($list_type === 'table') { $qt->prependv('this_right_title', $pre_title_html); } return '<div id="qblog">' . $items . '</div>'; }
function plugin_table_edit2_action() { global $vars, $post, $auth_users, $_string; $table_num = $vars['table_num']; $page = isset($vars['refer']) ? $vars['refer'] : null; if (empty($page)) { Utility::dieMessage('Page name is null.'); } $wiki = Factory::Wiki($page); if (is_freeze($page)) { check_editable($page, true, true); } if ($wiki->isFreezed()) { $wiki->checkEditable(true); } // Cancel $anchr_jump = PLUGIN_TABLE_EDIT2_ANCHR_JUMP ? '#TableEdit2TableNumber' . $table_num : ''; if (isset($vars['cancel'])) { Utility::redirect($wiki->uri() . $anchr_jump); exit; } $line_count = 1; $table_sub_num = 1; //td $table_sub_num_chk = 1; //td $setting = 0; $import = $export = $csv_cancel = 0; $edit_mod = isset($vars['edit_mod']) ? $vars['edit_mod'] : ''; $td_edit = $edit_mod == 't_edit_td' || $edit_mod == 'td' ? 1 : 0; $tr_edit = $edit_mod == 't_edit' || $edit_mod == 'tr' ? 1 : 0; $t_edit = $edit_mod == 't_edit_td' || $edit_mod == 't_edit' ? 1 : 0; $edit_show = $edit_mod == 'tdshow' || $edit_mod == 'show' ? 1 : 0; // Petit SPAM Check (Client(Browser)-Server Ticket Check) $spam = FALSE; if (!function_exists('honeypot_write') && $t_edit) { $spam = plugin_table_edit2_spam($post['encode_hint']); } if ($spam) { return plugin_table_edit2_honeypot(); } if (Auth::check_role('readonly')) { die_message('PKWK_READONLY prohibits editing'); } if (PLUGIN_TABLE_EDIT2_HTTP_REFERER) { if (!function_exists('path_check')) { if (!preg_match('/^(' . $script_uri . ')/', $_SERVER['HTTP_REFERER'])) { return; } } else { if (!path_check($script_uri, $_SERVER['HTTP_REFERER'])) { return; } } } if ($edit_mod === 'setting') { $set = new TableEdit2SettingWrite($vars); if (!$set->sc) { return $set->error; } $setting = 1; unset($vars['table_mod']); } $notimestamp = FALSE; if (isset($vars['csv_mod']) || isset($vars['ex_cancel']) || isset($vars['im_cancel']) || isset($vars['set_csv']) || isset($vars['csv_back'])) { $csv = new TableEdit2CsvAction(); if (isset($vars['csv_mod']) && $vars['csv_mod'] === 'import') { $csv->csv_import($vars); $import = 1; } else { if (isset($vars['csv_mod']) && $vars['csv_mod'] === 'export') { $export = 1; $csv_export_data = array(); } else { if (isset($vars['ex_cancel']) || isset($vars['im_cancel'])) { $csv_cancel = 1; $notimestamp = TRUE; } else { if (isset($vars['set_csv'])) { $set_csv = 1; $notimestamp = TRUE; } else { if (isset($vars['csv_back'])) { if (PLUGIN_TABLE_EDIT2_CSV_UNLINK) { $con = new TableEdit2CsvConversion($page, array('name' => $vars['file_name'])); unlink($con->filename); unlink($con->logname); } Utility::redirect($wiki->uri()); exit; } else { return array('msg' => 'csv error', 'body' => 'csv option error'); // . join("\n", $csv_data) } } } } } } if (isset($vars['table_mod'])) { $chg = new TableEdit2TableMod($vars['table_mod']); } if ($td_edit || $tr_edit) { $edit = new TableEdit2Edit($vars); } if ($edit_show) { $show = new TableEdit2Show($vars, $page); } $args = get_source($page); static $count = 0; $source_s = ''; $body = ''; $row_title = 0; $td_title_count = 0; if ($td_edit || $tr_edit || $setting || $import) { $notimestamp = isset($vars['notimestamp']) ? TRUE : FALSE; } foreach ($wiki->get() as $args_key => $args_line) { if (preg_match('/^#([^\\(\\{]+)(?:\\(([^\\r]*)\\))?(\\{*)/', $args_line, $matches) !== FALSE) { if (isset($matches[1]) && ($matches[1] == 'table_edit2' || $matches[1] == "table_edit2\n")) { $table_find = 1; $count++; if ($line_count === 1 && $count == $table_num) { if (preg_match('/auth_check[=_](on|off)/i', $matches[2], $auth_check)) { if ($auth_check[1] == 'on') { if (!auth::auth_pw($auth_users)) { $user = TableEdit2Auth::basic_auth(); if (empty($user)) { return; } } } } else { check_editable($page, true, true); } if ($setting) { $args_line = $set->plugin_set_opt($matches[3]); } if ($import) { $args_line = $csv->import_data_set($matches[2], $matches[3]); } if (isset($vars['ex_cancel'])) { $args_line = $csv->cancel($matches[2], $matches[3], 'export'); } if (isset($vars['im_cancel'])) { $args_line = $csv->cancel($matches[2], $matches[3], 'import'); } if (isset($set_csv)) { $args_line = $csv->set_csv_opt($matches[2], $matches[3], $vars['set_csv']); } if ($edit_mod == 'tdshow') { //tdshow - td_title - 06.11.11 if (preg_match('/title_c=(\\d+)/i', $matches[2], $match_title)) { $td_title_count = $match_title[1] - 1; } } if ($edit_mod == 'show') { //show header if (preg_match('/title_r=(\\d+)/i', $matches[2], $m_row_title)) { $row_title = $m_row_title[1]; } } if ($edit_show) { $show->text_type($matches[2]); } if (isset($vars['table_mod'])) { //table_mod $notimestamp = TRUE; $args_line = $chg->table_mod_chg($matches, $args_line); } } $end_line = strlen($matches[3]); } } if (isset($end_line) && preg_match('/^\\}{' . $end_line . '}/', $args_line) || !isset($end_line)) { $table_find = 0; } if ($table_find && $table_num == $count && !isset($vars['table_mod']) && !$setting && !$import) { $table_sub_num_count_chk = 0; $table_f_chose = preg_match('/^\\|(.+)\\|([hHfFcC]?)$/', $args_line, $match_line) ? 1 : 0; if ($args_line[0] == ',' && $args_line != ',') { $table_f_chose = 2; } if ($td_edit || $tr_edit) { $edit->chose = $table_f_chose; } if ($table_f_chose) { if ($table_f_chose === 1) { $match_t = explode("|", $match_line[1]); } elseif ($table_f_chose === 2) { $match_t = csv_explode(',', substr(str_replace("\n", '', $args_line), 1)); $match_line = array(1 => join(',', $match_t), 2 => ''); } if ($export) { $csv_export_data[] = $match_line[1]; } if (isset($vars['table_sub_num']) && $table_sub_num === $vars['table_sub_num'] && $table_sub_num_chk) { //td 06.09.18 $show->chk_table_sub_first_line = $line_count; $table_sub_num_chk = 0; } if (isset($vars['line_count']) && $vars['line_count'] === $line_count || strtolower($match_line[2]) === 'h' || $edit_mod == 'tdshow' || $td_edit || $row_title) { // $match_t = explode("|", $match_line[1]); if ($edit_mod == 'tdshow') { //tdshow - td_title - 06.11.11 $show->td_title[$line_count] = $match_t[$td_title_count]; } } if ($edit_mod == 'show') { //show header if ($match_line[2] == 'h' && !$row_title) { $show->table_header($match_t); } if ($line_count == $row_title) { $show->table_header($match_t); } } if ($vars['line_count'] == $line_count || $table_sub_num == $vars['table_sub_num']) { // textarea 06.11.12 if ($edit_show) { if ($show->t_type == 'textarea') { $show->text_type_textarea(count($match_t)); } } } if ($td_edit && $table_sub_num_chk == 0 && $table_sub_num == $vars['table_sub_num']) { $source_s .= $edit->td_edit($match_t) . $match_line[2] . "\n"; $table_sub_num_count_chk = 1; } else { if (isset($vars['line_count']) && $vars['line_count'] == $line_count && !$td_edit) { if ($tr_edit) { //t_edit tr_add if (isset($vars['add_show']) && $vars['add_show'] === 1) { $source_s .= $args_line; if ($edit->chose !== 2) { $edit->chk_csv_source($args, $args_key); } } $source_s .= $edit->tr_edit($args_line, $match_t, $match_line[2]); } else { if ($edit_show) { //show or tdshow $show->line_count = $line_count; $body = $show->show_mod($match_t); } } } else { if ($edit_mod == 'tdshow') { //tdshow and edit_td $show->cells[$line_count] = $match_t; } $table_sub_num_count_chk = 1; //td06.09.18 $source_s .= $args_line; } } $line_count++; } else { if ($table_sub_num_count_chk == 1 && substr($args_line, 0, 2) != '//') { //td $table_sub_num++; $table_sub_num_count_chk = 0; } $source_s .= $args_line; } } else { $source_s .= $args_line . "\n"; } } if ($export) { return $csv->csv_export($vars, $csv_export_data); } $collision = 0; if ($tr_edit || $td_edit) { if (Factory::Wiki($vars['refer'])->digest() !== $vars['digest']) { global $_string, $_title; $title = $_title['collided']; $body = $_string['msg_collided_auto'] . make_pagelink($vars['refer']); $collision = 1; } } if ($tr_edit || $td_edit || isset($vars['table_mod']) || $setting || $import || $csv_cancel || isset($set_csv)) { $source = explode("\n", $source_s); array_pop($source); // 末尾に余計な改行が入るので削除 // var_dump($source); // die; $wiki->set(explode("\n", $source_s), $notimestamp); } $get['page'] = $post['page'] = $vars['page'] = $page; if ($collision) { return array('msg' => $title, 'body' => $body); } if ($edit_show) { return array('msg' => $show->title, 'body' => $body); } //header('Location: ' . $script_uri . '?' . rawurlencode($page) . $anchr_jump); Utility::redirect($wiki->uri() . $anchr_jump); exit; }
function plugin_calendar2_convert() { $qt = get_qt(); //---- キャッシュのための処理を登録 ----- if ($qt->create_cache) { $args = func_get_args(); return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args); } //------------------------------------ global $script, $vars, $post, $get, $weeklabels, $WikiName, $BracketName; $qm = get_qm(); $date_str = get_date('Ym'); $base = strip_bracket($vars['page']); $today_view = TRUE; if (func_num_args()) { $args = func_get_args(); foreach ($args as $arg) { if (is_numeric($arg) && strlen($arg) == 6) { $date_str = $arg; } else { if ($arg == 'off') { $today_view = FALSE; } else { $base = strip_bracket($arg); } } } } if ($base == '*') { $base = ''; $prefix = ''; } else { $prefix = $base . '/'; } $r_base = rawurlencode($base); $s_base = htmlspecialchars($base); $r_prefix = rawurlencode($prefix); $s_prefix = htmlspecialchars($prefix); $yr = substr($date_str, 0, 4); $mon = substr($date_str, 4, 2); if ($yr != get_date('Y') || $mon != get_date('m')) { $now_day = 1; $other_month = 1; } else { $now_day = get_date('d'); $other_month = 0; } $today = getdate(mktime(0, 0, 0, $mon, $now_day, $yr) - LOCALZONE + ZONETIME); $m_num = $today['mon']; $d_num = $today['mday']; $year = $today['year']; $f_today = getdate(mktime(0, 0, 0, $m_num, 1, $year) - LOCALZONE + ZONETIME); $wday = $f_today['wday']; $day = 1; $m_name = $year . '.' . $m_num; $y = substr($date_str, 0, 4) + 0; $m = substr($date_str, 4, 2) + 0; $prev_date_str = $m == 1 ? sprintf('%04d%02d', $y - 1, 12) : sprintf('%04d%02d', $y, $m - 1); $next_date_str = $m == 12 ? sprintf('%04d%02d', $y + 1, 1) : sprintf('%04d%02d', $y, $m + 1); $ret = ''; $today_view_str = ''; if ($today_view) { $ret = '<table border="0" summary="calendar frame">' . "\n" . ' <tr>' . "\n" . ' <td valign="top">' . "\n"; } else { $today_view_str = "&view=off"; } $ret .= <<<EOD <table class="style_calendar" cellspacing="1" border="0" summary="calendar body"> <tr> <td class="style_td_caltop text-center" colspan="7"> <a href="{$script}?plugin=calendar2&file={$r_base}&date={$prev_date_str}{$today_view_str}"><<</a> <strong>{$m_name}</strong> <a href="{$script}?plugin=calendar2&file={$r_base}&date={$next_date_str}{$today_view_str}">>></a> EOD; if ($prefix) { $ret .= "\n" . ' <br />[<a href="' . $script . '?' . $r_base . '">' . $s_base . '</a>]'; } $ret .= "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n"; foreach ($weeklabels as $label) { $ret .= ' <td class="style_td_week text-center" width="30" height="30">' . $label . '</td>' . "\n"; } $ret .= ' </tr>' . "\n" . ' <tr>' . "\n"; // Blank for ($i = 0; $i < $wday; $i++) { $ret .= ' <td class="style_td_blank"> </td>' . "\n"; } while (checkdate($m_num, $day, $year)) { $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day); $page = $prefix . $dt; $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); if ($wday == 0 && $day > 1) { $ret .= ' </tr>' . "\n" . ' <tr>' . "\n"; } $style = 'style_td_day text-right'; // Weekday if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) { // Today $style = 'style_td_today text-right alert-success'; } else { if ($wday == 0) { // Sunday $style = 'style_td_sun text-right alert-danger'; } else { if ($wday == 6) { // Saturday $style = 'style_td_sat text-right alert-info'; } } } if (is_page($page)) { $link = '<a href="' . $script . '?' . $r_page . '" title="' . $s_page . '"><strong style="">' . $day . '</strong></a>'; $style .= ' btn-warning'; } else { if (PKWK_READONLY) { $link = '<span class="small">' . $day . '</span>'; } else { $editable = check_editable($page, FALSE, FALSE); // 管理ログイン後 if ($editable === TRUE) { $link = $script . '?cmd=edit&page=' . $r_page . '&refer=' . $r_base; $link = '<a class="small" href="' . $link . '" title="' . $s_page . '">' . $day . '</a>'; } else { $link = '<span class="small">' . $day . '</span>'; } } } $ret .= ' <td class="' . $style . '">' . "\n" . ' ' . $link . "\n" . ' </td>' . "\n"; ++$day; $wday = ++$wday % 7; } if ($wday > 0) { while ($wday++ < 7) { // Blank $ret .= ' <td class="style_td_blank"> </td>' . "\n"; } } $ret .= ' </tr>' . "\n" . ' </table>' . "\n"; if ($today_view) { $tpage = $prefix . sprintf('%4d-%02d-%02d', $today['year'], $today['mon'], $today['mday']); $r_tpage = rawurlencode($tpage); if (is_page($tpage)) { $_page = $vars['page']; $get['page'] = $post['page'] = $vars['page'] = $tpage; $str = convert_html(get_source($tpage)); $str .= '<hr /><a class="small" href="' . $script . '?cmd=edit&page=' . $r_tpage . '">' . $qm->m['plg_calendar2']['edit'] . '</a>'; $get['page'] = $post['page'] = $vars['page'] = $_page; } else { $str = $qm->replace('plg_calendar2.empty', make_pagelink(sprintf('%s%4d-%02d-%02d', $prefix, $today['year'], $today['mon'], $today['mday']))); } $ret .= ' </td>' . "\n" . ' <td valign="top">' . $str . '</td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n"; } return '<div class="qhm-plugin-calendar2">' . $ret . '</div>'; }
function plugin_unfreeze_action() { global $script, $vars, $function_freeze; $_title_isunfreezed = _(' $1 is not frozen'); $_title_unfreezed = _(' $1 has been unfrozen.'); $_title_unfreeze = _('Unfreeze $1'); $_msg_invalidpass = _('Invalid password.'); $_msg_unfreezing = _('Please input the password for unfreezing.'); $_btn_unfreeze = _('Unfreeze'); $page = isset($vars['page']) ? $vars['page'] : ''; if (!$function_freeze || is_cantedit($page) || !is_page($page)) { return array('msg' => '', 'body' => ''); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = $body = ''; if (!is_freeze($page)) { // Unfreezed already $msg = $_title_isunfreezed; $body = str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_isunfreezed); } else { if (!auth::check_role('role_adm_contents') || $pass !== NULL && pkwk_login($pass)) { // BugTrack2/255 check_readable($page, true, true); // Unfreeze $postdata = get_source($page); array_shift($postdata); $postdata = join('', $postdata); file_write(DATA_DIR, $page, $postdata, TRUE); // Update is_freeze($page, TRUE); if (PLUGIN_UNFREEZE_EDIT) { // BugTrack2/255 check_editable($page, true, true); // $vars['cmd'] = 'read'; // To show 'Freeze' link $vars['cmd'] = 'edit'; $msg = $_title_unfreezed; $body = edit_form($page, $postdata); } else { $vars['cmd'] = 'read'; $msg = $_title_unfreezed; $body = ''; } } else { // Show unfreeze form $msg = $_title_unfreeze; $s_page = htmlspecialchars($page); $body = $pass === NULL ? '' : "<p><strong>{$_msg_invalidpass}</strong></p>\n"; $body .= <<<EOD <p>{$_msg_unfreezing}</p> <form action="{$script}" method="post"> <div> <input type="hidden" name="cmd" value="unfreeze" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="password" name="pass" size="12" /> <input type="submit" name="ok" value="{$_btn_unfreeze}" /> </div> </form> EOD; } } return array('msg' => $msg, 'body' => $body); }
/** * Social Buttons Plugin * ------------------------------------------- * ./plugin/social_buttons.inc.php * * Copyright (c) 2012 hokuken * http://hokuken.com/ * * created : 2012-03-12 * modified : * * Description * * Usage : * */ function plugin_social_buttons_convert() { global $script, $vars; $qt = get_qt(); $qt->setv('jquery_include', true); $args = func_get_args(); $url = ''; $layout = 'h1'; //h1 | h2 | large $margin = '3px'; //margin-right per button $h_margin = '0'; //horizontal margin of buttons wrapper $text = ''; //extra text $float = 'right'; //left|right $service_list = array('google_plusone', 'twitter', 'facebook_like'); $services = array(); foreach ($args as $arg) { $arg = trim($arg); if (preg_match('/^tw(?:itter)?(?:=([^,\\)]*))?$/', $arg, $mts)) { $option_str = isset($mts[1]) ? $mts[1] : ''; $services['twitter'] = plugin_social_buttons_parse_option($option_str); } else { if (preg_match('/^(?:facebook|fb)(?:=([^,\\)]*))?$/', $arg, $mts)) { $option_str = isset($mts[1]) ? $mts[1] : ''; $services['facebook_like'] = plugin_social_buttons_parse_option($option_str); } else { if (preg_match('/^(?:google_plusone|gp)(?:=([^,\\)]*))?$/', $arg, $mts)) { $option_str = isset($mts[1]) ? $mts[1] : ''; $services['google_plusone'] = plugin_social_buttons_parse_option($option_str); } else { if (in_array($arg, array('h1', 'h2', 'large'))) { $layout = $arg; if ($layout === 'large') { $margin = '15px'; } } else { if (is_url($arg)) { $url = $arg; } else { if (preg_match('/^\\d+$/', $arg)) { $margin = intval($arg); $margin = $margin > 0 ? $margin . 'px' : 0; } else { if ($arg === 'right' or $arg === 'left') { $float = $arg; } else { $text = $arg; } } } } } } } } if (count($services) === 0) { foreach (array_flip($service_list) as $service => $v) { $services[$service] = array(); } } if ($float === 'right') { $services = array_combine(array_reverse(array_keys($services)), array_reverse(array_values($services))); } $use_fb = FALSE; foreach ($services as $service => $option) { switch ($service) { case 'twitter': switch ($layout) { case 'h1': $tmp = 'none'; break; case 'h2': $tmp = 'horizontal'; break; default: //large $tmp = 'vertical'; } $option['button'] = $tmp; break; case 'facebook_like': $use_fb = TRUE; $width = 120; switch ($layout) { case 'h1': $width = 100; case 'h2': $tmp = 'button_count'; break; default: //large $tmp = 'box_count'; } $option['show_faces'] = 'false'; $option['layout'] = $tmp; $option['width'] = isset($option['width']) ? $option['width'] : $width; break; case 'google_plusone': $count = TRUE; //size switch ($layout) { case 'h1': $count = 'false'; case 'h2': $tmp = 'medium'; break; default: //large $tmp = 'tall'; } $option['size'] = $tmp; $option['count'] = $count; //lang $option['lang'] = 'ja'; break; } $services[$service] = $option; } $tinyurl = $fburl = $url; $page = $vars['page']; if ($url === '') { $fburl = $script . '?' . rawurlencode($page); $url = $script . '?' . rawurlencode($page); $tinyurl = $script . '?go=' . get_tiny_code($page); } $addscript = ' <style type="text/css"> .qhm_plugin_social_buttons { margin: 3px 0; } </style> <script type="text/javascript" src="./js/jquery.socialbutton-1.9.1.js"></script> <script type="text/javascript"> $(function(){ $("div.qhm_plugin_social_button").each(function(){ var $$ = $(this), service = $$.attr("data-sb-service"), option = {}, attrs = this.attributes; var cnt = 0, attr, opt_name; while (1) { attr = attrs.item(cnt); cnt++; if (attr == null) break; if (attr.name == "data-sb-service") continue; if (/^data-sb-(.+)$/.test(attr.name)) { opt_name = attr.name.match(/^data-sb-(.+)$/)[1]; option[opt_name] = /^false$/.test(attr.value) ? false: attr.value; } } $$.socialbutton(service, option); }); }); </script> '; $body = ' <div class="qhm_plugin_social_buttons"> '; foreach ($services as $service => $option) { $option_attr = ''; foreach ($option as $key => $val) { $option_attr .= ' data-sb-' . $key . '="' . h($val) . '"'; } switch ($service) { case 'twitter': $service_url = $tinyurl; break; case 'facebook_like': $service_url = $fburl; break; default: $service_url = $url; } $body .= '<div class="qhm_plugin_social_button" data-sb-service="' . h($service) . '" data-sb-url="' . h($service_url) . '"' . $option_attr . ' style="margin-right:' . h($margin) . ';float:' . h($float) . ';"></div>'; } $body .= ' <div style="clear:both;"></div> </div> '; $editable = check_editable($page, FALSE, FALSE); //Facebook いいね!ボタンが表示されない問題への対処について。 //原因は不明だが、Fbデバッガへ通すと改善する。 //管理者にはFacebook のデバッガーへのリンクを表示する。 if ($editable && $use_fb) { $debuggerlink = 'http://developers.facebook.com/tools/debug/og/object?q=' . rawurlencode($fburl); $body .= ' <p style="text-align:' . h($float) . ';margin-top: 0;"> <button type="button" class="" style="color:navy;cursor:pointer;border:none;background:none;" data-toggle="collapse" data-target="div.plugin_social_button_alert"> <i class="icon icon-hand-up"></i> いいね!が表示されない </button> </p> <div class="collapse out plugin_social_button_alert"> <div class="alert alert-info"> <p> 以下の手順で復旧してください。 </p> 1. <a href="' . h($debuggerlink) . '" class="btn btn-default btn-sm">ここをクリック >></a><br /> 2. Facebook のページが開いたら、そのまま閉じる。<br /> 3. このページを<a href="#" class="btn btn-default btn-sm" onclick="document.location.reload();return false;">再読み込み</a>する。<br /> 4. 完了 </div> </div> '; } $qt->appendv_once('plugin_social_buttons', 'beforescript', $addscript); return $body; }
function plugin_dav_getfileobj($path, $readonly = true) { global $zslash; if (!isset($path)) { return NULL; } // $path = mb_convert_encoding($path, SOURCE_ENCODING, 'UTF-8'); if (preg_match('/^\\/(.+)\\/([^\\/]+)$/', $path, $matches) != 1) { return NULL; } $page = str_replace($zslash, '/', $matches[1]); if (!is_page($page)) { return NULL; } if (!$readonly && !is_editable($page)) { return NULL; } if (!check_readable($page, false, false)) { plugin_dav_error_exit(401); } // 'user/password' if (!$readonly && !check_editable($page, false, false)) { plugin_dav_error_exit(401); } // 'user/password' return new AttachFile($page, $matches[2]); }
function attach_showform() { global $vars, $_attach_messages; if (auth::check_role('safemode')) { die_message(_('PKWK_SAFE_MODE prohibits this')); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); $vars['refer'] = $page; $body = attach_form($page, TRUE); return array('msg' => $_attach_messages['msg_upload'], 'body' => $body); }
function plugin_amazon_action() { global $vars, $script; global $amazon_body; global $_amazon_msg; $check = new amazon_check_asin(htmlspecialchars(rawurlencode(strip_bracket($vars['asin'])))); if (!$check->is_asin) { $retvars['msg'] = $_amazon_msg['msg_BookReviewEdit']; $retvars['refer'] = $vars['refer']; $s_page = $vars['refer']; $r_page = $s_page . '/' . $check->asin; $retvars['body'] = plugin_amazon_convert(); return $retvars; } $s_page = $vars['refer']; $r_page = $s_page . '/' . $check->asin; // $r_page_url = rawurlencode($r_page); if (!check_readable($r_page, false, false)) { header('Location: ' . get_page_location_uri($r_page)); } elseif (check_editable($r_page, false, false)) { $info = new amazon_getinfo($check->asin, 'heavy'); $title = $info->items['title']; if ($title == '' or preg_match('/^\\//', $s_page)) { header('Location: ' . get_script_absuri() . '?' . encode($s_page)); } $body = "#amazon({$check->asin},,image)\n*{$title}\n" . $amazon_body; amazon_review_save($r_page, $body); header('Location: ' . get_location_uri('edit', $r_page)); } else { return false; } die; }
function plugin_guiedit_action() { // global $vars, $_title_edit, $load_template_func; global $vars, $load_template_func; global $menubar, $sidebar, $topicpath; // if (PKWK_READONLY) die_message( _('PKWK_READONLY prohibits editing') ); if (auth::check_role('readonly')) { die_message(_('PKWK_READONLY prohibits editing')); } if (PKWK_READONLY == ROLE_AUTH && auth::get_role_level() > ROLE_AUTH) { die_message(_('PKWK_READONLY prohibits editing')); } $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); if (!is_page($page) && auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(_('PKWK_CREATE_PAGE prohibits editing')); } global $guiedit_use_fck; $guiedit_use_fck = isset($vars['text']) ? false : true; if ($guiedit_use_fck) { global $guiedit_pkwk_root; $guiedit_pkwk_root = get_baseuri('abs'); } if (GUIEDIT_FULL_SIZE) { $menubar = $sidebar = ''; $topicpath = false; } if (isset($vars['edit'])) { return plugin_guiedit_edit_data($page); } else { if ($load_template_func && isset($vars['template'])) { return plugin_guiedit_template(); } else { if (isset($vars['preview'])) { return plugin_guiedit_preview(); } else { if (isset($vars['write'])) { return plugin_guiedit_write(); } else { if (isset($vars['cancel'])) { return plugin_guiedit_cancel(); } } } } } $source = get_source($page); $postdata = $vars['original'] = join('', $source); if (isset($vars['text'])) { if (!empty($vars['id'])) { exist_plugin('edit'); $postdata = plugin_edit_parts($vars['id'], $source); if ($postdata === FALSE) { unset($vars['id']); $postdata = $vars['original']; } } if ($postdata == '') { $postdata = auto_template($page); } } return array('msg' => $_title_edit, 'body' => plugin_guiedit_edit_form($page, $postdata)); }
function plugin_check_login_convert() { global $vars, $script, $check_login; //$check_login が初期化されていない場合、1 を代入 if (!isset($check_login)) { $check_login = 1; } if (!$check_login) { return ''; } //一般アクセス時には実行しない if (!check_editable($vars['page'], false, false)) { return; } $qm = get_qm(); $qt = get_qt(); if (!$qt->is_appended('plugin_check_login')) { // !javascript $interval = '10000'; $slidespeed = '3000'; $addjs = ' <script type="text/javascript"> window.qhm_check_login = '******'; $(function(){ var $loginForm = $("#loginForm"), $loginOL = $("#loginOverlay"), $loginMsg = $("#loginMessage"), $logoutNtfr = $("#logoutNotifier"), $usrInput = $("input:text[name=username]", $loginForm), $pwInput = $("input:password[name=password]", $loginForm), $loginBtn = $("div.submit_login a", $loginForm), $cancelBtn = $("div.cancel_login a", $loginForm); //loginForm init //position var top = (($(window).height() / 2) - ($loginForm.outerHeight() / 2)) + 0; var left = (($(window).width() / 2) - ($loginForm.outerWidth() / 2)) + 0; if( top < 0 ) top = 0; if( left < 0 ) left = 0; $loginForm.css({ top: top + "px", left: left + "px" }); //loginOverlay init $loginOL .css({ height: $(document).height() }); function checkLogin(callback) { if (window.qhm_check_login == 2) { setTimeout(checkLogin, ' . $interval . '); } callback = callback || function(){}; if ($loginOL.is(":visible")) return; var is_login = true; $.ajax({ url: "' . $script . '", global: false, data: {cmd: "check_login", mode: "check"}, dataType: "json", type: "GET", success: function(res, result){ var mode = ""; //切れていればlogout notifier 表示 if (res.status == 0) { if (window.qhm_check_login == 1) { showLoginForm(); $("#loginMessage") .text("' . $qm->m['plg_check_login']['logout2'] . '") .css("color", "red"); } else { var $ln = $logoutNtfr.slideDown(' . $slidespeed . '); } is_login = false; } }, complete: function(){callback.apply(this, [is_login])} }); } if (window.qhm_check_login == 1) { $("#edit_form_main").bind("submit.check_login", function(e){ checkLogin(function(is_login){ if (is_login) { var $form = $("#edit_form_main"), target = $form.data("clicked") || "preview"; $form.unbind("submit.check_login") .find("input:submit[name="+target+"]").click(); } }); return false; }) .find("input:submit").click(function(){ var $$ = $(this); $$.closest("form").data("clicked", $$.attr("name")); }); } if (window.qhm_check_login == 2) { checkLogin(); } function removeLoginForm() { $loginOL.fadeOut(); $loginForm.fadeOut("normal", function(){ $loginMsg.text(""); }); } function showLoginForm() { //init removeLoginForm(); //show prompt $loginForm.fadeIn(); $loginOL.fadeIn(); $usrInput.focus().select(); } $logoutNtfr.click(function(){ //セッションが切れているかチェック $.ajax({ url: "' . $script . '", global: false, data: {cmd: "check_login", mode: "check"}, dataType: "json", type: "GET", success: function(res, result){ var mode = ""; //切れていればフォームを表示 if (res.status == 0) { showLoginForm(); } else { //$.flash(res.result.message); } } }); $(this).slideUp(1000); return false; }); //If click overlay, cancel form $("#loginOverlay").click(function(){ $cancelBtn.trigger("click"); return false; }); //login button click $loginBtn.click( function() { var data = { cmd: "check_login", mode: "auth", username: $usrInput.val(), password: $pwInput.val() }; //ログインを試行 $.ajax({ url: "' . $script . '", global: false, data: data, dataType: "json", type: "POST", success: function(res, result){ //login success if (res.status == 1) { $loginMsg .css({ color: "#0f0" }) .text(res.message); removeLoginForm(); } else { $loginMsg .css({ color: "#f00" }) .text(res.message); //retry $usrInput.focus().select(); } } }); // ページの更新、プレビューボタンのロックを解除 $("#edit_form_main input:submit, #edit_form_cancel input:submit") .prop("disabled", false) .prev("input:hidden").remove(); return false; }); $cancelBtn.click( function() { removeLoginForm(); $logoutNtfr.slideDown(1000); return false; }); $("input", $loginForm).keypress( function(e) { if( e.keyCode == 13 ) $loginBtn.trigger("click"); if( e.keyCode == 27 ) $cancelBtn.trigger("click"); }); }); </script> '; // !CSS $addstyle = ' <style type="text/css"> #logoutNotifier { border: #999 6px solid; border-bottom: none; background-color: black; position: fixed; bottom: 0; left: 50%; width: 600px; height: 50px; line-height: 50px; text-align: center; -moz-border-radius-topleft: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-left-radius: 6px; -webkit-border-top-right-radius: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; color: white; margin-left: -300px; opacity: 0.75; display: none; cursor: pointer; z-index: 9000; } #logoutNotifier:hover { background-color: #666; } #logoutNotifier a{ color: white; } #loginForm { display: none; position: fixed; z-index: 1000; min-width: 300px; max-width: 600px; min-height: 210px; background-color: #FFF; border: solid 5px #999; color: #000; font-size: 12; margin: 0; padding: 0; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, .3); -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, .3); box-shadow: 0 1px 5px rgba(0, 0, 0, .3); } #loginForm input[type=text], #loginForm input[type=password] { border: 1px solid #C5C6C8; border-bottom: 1px solid #8D8D8F; font-size: 16px; width: 284px; height: 25px; padding: 4px 4px; /* -webkit-transition: .2s ease-in-out; -moz-transition: .2s ease-in-out; -o-transition: .2s ease-in-out; */ -moz-box-shadow: inset 0 1px 5px rgba(0, 0, 0, .3),0 1px 0 0 #FAFBFB; -webkit-box-shadow: inset 0 1px 5px rgba(0, 0, 0, .3),0 1px 0 0 #FAFBFB; box-shadow: inset 0 1px 5px rgba(0, 0, 0, .3),0 1px 0 0 #FAFBFB; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; } #loginForm input[type=text]:focus, #loginForm input[type=password]:focus { border: 1px solid #228DED; -moz-box-shadow: 0 0 5px #228DED; -webkit-box-shadow: 0 0 5px #228DED; box-shadow: 0 0 5px #228DED; } #loginForm label { display: block; width: 85%; font-weight: bold; font-size: 12px; text-align: left; margin-bottom: 10px; } #loginForm div.title { background-color: #999; color: white; font-weight: bold; height: 25px; line-height: 25px; margin: 0; text-align: left; padding-left: 1em; } #loginForm div.content { padding: 1em; } #loginForm div.btn_block { float: left; margin-right: 5px; } #loginForm div.btn_block a.btn_style { display: inline-block; text-decoration: none; /* background-image: url(http://hootsuite.com/images/themes/blue_steel/maps/trim.png); background-position: 0 -1300px; background-repeat: repeat-x; */ background-color: #565F6F; background: -webkit-gradient(linear, left top, left bottom, from(#7B8596), to(#565F6F)); background: -moz-linear-gradient(top, #7B8596, #565F6F); outline: none; white-space: nowrap; cursor: pointer; border-color: #AAB0BB #525A69 #333842; background-color: #525B69; color: white; text-shadow: 0 -1px 0 rgba(0, 0, 0, .4); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .5); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .5); box-shadow: 0 1px 2px rgba(0, 0, 0, .5); border-width: 1px; border-style: solid; padding: 3px 10px 4px 9px; font-size: 12px; font-weight: bold; line-height: 15px; white-space: nowrap; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } #loginForm div.btn_block a.btn_style:hover { /* background-position: 0 -1200px; */ background: -webkit-gradient(linear, left top, left bottom, from(#5D94D6), to(#1B58AE)); background-color: #1B58AE; background: -moz-linear-gradient(top, #5D94D6, #1B58AE); outline: none; border-color: #59E #47C #35A; } #loginMsg { font-weight: bold; } #loginOverlay { display: none; position: fixed; z-index: 999; top: 0; left: 0; width: 100%; background: #000; opacity: 0.15; } </style> '; // !HTML $addblock = ' <div id="logoutNotifier"> ' . $qm->m['plg_check_login']['logout'] . ' </div> <div id="loginForm"> <div class="title">' . $qm->m['plg_check_login']['title'] . '</div> <div class="content"> <label>' . $qm->m['username'] . ':<br /> <input type="text" name="username" /></label> <label>' . $qm->m['password'] . ':<br /> <input type="password" name="password" /></label> <div id="loginMessage"></div> <div class="btn_block submit_login" title="' . $qm->m['ss_authform']['btn_login'] . '"> <a href="#" class="btn_style">' . $qm->m['ss_authform']['btn_login'] . '</a> </div> <div class="btn_block cancel_login" title="' . $qm->m['ss_authform']['btn_cancel'] . '"> <a href="#" class="btn_style">' . $qm->m['ss_authform']['btn_cancel'] . '</a> </div> <div style="clear:both;"></div> </div> </div> <div id="loginOverlay"></div> '; $qt->appendv_once('plugin_check_login', 'beforescript', $addstyle . $addjs); $qt->appendv_once('plugin_check_login_ls', 'lastscript', $addblock); } return; }
function plugin_edit_action() { global $vars, $load_template_func, $style_name, $layout_pages; global $qblog_defaultpage; $qm = get_qm(); $qt = get_qt(); if (PKWK_READONLY) { die_message($qm->m['fmt_err_pkwk_readonly']); } $page = isset($vars['page']) ? $vars['page'] : ''; $prefix = ''; //メニューやナビの編集はスタイルを変える if (array_key_exists($page, $layout_pages) && !isset($vars['preview'])) { $prefix = '<h2 class="title">' . h($layout_pages[$page]) . 'の編集</h2>'; if (is_bootstrap_skin()) { if (exist_plugin("noeyecatch")) { do_plugin_convert("noeyecatch"); } } else { $style_name = '../'; $addscript = <<<EOD <script type="text/javascript"> \$(function(){ if (window != parent) { \t\t\$("input:submit").click(function(e){ \t\t\twindow.onbeforeunload = null; \t\t\tvar name = \$(this).attr("name"); \t\t\t\$(this).before('<input type="hidden" name="'+name+'" value="'+\$(this).val()+'">').prop("disabled", true); \t\t\tvar \$form = \$(this).closest("form"); \t\t\tvar \$parent = \$(window.parent.document).find("body"); \t \t\t\tvar params = \$form.serialize().split('&'); \t\t\tvar \$fm = \$('<form></form>'); \t\t\tfor (var i = 0; i < params.length; i++) \t\t\t{ \t\t\t\tvar param = params[i].split('='); \t\t\t\t\$fm.append(\$('<input type="hidden" name="'+param[0]+'" value="" />').val(decodeURIComponent(param[1].replace(/\\+/g, ' ')))); \t\t\t} \t\t\t\$fm.attr('action', \$form.attr('action')); \t\t\t\$fm.attr('method', \$form.attr('method')); \t\t\t\$parent.append(\$fm).find("form:last").submit(); \t\t\treturn false; \t\t}); \t} }); </script> EOD; $qt->appendv('beforescript', $addscript); } } check_editable($page, true, true); if (isset($vars['preview']) || $load_template_func && isset($vars['template'])) { return plugin_edit_preview(); } else { if (isset($vars['write'])) { return plugin_edit_write(); } else { if (isset($vars['cancel'])) { return plugin_edit_cancel(); } } } $postdata = @join('', get_source($page)); if ($postdata == '') { $postdata = auto_template($page); } return array('msg' => $qm->m['fmt_title_edit'], 'body' => $prefix . edit_form($page, $postdata)); }
function dav_getfileobj($path, $readonly = true, $must_compress = false) { // $path = mb_convert_encoding($path, SOURCE_ENCODING, 'UTF-8'); list($page, $_file) = dav_get_filename($path); if (empty($_file)) { return NULL; } if (!is_page($page)) { return NULL; } if (!$readonly && !is_editable($page)) { return NULL; } if (!check_readable($page, false, false)) { dav_error_exit(401); } // 'user/password' if (!$readonly && !check_editable($page, false, false)) { dav_error_exit(401); } // 'user/password' $ext = $must_compress ? dav_attach_get_ext() : ''; return new AttachFile($page, $_file . $ext); }
function plugin_calendar_viewer_convert() { global $vars, $get, $post, $script, $weeklabels; $qm = get_qm(); static $viewed = array(); if (func_num_args() < 2) { return $qm->replace('fmt_err_cvt', 'calendar_viewer', $qm->m['plg_calendar_viewer']['err_usage']); } $func_args = func_get_args(); // Default values $pagename = $func_args[0]; // 基準となるページ名 $page_YM = ''; // 一覧表示する年月 $limit_base = 0; // 先頭から数えて何ページ目から表示するか (先頭) $limit_pitch = 0; // 何件づつ表示するか $limit_page = 0; // サーチするページ数 $mode = 'past'; // 動作モード $date_sep = '-'; // 日付のセパレータ calendar2なら '-', calendarなら '' // Check $func_args[1] $matches = array(); if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_args[1])) { // 指定年月の一覧表示 $page_YM = $func_args[1]; $limit_page = 31; } else { if (preg_match('/this/si', $func_args[1])) { // 今月の一覧表示 $page_YM = get_date('Y' . $date_sep . 'm'); $limit_page = 31; } else { if (preg_match('/^[0-9]+$/', $func_args[1])) { // n日分表示 $limit_pitch = $func_args[1]; $limit_page = $func_args[1]; } else { if (preg_match('/(-?[0-9]+)\\*([0-9]+)/', $func_args[1], $matches)) { // 先頭より数えて x ページ目から、y件づつ表示 $limit_base = $matches[1]; $limit_pitch = $matches[2]; $limit_page = $matches[1] + $matches[2]; // 読み飛ばす + 表示する } else { return $qm->replace('fmt_err_cvt', 'calendar_viewer', $qm->m['plg_calendar_viewer']['err_param2']); } } } } // $func_args[2]: Mode setting if (isset($func_args[2]) && preg_match('/^(past|view|future)$/si', $func_args[2])) { $mode = $func_args[2]; } // $func_args[3]: Change default delimiter if (isset($func_args[3])) { $date_sep = $func_args[3]; } // Avoid Loop etc. if (isset($viewed[$pagename])) { $s_page = htmlspecialchars($pagename); return "#calendar_viewer(): You already view: {$s_page}<br />"; } else { $viewed[$pagename] = TRUE; // Valid } // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む if ($pagename == '') { // pagename無しのyyyy-mm-ddに対応するための処理 $pagepattern = ''; $pagepattern_len = 0; $filepattern = encode($page_YM); $filepattern_len = strlen($filepattern); } else { $pagepattern = strip_bracket($pagename) . '/'; $pagepattern_len = strlen($pagepattern); $filepattern = encode($pagepattern . $page_YM); $filepattern_len = strlen($filepattern); } // ページリストの取得 $pagelist = array(); if ($dir = @opendir(DATA_DIR)) { $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd'); $page_date = ''; while ($file = readdir($dir)) { if ($file == '..' || $file == '.') { continue; } if (substr($file, 0, $filepattern_len) != $filepattern) { continue; } $page = decode(trim(preg_replace('/\\.txt$/', ' ', $file))); $page_date = substr($page, $pagepattern_len); // Verify the $page_date pattern (Default: yyyy-mm-dd). // Past-mode hates the future, and // Future-mode hates the past. if (plugin_calendar_viewer_isValidDate($page_date, $date_sep) == FALSE || $page_date > $_date && $mode == 'past' || $page_date < $_date && $mode == 'future') { continue; } $pagelist[] = $page; } } closedir($dir); if ($mode == 'past') { rsort($pagelist); // New => Old } else { sort($pagelist); // Old => New } // Include start $tmppage = $vars['page']; $return_body = ''; // $limit_page の件数までインクルード $tmp = max($limit_base, 0); // Skip minus while ($tmp < $limit_page) { if (!isset($pagelist[$tmp])) { break; } $page = $pagelist[$tmp]; $get['page'] = $post['page'] = $vars['page'] = $page; // 現状で閲覧許可がある場合だけ表示する if (check_readable($page, FALSE, FALSE)) { $body = convert_html(get_source($page)); } else { $body = $qm->replace('plg_calendar_viewer.ntc_restrict', $page); } $r_page = rawurlencode($page); if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) { $time = strtotime(basename($page)); // $date_sep must be assumed '-' or ''! if ($time == -1) { $s_page = htmlspecialchars($page); // Failed. Why? } else { $week = $weeklabels[date('w', $time)]; $s_page = htmlspecialchars(str_replace(array('$w'), array($week), date(PLUGIN_CALENDAR_VIEWER_DATE_FORMAT, $time))); } } else { $s_page = htmlspecialchars($page); } if (PKWK_READONLY) { $link = $script . '?' . $r_page; } else { $editable = check_editable($page, FALSE, FALSE); // 管理ログイン後 if ($editable === TRUE) { $link = $script . '?cmd=edit&page=' . $r_page; } else { $link = $script . '?' . $r_page; } } $link = '<a href="' . $link . '">' . $s_page . '</a>'; $head = '<h2 class="calender">' . $link . '</h2>' . "\n"; $return_body .= $head . $body; ++$tmp; } // ここで、前後のリンクを表示 // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1)); if ($page_YM != '') { // 年月表示時 $date_sep_len = strlen($date_sep); $this_year = substr($page_YM, 0, 4); $this_month = substr($page_YM, 4 + $date_sep_len, 2); // 次月 $next_year = $this_year; $next_month = $this_month + 1; if ($next_month > 12) { ++$next_year; $next_month = 1; } $next_YM = sprintf('%04d%s%02d', $next_year, $date_sep, $next_month); // 前月 $prev_year = $this_year; $prev_month = $this_month - 1; if ($prev_month < 1) { --$prev_year; $prev_month = 12; } $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month); if ($mode == 'past') { $right_YM = $prev_YM; $right_text = $prev_YM . '>>'; // >> $left_YM = $next_YM; $left_text = '<<' . $next_YM; // << } else { $left_YM = $prev_YM; $left_text = '<<' . $prev_YM; // << $right_YM = $next_YM; $right_text = $next_YM . '>>'; // >> } } else { // n件表示時 if ($limit_base <= 0) { $left_YM = ''; // 表示しない (それより前の項目はない) } else { $left_YM = $limit_base - $limit_pitch . '*' . $limit_pitch; $left_text = sprintf($qm->m['plg_calendar_viewer']['left'], $limit_pitch); } if ($limit_base + $limit_pitch >= count($pagelist)) { $right_YM = ''; // 表示しない (それより後の項目はない) } else { $right_YM = $limit_base + $limit_pitch . '*' . $limit_pitch; $right_text = sprintf($qm->m['plg_calendar_viewer']['right'], $limit_pitch); } } // ナビゲート用のリンクを末尾に追加 if ($left_YM != '' || $right_YM != '') { $s_date_sep = htmlspecialchars($date_sep); $left_link = $right_link = ''; $link = $script . '?plugin=calendar_viewer&mode=' . $mode . '&file=' . $enc_pagename . '&date_sep=' . $s_date_sep . '&'; if ($left_YM != '') { $left_link = '<a href="' . $link . 'date=' . $left_YM . '">' . $left_text . '</a>'; } if ($right_YM != '') { $right_link = '<a href="' . $link . 'date=' . $right_YM . '">' . $right_text . '</a>'; } // past modeは<<新 旧>> 他は<<旧 新>> $return_body .= '<div class="calendar_viewer">' . '<span class="calendar_viewer_left">' . $left_link . '</span>'; if ($left_link != '') { $return_body .= ' | '; } $return_body .= '<span class="calendar_viewer_right">' . $right_link . '</span>' . '</div>'; } $get['page'] = $post['page'] = $vars['page'] = $tmppage; return $return_body; }
function plugin_attach_action() { global $vars, $_attach_messages; // Backward compatible if (isset($vars['openfile'])) { $vars['file'] = $vars['openfile']; $vars['pcmd'] = 'open'; } if (isset($vars['delfile'])) { $vars['file'] = $vars['delfile']; $vars['pcmd'] = 'delete'; } $pcmd = isset($vars['pcmd']) ? $vars['pcmd'] : ''; $refer = isset($vars['refer']) ? $vars['refer'] : ''; $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $page = isset($vars['page']) ? $vars['page'] : ''; if ($refer != '' && is_pagename($refer)) { if (in_array($pcmd, array('info', 'open', 'list'))) { check_readable($refer); } else { check_editable($refer); } } // Dispatch if (isset($_FILES['attach_file'])) { // Upload return attach_upload($_FILES['attach_file'], $refer, $pass); } else { switch ($pcmd) { case 'delete': /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'freeze': case 'unfreeze': if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } } switch ($pcmd) { case 'info': return attach_info(); case 'delete': return attach_delete(); case 'open': return attach_open(); case 'list': return attach_list(); case 'freeze': return attach_freeze(TRUE); case 'unfreeze': return attach_freeze(FALSE); case 'rename': return attach_rename(); case 'upload': return attach_showform(); } if ($page == '' || !is_page($page)) { return attach_list(); } else { return attach_showform(); } } }
function plugin_pcomment_insert() { global $vars, $now, $_title_updated, $_no_name, $_pcmt_messages; $refer = isset($vars['refer']) ? $vars['refer'] : ''; $page = isset($vars['page']) ? $vars['page'] : ''; $page = get_fullname($page, $refer); if (!is_pagename($page)) { return array('msg' => 'Invalid page name', 'body' => 'Cannot add comment', 'collided' => TRUE); } check_editable($page, true, true); $ret = array('msg' => $_title_updated, 'collided' => FALSE); $msg = str_replace('$msg', rtrim($vars['msg']), PLUGIN_PCOMMENT_FORMAT_MSG); $name = !isset($vars['name']) || $vars['name'] == '' ? $_no_name : $vars['name']; $name = $name == '' ? '' : str_replace('$name', $name, PLUGIN_PCOMMENT_FORMAT_NAME); $date = !isset($vars['nodate']) || $vars['nodate'] != '1' ? str_replace('$now', $now, PLUGIN_PCOMMENT_FORMAT_NOW) : ''; if ($date != '' || $name != '') { $msg = str_replace("" . 'MSG' . "", $msg, PLUGIN_PCOMMENT_FORMAT_STRING); $msg = str_replace("" . 'NAME' . "", $name, $msg); $msg = str_replace("" . 'DATE' . "", $date, $msg); } $reply_hash = isset($vars['reply']) ? $vars['reply'] : ''; if ($reply_hash || !is_page($page)) { $msg = preg_replace('/^\\-+/', '', $msg); } $msg = rtrim($msg); if (!is_page($page)) { $postdata = '[[' . htmlsc(strip_bracket($refer)) . ']]' . "\n\n" . '-' . $msg . "\n"; } else { $postdata = get_source($page); $count = count($postdata); $digest = isset($vars['digest']) ? $vars['digest'] : ''; if (md5(join('', $postdata)) != $digest) { $ret['msg'] = $_pcmt_messages['title_collided']; $ret['body'] = $_pcmt_messages['msg_collided']; } $start_position = 0; while ($start_position < $count) { if (preg_match('/^\\-/', $postdata[$start_position])) { break; } ++$start_position; } $end_position = $start_position; $dir = isset($vars['dir']) ? $vars['dir'] : ''; // Find the comment to reply $level = 1; $b_reply = FALSE; if ($reply_hash != '') { while ($end_position < $count) { $matches = array(); if (preg_match('/^(\\-{1,2})(?!\\-)(.*)$/', $postdata[$end_position++], $matches) && md5($matches[2]) == $reply_hash) { $b_reply = TRUE; $level = strlen($matches[1]) + 1; while ($end_position < $count) { if (preg_match('/^(\\-{1,3})(?!\\-)/', $postdata[$end_position], $matches) && strlen($matches[1]) < $level) { break; } ++$end_position; } break; } } } if ($b_reply == FALSE) { $end_position = $dir == '0' ? $start_position : $count; } // Insert new comment array_splice($postdata, $end_position, 0, str_repeat('-', $level) . $msg . "\n"); if (PLUGIN_PCOMMENT_AUTO_LOG) { $_count = isset($vars['count']) ? $vars['count'] : ''; plugin_pcomment_auto_log($page, $dir, $_count, $postdata); } $postdata = join('', $postdata); } page_write($page, $postdata, PLUGIN_PCOMMENT_TIMESTAMP); if (PLUGIN_PCOMMENT_TIMESTAMP) { if ($refer != '') { pkwk_touch_file(get_filename($refer)); } put_lastmodified(); } return $ret; }
function plugin_include_convert() { global $script, $vars, $get, $post, $menubar; static $included = array(); static $count = 1; $qm = get_qm(); $qt = get_qt(); if (func_num_args() == 0) { return $qm->m['plg_include']['err_usage'] . "\n"; } // $menubar will already be shown via menu plugin if (!isset($included[$menubar])) { $included[$menubar] = TRUE; } // Loop yourself $root = isset($vars['page']) ? $vars['page'] : ''; $included[$root] = TRUE; // Get arguments $args = func_get_args(); // strip_bracket() is not necessary but compatible $page = isset($args[0]) ? get_fullname(strip_bracket(array_shift($args)), $root) : ''; //キャッシュのために、追加 if (!in_array($page, $qt->get_rel_pages())) { $qt->set_rel_page($page); } $with_title = PLUGIN_INCLUDE_WITH_TITLE; if (isset($args[0])) { switch (strtolower(array_shift($args))) { case 'title': $with_title = TRUE; break; case 'notitle': $with_title = FALSE; break; } } $s_page = h($page); $r_page = rawurlencode($page); $link = '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>'; // Read link // I'm stuffed if (isset($included[$page])) { return $qm->replace('plg_include.err_already_include', $link) . "\n"; } if (!is_page($page)) { return $qm->replace('plg_include.err_no_page', $s_page) . "\n"; } if ($count > PLUGIN_INCLUDE_MAX) { return $qm->replace('plg_include.err_limit', $link) . "\n"; } else { ++$count; } // One page, only one time, at a time $included[$page] = TRUE; // Include A page, that probably includes another pages $get['page'] = $post['page'] = $vars['page'] = $page; if (check_readable($page, false, false)) { $body = convert_html(get_source($page)); } else { $body = str_replace('$1', $page, $qm->m['plg_include']['err_restrict']); } $get['page'] = $post['page'] = $vars['page'] = $root; // Put a title-with-edit-link, before including document if ($with_title) { $link = '<a href="' . $script . '?cmd=read&page=' . $r_page . '">' . $s_page . '</a>'; if ($page == $menubar) { $body = '<span align="center"><h5 class="side_label">' . $link . '</h5></span><small>' . $body . '</small>'; } else { $body = '<h2>' . $link . '</h2>' . "\n" . $body . "\n"; } } //編集状態の場合、hover でメッセージを表示 if (check_editable($vars['page'], false, false)) { $goto_page = $qm->replace('plg_include.goto_include_page', $s_page); $addscript = ' <style type="text/css"> .qhm_include_hover { outline: 5px dashed #f99; -ms-filter: "alpha( opacity=60 )";/* IE8 */ filter: alpha( opacity=60 );/* IE6-7 */ opacity: 0.4; background-color: #fff; } .qhm_include_hover * { } .qhm_include_wrapper { position: relative; cursor: pointer; } .qhm_include { } .qhm_include * { cursor: pointer; } .qhm_include_title { position: absolute; text-align: center; color: #f66; font-size: 36px; width: 100%; line-height: 40px; top: 50%; opacity: 1; } /* IE7 */ *+html .qhm_include_hover { border: 5px dashed #f99; } *+html .qhm_include_title { background-color: #f66; color: #fff; } </style> <script type="text/javascript"> $(function(){ $("div.qhm_include_wrapper").click(function(){ location.href = $("> div.qhm_include > span.qhm_include_page", this).text(); }) .hover( function(){ var $$ = $(this), title = $$.attr("title"); $$.append("<div class=\\"qhm_include_title\\">"+ title+ "</div>") .children("div.qhm_include").addClass("qhm_include_hover") }, function(){ var $$ = $(this); $$.children("div.qhm_include_title").remove() $$.children("div.qhm_include").removeClass("qhm_include_hover") } ); //二重を避けるため $("div.qhm_include_wrapper div.qhm_include_wrapper").unbind("click").unbind("mouseenter").unbind("mouseleave"); }); </script> '; $qt->appendv_once('plugin_include', 'beforescript', $addscript); $body = '<div class="qhm_include_wrapper" title="' . $goto_page . '"><div class="qhm_include"> <span class="qhm_include_page" style="display:none;">' . $script . '?' . $r_page . '</span>' . $body . '</div></div>'; return $body; } return $body; }
/** * QBlog Setting Plugin * ------------------------------------------- * ./plugin/qblog.inc.php * * Copyright (c) 2012 hokuken * http://hokuken.com/ * * created : 12/07/31 * modified : * * Description * * Usage : * */ function plugin_qblog_action() { global $vars, $script, $style_name; global $qblog_defaultpage, $qblog_default_cat, $qblog_date_format, $qblog_page_prefix; global $qblog_social_widget, $qblog_social_html, $qblog_social_wiki, $qblog_title; global $qblog_enable_comment, $qblog_close, $qblog_enable_ping, $qblog_ping; global $qblog_comment_notice, $admin_email; $qt = get_qt(); $style_name = '..'; $vars['disable_toolmenu'] = TRUE; $qt->setv('no_menus', TRUE); //メニューやナビ等をconvertしない $include_bs = ' <link rel="stylesheet" href="skin/bootstrap/css/bootstrap.min.css" /> <script type="text/javascript" src="skin/bootstrap/js/bootstrap.min.js"></script>'; $qt->appendv_once('include_bootstrap_pub', 'beforescript', $include_bs); $beforescript = ' <link rel="stylesheet" href="' . PLUGIN_DIR . 'qblog/qblog.css" /> <script type="text/javascript" src="js/jQuery.ajaxQueue.min.js"></script>'; $qt->appendv('beforescript', $beforescript); // 管理者でない場合はブログトップへ移動する // 記事の追加のみ、編集権限を後でチェックする if ($vars['mode'] !== 'addpost' && !ss_admin_check()) { $url = $script . '?' . $qblog_defaultpage; header('Location: ' . $url); exit; } // モード毎の処理 if (isset($vars['mode'])) { if ($vars['mode'] == 'delete') { plugin_qblog_delete_category(); } else { if ($vars['mode'] === 'rebuild') { plugin_qblog_rebuild_posts(); } else { if ($vars['mode'] === 'social_widget') { plugin_qblog_save_social_widget(); } else { if ($vars['mode'] === 'move_confirm') { $ret = plugin_qblog_move_from_ameba_confirm(); if ($ret) { return $ret; } } else { if ($vars['mode'] == 'move') { plugin_qblog_move_from_ameba(); } else { if ($vars['mode'] == 'move_from_eblog_confirm') { $ret = plugin_qblog_move_from_eblog_confirm(); if ($ret !== FALSE) { return $ret; } } else { if ($vars['mode'] == 'move_from_eblog') { plugin_qblog_move_from_eblog(); } else { if ($vars['mode'] == 'start') { plugin_qblog_start(); } else { if ($vars['mode'] == 'addpost') { $newpage = qblog_get_newpage(); if (check_editable($newpage, TRUE, FALSE)) { $newpage_url = $script . '?cmd=edit&page=' . $newpage; redirect($newpage_url); } else { $url = $script . '?' . $qblog_defaultpage; header('Location: ' . $url); exit; } } else { if ($vars['mode'] == 'edit_title') { plugin_qblog_edit_title(); } else { if ($vars['mode'] == 'enable_comment') { plugin_qblog_enable_comment(); } else { if ($vars['mode'] == 'close') { plugin_qblog_close(); } else { if ($vars['mode'] == 'rename_category') { plugin_qblog_rename_category(); } else { if ($vars['mode'] == 'update_ping') { plugin_qblog_update_ping(); } else { if ($vars['mode'] == 'comment_notice') { plugin_qblog_update_comment_notice(); } } } } } } } } } } } } } } } } // ! お知らせをセットする $qblog_info = ''; if (isset($vars['phase'])) { switch ($vars['phase']) { case 'set_title': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> <p> <b>ブログに名前を付けましょう!</b><br /> <a href="#qblog_title" data-tab="move" id="go_qblog_title" class="btn">ブログタイトル設定</a>へ進んでください。 </p> </div> '; break; case 'edit_title': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> <p> ブログタイトルを変更しました。 </p>'; if (!glob(DATA_DIR . encode($qblog_page_prefix) . '*')) { $vars['hash'] = 'misc'; $qblog_info .= ' <p> <b>アメブロをお持ちの方:</b><br /> <a href="#qblog_move_ameba" data-tab="move" class="btn">アメブロからの引越し</a>に進んでください。 </p> <p> <b>QHMプロの簡易ブログをご利用の方:</b><br /> <a href="#qblog_move_eblog" data-tab="move" class="btn">簡易ブログからの引越し</a>に進んでください。 </p> <p> <b>ブログを利用されていない方:</b><br /> <a href="' . $script . '?cmd=qblog&mode=addpost" class="btn">さっそく、新しい記事を投稿しましょう!</a> </p>'; } $qblog_info .= ' </div> '; break; case 'social_widget': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> ソーシャルウィジェット設定を保存しました。 </div> '; break; case 'rebuild': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> ブログの修復が完了しました。 </div> '; break; case 'delete_category': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> カテゴリー:' . h($vars['category']) . ' を削除しました。 </div> '; break; case 'enable_comment': $commentmsg = $qblog_enable_comment ? '表示する' : '表示しない'; $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> コメントの表示を「' . $commentmsg . '」にしました。 </div> '; break; case 'close': $msg = $qblog_close ? '閉鎖' : '公開'; $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> ブログを「' . $msg . '」しました。 </div> '; break; case 'rename_category': $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> カテゴリー名を変更しました。 </div> '; break; case 'ping': $msg = $qblog_enable_ping ? '有効' : '無効'; $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> Ping送信を「' . $msg . '」にしました。 </div> '; break; case 'comment_notice': $msg = $qblog_comment_notice ? '通知する' : '通知しない'; $qblog_info = ' <div class="qblog_info alert alert-success"> <button class="close" data-dismiss="alert">×</button> コメントを「' . $msg . '」にしました。 </div> '; break; default: } } else { if ($qblog_close) { $qblog_info = ' <div class="qblog_info alert alert-danger"> <button class="close" data-dismiss="alert">×</button> ブログは<strong>閉鎖中</strong>です。<br /> 公開する場合、「その他」タブを開いて、ブログの閉鎖設定を変更してください。 </div> '; } } // エラーがあればエラーをセットする $qblog_error = ''; if (isset($vars['qblog_error']) && $vars['qblog_error'] != '') { $qblog_error = $vars['qblog_error']; } //開くタブをセットする $hash = isset($vars['hash']) ? $vars['hash'] : ''; // ブログの初期設定 // ! ブログの記事が存在するかチェック $files = glob(DATA_DIR . encode($qblog_page_prefix) . '*'); // ! アメブロからの引越を表示するかしないか $move_amebro = FALSE && count($files) == 0; // !カテゴリ一覧の取得 $categories_file = CACHEQBLOG_DIR . 'qblog_categories.dat'; $categories = array(); if (file_exists($categories_file)) { $categorydata = explode("\n", file_get_contents($categories_file)); foreach ($categorydata as $data) { if (strlen(trim($data)) > 0) { list($name, $num) = explode("\t", trim($data)); $categories[$name] = array('name' => $name, 'num' => $num); } } } // !未承認コメントの一覧 $pending_comments = unserialize(file_get_contents(CACHEQBLOG_DIR . 'qblog_pending_comments.dat')); $pending_comments = $pending_comments === FALSE ? array() : $pending_comments; foreach ($pending_comments as $i => $comment) { $pending_comments[$i]['post_title'] = mb_strimwidth(get_page_title($comment['page']), 0, 16, '...'); $pending_comments[$i]['title'] = mb_strimwidth($comment['title'], 0, 16, '...'); $pending_comments[$i]['name'] = mb_strimwidth($comment['name'], 0, 12, '...'); } // !RSSのURL $rss_url = ''; if (exist_plugin('rss')) { $rss_url = $script . '?cmd=rss&qblog_rss=1'; } // !Ping if (trim($qblog_ping) === '') { $qblog_ping = plugin_qblog_get_default_ping(); } //! テンプレートを読み込む $html = ''; ob_start(); include PLUGIN_DIR . 'qblog/qblog_index_template.html'; $html .= ob_get_clean(); return array('msg' => 'ブログ設定', 'body' => $html); }