function plugin_doc_ini_action() { global $vars, $_doc_ini_msg; if (Auth::check_role('role_contents_admin')) { die_message('NOT AUTHORIZED.'); } if (empty($vars['page'])) { return; } if (!is_pagename($vars['page'])) { return ''; } // Invalid page name; $action = empty($vars['action']) ? '' : $vars['action']; $retval = array(); $msg_title = sprintf($_doc_ini_msg['msg_confirmation'], $vars['page']); if ($action === 'exec') { return plugin_doc_ini_exec($vars['page']); } $script = get_script_uri(); $retval['body'] = <<<EOD <form action="{$script}" method="post" class="doc_ini_form"> \t<input type="hidden" name="cmd" value="doc_ini" /> \t<input type="hidden" name="action" value="exec" /> \t<input type="hidden" name="page" value="{$vars['page']}" /> \t{$msg_title} \t<input class="btn btn-primary" type="submit" value="{$_doc_ini_msg['btn_exec']}" /> </form> EOD; $retval['msg'] = $_doc_ini_msg['title_confirmation']; return $retval; }
function plugin_jugemkey_inline() { global $script, $vars, $auth_api, $_jugemkey_msg; if (!$auth_api['jugemkey']['use']) { return $_jugemkey_msg['msg_invalid']; } $obj = new AuthJugem(); $name = $obj->getSession(); if (!empty($name['api']) && $obj->auth_name !== $name['api']) { return; } if (isset($name['title'])) { // $name = array('title','ts','token'); $link = $name['title']; $logout_url = $script . '?cmd=jugemkey'; if (!empty($vars['page'])) { $logout_url .= '&page=' . rawurlencode($vars['page']) . '&logout'; } return sprintf($_jugemkey_msg['msg_logined'], $link) . '(<a href="' . $logout_url . '">' . $_jugemkey_msg['msg_logout'] . '</a>)'; } $auth_key = Auth::get_user_name(); if (!empty($auth_key['nick'])) { return $_jugemkey_msg['msg_jugemkey']; } $login_url = plugin_jugemkey_jump_url(1); return '<a href="' . $login_url . '">' . $_jugemkey_msg['msg_jugemkey'] . '</a>'; }
function plugin_newpage_action() { global $vars, $_string, $_newpage_messages; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); if (Auth::check_role('readonly')) { Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_READONLY'), '', 403); } if (Auth::is_check_role(PKWK_CREATE_PAGE)) { Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_CREATE_PAGE'), '', 403); } if (!isset($vars['page'])) { $retvars['msg'] = $_newpage_messages['title']; $retvars['body'] = plugin_newpage_convert(); return $retvars; } else { $page = Utility::stripNullBytes($vars['page']); if (isset($vars['refer'])) { $r_page = Utility::getPageName($page, $vars['refer']); $r_refer = 'refer=' . $vars['refer']; } else { $r_page = $page; $r_refer = ''; } Utility::redirect(get_page_location_uri($r_page, $r_refer)); exit; } }
function plugin_insert_convert() { global $vars, $digest; static $numbers = array(); $_btn_insert = T_('add'); // if (PKWK_READONLY) return ''; // Show nothing if (Auth::check_role('readonly')) { return ''; } // Show nothing if (!isset($numbers[$vars['page']])) { $numbers[$vars['page']] = 0; } $insert_no = $numbers[$vars['page']]++; $script = get_script_uri(); $s_page = Utility::htmlsc($vars['page']); $s_digest = Utility::htmlsc($digest); $s_cols = INSERT_COLS; $s_rows = INSERT_ROWS; $string = <<<EOD <form action="{$script}" method="post" class="insert_form"> \t<input type="hidden" name="insert_no" value="{$insert_no}" /> \t<input type="hidden" name="refer" value="{$s_page}" /> \t<input type="hidden" name="cmd" value="insert" /> \t<input type="hidden" name="digest" value="{$s_digest}" /> \t<textarea name="msg" rows="{$s_rows}" cols="{$s_cols}" class="form-control"></textarea><br /> \t<input type="submit" class="btn btn-primary" name="insert" value="{$_btn_insert}" /> </form> EOD; return $string; }
function plugin_deleted_action() { global $vars, $_deleted_msg; $dir = isset($vars['dir']) ? $vars['dir'] : 'backup'; $withfilename = isset($vars['file']); $_DIR['diff']['dir'] = DIFF_DIR; $_DIR['diff']['ext'] = '.txt'; $_DIR['backup']['dir'] = BACKUP_DIR; $_DIR['backup']['ext'] = BACKUP_EXT; // .gz or .txt //$_DIR['cache' ]['dir'] = CACHE_DIR; // No way to delete them via web browser now //$_DIR['cache' ]['ext'] = '.ref'; //$_DIR['cache' ]['ext'] = '.rel'; if (!isset($_DIR[$dir])) { return array('msg' => 'Deleted plugin', 'body' => $_deleted_msg['no_such_setting']); } $deleted_pages = array_diff(Auth::get_existpages($_DIR[$dir]['dir'], $_DIR[$dir]['ext']), Auth::get_existpages()); if ($withfilename) { $retval['msg'] = $_deleted_msg['title_withfilename']; } else { $retval['msg'] = $_deleted_msg['title_collision']; } $retval['body'] = page_list($deleted_pages, $dir, $withfilename); return $retval; }
function plugin_showrss_action() { global $vars, $cache; // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibit this'); if (Auth::check_role('safemode')) { Utility::dieMessage('PKWK_SAFE_MODE prohibits this'); } if ($vars['feed']) { // ajaxによる読み込み $target = $vars['feed']; list($data, $time, $reason) = plugin_showrss_get_rss($vars['feed'], 1, true); $header = Header::getHeaders('aplication/xml', $time); if (empty($reason)) { Header::writeResponse($header, Response::STATUS_CODE_200, $data); } else { // とりあえずXMLでエラー Header::writeResponse($header, Response::STATUS_CODE_200, '<?xml version="1.0" encoding="UTF-8"?><response><error>1</error><message>' . Utility::htmlsc($reason) . '</message></response>'); } exit; } $body = ''; foreach (array('xml', 'mbstring') as $extension) { ${$extension} = extension_loaded($extension) ? '&color(green){Found};' : '&color(red){Not found};'; $body .= '| ' . $extension . ' extension | ' . ${$extension} . ' |' . "\n"; } return array('msg' => 'showrss_info', 'body' => convert_html($body)); }
function plugin_mypage_convert() { global $_mypage_msg; @(list($is_page) = func_get_args()); $is_page = empty($is_page) ? false : true; $auth_key = Auth::get_user_info(); // 認証確認 if (empty($auth_key['key'])) { return ''; } // マイページ利用の確認 if (empty($auth_key['mypage'])) { return ''; } // マイページの作成により制御 // マイページ未作成の場合 // is_page : true -> プラグイン利用ページに遷移 -> #mypage(1) // : false -> 新規作成画面に遷移 -> #mypage // The page cannot be prepared. -> ページの準備ができていません。 if ($is_page && !is_page($auth_key['mypage'])) { return $_mypage_msg['msg_no_page']; } // 画面に誘導 header('Location: ' . get_page_location_uri($auth_key['mypage'])); // 誘導失敗時の対処(ブラウザによる) die_message($_mypage_msg['err_jump']); }
function plugin_ls_convert() { global $vars; $with_title = FALSE; if (func_num_args()) { $args = func_get_args(); $with_title = in_array('title', $args); } $prefix = $vars['page'] . '/'; $page = isset($vars['page']) ? $vars['page'] : ''; $pages = array(); foreach (Auth::get_existpages() as $page) { if (strpos($page, $prefix) === 0) { $pages[] = $page; } } natcasesort($pages); $ls = array(); foreach ($pages as $page) { $comment = ''; if ($with_title) { $array = file_head(get_filename($page), 1); if ($array) { $comment = ' - ' . preg_replace(array('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/S', '/^(?:-+|\\*+)/'), array('$1$2', null), current($array)); } } $ls[] = "-[[{$page}]] {$comment}"; } return RendererFactory::factory($ls); }
function plugin_typekey_inline() { global $vars, $_typekey_msg, $auth_api; if ($auth_api['typekey']['use'] != 1) { return $_typekey_msg['msg_invalid']; } if (empty($auth_api['typekey']['site_token'])) { return $_typekey_msg['msg_error']; } $obj = new AuthTypekey(); $link = $obj->get_profile_link(); if ($link === false) { return ''; } if (!empty($link)) { // 既に認証済 $page = get_script_absuri() . rawurlencode('?plugin=typekey'); if (!empty($vars['page'])) { $page .= rawurlencode('&page=' . $vars['page']); } return sprintf($_typekey_msg['msg_logined'], $link) . '(<a href="' . $obj->typekey_logout_url($page) . rawurlencode('&logout') . '">' . $_typekey_msg['msg_logout'] . '</a>)'; } $auth_key = Auth::get_user_name(); if (!empty($auth_key['nick'])) { return $_typekey_msg['msg_typekey']; } return '<a href="' . plugin_typekey_jump_url() . '">' . $_typekey_msg['msg_typekey'] . '</a>'; }
function count_files($no = 0, $pref = '') { // 0:DATA, 1:TB, 2:Referer, 3: DIFF, 4:BKUP, 5:CTR static $dir = array(DATA_DIR, TRACKBACK_DIR, REFERER_DIR, DIFF_DIR, BACKUP_DIR, COUNTER_DIR); static $ext = array('.txt', '.txt', '.ref', '.txt', BACKUP_EXT, '.count'); // コンテンツ管理者以上は、全てのファイルを対象にする if (!Auth::check_role('role_contents_admin')) { $pages = get_existpages($dir[$no], $ext[$no]); } else { // 自分が閲覧できるページ数のみ戻す $pages = Auth::get_existpages($dir[$no], $ext[$no]); } // 条件なし if (empty($pref)) { return count($pages); } // 指定文書のカウント $i = 0; foreach ($pages as $page) { if (strpos($page, $pref) === 0) { $i++; } } return $i; }
function plugin_group_convert() { global $_group_msg; $auth_key = Auth::get_user_info(); if (empty($auth_key['group'])) { return ''; } $argv = func_get_args(); $i = count($argv); if ($i < 2) { return <<<EOD <div> \t<label>{$_group_msg['group']}</label>: \t{$auth_key['group']} </div> EOD; } $msg = $argv[$i - 1]; array_pop($argv); if (in_array($auth_key['group'], $argv)) { return RendererFactory::factory(str_replace("\r", "\n", $msg)); } return ''; }
function plugin_version_value() { // if (PKWK_SAFE_MODE) return ''; if (Auth::check_role('safemode')) { return ''; } return S_VERSION; }
function plugin_server_convert() { // if (PKWK_SAFE_MODE) return ''; // Show nothing if (Auth::check_role('safemode')) { return ''; } // Show nothing return '<dl>' . "\n" . '<dt>Server Name</dt>' . '<dd>' . SERVER_NAME . '</dd>' . "\n" . '<dt>Server Software</dt>' . '<dd>' . SERVER_SOFTWARE . '</dd>' . "\n" . '<dt>Server Admin</dt>' . '<dd>' . '<a href="mailto:' . SERVER_ADMIN . '">' . SERVER_ADMIN . '</a></dd>' . "\n" . '</dl>' . "\n"; }
function plugin_yetlist_action() { // global $_title_yetlist, $_err_notexist, $_symbol_noexists, $non_list; global $_symbol_noexists, $non_list, $whatsdeleted; $retval = array('msg' => 'yetlist', 'body' => T_('List of pages which have not yet been created.')); // Diff $pages = array_diff(Auth::get_existpages(CACHE_DIR, '.ref'), Auth::get_existpages()); if (empty($pages)) { $retval['body'] = T_('All pages have been created.'); return $retval; } $empty = TRUE; // Load .ref files and Output $refer_regex = '/' . $non_list . '|^' . preg_quote($whatsdeleted, '/') . '$/S'; asort($pages, SORT_STRING); foreach ($pages as $file => $page) { $refer = array(); foreach (file(CACHE_DIR . $file) as $line) { list($_page) = explode("\t", rtrim($line)); $refer[] = $_page; } // Diff $refer = array_diff($refer, preg_grep($refer_regex, $refer)); if (!empty($refer)) { $empty = FALSE; $refer = array_unique($refer); sort($refer, SORT_STRING); $r_refer = ''; $link_refs = array(); foreach ($refer as $_refer) { $r_refer = rawurlencode($_refer); $link_refs[] = '<a href="' . get_page_uri($_refer) . '">' . htmlsc($_refer) . '</a>'; } $link_ref = join(' ', $link_refs); unset($link_refs); $s_page = htmlsc($page); // if (PKWK_READONLY) { if (Auth::check_role('readonly')) { $href = $s_page; } else { // Dangling link $href = '<span class="noexists">' . $s_page . '<a href="' . get_cmd_uri('edit', $page, '', 'refer=' . $r_refer) . '">' . $_symbol_noexists . '</a></span>'; } $retval['body'] .= '<li>' . $href . ' <em>(' . $link_ref . ')</em></li>' . "\n"; } } if ($empty) { $retval['body'] = $_err_notexist; return $retval; } if ($retval['body'] != '') { $retval['body'] = '<ul>' . "\n" . $retval['body'] . '</ul>' . "\n"; } return $retval; }
function plugin_stationary_action() { // See above // if (PKWK_SAFE_MODE || PKWK_READONLY) if (Auth::check_role('safemode') || Auth::check_role('readonly')) { die_message('PKWK_SAFE_MODE or PKWK_READONLY prohibits this'); } $msg = 'Message'; $body = 'Message body'; return array('msg' => htmlsc($msg), 'body' => htmlsc($body)); }
function plugin_unfreeze_action() { global $vars, $function_freeze, $_unfreeze_msg; $page = isset($vars['page']) ? $vars['page'] : ''; $wiki = Factory::Wiki($page); if (!$function_freeze || !$wiki->isEditable(false, true) || !$wiki->isValied($page)) { return array('msg' => $_unfreeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to unfreeze this page.</p>'); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = ''; $body = array(); if (!$wiki->isFreezed()) { // Unfreezed already $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_isunfreezed']); $body[] = '<p class="alert alert-info">' . $msg . '</p>'; } else { if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) { // BugTrack2/255 $wiki->checkReadable(); // Unfreeze $postdata = $wiki->get(); array_shift($postdata); $wiki->set($postdata); // Update if (PLUGIN_UNFREEZE_EDIT) { // BugTrack2/255 $wiki->checkEditable(true); // $vars['cmd'] = 'read'; // To show 'Freeze' link $vars['cmd'] = 'edit'; } else { $vars['cmd'] = 'read'; } $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_unfreeze_msg['title_unfreezed']); $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p>'; $body[] = '<div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>'; Utility::redirect($wiki->uri()); exit; } else { // Show unfreeze form $msg = $_unfreeze_msg['title_unfreeze']; $body[] = $pass === NULL ? '' : '<p class="alert alert-danger">' . $_unfreeze_msg['msg_invalidpass'] . '</p>' . "\n"; $body[] = '<fieldset>'; $body[] = '<legend>' . $_unfreeze_msg['msg_unfreezing'] . '</legend>'; $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">'; $body[] = '<input type="hidden" name="cmd" value="unfreeze" />'; $body[] = '<input type="hidden" name="page" value="' . Utility::htmlsc($page) . '" />'; $body[] = '<input type="password" name="pass" size="12" class="form-control" />'; $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_unfreeze_msg['btn_unfreeze'] . '</button>'; $body[] = '</form>'; $body[] = '</fieldset>'; } } return array('msg' => $msg, 'body' => join("\n", $body)); }
function plugin_back_convert() { $_msg_back_word = T_('Back'); if (func_num_args() > 4) { return PLUGIN_BACK_USAGE; } list($word, $align, $hr, $href) = array_pad(func_get_args(), 4, ''); $word = trim($word); $word = $word == '' ? $_msg_back_word : htmlsc($word); $align = strtolower(trim($align)); switch ($align) { case '': $align = 'center'; /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'center': /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'left': /*FALLTHROUGH*/ /*FALLTHROUGH*/ case 'right': break; default: return PLUGIN_BACK_USAGE; } $hr = trim($hr) != '0' ? '<hr class="full_hr" />' . "\n" : ''; $link = TRUE; $href = trim($href); if (!empty($href)) { if (Auth::check_role('safemode')) { if (is_url($href)) { $href = rawurlencode($href); } else { $wiki = Factory::Wiki($array[0]); $array = Utility::explodeAnchor($href); $array[1] = !empty($array[1]) ? '#' . rawurlencode($array[1]) : ''; $href = $wiki->uri() . $array[1]; $link = $wiki->has(); } } else { $href = rawurlencode($href); } } else { $href = 'javascript:history.go(-1)'; } if ($link) { // Normal link return $hr . '<div style="text-align:' . $align . '">' . '[ <a href="' . $href . '">' . $word . '</a> ]</div>' . "\n"; } else { // Dangling link return $hr . '<div style="text-align:' . $align . '">' . '[ <span class="noexists">' . $word . '<a href="' . $href . '">?</a></span> ]</div>' . "\n"; } }
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_add_action() { global $get, $post, $vars, $_string; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); if (Auth::check_role('readonly')) { Utility::dieMessage($_string['prohibit']); } $page = isset($vars['page']) ? $vars['page'] : ''; $wiki = Factory::Wiki($page); $wiki->checkEditable(); $get['add'] = $post['add'] = $vars['add'] = TRUE; return array('msg' => _("Add to \$1"), 'body' => '<ul>' . "\n" . ' <li>' . T_('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_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'); }
/** * コンストラクタ */ public function __construct() { global $adminpass, $vars; // if (!isset($this->auth_name)) throw new Exception('$this->auth_name has not set.'); // コールバック先のページ $page = isset($vars['page']) ? $vars['page'] : null; // 管理人のパスワードのハッシュを暗号/復号のキーとする list(, $salt) = Auth::passwd_parse($adminpass); // 暗号化/復号化用 $this->bc = BlockCipher::factory('mcrypt', array('algo' => 'des', 'mode' => 'cfb', 'hash' => 'sha512', 'salt' => $salt)); // コールバック先のURL。通常プラグインのコールバックアドレスが返される $this->callbackUrl = isset($this->auth_name) ? Router::get_resolve_uri($this->auth_name, $vars['page'], 'full') : null; // セッション名 $this->session_name = self::SESSION_PREFIX . md5(Router::get_script_absuri() . session_id()); }
function plugin_links_action() { global $post, $vars, $foot_explain; global $_links_messages, $_string; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this'); if (Auth::check_role('readonly')) { Utility::dieMessage($_string['error_prohibit']); } $msg = $_links_messages['title_update']; $admin_pass = empty($post['adminpass']) ? null : $post['adminpass']; if (isset($vars['execute']) && $vars['execute'] === 'true') { if (!Auth::check_role('role_contents_admin') || Auth::login($admin_pass)) { // $force = (isset($post['force']) && $post['force'] === 'on') ? true : false; $links = new Relational(''); $links->init(); return array('msg' => $msg, 'body' => $_links_messages['msg_done']); } else { $msg = $_links_messages['msg_error']; } } $body = RendererFactory::factory(sprintf($_links_messages['msg_usage1'])); $script = Router::get_script_uri(); if (Auth::check_role('role_contents_admin')) { $body .= RendererFactory::factory(sprintf($_links_messages['msg_usage2'])); } $body .= <<<EOD <form method="post" action="{$script}" class="form-inline plugin-links-form"> \t<input type="hidden" name="cmd" value="links" /> \t<input type="hidden" name="execute" value="true" /> EOD; if (Auth::check_role('role_contents_admin')) { $body .= <<<EOD \t<div class="form-group"> \t\t<label for="_p_links_adminpass" class="sr-only">{$_links_messages['msg_adminpass']}</label> \t\t<input type="password" name="adminpass" id="_p_links_adminpass" class="form-control" size="20" value="" placeholder="{$_links_messages['msg_adminpass']}" /> \t</div> EOD; } $body .= <<<EOD \t<!--div class="checkbox"> \t\t<input type="checkbox" name="force" id="_c_force" /> \t\t<label for="_c_force">{$_links_messages['btn_force']}</label> \t</div--> \t<input type="submit" class="btn btn-primary" value="{$_links_messages['btn_submit']}" /> </form> EOD; return array('msg' => $msg, 'body' => $body); }
function plugin_freeze_action() { global $vars, $function_freeze, $_freeze_msg; $page = isset($vars['page']) ? $vars['page'] : null; if (is_null($page)) { return array('msg' => 'Not Found', 'body' => 'Page not found'); } $wiki = Factory::Wiki($page); if (!$function_freeze || !$wiki->isEditable(true) || !$wiki->has()) { return array('msg' => $_freeze_msg['title_disabled'], 'body' => '<p class="alert alert-danger">You have no permission to freeze this page.</p>'); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = ''; $body = array(); if ($wiki->isFreezed()) { // Freezed already $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_isfreezed']); $body[] = '<p class="alert alert-info">' . $msg . '</p>'; } else { if (!Auth::check_role('role_contents_admin') || $pass !== NULL && Auth::login($pass)) { // Freeze $postdata = $wiki->get(); array_unshift($postdata, "#freeze"); //凍結をページに付加 $wiki->set($postdata, true); // Update //$wiki->is_freezed(); $vars['cmd'] = 'read'; $msg = str_replace('$1', Utility::htmlsc(Utility::stripBracket($page)), $_freeze_msg['title_freezed']); $body[] = !IS_AJAX ? '' : '<p class="alert alert-success">' . $msg . '</p><div class="pull-right"><a href="' . $wiki->uri() . '" class="btn btn-primary">OK</a></div>'; } else { // Show a freeze form $msg = $_freeze_msg['title_freeze']; $body[] = $pass === NULL ? '' : '<p class="alert alert-warning">' . $_freeze_msg['msg_invalidpass'] . '</p>'; $body[] = '<fieldset>'; $body[] = '<legend>' . $_freeze_msg['msg_freezing'] . '</legend>'; $body[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-freeze-form">'; $body[] = '<input type="hidden" name="cmd" value="freeze" />'; $body[] = '<input type="hidden" name="page" value="' . Utility::htmlsc($page) . '" />'; $body[] = '<input type="password" name="pass" size="12" class="form-control" />'; $body[] = '<button type="submit" class="btn btn-primary" name="ok"><span class="fa fa-lock"></span>' . $_freeze_msg['btn_freeze'] . '</button>'; $body[] = '</form>'; $body[] = '</fieldset>'; } } return array('msg' => $msg, 'body' => join("\n", $body)); }
function replace_adm($pass, $search) { global $_replace_msg; global $_button; $body = ''; if (!Auth::check_role('role_contents_admin')) { $msg = $_replace_msg['msg_input_str']; $body_pass = ""; } else { $msg = $_replace_msg['msg_input_pass']; $body_pass = '******' . $_replace_msg['msg_pass'] . '</label><input type="password" name="pass" size="12" id="pass" class="form-control" /></div>'; if ($pass == 'pass') { $body .= '<p class="alert alert-warning">' . $_replace_msg['msg_warn_pass'] . '</p>' . "\n"; } elseif ($pass != '__nopass__') { $body .= '<p class="alert alert-warning">' . $_replace_msg['msg_no_pass'] . '</p>' . "\n"; } } if ($search === '') { $body .= '<p class="alert alert-warning">' . $_replace_msg['msg_no_search'] . "</p>\n"; } $script = get_script_uri(); $body .= <<<EOD <fieldset> \t<legend>{$msg}</legend> \t<form action="{$script}" method="post" class="plugin-replace-form"> \t\t<input type="hidden" name="cmd" value="replace" /> \t\t<div class="form-group"> \t\t\t<label for="replace_search">{$_replace_msg['msg_input_search_word']}</label> \t\t\t<input type="text" name="search" id="replace_search" size="24" class="form-control" /> \t\t</div> \t\t<div class="form-group"> \t\t\t<label for="replace_replace">{$_replace_msg['msg_input_replace_word']}</label> \t\t\t<input type="text" name="replace" id="replace_replace" size="24" class="form-control" /> \t\t</div> \t\t{$body_pass} \t\t<div class="checkbox"> \t\t\t<input type="checkbox" name="notimestamp" id="replace_notimestamp" /> \t\t\t<label for="replace_notimestamp">{$_button['notchangetimestamp']}</label> \t\t</div> \t\t<input type="submit" class="btn btn-warning" name="ok" value="{$_replace_msg['btn_exec']}" /> \t</form> </fieldset> EOD; return array('msg' => $_replace_msg['msg_H0_replace'], 'body' => $body); }
function plugin_random_action() { global $vars; $pattern = strip_bracket($vars['refer']) . '/'; $pages = array(); foreach (Auth::get_existpages() as $_page) { if (strpos($_page, $pattern) === 0) { $pages[$_page] = strip_bracket($_page); } } srand((double) microtime() * 1000000); $page = array_rand($pages); if ($page != '') { $vars['refer'] = $page; } return array('body' => '', 'msg' => ''); }
function plugin_source_action() { global $vars; //, $_source_messages; // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this'); if (Auth::check_role('safemode')) { Utility::dieMessage('PKWK_SAFE_MODE prohibits this'); } $page = isset($vars['page']) ? $vars['page'] : ''; $vars['refer'] = $page; $wiki = Factory::Wiki($page); if (!$wiki->isValied() || !$wiki->isReadable()) { return array('msg' => T_(' $1 was not found.'), 'body' => T_('cannot display the page source.')); } $source = $wiki->get(true); Auth::is_role_page($source); return array('msg' => T_('Source of $1'), 'body' => '<pre class="sh sunlight-highlight-plain">' . Utility::htmlsc($source) . '</pre>'); }
function plugin_role_convert() { global $_role_msg; $role = Auth::get_role_level(); if ($role == 0) { return ''; } $argv = func_get_args(); $i = count($argv); if ($i < 2) { return role_list($role); } $msg = $argv[$i - 1]; if (!Auth::is_check_role($argv[0])) { return RendererFactory::factory(str_replace("\r", "\n", $msg)); } return ''; }
function plugin_brokenlink_action() { global $vars, $_brokenlink_msg; $retval = array('msg' => $_brokenlink_msg['msg_title'], 'body' => ''); if (empty($vars['page'])) { $retval['body'] = $_brokenlink_msg['msg_param_error']; return $retval; } // ユーザ認証されていない $id = Auth::check_auth(); if (empty($id)) { $retval['body'] = $_brokenlink_msg['msg_not_access']; return $retval; } if (!exist_plugin('xbel')) { $retval['body'] = $_brokenlink_msg['msg_not_found_xbel']; return $retval; } $links = xbel::get_link_list($vars['page']); $data = ''; foreach ($links as $href => $aname) { $rc = http_request($href, 'HEAD'); switch ($rc['rc']) { case 200: // Ok // Ok case 301: // Moved Permanently // Moved Permanently case 401: // Unauthorized continue; default: $data .= '-[[' . $aname . '>' . $href . ']] (' . $rc['rc'] . ")\n"; } } if ($data == '') { $data = $_brokenlink_msg['msg_all_ok']; } $retval['body'] = RendererFactorty::factory($data); return $retval; }
function plugin_topicpath_inline() { global $vars, $defaultpage, $topicpath; if (isset($topicpath) && $topicpath == false) { return ''; } $page = isset($vars['page']) ? $vars['page'] : ''; if ($page == '' || $page == $defaultpage) { return ''; } $parts = explode('/', $page); $b_link = TRUE; if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) { $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK; } else { array_pop($parts); // Remove the page itself } $topic_path = array(); while (!empty($parts)) { $_landing = join('/', $parts); $element = htmlsc(array_pop($parts)); if (!$b_link) { // This page ($_landing == $page) $b_link = TRUE; $topic_path[] = $element; // } else if (PKWK_READONLY && ! is_page($_landing)) { } else { if (Auth::check_role('readonly') && !is_page($_landing)) { // Page not exists $topic_path[] = $element; } else { // Page exists or not exists $topic_path[] = '<a href="' . get_page_uri($_landing) . '">' . $element . '</a>'; } } } if (PLUGIN_TOPICPATH_TOP_DISPLAY) { $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL); } return '<ul><li>' . join('</li><li>', array_reverse($topic_path)) . '</li></ul>'; }
function plugin_touchgraph_ref() { foreach (Auth::get_existpages() as $page) { if (check_non_list($page)) { continue; } $file = CACHE_DIR . encode($page) . '.ref'; if (file_exists($file)) { echo $page; foreach (file($file) as $line) { list($name) = explode("\t", $line); if (check_non_list($name)) { continue; } echo ' ', $name; } echo "\n"; } } }