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_pcomment_action() { global $vars, $_string; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); if (Auth::check_role('readonly')) { Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_READONLY')); } if (!isset($vars['msg']) || empty($vars['msg'])) { return array(); } // Validate if (is_spampost(array('msg'))) { Utility::dump(); return array('msg' => '', 'body' => ''); // Do nothing } $refer = isset($vars['refer']) ? $vars['refer'] : ''; if (!is_page($refer) && Auth::is_check_role(PKWK_CREATE_PAGE)) { Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_CREATE_PAGE')); } $retval = plugin_pcomment_insert(); if ($retval['collided']) { $vars['page'] = $refer; return $retval; } $hash = isset($vars['reply']) ? '#pcmt' . Utility::htmlsc($vars['reply']) : ''; Utility::redirect(get_page_location_uri($refer) . $hash); }
function plugin_read_action() { global $vars, $_read_msg; $page = isset($vars['page']) ? Utility::stripBracket($vars['page']) : null; $ret = array('msg' => null, 'body' => null); $id = isset($vars['id']) ? $vars['id'] : null; if (!$page) { return $ret; } // 読み込むことができるページか $wiki = Factory::Wiki($page); if ($wiki->isReadable(true)) { return array('msg' => Utility::htmlsc($page), 'body' => $wiki->render($id)); //return $ret; } global $referer; $referer = 0; // InterWikiNameに含まれるページか? // ?adv:FrontPageみたいな感じでアクセス if (preg_match('/^' . RendererDefines::INTERWIKINAME_PATTERN . '$/', $page, $match)) { $url = InterWikiName::getInterWikiUrl($match[2], $match[3]); if ($url == false) { return array('msg' => $_read_msg['title_invalied'], 'body' => sprintf($_read_msg['msg_ibvaliediw'], $match[2])); } Utility::redirect($url); return; } // AutoAliasに含まれるページか? $realpage = AutoAlias::getAutoAlias($page); if (count($realpage) === 1) { // AutoAliasの指定先のページを指定 $a_wiki = Factory::Wiki($realpage); if ($a_wiki->isValied()) { Utility::redirect($a_wiki->link()); return; } else { if (Utility::isUri($realpage)) { Utility::redirect($realpage); return; } } } else { if (count($realpage) >= 2) { $body = '<p>'; $body .= $_read_msg['msg_invalidwn'] . '<br />'; foreach ($realpage as $entry) { $link[] = '[[' . $entry . '>' . $entry . ']]&br;'; } $body .= InlineFactory::Wiki(join("\n", $link)); $body .= '</p>'; return array('msg' => $_read_msg['title_invalied'], 'body' => $body); } } Utility::notfound(); exit; }
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_redirect_action() { global $vars; if (empty($vars['u'])) { return ''; } // 自サイトからのリダイレクトのみ飛ばす if (path_check($_SERVER['HTTP_REFERER'], get_script_absuri())) { Utility::redirect($vars['u']); } return ''; }
function plugin_newpage_subdir_action() { global $vars; if (Auth::check_role('readonly') || Auth::is_check_role(PKWK_CREATE_PAGE)) { return sprintf($_string['error_prohibit'], 'Readonly'); } $roots = $retval = array(); $page = empty($vars['page']) ? '' : $vars['page']; $dir = empty($vars['directory']) ? '' : strip_bracket($vars['directory']); if (empty($page)) { if (!empty($dir)) { $roots[] = substr($dir, -1) == '/' ? substr($dir, 0, -1) : $dir; } return array('msg' => sprintf(T_('Create new page to %s directory'), $dir), 'body' => print_form_string(build_directory_list($roots))); } Utility::redirect(Factory::Wiki($dir . $page)->uri('edit')); }
function plugin_livedoor_action() { global $vars, $auth_api, $_livedoor_msg; if (!$auth_api['livedoor']['use']) { return ''; } // LOGIN if (isset($vars['login'])) { Utility::redirect(plugin_livedoor_jump_url()); } $obj = new auth_livedoor(); // LOGOUT if (isset($vars['logout'])) { $obj->unsetSession(); $page = empty($vars['page']) ? '' : decode($vars['page']); Utility::redirect(get_page_location_uri($page)); } // AUTH $rc = $obj->auth($vars); if (!isset($rc['has_error']) || $rc['has_error'] == 'true') { // ERROR $body = isset($rc['message']) ? $rc['message'] : 'unknown error.'; $die_message($body); } $obj->setSession(); Utility::redirect(get_page_location_uri($obj->get_return_page())); }
function plugin_typekey_action() { global $vars, $auth_api; if (empty($auth_api['typekey']['site_token'])) { return ''; } $obj = new AuthTypekey(); $obj->set_regkeys(); $obj->set_need_email($auth_api['typekey']['need_email']); $obj->set_sigKey($vars); $page = empty($vars['page']) ? '' : $vars['page']; if (!$obj->auth()) { if (isset($vars['logout'])) { $obj->unsetSession(); } Utility::redirect(get_page_location_uri($page)); } // 認証成功 $obj->setSession(); Utility::redirect(get_page_location_uri($page)); }
function plugin_jugemkey_action() { global $vars, $auth_api, $_jugemkey_msg; if (!$auth_api['jugemkey']['use']) { return ''; } // LOGIN if (isset($vars['login'])) { Utility::redirect(plugin_jugemkey_jump_url()); die; } $obj = new AuthJugem(); // LOGOUT if (isset($vars['logout'])) { $obj->unsetSession(); Utility::redirect(); } // Get token info if (isset($vars['userinfo'])) { $rc = $obj->get_userinfo($vars['token']); if ($rc['rc'] != 200) { $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')'; Utility::dieMessage('JugemKey: RC=' . $rc['rc'] . $msg); } $body = '<h3>' . $_jugemkey_msg['msg_userinfo'] . '</h3>' . '<strong>' . $_jugemkey_msg['msg_user_name'] . ': ' . $rc['title'] . '</strong>'; return array('msg' => 'JugemKey', 'body' => $body); } // AUTH $rc = $obj->auth($vars['frob']); if ($rc['rc'] != 200) { $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')'; Utility::dieMessage('JugemKey: ' . $rc['rc'] . $msg); } $obj->setSession(); Utility::redirect(); die; }
function plugin_amazon_action() { global $vars; global $_amazon_msg, $_string; global $_title; // global $_no_name; if (empty($vars['itemid'])) { $retvars['msg'] = $_amazon_msg['msg_ReviewEdit']; $retvars['body'] = amazon_make_review_page(); return $retvars; } else { $itemid = Utility::htmlsc($vars['itemid']); } if (Auth::check_role('readonly')) { die_message($_string['prohibit']); } if (Auth::is_check_role(PKWK_CREATE_PAGE)) { die_message($_amazon_msg['err_newpage']); } if (empty($vars['refer']) || !check_readable($vars['refer'], false, false)) { die; } $locale = empty($vars['locale']) ? 'jp' : Utility::htmlsc($vars['locale']); $obj = new amazon_ecs($itemid, $locale); if (!$obj->is_itemid) { $retvars['msg'] = $_amazon_msg['err_code_set']; $retvars['body'] = amazon_make_review_page(); return $retvars; } $obj->get_items(); if (empty($obj->asin)) { die_message($_amazon_msg['err_not_found']); } $s_page = $vars['refer']; // 入力された内容ではなく、一律 ASINに変換 $r_page = $s_page . '/' . $obj->asin; // 入力された ISBNm ASINで作成 // $r_page = $s_page . '/' . $obj->itemid; $r_page_url = rawurlencode($r_page); $wiki = Factory::Wiki($r_page); $wiki->checkEditable(true); if (!empty($obj->items['Error'])) { $obj->rm_cache(array('xml' => true, 'img' => true)); return array('msg' => 'Error', 'body' => $obj->items['Error']); } if (empty($obj->items['title']) or preg_match('/^\\//', $s_page)) { Utility::redirect(Router::get_page_uri($s_page)); } // レビューページ編集 $body = Factory::Wiki(PLUGIN_AMAZON_TRACKER_PAGE_NAME)->get(true); // $body = str_replace('$1', $obj->itemid, $body); $body = str_replace('$1', $obj->asin, $body); $body = str_replace('$2', $obj->locale, $body); $body = str_replace('[title]', $obj->items['title'], $body); $body = str_replace('[asin]', $obj->asin, $body); $author = $obj->items['author']; $author = empty($author) ? $obj->items['manufact'] : $author; $body = str_replace('[author]', $author, $body); $body = str_replace('[group]', $obj->items['group'], $body); $auth_key = Auth::get_user_name(); $name = empty($auth_key['nick']) ? $_amazon_msg['msg_myname'] : $auth_key['nick']; $body = str_replace('[critic]', '[[' . $name . ']]', $body); $body = str_replace('[date]', '&date;', $body); $body = str_replace('[recommendation]', '[[' . $_amazon_msg['msg_this_edit'] . ']]', $body); $body = str_replace('[body]', '[[' . $_amazon_msg['msg_this_edit'] . ']]', $body); $wiki->set($body); Utility::redirect($wiki->uri('edit')); }
function plugin_help_action() { global $help_page; Utility::redirect(Factory::Wiki('Help')->uri()); }
function plugin_tracker_action() { global $vars, $now, $config_name, $_string, $session; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); // Plus! code start if (Auth::check_role('readonly')) { die_message($_string['prohibit']); } if (Auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(_('PKWK_CREATE_PAGE prohibits editing')); } $base = isset($vars['_base']) ? $vars['_base'] : null; $refer = isset($vars['_refer']) ? $vars['_refer'] : null; if (isset($vars['cancel'])) { Utility::redirect(Router::get_page_uri($refer)); } $tracker_form = new Tracker_form(); // Petit SPAM Check (Client(Browser)-Server Ticket Check) $config = $tracker_form->config_name; // Rescan if ($session->offsetGet('tracker') !== md5(get_ticket() . $config_name)) { honeypot_write(); return array('msg' => 'Cannot write', 'body' => 'Prohibits editing'); } // Plus! code end // $page name to add will be decided here $num = 0; $name = isset($vars['_name']) ? $vars['_name'] : null; if (isset($vars['_page'])) { $real = $page = $vars['_page']; } else { $real = is_pagename($name) ? $name : ++$num; $page = get_fullname('./' . $real, $base); } if (!is_pagename($page)) { $page = $base; } while (is_page($page)) { $real = ++$num; $page = $base . '/' . $real; } $config = isset($vars['_config']) ? $vars['_config'] : null; // TODO: Why here // Default if (isset($_FILES)) { $_post = array_merge($vars, $_FILES); } $_post['_date'] = $now; $_post['_page'] = $page; $_post['_name'] = $name; $_post['_real'] = $real; // $_post['_refer'] = $_post['refer']; // TODO: Why here => See BugTrack/662 // Creating an empty page, before attaching files $from = $to = array(); $tracker_form = new Tracker_form(); if (!$tracker_form->init($base, $refer, $config)) { return array('msg' => 'Cannot write', 'body' => '<p class="alert alert-warning">' . Utility::htmlsc($tracker_form->error) . '</p>'); } // Load $template $template_page = $tracker_form->config->page . '/' . PLUGIN_TRACKER_DEFAULT_PAGE; $template = plugin_tracker_get_source($template_page); if ($template === FALSE || empty($template)) { return array('msg' => 'Cannot write', 'body' => '<p class="alert alert-warning">Page template (' . Utility::htmlsc($template_page) . ') not found</p>'); } if (!$tracker_form->initFields(plugin_tracker_field_pickup(implode(null, $template)))) { return array('msg' => 'Cannot write', 'body' => '<p class="alert alert-warning">' . Utility::htmlsc($tracker_form->error) . '</p>'); } $fields = $tracker_form->fields; unset($tracker_form); foreach (array_keys($fields) as $field) { $from[] = '[' . $field . ']'; $to[] = isset($_post[$field]) ? $fields[$field]->format_value($_post[$field]) : null; unset($fields[$field]); } // Repalace every [$field]s (found inside $template) to real values $subject = $escape = array(); foreach (array_keys($template) as $linenum) { if (trim($template[$linenum]) == null) { continue; } // Escape some TextFormattingRules $letter = $template[$linenum][0]; if ($letter == '|' || $letter == ':') { $escape['|'][$linenum] = $template[$linenum]; } else { if ($letter == ',') { $escape[','][$linenum] = $template[$linenum]; } else { // TODO: Escape "\n" except multiline-allowed fields $subject[$linenum] = $template[$linenum]; } } } foreach (str_replace($from, $to, $subject) as $linenum => $line) { $template[$linenum] = $line; } if ($escape) { // Escape for some TextFormattingRules foreach (array_keys($escape) as $hint) { $to_e = plugin_tracker_escape($to, $hint); foreach (str_replace($from, $to_e, $escape[$hint]) as $linenum => $line) { $template[$linenum] = $line; } } unset($to_e); } unset($from, $to); if (isset($vars['preview'])) { global $_button; unset($vars['preview']); $form[] = '<p class="alert alert-success">' . T_('It will be sent with the contents of the following.') . '</p>'; $form[] = '<form action="' . Router::get_script_uri() . '"enctype="multipart/form-data" method="post" class="form-horizontal plugin-tracker-form">'; foreach ($vars as $key => $value) { $form[] = '<input type="hidden" name="' . $key . '" value="' . $value . '" />'; } $form[] = '<button type="submit" class="btn btn-primary" name="write" accesskey="s"><span class="fa fa-check"></span>' . $_button['update'] . '</button>'; $form[] = '<button type="submit" class="btn btn-warning" name="cancel" accesskey="c"><span class="fa fa-ban"></span>' . $_button['cancel'] . '</button>'; $form[] = '</form>'; $form[] = '<hr />'; $form[] = RendererFactory::factory($template); return array('msg' => 'Preview', 'body' => join("\n", $form)); } else { // Write $template, without touch $wiki = Factory::Wiki($page); $wiki->set($template); Utility::redirect($wiki->uri()); } exit; }
function plugin_openid_verify($consumer) { global $vars, $_openid_msg; $page = empty($vars['page']) ? '' : '' . $vars['page']; $openid = $vars['openid_url']; $return_to = get_location_uri('openid', '', 'action=finish_auth'); $trust_root = get_script_absuri(); // FIXME: 不正な文字列の場合は、logoff メッセージを設定できない $author = empty($vars['author']) ? 'openid' : $vars['author']; $auth_request = $consumer->begin($openid); if (!$auth_request) { Utility::dieMessage($_openid_msg['err_authentication']); } $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email')); if ($sreg_request) { $auth_request->addExtension($sreg_request); } $shouldSendRedirect = $auth_request->shouldSendRedirect(); if ($shouldSendRedirect) { $redirect_url = $auth_request->redirectURL($trust_root, $return_to); if (Auth_OpenID::isFailure($redirect_url)) { Utility::dieMessage(sprintf($_openid_msg['err_redirect'], $redirect_url->message)); } } else { $form_id = 'openid_message'; $form_html = $auth_request->htmlMarkup($trust_root, $return_to, false, array('id' => $form_id)); if (Auth_OpenID::isFailure($form_html)) { Utility::dieMessage(sprintf($_openid_msg['err_redirect'], $form_html->message)); } } // v1 v2 // openid.server openid2.provider => $auth_request->endpoint->server_url ex. http://www.myopenid.com/server // openid.delegate openid2.local_id => $auth_request->endpoint->local_id ex. http://youraccount.myopenid.com/ $obj = new auth_openid_plus_verify(); $obj->response = array('server_url' => $auth_request->endpoint->server_url, 'local_id' => $auth_request->endpoint->local_id, 'page' => $page, 'author' => $author); $obj->setSession(); if ($shouldSendRedirect) { Utility::redirect($redirect_url); } else { //print $form_html; Utility::dieMessage($form_html); } }
function csv_export($opt, $csv_source) { $this->script_uri = get_script_uri(); $page = isset($opt['refer']) ? $opt['refer'] : ''; $opt_name = ''; switch ($opt['w_quote']) { case 'moji': $opt_name = '_str'; break; case 'retu': $opt_name = str_replace(',', '', $opt['column_w_q']); break; } $opt_name = $opt['charset_out'] . $opt['end_of_line'] . $opt_name; $file['name'] = 'table_data' . $opt['table_num'] . '_' . $opt_name . '.csv'; $obj = new TableEdit2CsvConversion($page, $file, SOURCE_ENCODING, 'export'); $obj->w_quote = $opt['w_quote']; if (strpos($opt['column_w_q'], ',') === FALSE) { $obj->column_w_q[] = $opt['column_w_q']; } else { $obj->column_w_q = explode(',', $opt['column_w_q']); } $csv_file = $obj->convert_csv_fields($csv_source, $obj->end_of_line($opt['end_of_line']), SOURCE_ENCODING); $fp = @fopen($obj->filename, 'w'); if ($fp) { @flock($fp, LOCK_EX); $csv_file = join('', $csv_file); stream_set_write_buffer($fp, 0); fwrite($fp, $obj->mb_out_c($csv_file, $opt['charset_out'])); @flock($fp, LOCK_UN); @fclose($fp); } $obj->getstatus(); $obj->putstatus(); $this->logname = $obj->logname; $this->filename = $obj->filename; return $this->export_d($page, $opt['table_num'], $file['name']); Utility::redirect(get_page_uri($page)); exit; }
function plugin_attachref_action() { global $vars; global $_attachref_messages; $retval['msg'] = $_attachref_messages['msg_title']; $retval['body'] = ''; $refer = isset($vars['refer']) ? $vars['refer'] : false; if (isset($_FILES[PLUGIN_ATTACH_FILE_FIELD_NAME]) && $refer !== false) { $wiki = Factory::Wiki($refer); if (!$wiki->isValied()) { Utility::dieMessage('#attachref : invalied page.'); } $file = $_FILES[PLUGIN_ATTACH_FILE_FIELD_NAME]; $attachname = $file['name'][0]; $filename = preg_replace('/\\..+$/', '', $attachname, 1); // If exist file, add a name '_0', '_1', ... $count = '_0'; while (file_exists(UPLOAD_DIR . encode($refer) . '_' . encode($attachname))) { $attachname = preg_replace('/^[^\\.]+/', $filename . $count++, $attachname); } $file['name'][0] = $attachname; $attach_filename = attachref_get_attach_filename($file); $pass = isset($vars['pass']) ? md5($vars['pass']) : NULL; $retval = attach_upload($refer, $pass); if ($retval['result'] == TRUE) { $retval = attachref_insert_ref($attach_filename); } Utility::redirect($wiki->uri()); } else { $retval = attachref_showform(); } return $retval; }
function plugin_login_action() { global $vars, $_login_msg, $defaultpage; $api = isset($vars['api']) ? $vars['api'] : 'plus'; $page = isset($vars['page']) ? $vars['page'] : $defaultpage; if ($api !== 'plus') { if (!PluginRenderer::hasPlugin($vars['api'])) { return; } $call_api = 'plugin_' . $vars['api'] . '_jump_url'; Utility::redirect($call_api()); exit; } $auth = Auth::authenticate(); if ($auth === true) { // ログイン成功 LogFactory::factory('login')->set(); Utility::redirect(Factory::Wiki($page)->uri()); exit; } return array('msg' => $_login_msg['err_auth'], 'body' => $_login_msg['err_auth_guide'], 'http_code' => 401); }
function plugin_hatena_action() { global $vars, $auth_api; if (!$auth_api['hatena']['use']) { return ''; } $page = empty($vars['page']) ? '' : Utility::decode($vars['page']); $obj = new AuthHatena(); // LOGIN if (isset($vars['login'])) { Utility::redirect($obj->make_login_link()); } // LOGOUT if (isset($vars['logout'])) { $obj->unsetSession(); Utility::redirect(); } // AUTH $rc = $obj->auth($vars['cert']); if (!isset($rc['has_error']) || $rc['has_error'] == 'true') { // ERROR $body = isset($rc['message']) ? $rc['message'] : 'unknown error.'; Utility::dieMessage($body); } $obj->setSession(); Utility::redirect(); }
function plugin_edit_cancel() { Utility::redirect(); exit; }
function plugin_bugtrack_action() { global $vars; global $_plugin_bugtrack, $_string; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); if (Auth::check_role('readonly')) { die_message($_string['prohibit']); } if (Auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(str_replace('PKWK_CREATE_PAGE', 'PKWK_READONLY', $_string['prohibit'])); } if ($vars['mode'] != 'submit') { return FALSE; } // Vaildation foreign values(by miko) $spam = !in_array($vars['priority'], $_plugin_bugtrack['priority_list']) || !in_array($vars['state'], $_plugin_bugtrack['state_list']) ? TRUE : FALSE; if ($spam) { honeypot_write(); return array('msg' => 'cannot write', 'body' => '<p>prohibits editing</p>'); } $page = plugin_bugtrack_write($vars['base'], $vars['pagename'], $vars['summary'], $vars['name'], $vars['priority'], $vars['state'], $vars['category'], $vars['version'], $vars['body']); Utility::redirect(get_page_location_uri($page)); exit; }
function plugin_guiedit_cancel() { global $vars, $defaultpage; $page = isset($vars['page']) ? $vars['page'] : $defaultpage; $location = Factory::Wiki($page)->uri(); if (!empty($vars['id'])) { $location .= '#' . $vars['id']; } Utility::redirect($location); exit; }
function plugin_comment_write() { global $vars, $now; global $_no_name, $_comment_messages, $_comment_formats; if (!isset($vars['msg']) || !isset($vars['refer'])) { return array('msg' => '', 'body' => ''); } // Do nothing $wiki = Factory::Wiki($vars['refer']); if (!$wiki->has()) { return array('msg' => '', 'body' => ''); } // Do nothing $vars['msg'] = str_replace("\n", '', $vars['msg']); // Cut LFs $head = ''; $match = array(); if (preg_match('/^(-{1,2})-*\\s*(.*)/', $vars['msg'], $match)) { $head =& $match[1]; $vars['msg'] =& $match[2]; } if ($vars['msg'] == '') { return array('msg' => '', 'body' => ''); } // Do nothing $comment = str_replace('$msg', $vars['msg'], $_comment_formats['msg']); list($nick, $vars['name'], $disabled) = plugin_comment_get_nick(); if (isset($vars['name']) || isset($vars['nodate']) && $vars['nodate'] !== '1') { $_name = !isset($vars['name']) || $vars['name'] == '' ? $_no_name : $vars['name']; $_name = $_name == '' ? '' : str_replace('$name', $_name, $_comment_formats['name']); $_now = isset($vars['nodate']) && $vars['nodate'] == '1' ? '' : str_replace('$now', $now, PLUGIN_COMMENT_FORMAT_NOW); $comment = str_replace("MSG", $comment, $_comment_formats['str']); $comment = str_replace("NAME", $_name, $comment); $comment = str_replace("NOW", $_now, $comment); } $comment = '-' . $head . ' ' . $comment; $postdata = array(); $comment_no = 0; $above = isset($vars['above']) && $vars['above'] == '1'; foreach ($wiki->get() as $line) { if (!$above) { $postdata[] = $line; } if (preg_match('/^#comment/i', $line) && $comment_no++ == (isset($vars['comment_no']) ? $vars['comment_no'] : 0)) { $postdata[] = $comment; // Insert one blank line above #commment, to avoid indentation } if ($above) { $postdata[] = $line; } } $title = $_comment_messages['title_updated']; $body = ''; if ($wiki->digest() !== $vars['digest']) { $title = $_comment_messages['title_collided']; $body = $_comment_messages['msg_collided'] . $wiki->uri(); } $wiki->set($postdata); if (isset($vars['refpage'])) { Utility::redirect(get_page_location_uri($vars['refpage'])); exit; } $vars['page'] = $vars['refer']; return array('msg' => $title, 'body' => $body); }
/** * POST action via convert plugin */ function action_convert() { global $vars, $defaultpage, $_string; if (method_exists('auth', 'check_role')) { // Plus! if (Auth::check_role('readonly')) { die_message('PKWK_READONLY prohibits editing'); } } else { if (PKWK_READONLY) { die_message('PKWK_READONLY prohibits editing'); } } $page = isset($vars['refer']) ? $vars['refer'] : $defaultpage; $pcmd = $vars['pcmd']; $vote_id = $vars['vote_id']; $vars['page'] = $page; $choice_id = $this->get_selected_choice_convert(); $addchoice = isset($vars['addchoice']) && $vars['addchoice'] !== '' ? $vars['addchoice'] : null; if ($this->is_continuous_vote($page, $pcmd, $vote_id)) { return array('msg' => T_('Error in vote'), 'body' => T_('Continuation vote cannot be performed.')); } // parse contents of wiki page and get update $wiki = Factory::Wiki($page); $lines = $wiki->get(); list($linenum, $newline, $newtext, $newvotes) = $this->get_update_convert($lines, $vote_id, $choice_id, $addchoice); if ($linenum === false) { die_message(T_('There was no matching vote. ')); } $newlines = $lines; $newlines[$linenum] = $newline; $newcontents = implode('', $newlines); // collision check $contents = implode('', $lines); if ($wiki->digest() !== $vars['digest']) { $msg = $_string['title_collided']; $body = $this->show_preview_form($_string['msg_collided'], $newline); return array('msg' => $msg, 'body' => $body); } $wiki->set($newcontents, TRUE); // notimestamp if (isset($addchoice)) { $choice_id = count($newvotes) - 1; } // to make sure $this->update_recent_voted($page, $pcmd, $vote_id, $choice_id, $newvotes); //static in convert() was somehow wierd if return(msg=>'',body=>''); //$msg = $_string['updated']; //$body = ''; //return array('msg'=>$msg, 'body'=>$body); $anchor = $this->get_anchor($pcmd, $vote_id); Utility::redirect($wiki->uri() . '#' . $anchor); exit; }
function typekey_login() { Utility::redirect($this->typekey_login_url()); }