function plugin_close_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //キャッシュ無効 $qt->enable_cache = false; $title = $qm->m['plg_close']['title']; $msg = $qm->m['plg_close']['ntc']; //parse arguments $args = func_get_args(); $num = count($args); if ($num == 0) { //do nothing } else { if ($num == 1) { $title = array_pop($args); } else { list($title, $msg) = $args; } } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return $qm->m['plg_close']['ntc_admin']; } else { force_output_message($title, '', $msg); } }
function plugin_fb_recommends_convert() { if ($alt = plugin_fb_root_is_deprecated('recommends')) { $args = func_get_args(); return call_user_func_array($alt, $args); } global $script, $vars; $page = $vars['page']; $r_page = rawurlencode($page); $qm = get_qm(); $qt = get_qt(); $args = func_get_args(); // scaffold $def_attrs = array('site' => '', 'width' => FALSE, 'height' => FALSE, 'header' => 'true', 'colorscheme' => 'light', 'ref' => FALSE, 'action' => 'og.likes', 'app-id' => FALSE, 'linktarget' => FALSE, 'max-age' => FALSE); $attrs = plugin_fb_root_parse_args($args, $def_attrs); //default site set if ($attrs['site'] == '') { $parsed = parse_url($script); $host = $parsed['host']; $attrs['site'] = $host; } plugin_fb_root_set_jsapi(TRUE); $body = plugin_fb_root_create_tag('fb-recommendations', $attrs); if (edit_auth($page, FALSE, FALSE)) { $fb_pagebox_help = h(QHM_HOME . '?PageName'); $warning = <<<EOM \t\t\t<div class="alert alert-warning"> \t\t\t\tFacebook Recommends は Graph API v2.3 より廃止されました。<br> \t\t\t\t<strong>2015 年 6 月 23 日</strong>に完全に使えなくなります。 \t\t\t</div> EOM; $body = $warning . $body; } return $body; }
function plugin_diff_action() { global $vars, $script; global $layout_pages, $style_name; $editable = edit_auth($page, FALSE, FALSE); if (!$editable) { header("Location: {$script}"); exit; } $page = isset($vars['page']) ? $vars['page'] : ''; check_readable($page, true, true); //レイアウト部品の場合、スタイルを変更する $is_layout = FALSE; if (isset($layout_pages) && isset($layout_pages[$page])) { $style_name = '..'; $is_layout = TRUE; } $action = isset($vars['action']) ? $vars['action'] : ''; switch ($action) { case 'delete': $retval = plugin_diff_delete($page); break; default: $retval = plugin_diff_view($page); break; } return $retval; }
function plugin_ga_link_inline() { global $accesstag_moved; global $accesstag; global $vars; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //parameter check $args = func_get_args(); $num = func_num_args(); if ($num != 2) { return $qm->replace('fmt_err_iln', 'ga_link', $qm->m['plg_ga_link']['err_usage']); } $text = strip_autolink(array_pop($args)); //テキストデータ $url = array_pop($args); if (!is_url($url)) { $url = 'index.php?' . rawurlencode($url); } $acc_tag = ''; //初めて呼び出される場合、accesstag情報を表示する if (!$accesstag_moved) { $accesstag_moved = TRUE; //accesstag_movedを設定 $editable = edit_auth($page, FALSE, FALSE); if (!$editable) { $qt->setv('toolkit_upper', $accesstag); } } //Google Analytics用のjavascriptを先に読み込んでから、関数を呼び出す $ret = '<a href="index.php?cmd=ga_link&url=' . rawurlencode($url) . '" onClick="javascript:pageTracker._link(this.href);return false;">' . $text . '</a>'; return $ret; }
function plugin_canonical_show_info() { global $vars, $style_name; $qt = get_qt(); $page = $vars['page']; if (edit_auth($page, FALSE, FALSE)) { if (strpos($style_name, 'haik_') !== 0) { return ' <div style="border:solid 1px #00e;background-color:#eef;max-width:80%;width:80%;text-align:left;padding:0 1.5em;margin:1em auto;"> <p> <strong>このページは canonical URL が指定されています。</strong><br> <a href="' . h($qt->getv('canonical_url')) . '" target="_blank">確認</a> </p> </div>'; } else { return ' <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert"> <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <strong>このページは canonical URL が指定されています。</strong><br> <a href="' . h($qt->getv('canonical_url')) . '" target="_blank" class="btn btn-info">確認</a> </div>'; } } }
function plugin_conversion_r_inline() { global $vars, $script; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); if (count($args) != 6) { return $qm->replace('fmt_err_iln', 'conversion_r', $qm->m['plg_conversion_r']['err_usage']); } $text = array_pop($args); list($step, $group, $name, $url, $site_url) = $args; if (!is_url($url)) { return $qm->replace('fmt_err_iln', 'conversion_r', $qm->m['plg_conversion_r']['err_url']); } $raw_url = $url; $step = rawurlencode($step); $group = rawurlencode($group); $name = rawurlencode($name); $url = rawurlencode($url); $site_url .= preg_match('/\\/$/', $site_url) ? '' : '/'; $dest = $site_url . '?cmd=conversion&mode=link&step=' . $step . '&group=' . $group . '&name=' . $name . '&url=' . $url; //edit auth check $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<a href="' . $dest . '">' . $text . '</a><span style="font-size:11px;background-color:#fdd">←' . $qm->m['plg_conversion_r']['ntc_admin'] . '</span>'; } else { return '<a href="' . $dest . '">' . $text . '</a>'; } }
function plugin_ganatracker_convert() { global $accesstag; global $vars; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $num = func_num_args(); if ($num != 1) { return $qm->replace('fmt_err_cvt', 'ganatracker', $qm->m['plg_ganatracker']['err_usage_cvt']); } $name = $args[0]; //versionをチェックして、置換 $version = $qm->m['plg_ganatracker']['old']; if (strstr($accesstag, "gaJsHost") == false) { //Old version $repstr = 'urchinTracker(\'' . $name . '\')'; $accesstag = str_replace('urchinTracker()', $repstr, $accesstag); } else { $version = $qm->m['plg_ganatracker']['old']; $repstr = 'pageTracker._trackPageview(\'' . $name . '\')'; $accesstag = str_replace('pageTracker._trackPageview()', $repstr, $accesstag); } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<div style="margin:1em;border:dashed 2px #f00;background-color:#fee">' . $qm->replace('plg_ganatracker.ntc_admin_cvt', $version, $name) . '</div>'; } else { return ''; } }
/** * QHM Secret Plugin ver 0.9 * ------------------------------------------- * plugin/secret.inc.php * * Copyright (c) 2010 hokuken * http://hokuken.com/ * * created : 2007-09-11 * modified : * * 簡易パスワード認証ページを作るプラグイン * * Usage : * &secret(パスワード(英数のみ)); * */ function plugin_secret_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); //---- キャッシュのための処理を登録 ----- if ($qt->create_cache) { $args = func_get_args(); return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args); } //------------------------------------ $page = isset($vars['page']) ? $vars['page'] : ''; $en_page = rawurlencode($page); $secretplugin = isset($vars['secretplugin']) ? $vars['secretplugin'] : ''; $password = isset($vars['password']) ? $vars['password'] : ''; $auth_url = $script . "?plugin=secret&page=" . urlencode($page); $args = func_get_args(); $masterpasswd = array_pop($args); if ($masterpasswd == "") { return $qm->replace('fmt_err_cvt', 'secret', 'パスワードを設定して下さい。'); } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return "<div style=\"border:dashed 1px #f00;background-color:#fee;padding:1em;\"><p><strong>{$qm->m['plg_secret']['ntc_admin']}</strong></p></div>"; } else { //session check if (isset($_SESSION['secretplugin_' . $en_page]) && $_SESSION['secretplugin_' . $en_page] == $en_page) { return ''; } if ($secretplugin == "secretplugin") { //passwd check if ($password == $masterpasswd) { $_SESSION['secretplugin_' . $en_page] = $en_page; return ""; } else { header("Location: {$auth_url}&errmsg=true"); exit; } } //携帯アクセスのことを考えての処理(cookieをちぇっくして、処理を行う) if (isset($vars['chkck'])) { $cookie = $_COOKIE['QHMDUMMY']; setcookie('QHMDUMMY', '', time() - 3600); //del cookie if ($cookie) { header("Location: {$auth_url}"); exit; } else { header("Location: {$auth_url}&mobssid=yes"); exit; } } else { //はじめてのアクセス setcookie('QHMDUMMY', TRUE); header('Location: ' . $script . '?cmd=read&page=' . $en_page . '&chkck'); exit; } } }
function plugin_fb_likegate_convert() { global $vars, $script, $nowindow; $qm = get_qm(); $qt = get_qt(); $editable = edit_auth($page, FALSE, FALSE); //本文部分以外のページに設置した場合、無効にする if (isset($vars['page_alt']) && is_page($vars['page_alt'])) { if ($editable) { return 'error: #fb_likegate: 本文に設置してください。'; } else { return ''; } } $page = isset($vars['page']) ? $vars['page'] : ''; //キャッシュ無効 $qt->enable_cache = false; $args = func_get_args(); if (count($args) === 0) { return $qm->replace('fmt_err_cvt', 'fb_likegate', $qm->m['plg_fb_likegate']['err_usage']); } list($unlike_page) = $args; $fb_apps_url = plugin_fb_root_get_apps_url(); //Facebook からのアクセス if ($signed_request = plugin_fb_root_parse_request()) { $nowindow = 1; $edit_url = $script . '?cmd=edit&page=' . rawurlencode($page); plugin_fb_root_set_page(); $liked = (isset($signed_request->page->liked) and !is_null($signed_request->page->liked)) ? $signed_request->page->liked : $signed_request->page['liked']; if ($liked) { $src = get_source($page); foreach ($src as $i => $line) { if (strpos($line, '#fb_likegate') === 0) { unset($src[$i]); break; } } $body = convert_html($src); } else { $src = get_source($unlike_page); foreach ($src as $i => $line) { if (strpos($line, '#fb_page') === 0) { unset($src[$i]); } } $body = convert_html($src); } if ($editable) { $add_body = convert_html($qm->replace('plg_fb_likegate.ntc_admin_fb', $edit_url, $unlike_page, $fb_apps_url)); } force_output_message('', '', $add_body . $body); } else { if ($editable) { return convert_html($qm->replace('plg_fb_likegate.ntc_admin', $unlike_page, $fb_apps_url)); } force_output_message($qm->m['plg_fb_likegate']['ntc_title'], '', $qm->m['plg_fb_likegate']['ntc_msg']); } }
function plugin_utf8_convert() { global $utf8, $vars; //edit auth check $editable = edit_auth($vars['page'], FALSE, FALSE); if ($editable) { return "<p><strong>【お知らせ】</strong><br />このページは、ユーザーモードの際、UTF8化されています<br />\nQHM v4からは、UTF-8が標準になったので、このプラグインは不要です</p>"; } else { $utf8 = false; return ""; } }
function plugin_shiftjis_convert() { global $shiftjis, $vars; $qm = get_qm(); //edit auth check $editable = edit_auth($vars['page'], FALSE, FALSE); if ($editable) { return $qm->m['plg_shiftjis']['ntc_admin']; } else { $shiftjis = TRUE; return ""; } }
function plugin_read_action() { global $vars, $script; global $post; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //キャッシュを無効化 if (isset($vars['word'])) { $qt->enable_cache = false; } if (is_page($page)) { // ページを表示 check_readable($page, true, true); header_lastmod($page); return array('msg' => '', 'body' => ''); } else { if (!PKWK_SAFE_MODE && is_interwiki($page)) { return do_plugin_action('interwiki'); // InterWikiNameを処理 } else { if (is_pagename($page)) { $vars['cmd'] = 'edit'; // 編集権限があれば、編集モードへ。なければ、メッセージを表示 $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return do_plugin_action('edit'); // 存在しないので、編集フォームを表示 } else { //404 NOT FOUND header('HTTP/1.1 404 Not Found'); return array('msg' => $qm->m['fmt_err_notfoundpage_title'], 'body' => $qm->replace('fmt_err_notfoundpage', $script)); } } else { //EUCエンコーディングかチェック if (mb_detect_encoding($post['page'], 'UTF-8,EUC-JP') == 'EUC-JP') { $u_page = mb_convert_encoding($post['page'], 'UTF-8', 'EUC-JP'); $enc_page = rawurlencode($u_page); //redirect header("HTTP/1.1 301 Moved Permanently"); header('Location: ' . $script . '?' . $enc_page); exit; } // 無効なページ名 return array('msg' => $qm->m['fmt_title_invalidiwn'], 'body' => $qm->replace('fmt_err_invalidiwn', h($page), 'WikiName')); } } } }
function plugin_edit_this_inline() { global $vars, $script; $qm = get_qm(); $page = $vars['page']; if (!edit_auth($page, FALSE, FALSE)) { return ''; } $args = func_get_args(); if ($args[0] != '') { $page = trim($args[0]); } return <<<EOD <a href="{$script}?cmd=edit&page={$page}">[{$qm->m['plg_edit_this']['label']}]</a> EOD; }
function plugin_commu_auth_convert() { global $script, $vars; //キャッシュを無効に if (QHM_VERSION < 4.6) { global $enable_cache; $enable_cache = false; } else { $qt = get_qt(); $qt->enable_cache = false; } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<p style="padding:1em;background-color:#fdd;border:1px dashed #f00;"><strong>【お知らせ】管理者モード以外のアクセスは、commu_authプラグインによって' . 'ログインページへ転送されます</strong></p>'; } else { if (!isset($_SESSION['commu_user'])) { // ログイン画面にとばす commu_redirect($script . '?' . rawurlencode($vars['page'])); } if (func_num_args()) { $flg_show = false; $args = func_get_args(); foreach ($args as $line) { if (strpos($line, '=') !== FALSE) { list($field, $value) = explode('=', trim($line)); $field = trim($field); $value = trim($value); } if (isset($_SESSION['commu_user'][$field])) { $cmpval = $_SESSION['commu_user'][$field]; $cmpval = mb_convert_encoding($cmpval, "UTF-8", "UTF-8,EUC-JP"); if ($cmpval == $value) { $flg_show = true; } } } if ($flg_show == false) { $url = $script . '?FrontPage'; if (isset($vars['QHMSSID'])) { $url .= '&QHMSSID=' . $vars['QHMSSID']; } header("Location: {$url}"); exit; } } } }
function plugin_commu_auth_return_inline() { global $script; //キャッシュを無効に if (QHM_VERSION < 4.6) { global $enable_cache; $enable_cache = false; } else { $qt = get_qt(); $qt->enable_cache = false; } $editable = edit_auth($page, FALSE, FALSE); if (!isset($_SESSION['commu_user'])) { // 何も表示しない return ''; // ログイン画面にとばす // commu_redirect($script.'?'.rawurlencode($vars['page'])); } if (func_num_args()) { $flg_show = false; $args = func_get_args(); $text = array_pop($args); // フィールドの指定がない場合は、認証成功として表示する if (count($args) == 0) { return $text; } foreach ($args as $line) { if (strpos($line, '=') !== FALSE) { list($field, $value) = explode('=', trim($line)); $field = trim($field); $value = trim($value); } if (isset($_SESSION['commu_user'][$field])) { $cmpval = $_SESSION['commu_user'][$field]; $cmpval = mb_convert_encoding($cmpval, "UTF-8", "UTF-8,EUC-JP"); if ($cmpval == $value) { // return convert_html($text); return $text; } } } if ($flg_show == false) { return ''; } } }
function plugin_autoclose_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); //---- キャッシュのための処理を登録 ----- if ($qt->create_cache) { $args = func_get_args(); return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args); } //------------------------------------ $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $args_num = count($args); //args check if ($args_num != 1 && $args_num != 2) { return $qm->replace('fmt_err_cvt', 'autoclose', $qm->m['plg_autoclose']['err_usage']); } list($date, $url) = array_pad($args, 2, ''); $closedate = strtotime($date); if (is_url($url)) { } else { if ($url != "") { $url = $script . "?" . urlencode($url); } else { //no-target $url = $script . "?plugin=autoclose&page=" . urlencode($page); } } $editable = edit_auth($page, FALSE, FALSE); if ($editable) { $tag_s = "<div style=\"border:dashed 1px #f00;background-color:#fee;padding:1em;\">"; $tag_e = "</div>"; $msg = $qm->replace('plg_autoclose.format_ntc', date('Y/m/d(D) H:i', $closedate), $url); return $tag_s . $qm->m['plg_autoclose']['ntc_admin'] . $msg . $tag_e; } else { $diff = strtotime($date) - time(); if ($diff < 0) { header("Location: " . $url); exit; } else { return ""; } } }
function plugin_editacc_convert() { global $accesstag, $vars; $page = $vars['page']; $qm = get_qm(); $args = func_get_args(); $num = func_num_args(); if ($num != 1) { return $qm->m['plg_editacc']['err_usage']; } $addedcode = array_pop($args); $accesstag = "\n\n<!-- {$qm->m['plg_editacc']['comment']} -->\n" . $addedcode; $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<div style="border:2px dashed #f00;background-color:#fee;margin:1em">' . $qm->m['plg_editacc']['ntc_admin'] . '<center><textarea rows="5" cols="50" disabled>' . $accesstag . '</textarea></center></div>'; } else { return ''; } }
function plugin_absplit_convert() { global $vars, $script; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; //--- キャッシュを無効に --- $qt->enable_cache = false; $args = func_get_args(); $num = func_num_args(); //check if ($num != 2) { return "<p>{$qm->m['plg_absplit']['err_param_count']}</p>"; } $url = array(); $url[1] = strip_autolink(array_pop($args)); $url[0] = strip_autolink(array_pop($args)); if (!is_url($url[0])) { return "<p> " . $qm->replace('plg_absplit.err_invalid_url', $url[0]) . "</p>"; } if (!is_url($url[1])) { return "<p> " . $qm->replace('plg_absplit.err_invalid_url', $url[1]) . "</p>"; } //edit auth check $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return $qm->replace('plg_absplit.ntc_admin', $url[0], $url[1], $page); } else { //generate cookie name from $page $ckname = encode($page); if (isset($_COOKIE[$ckname])) { $target = $_COOKIE[$ckname]; header("Location: " . $url[$target]); exit; } else { $target = rand(0, 1); //set cookie for split test $result = setcookie($ckname, $target, time() + 60 * 60 * 24 * 30); header("Location: " . $url[$target]); exit; } } }
function plugin_addacc_convert() { global $accesstag, $vars; $page = $vars['page']; $qm = get_qm(); $args = func_get_args(); $num = func_num_args(); if ($num != 1) { return $qm->m['plg_addacc']['err_usage']; } $addedcode = array_pop($args); $accesstag .= "\n\n<!-- added follow code by addacc plugin -->\n" . $addedcode; $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return $qm->replace('plg_addacc.ntc_admin', $accesstag); } else { return ''; } }
function plugin_fb_page_convert() { global $vars, $script, $nowindow; $qm = get_qm(); $qt = get_qt(); $qt->setv('jquery_include', true); $editable = edit_auth($page, FALSE, FALSE); //本文部分以外のページに設置した場合、無効にする if (isset($vars['page_alt']) && is_page($vars['page_alt'])) { if ($editable) { return 'error: #fb_page: 本文に設置してください。'; } else { return ''; } } $page = isset($vars['page']) ? $vars['page'] : ''; //キャッシュ無効 $qt->enable_cache = false; $args = func_get_args(); $fb_apps_url = plugin_fb_root_get_apps_url(); //Facebook からのアクセス if ($signed_request = plugin_fb_root_parse_request()) { $nowindow = 1; $edit_url = $script . '?cmd=edit&page=' . rawurlencode($page); plugin_fb_root_set_page(); $lines = get_source($page); foreach ($lines as $k => $v) { if (strpos($v, '#fb_page') === 0) { unset($lines[$k]); } } $body = convert_html($lines); if ($editable) { $add_body = convert_html($qm->replace('plg_fb_page.ntc_admin_fb', $edit_url, $fb_apps_url)); } force_output_message('', '', $add_body . $body); } else { if ($editable) { return convert_html($qm->m['plg_fb_page']['ntc_admin']); } force_output_message($qm->m['plg_fb_likegate']['ntc_title'], '', $qm->m['plg_fb_likegate']['ntc_msg']); } }
function plugin_fb_likebox_convert() { if ($alt = plugin_fb_root_is_deprecated('likebox')) { $args = func_get_args(); return call_user_func_array($alt, $args); } global $script, $vars; $page = $vars['page']; $r_page = rawurlencode($page); $qm = get_qm(); $qt = get_qt(); $args = func_get_args(); // scaffold $def_attrs = array('href' => '', 'width' => FALSE, 'height' => FALSE, 'colorscheme' => 'light', 'show-faces' => 'true', 'stream' => 'true', 'header' => 'true', 'force-wall' => 'false', 'show-border' => 'true'); $attrs = plugin_fb_root_parse_args($args, $def_attrs); //no URL error if ($attrs['href'] == '') { $errmsg = 'error - #fb_likebox: no facebook page url'; return "<p>{$errmsg}</p>\n"; } plugin_fb_root_set_jsapi(TRUE); $body = plugin_fb_root_create_tag('fb-like-box', $attrs); if (edit_auth($page, FALSE, FALSE)) { $fb_pagebox_help = h(QHM_HOME . '?FacebookPlugins#pagebox'); $warning = <<<EOM \t\t\t<div class="alert alert-warning"> \t\t\t\tFacebook Like Box は Graph API v2.3 より廃止されました。<br> \t\t\t\t<strong>2015 年 6 月 23 日</strong>に完全に使えなくなりますので、 \t\t\t\t<code>#fb_pagebox</code> プラグインへの移行をしてください。<br> \t\t\t\tなお、このプラグインは <strong>2015 年 6 月 23 日</strong>に自動的に \t\t\t\t<code>#fb_pagebox</code> を利用するように切り替わります。<br> \t\t\t\tオプションは引き継ぎませんので、細かい設定を行いたい場合は \t\t\t\t<a href="{$fb_pagebox_help}">こちら</a> \t\t\t\tを参考に \t\t\t\t<code>#fb_pagebox</code> プラグインへ書き換えてください。 \t\t\t</div> EOM; $body = $warning . $body; } return $body; }
function plugin_ganatracker2_convert() { global $accesstag; global $vars; $qm = get_qm(); $page = isset($vars['page']) ? $vars['page'] : ''; $args = func_get_args(); $num = func_num_args(); if ($num != 1) { return $qm->replace('fmt_err_cvt', 'ganatracker2', $qm->m['plg_ganatracker2']['err_usage_cvt']); } $name = $args[0]; $repstr = 'pageTracker._trackPageview(\'' . $name . '\')'; $accesstag = str_replace('pageTracker._trackPageview()', $repstr, $accesstag); $editable = edit_auth($page, FALSE, FALSE); if ($editable) { return '<div style="margin:1em;border:dashed 2px #f00;background-color:#fee">' . $qm->m['plg_ganatracker2']['ntc_admin_cvt'] . '</div>'; } else { return ''; } }
function plugin_enable_cache_convert() { global $vars; $qm = get_qm(); $qt = get_qt(); //edit auth check $editable = edit_auth($vars['page'], FALSE, FALSE); $v = func_get_args(); if (isset($v[0]) && strtolower($v[0]) == "false") { if ($editable) { return $qm->m['plg_enable_cache']['ntc_admin2']; } else { $qt->enable_cache = 0; return ''; } } else { if ($editable) { return $qm->m['plg_enable_cache']['ntc_admin']; } else { $qt->enable_cache = 1; return ''; } } }
function plugin_fb_root_deprecated() { global $vars; if (!edit_auth($vars['page'], FALSE, FALSE)) { return ''; } $backtrace = debug_backtrace(); $plugin_name = str_replace(array('plugin_', '_convert', '_inline'), '', $backtrace[2]['function']); return <<<EOM \t\t<div class="alert alert-danger"> \t\t\t<code>#{$plugin_name}</code> このプラグインは現在利用できません。 \t\t</div> EOM; }
/** * Set OGP Tags to QHM Template */ function plugin_ogp_set_template() { global $ogp_tag, $add_xmlns; if (!$ogp_tag) { return; } $qt = get_qt(); $editable = edit_auth($page, FALSE, FALSE); $defdata = plugin_ogp_get_defdata(); //先にセットしたデータを取得 if ($data = $qt->getv('plugin_ogp_tags')) { $data = array_merge($defdata, $data); } else { $data = $defdata; } //画像(og:image)がなければ、showプラグインで使った最初の画像を探す。 if (!isset($data['og:image']) or $data['og:image'] === FALSE) { if ($fimg = $qt->getv('first_image')) { $data['og:image'] = $fimg; } else { $data['og:image'] = plugin_ogp_get_defaultimage(); } } //set ogp tags $beforescript = ''; foreach ($data as $prop => $content) { if ($content !== FALSE) { $beforescript .= '<meta property="' . h($prop) . '" content="' . h($content) . '" />' . "\n"; } } $qt->appendv('beforescript', $beforescript); }
if (!defined('PKWK_READONLY')) { define('PKWK_READONLY', 0); } // 0 or 1 // PKWK_SAFE_MODE - Prohibits some unsafe(but compatible) functions if (!defined('PKWK_SAFE_MODE')) { define('PKWK_SAFE_MODE', 0); } // PKWK_DISABLE_INLINE_IMAGE_FROM_URI - Disallow using inline-image-tag for URIs // Inline-image-tag for URIs may allow leakage of Wiki readers' information // (in short, 'Web bug') or external malicious CGI (looks like an image's URL) // attack to Wiki readers, but easy way to show images. if (!defined('PKWK_DISABLE_INLINE_IMAGE_FROM_URI')) { define('PKWK_DISABLE_INLINE_IMAGE_FROM_URI', 0); } if (!edit_auth($page, TRUE, FALSE)) { $rw = 0; } else { $rw = 1; } // PKWK_QUERY_STRING_MAX // Max length of GET method, prohibits some worm attack ASAP // NOTE: Keep (page-name + attach-file-name) <= PKWK_QUERY_STRING_MAX define('PKWK_QUERY_STRING_MAX', 640); // Bytes, 0 = OFF ///////////////////////////////////////////////// // Experimental features // Multiline plugin hack (See BugTrack2/84) // EXAMPLE(with a known BUG): // #plugin(args1,args2,...,argsN){{ // argsN+1
function plugin_backup_action() { global $vars, $do_backup, $hr, $script; global $layout_pages, $style_name; $qm = get_qm(); $editable = edit_auth($page, FALSE, FALSE); if (!$editable) { header("Location: {$script}"); exit; } if (!$do_backup) { return; } $page = isset($vars['page']) ? $vars['page'] : ''; if ($page == '') { return array('msg' => $qm->m['plg_backup']['title_backuplist'], 'body' => plugin_backup_get_list_all()); } //レイアウト部品の場合、スタイルを変更する $is_layout = FALSE; if (isset($layout_pages) && isset($layout_pages[$page])) { $style_name = '..'; $is_layout = TRUE; } check_readable($page, true, true); $s_page = htmlspecialchars($page); $r_page = rawurlencode($page); $action = isset($vars['action']) ? $vars['action'] : ''; if ($action == 'delete') { return plugin_backup_delete($page); } $s_action = $r_action = ''; if ($action != '') { $s_action = htmlspecialchars($action); $r_action = rawurlencode($action); } $s_age = isset($vars['age']) && is_numeric($vars['age']) ? $vars['age'] : 0; if ($s_age <= 0) { $title = $is_layout ? h($layout_pages[$page]) . 'のバックアップ一覧' : $qm->m['plg_backup']['title_pagebackuplist']; return array('msg' => $title, 'body' => plugin_backup_get_list($page)); } $script = get_script_uri(); $body = '<ul>' . "\n"; if (!$is_layout) { $body .= ' <li><a href="' . $script . '?cmd=backup">' . $qm->m['plg_backup']['backuplist'] . '</a></li>' . "\n"; } $href = $script . '?cmd=backup&page=' . $r_page . '&age=' . $s_age; $is_page = is_page($page); if ($is_page && $action != 'diff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=diff">' . $qm->m['plg_backup']['diff'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($is_page && $action != 'nowdiff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=nowdiff">' . $qm->m['plg_backup']['nowdiff'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($action != 'source') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=source">' . $qm->m['plg_backup']['source'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING && $action) { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '">' . $qm->m['plg_backup']['backup'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($is_page && $is_layout) { $body .= ' <li><a href="' . $script . '?cmd=edit&page=' . $r_page . '">' . h($layout_pages[$page]) . 'を編集する</a>'; } else { if ($is_page) { $body .= ' <li>' . str_replace('$1', '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>', $qm->m['fmt_msg_goto']) . "\n"; } else { $body .= ' <li>' . str_replace('$1', $s_page, $qm->m['plg_backup']['deleted']) . "\n"; } } $backups = get_backup($page); $backups_count = count($backups); if ($s_age > $backups_count) { $s_age = $backups_count; } if ($backups_count > 0) { $body .= ' <ul>' . "\n"; foreach ($backups as $age => $val) { $date = format_date($val['time'], TRUE); $body .= $age == $s_age ? ' <li><em>' . $age . ' ' . $date . '</em></li>' . "\n" : ' <li><a href="' . $script . '?cmd=backup&action=' . $r_action . '&page=' . $r_page . '&age=' . $age . '">' . $age . ' ' . $date . '</a></li>' . "\n"; } $body .= ' </ul>' . "\n"; } $body .= ' </li>' . "\n"; $body .= '</ul>' . "\n"; if ($action == 'diff') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップ差分(No.$2)' : $qm->m['plg_backup']['title_backupdiff']; $old = $s_age > 1 ? join('', $backups[$s_age - 1]['data']) : ''; $cur = join('', $backups[$s_age]['data']); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'nowdiff') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップの現在との差分(No.$2)' : $qm->m['plg_backup']['title_backupnowdiff']; $old = join('', $backups[$s_age]['data']); $cur = join('', get_source($page)); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'source') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップソース(No.$2)' : $qm->m['plg_backup']['title_backupsource']; $body .= '<pre>' . htmlspecialchars(join('', $backups[$s_age]['data'])) . '</pre>' . "\n"; } else { if (PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { die_message($qm->m['fmt_err_prohibited']); } else { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップ(No.$2)' : $qm->m['plg_backup']['title_backup']; $body .= $hr . "\n" . drop_submit(convert_html($backups[$s_age]['data'])); } } } } return array('msg' => str_replace('$2', $s_age, $title), 'body' => $body); }
/** * 画像を添付するためのもの */ function plugin_show_action() { global $script, $vars, $username; global $html_transitional; $qm = get_qm(); //check auth $editable = edit_auth($vars['refer'], FALSE, FALSE); if (!$editable) { return array('msg' => $qm->m['plg_attachref']['title_ntc_admin'], 'body' => '<p>' . $qm->m['plg_attachref']['ntc_admin'] . '</p>'); } //戻り値を初期化 $retval['msg'] = $qm->m['plg_attachref']['title']; $retval['body'] = ''; if (array_key_exists('attach_file', $_FILES) and array_key_exists('refer', $vars) and is_page($vars['refer'])) { $file = $_FILES['attach_file']; $attachname = $file['name']; $filename = preg_replace('/\\..+$/', '', $attachname, 1); //! swfuを持っていたら (管理者のみ)-------------------------------------------- if ($editable && has_swfu()) { //アップロードするファイル名を決める(日本語ダメ、重複もダメ) $upload_name = $file['name']; if (preg_match('/^[-_.+a-zA-Z0-9]+$/', $upload_name)) { while (!$overwrite && file_exists(SWFU_IMAGE_DIR . $upload_name)) { $upload_name = 's_' . $upload_name; } $upload_file = SWFU_IMAGE_DIR . $upload_name; $fname = $upload_name; $disp = $qm->m['plg_attachref']['img_desc']; } else { $matches = array(); if (!preg_match('/[^.]+\\.(.*)$/', $upload_name, $matches)) { echo 'invalid file name : ' . $upload_name; exit(0); } $ext = $matches[1]; $tmp_name = tempnam(SWFU_IMAGE_DIR, 'auto_'); $upname = $tmp_name . '.' . $ext; $disp = $upload_name; rename($tmp_name, $upname); $upload_file = SWFU_IMAGE_DIR . basename($upname); $fname = basename($upname); } move_uploaded_file($file['tmp_name'], $upload_file); chmod($upload_file, 0666); //regist db $stat = stat($upload_file); $data = array('name' => $fname, 'description' => $disp, 'created' => $stat['mtime'], 'size' => $stat['size'], 'page_name' => $vars['refer']); require_once SWFU_TEXTSQL_PATH; $db = new CTextDB(SWFU_IMAGEDB_PATH); $db->insert($data); $retval = show_insert_ref(SWFU_IMAGE_DIR . $fname); return $retval; } // open qhm用 attachフォルダにファイルを置く //すでに存在した場合、 ファイル名に'_0','_1',...を付けて回避(姑息) $count = '_0'; while (file_exists('./attach/' . encode($vars['refer']) . '_' . encode($attachname))) { $attachname = preg_replace('/^[^\\.]+/', $filename . $count++, $file['name']); } $file['name'] = $attachname; require_once PLUGIN_DIR . "attach.inc.php"; if (!exist_plugin('attach') or !function_exists('attach_upload')) { return array('msg' => $qm->m['plg_attachref']['err_notfound']); } $pass = array_key_exists('pass', $vars) ? $vars['pass'] : NULL; $retval = attach_upload($file, $vars['refer'], $pass); if ($retval['result'] == TRUE) { $retval = show_insert_ref($file['name']); } } else { $retval = show_showform(); // XHTML 1.0 Transitional $html_transitional = TRUE; } return $retval; }
function plugin_weblog_convert() { global $options; if (func_num_args() > 0) { $args = func_get_args(); } if ($args[0] != "") { //コンフィグの読み込み(指定weblog固有) $conf_name = $args[0]; $options = weblog_get_options($conf_name, $options); } $prefix = strip_bracket($options['PREFIX']); if (!edit_auth($prefix, FALSE, FALSE)) { return ""; } return plugin_weblog_make_form($conf_name, "new", "", "", "", ""); }
function check_editable($page, $auth_flag = true, $exit_flag = true) { global $script, $_title_cannotedit, $_msg_unfreeze; if (edit_auth($page, $auth_flag, $exit_flag) && is_editable($page)) { // Editable return true; } else { // Not editable if ($exit_flag === false) { return false; // Without exit } else { // With exit $body = $title = str_replace('$1', htmlsc(strip_bracket($page)), $_title_cannotedit); if (is_freeze($page)) { $body .= '(<a href="' . $script . '?cmd=unfreeze&page=' . rawurlencode($page) . '">' . $_msg_unfreeze . '</a>)'; } $page = str_replace('$1', make_search($page), $_title_cannotedit); catbody($title, $page, $body); exit; } } }