function plugin_read_action() { global $vars, $_title_invalidwn, $_msg_invalidiwn; $page = isset($vars['page']) ? $vars['page'] : ''; 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'; return do_plugin_action('edit'); // 存在しないので、編集フォームを表示 } else { // 無効なページ名 return array('msg' => $_title_invalidwn, 'body' => str_replace('$1', htmlsc($page), str_replace('$2', 'WikiName', $_msg_invalidiwn))); } } } }
function plugin_read_action() { global $vars, $_title_invalidwn, $_msg_invalidiwn; $page = isset($vars['page']) ? $vars['page'] : ''; if (is_page($page)) { // ページを表示 check_readable($page, true, true); header_lastmod($page); return array('msg' => '', 'body' => ''); // } else if (! PKWK_SAFE_MODE && is_interwiki($page)) { } else { if (!auth::check_role('safemode') && is_interwiki($page)) { return do_plugin_action('interwiki'); // InterWikiNameを処理 } else { if (is_pagename($page)) { $realpages = get_autoaliases($page); if (count($realpages) == 1) { $realpage = $realpages[0]; if (is_page($realpage)) { header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . get_page_location_uri($realpage)); return; } elseif (is_url($realpage)) { header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . $realpage); return; } elseif (is_interwiki($realpage)) { header('HTTP/1.0 301 Moved Permanently'); $vars['page'] = $realpage; return do_plugin_action('interwiki'); // header('Location'); } else { // 存在しない場合、直接編集フォームに飛ばす // To avoid infinite loop header('Location: ' . get_location_uri('edit', $realpage)); return; } } elseif (count($realpages) >= 2) { $body = '<p>'; $body .= _('This pagename is an alias to') . '<br />'; $link = ''; foreach ($realpages as $realpage) { $link .= '[[' . $realpage . '>' . $realpage . ']]&br;'; } $body .= make_link($link); $body .= '</p>'; return array('msg' => _('Redirect'), 'body' => $body); } $vars['cmd'] = 'edit'; return do_plugin_action('edit'); // 存在しないので、編集フォームを表示 } else { // 無効なページ名 return array('msg' => $_title_invalidwn, 'body' => str_replace('$1', htmlspecialchars($page), str_replace('$2', 'WikiName', $_msg_invalidiwn))); } } } }
function plugin_filelist_action() { global $script, $vars; // check editable if (!ss_admin_check()) { $vars['cmd'] = 'list'; } return do_plugin_action('list'); }
function plugin_loglist_convert() { global $script, $log; global $vars; global $_loglist_messages; list($kind) = func_get_args(); $kind = empty($kind) ? 'update' : htmlsc($kind, ENT_QUOTES); if (!$log[$kind]['use']) { return $_loglist_messages['not_active']; } if (!empty($log[$kind]['file'])) { $vars['kind'] = $kind; $rc = do_plugin_action('logview'); return $rc['body']; } $dir = log::get_filename($kind, '', ''); $pages = Auth::get_existpages($dir); if (count($pages) == 0) { return $_loglist_messages['msg_not_found']; } $data = array(); foreach ($pages as $_real => $_page) { $data[] = array(filemtime($dir . '/' . $_real), $_page, log_count($kind, $_page)); } usort($data, function ($a, $b) { return $b[0] - $a[0]; }); // D // usort($data,create_function('$a,$b','return $a[0] - $b[0];')); // A //$str_view = $script.'?plugin=logview&kind='.$kind.'&page='; $str_view = get_cmd_uri('logview', $_page, null, array('kind' => $kind)); $rc = ''; $rc .= '|' . $_loglist_messages['fld_UTIME'] . '|' . $_loglist_messages['fld_PAGE'] . '|' . $_loglist_messages['fld_COUNT'] . "|h\n"; foreach ($data as $_line) { $i = 0; foreach ($_line as $_field) { $rc .= '|'; switch ($i) { case 0: $rc .= get_date('Y-m-d H:i:s', $_field) . ' ' . get_passage($_field); continue; case 1: $rc .= '[' . $str_view . rawurlencode($_field) . ' ' . $_field . ']'; continue; default: $rc .= $_field; } $i++; } $rc .= "|\n"; } return RendererFactory::factory($rc); }
function plugin_filelist_action() { global $vars; if (!Auth::check_role('role_contents_admin')) { return do_plugin_action('list'); } if (!isset($vars['pass'])) { return filelist_adm(''); } if (!pkwk_login($vars['pass'])) { return filelist_adm('__nopass__'); } return do_plugin_action('list'); }
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_revert_action() { global $vars, $post, $_revert_messages, $_msg_preview; $pass = isset($post['pass']) ? $post['pass'] : FALSE; $page = isset($vars['page']) ? $vars['page'] : ''; $age = isset($vars['age']) ? $vars['age'] : ''; if ($page === '') { return; } if (PLUGIN_REVERT_USE_ADMIN_ONLY && $pass === FALSE) { return array('msg' => 'revert plugin', 'body' => plugin_revert_auth($page, $age)); } if (PLUGIN_REVERT_USE_ADMIN_ONLY && !pkwk_login($pass)) { return array('msg' => 'revert plugin', 'body' => $_revert_messages['invalidpass']); } if ($age) { // get_backup($page, $age)の形式だと最後の世代だけ取得できず全世代取得になる $backups = get_backup($page); if (empty($backups[$age]['data'])) { return array('msg' => 'revert plugin', 'body' => 'Backup file not found.'); } $revertdata = $backups[$age]['data']; unset($backups); } else { $filename = DIFF_DIR . encode($page) . '.txt'; if (!file_exists($filename)) { return array('msg' => 'revert plugin', 'body' => 'Diff file not found.'); } $revertdata = array(); foreach (file($filename) as $line) { if ($line[0] !== '+') { $revertdata[] = substr($line, 1); } } } $vars['preview'] = $post['preview'] = 1; $vars['msg'] = $post['msg'] = join('', $revertdata); $vars['digest'] = $post['digest'] = is_page($page) ? md5(join('', get_source($page))) : FALSE; $_msg_preview = $_revert_messages['caution'] . "<br />\n" . $_msg_preview; return do_plugin_action('edit'); }
$retvars = array(); $is_cmd = FALSE; if (isset($vars['cmd'])) { $is_cmd = TRUE; $plugin =& $vars['cmd']; } else { if (isset($vars['plugin'])) { $plugin =& $vars['plugin']; } else { $plugin = ''; } } if ($plugin != '') { if (exist_plugin_action($plugin)) { // Found and exec $retvars = do_plugin_action($plugin); if ($retvars === FALSE) { exit; } // Done if ($is_cmd) { $base = isset($vars['page']) ? $vars['page'] : ''; } else { $base = isset($vars['refer']) ? $vars['refer'] : ''; } } else { // Not found $msg = 'plugin=' . htmlsc($plugin) . ' is not implemented.'; $retvars = array('msg' => $msg, 'body' => $msg); $base =& $defaultpage; }
function plugin_auth_mixi_action() { global $vars, $auth_api, $_auth_mixi_msg; if (!isset($auth_api['openid']['use'])) { return ''; } if (!$auth_api['openid']['use']) { die($_auth_mixi_msg['msg_invalid']); } // マイミク認証のみ許可 list($openid_url, $icon_img) = auth_mixi_set_loginuri('friends', '', PLUGIN_AUTH_MIXI_MY_ID); exist_plugin('openid'); $vars['action'] = 'verify'; $vars['openid_url'] = $openid_url; $vars['author'] = 'auth_mixi'; return do_plugin_action('openid'); }
$msg = 'plugin=' . htmlspecialchars($plugin) . ' is not implemented.'; $retvars = array('msg' => $msg, 'body' => $msg); $base =& $defaultpage; } } // Location で飛ぶようなプラグインの対応のため // 上のアクションプラグインの実行後に処理を実施 if ($is_protect) { if (exist_plugin_convert('protect')) { do_plugin_convert('protect'); } die('PLUS_PROTECT_MODE is set.'); } // WebDAV if (is_webdav() && exist_plugin('dav')) { do_plugin_action('dav'); exit; } // Set Home $auth_key = auth::get_user_info(); if (!empty($auth_key['home'])) { if ($base == $defaultpage || $base == $auth_key['home']) { $base = $defaultpage = $auth_key['home']; } } // Page output $title = htmlspecialchars(strip_bracket($base)); $page = make_search($base); if (isset($retvars['msg']) && $retvars['msg'] != '') { $title = str_replace('$1', $title, $retvars['msg']); $page = str_replace('$1', $page, $retvars['msg']);
function plugin_filelist_action() { return do_plugin_action('list'); }
function plugin_wikinote_action() { global $vars, $post; $_post = array(); foreach ($post as $key => $value) { if (strpos($key, '_wikinote_') === 0) { $_post[substr($key, 10)] = $value; } } $page = ''; if (isset($_post['refer'])) { $page = $_post['refer']; } elseif (isset($vars['page'])) { $page = $vars['page']; } if ($page === '') { return; } // if the notepage exists already, do nothing if (is_page($page)) { header('Location: ' . get_script_uri() . '?' . rawurlencode($page)); exit; } $wikinote = new PluginWikinote(); if (!$wikinote->is_effect($page)) { return; } if (!$wikinote->is_notepage($page)) { return; } // if the wikinote page does not exist, show template html if (empty($_post)) { return $wikinote->show_template_html($page); } // if POST, create the notepage // Check whether the POST is for allowed plugins or not $allowed = TRUE; if (isset($_post['plugin']) && isset($wikinote->allowed_plugin[$_post['plugin']])) { foreach ($wikinote->allowed_plugin[$_post['plugin']] as $name) { if ($_post[$name] === NULL || $_post[$name] === '') { $allowed = FALSE; break; } } } else { $allowed = FALSE; } if (!$allowed) { header('Location: ' . get_script_uri() . '?cmd=wikinote&page=' . rawurlencode($page)); exit; } // create the notepage $vars['cmd'] = 'read'; if (!$wikinote->create_notepage($page)) { header('Location: ' . get_script_uri() . '?cmd=wikinote&page=' . rawurlencode($page)); exit; } $_post['digest'] = md5(@join('', get_source($page))); $vars = $post = $_post; return do_plugin_action($post['plugin']); }
/** * アクションプラグイン処理 */ function plugin_logview_action() { global $vars, $_logview_msg; global $log, $sortable_tracker; static $count = 0; $kind = isset($vars['kind']) ? $vars['kind'] : 'update'; $title = sprintf($_logview_msg['msg_title'], $kind); // タイトルを設定 $page = isset($vars['page']) ? $vars['page'] : ''; // ゲスト表示ができない場合は、認証を要求する if ($log[$kind]['guest'] == '') { $obj = new auth(); $user = $obj->check_auth(); if (empty($user)) { if (exist_plugin('login')) { do_plugin_action('login'); } unset($obj); return array('msg' => $title, 'body' => $_logview_msg['msg_not_auth']); } } unset($obj); check_readable($page, false); // 保存データの項目名を取得 $name = log::get_log_field($kind); $view = log::get_view_field($kind); // 表示したい項目設定 if ($sortable_tracker && $count == 0) { global $head_tags; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'sortabletable.js"></script>'; } $count++; $body = <<<EOD <table id="logview{$count}" class="style_table" cellspacing="1" border="0"> <thead> <tr> EOD; $cols = 0; $is_role_adm = auth::check_role('role_adm'); // タイトルの処理 foreach ($view as $_view) { if ($_view === 'local_id' && $is_role_adm) { continue; } $body .= '<td class="style_td">' . $_logview_msg[$_view] . '</td>' . "\n"; $cols++; } $body .= <<<EOD </tr> </thead> <tbody> EOD; // データを取得 $fld = logview_get_data(log::set_filename($kind, $page), $name); if (empty($fld)) { return array('msg' => $title, 'body' => 'no data'); } // USER-AGENT クラス $obj_ua = new user_agent(USE_UA_OPTION); $path_flag = IMAGE_URI . 'icon/flags/'; $path_browser = IMAGE_URI . 'icon/browser/'; $path_os = IMAGE_URI . 'icon/os/'; $path_domain = IMAGE_URI . 'icon/option/domain/'; $guess = $log['guess_user']['use'] ? log::read_guess() : log::summary_signature(); $ctr = 0; // データの編集 foreach ($fld as $data) { if (!VIEW_ROBOTS && $obj_ua->is_robots($data['ua'])) { continue; } // ロボットは対象外 $body .= "<tr>\n"; foreach ($view as $field) { switch ($field) { case 'ts': // タイムスタンプ (UTIME) $body .= ' <td class="style_td">' . get_date('Y-m-d H:i:s', $data['ts']) . ' ' . get_passage($data['ts']) . "</td>\n"; break; case '@guess_diff': case '@diff': // 差分内容 $update = $field == '@diff' ? true : false; // FIXME: バックアップ/差分 なしの新規の場合 // バックアップデータの確定 $body .= ' <td class="style_td">'; $age = log::get_backup_age($page, $data['ts'], $update); switch ($age) { case -1: // データなし $body .= '<a class="ext" href="' . get_page_uri($page) . '" rel="nofollow">none</a>'; break; case 0: // diff $body .= '<a class="ext" href="'; $body .= log::diff_exist($page) ? get_cmd_uri('diff', $page) : get_page_uri($page); $body .= '" rel="nofollow">now</a>'; break; default: // あり $body .= '<a class="ext" href="' . get_cmd_uri('backup', $page, '', array('age' => $age, 'action' => 'visualdiff')) . '"' . ' rel="nofollow">' . $age . '</a>'; break; } $body .= "</td>\n"; break; case 'host': // ホスト名 (FQDN) $body .= ' <td class="style_td">'; if ($data['ip'] != $data['host']) { // 国名取得 list($flag_icon, $flag_name) = $obj_ua->get_icon_flag($data['host']); if (!empty($flag_icon) && $flag_icon != 'jp') { $body .= '<img src="' . $path_flag . $flag_icon . '.png"' . ' alt="' . $flag_name . '" title="' . $flag_name . '" />'; } // ドメイン取得 $domain = $obj_ua->get_icon_domain($data['host']); if (!empty($domain)) { $body .= '<img src="' . $path_domain . $domain . '.png"' . ' alt="' . $data['host'] . '" title="' . $data['host'] . '" />'; } } $body .= $data['host'] . "</td>\n"; break; case '@guess': // 推測 $body .= ' <td class="style_td">' . htmlspecialchars(logview_guess_user($data, $guess), ENT_QUOTES) . "</td>\n"; break; case 'ua': // ブラウザ情報 (USER-AGENT) $body .= ' <td class="style_td">'; $os = $obj_ua->get_icon_os($data['ua']); if (!empty($os)) { $body .= '<img src="' . $path_os . $os . '.png"' . ' alt="' . $os . '" title="' . $os . '" />'; } $browser = $obj_ua->get_icon_broeswes($data['ua']); if (!empty($browser)) { $body .= '<img src="' . $path_browser . $browser . '.png"' . ' alt="' . htmlspecialchars($data['ua'], ENT_QUOTES) . '" title="' . htmlspecialchars($data['ua'], ENT_QUOTES) . '" />'; } $body .= "</td>\n"; break; case 'local_id': if ($is_role_adm) { continue; } default: $body .= ' <td class="style_td">' . htmlspecialchars($data[$field], ENT_QUOTES) . "</td>\n"; } } $body .= "</tr>\n"; $ctr++; } unset($obj_ua); if ($ctr == 0) { return array('msg' => $title, 'body' => 'no data'); } $body .= <<<EOD </tbody> </table> EOD; switch ($kind) { case 'login': case 'check': $body .= logview_user_list($fld, $page, $kind); break; } if ($sortable_tracker) { $logviewso = join(',', array_fill(0, $cols, '"String"')); $body .= <<<EOD <script type="text/javascript"> <!-- <![CDATA[ var st = new SortableTable(document.getElementById('logview{$count}'),[{$logviewso}]); //]]>--> </script> EOD; } return array('msg' => $title, 'body' => $body); }
function submitham_action() { global $vars, $post, $get; $error = NULL; if (PLUGIN_AKISMET_USE_RECAPTCHA) { // was there a reCAPTCHA response? if (isset($post["recaptcha_response_field"])) { $resp = recaptcha_check_answer(PLUGIN_AKISMET_RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]); $error = $resp->error; $captcha_valid = $resp->is_valid; // If no response from reCAPTCHA, Assume as valid. } else { $captcha_valid = TRUE; if (PLUGIN_AKISMET_RECAPTCHA_LOG) { PluginAkismet::spamlog_write($vars, array('body' => 'reCaptcha invalid'), LOG_DIR . 'captchalog.txt'); } } } $comment = $vars['comment']; $vars = $vars['vars']; if ($captcha_valid) { if (PLUGIN_AKISMET_RECAPTCHA_LOG) { PluginAkismet::spamlog_write($vars, array('body' => 'break'), LOG_DIR . 'captchalog.txt'); } // Memorize the user is human because he could pass captcha $use_authlevel = PLUGIN_AKISMET_THROUGH_IF_ENROLLEE ? ROLE_AUTH : (PLUGIN_AKISMET_THROUGH_IF_ADMIN ? ROLE_ADM_CONTENTS : 0); is_human(TRUE, PLUGIN_AKISMET_USE_SESSION, $use_authlevel); // set to session // submitHam if (PLUGIN_AKISMET_USE_AKISMET) { $akismet = new Akismet(get_script_uri(), PLUGIN_AKISMET_API_KEY, $comment); $akismet->submitHam(); } // autopost if (PLUGIN_AKISMET_AUTOPOST_AFTER_SUBMITHAM) { // throw to originally called plugin // refer lib/pukiwiki.php $cmd = isset($vars['cmd']) ? $vars['cmd'] : (isset($vars['plugin']) ? $vars['plugin'] : 'read'); if (exist_plugin_action($cmd)) { $post = $vars; $get = array(); do_plugin_init($cmd); return do_plugin_action($cmd); } else { $msg = 'plugin=' . htmlspecialchars($cmd) . ' is not implemented.'; return array('msg' => $msg, 'body' => $msg); } } else { $body = '<p>スパム取り消し報告を行いました。以下がスパムと判断された投稿内容です。再度投稿してください。</p>' . "\n"; $body .= '<div class="ie5"><table class="style_table" cellspacing="1" border="0"><tbody>' . "\n"; foreach ($vars as $key => $val) { $body .= '<tr>' . "\n"; $body .= ' <td class="style_td">' . htmlspecialchars($key) . '<td>' . "\n"; $body .= ' <td class="style_td">' . htmlspecialchars($val) . '<td>' . "\n"; $body .= '</tr>' . "\n"; } $body .= '</tbody></table></div>' . "\n"; return array('msg' => 'キャプチャ認証', 'body' => $body); } } else { $form = PluginAkismet::get_captcha_form($vars, $comment, $error); return array('msg' => 'キャプチャ認証', 'body' => $form); } }