function plugin_region_convert() { static $first = 0; // at first call $usage = '<p class="alert alert-warning">#region usage: <code>#region(title){{ content }}</code> or <code>#region([[Pagename#hash]])</code></p>'; $title = $body = ''; $args = func_get_args(); $num = func_num_args(); $title = array_shift($args); if ($num === 1) { // BlacketNameだった場合、そのページをajaxで取得 if (preg_match('/^\\[\\[(.*)\\]\\]$/', $title, $match)) { $ret[] = '<div class="plugin-region clearfix">'; $ret[] = '<div class="plugin-region-title">' . RendererFactory::factory($title) . '</div>'; $ret[] = '<div class="plugin-region-body" data-page="' . $match[1] . '"></div>'; $ret[] = '</div>'; return join("\n", $ret); } } else { if ($num === 2) { $ret[] = '<div class="plugin-region clearfix">'; $ret[] = '<div class="plugin-region-title">' . Utility::htmlsc($title) . '</div>'; $ret[] = '<div class="plugin-region-body">' . RendererFactory::factory(array_pop($args)) . '</div>'; $ret[] = '</div>'; return join("\n", $ret); } } return $usage; }
/** * 差分をHTMLにして出力 * @return string */ public function render() { foreach (self::get() as $line) { // 先頭の1文字だけを抜き出す $str = Utility::htmlsc(substr($line, 1)); if ($str === '') { // 空行 $ret[] = ' '; continue; } switch (substr($line, 0, 1)) { case '+': $ret[] = '+<ins class="diff_added">' . $str . '</ins>'; break; case '-': $ret[] = '-<del class="diff_removed">' . $str . '</del>'; break; case '/': $ret[] = '/' . $str; break; default: $ret[] = ' ' . $str; break; } } return '<pre class="sh sunlight-highlight-diff">' . "\n" . join("\n", $ret) . '</pre>'; }
function replace_do($search, $replace, $notimestamp) { global $cycle, $cantedit; global $_replace_msg; // パスワードが合ってたらいよいよ置換 $pages = Auth::get_existpages(); $replaced_pages = array(); foreach ($pages as $page) { $wiki = Factory::Wiki($page); if ($wiki->isEditable(false, REPLACE_IGNORE_FREEZE)) { // パスワード一致 $postdata = array(); foreach ($wiki->get() as $line) { // キーワードの置換 $postdata[] = str_replace($search, $replace, $line); } if (md5(join("\n", $postdata)) !== $wiki->digest()) { $cycle = 0; set_time_limit(30); $wiki->set($postdata, $notimestamp); $replaced_pages[] = '<li><a href="' . $wiki->uri() . '">' . Utility::htmlsc($page) . '</a></li>'; } } } $vars['cmd'] = 'read'; if (count($replaced_pages) == 0) { return array('msg' => $_replace_msg['msg_H0_no_data'], 'body' => '<p class="alert alert-danger">' . $_replace_msg['msg_no_replaced'] . '</p>'); } return array('msg' => $_replace_msg['msg_H0_replaced'], 'body' => '<p class="alert alert-success">' . $_replace_msg['msg_replaced'] . '</p>' . "\n" . '<ul>' . join("\n", $replaced_pages) . '</ul>'); }
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 convertRef($args, $div = TRUE) { $options = Utility::htmlsc(join(',', $args)); $filename = array_shift($args); $_title = array(); $params = array('left' => 0, 'center' => 0, 'right' => 0, 'wrap' => 0, 'nowrap' => 0, 'around' => 0, 'noicon' => 0, 'nolink' => 0, 'noimg' => 0, 'zoom' => 0, '_w' => 0, '_h' => 0, '_size' => '%'); // パラメータ解析 foreach ($args as $arg) { $s_arg = strtolower($arg); if (array_key_exists($s_arg, $params)) { $params[$s_arg] = 1; } else { if (preg_match('/^([0-9]+)x([0-9]+)$/', $arg, $matches)) { $params['_w'] = $matches[1]; $params['_h'] = $matches[2]; $params['_size'] = 'px'; } else { if (preg_match('/^([0-9.]+)%$/', $arg, $matches) && $matches[1] > 0) { $params['_w'] = $matches[1]; } else { $_title[] = $arg; } } } } $align = ''; if ($params['left']) { $align = 'left'; } else { if ($params['center']) { $align = 'center'; } else { if ($params['right']) { $align = 'right'; } } } $alt = !empty($_title) ? Utility::htmlsc(join(',', $_title)) : ''; $alt = preg_replace("/^,/", '', $alt); $attribute = 'class="bg-primary" contenteditable="false"' . (UA_NAME == MSIE ? '' : ' style="cursor:default"'); $attribute .= ' _filename="' . $filename . '"'; $attribute .= ' _alt="' . $alt . '"'; $attribute .= ' _width="' . ($params['_w'] ? $params['_w'] : '') . '"'; $attribute .= ' _height="' . ($params['_h'] ? $params['_h'] : '') . '"'; $attribute .= ' _size="' . $params['_size'] . '"'; $attribute .= ' _align="' . $align . '"'; $attribute .= ' _wrap="' . $params['wrap'] . '"'; $attribute .= ' _around="' . $params['around'] . '"'; $attribute .= ' _nolink="' . $params['nolink'] . '"'; $attribute .= ' _noicon="' . $params['noicon'] . '"'; $attribute .= ' _noimg="' . $params['noimg'] . '"'; $attribute .= ' _zoom="' . $params['zoom'] . '"'; if ($div) { $tags = "<div {$attribute}>#ref({$options})</div>"; } else { $tags = "<span {$attribute}>&ref({$options});</span>"; } return $tags; }
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; }
/** * コンストラクタ * @param string $page */ public function __construct($page = null) { if (empty($page)) { throw new Exception('CounterFile::__construct(): Page name is missing!'); } if (!is_string($page)) { throw new Exception('CounterFile::__construct(): Page name must be string!'); } $this->page = $page; parent::__construct(self::$dir . Utility::encode($page) . '.count'); }
function plugin_description_convert() { global $description; $num = func_num_args(); if ($num == 0) { return '<p class="alert alert-warning">Usage: #description(description)</p>'; } $args = func_get_args(); $description = Utility::htmlsc($args[0]); return ''; }
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_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_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, '')); }
public function __toString() { $body = empty($this->body) ? null : InlineFactory::factory($this->body); $str = FALSE; // Try to call the plugin $str = PluginRenderer::executePluginInline($this->name, $this->param, $body); if ($str !== FALSE) { return $str; // Succeed } else { // No such plugin, or Failed $body = (empty($body) ? '' : '{' . $body . '}') . ';'; return parent::setLineRules(Utility::htmlsc('&' . $this->plain) . $body); } }
function plugin__get_inline() { switch (func_num_args()) { case 2: list($msg) = func_get_args(); return Utility::stripHtmlTags($msg); case 3: list($name, $msg) = func_get_args(); return i18n_gettext($name, $msg); case 4: list($name, $lang, $msg) = func_get_args(); return i18n_setlocale($name, $lang, $msg); } return ''; }
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 legend_set_parm($argv) { $parm = array(); $parm['align'] = $parm['title'] = ''; foreach ($argv as $arg) { $val = explode('=', $arg); $val[1] = Utility::htmlsc(empty($val[1]) ? $val[0] : $val[1]); switch ($val[0]) { case 'r': case 'right': $parm['align'] = 'right'; break; case 'l': case 'left': $parm['align'] = 'left'; break; case 'c': case 'center': $parm['align'] = 'center'; break; /* case 't': case 'top': $parm['align'] = 'top'; break; case 'b': case 'bottom': $parm['align'] = 'bottom'; break; */ /* case 't': case 'top': $parm['align'] = 'top'; break; case 'b': case 'bottom': $parm['align'] = 'bottom'; break; */ default: $parm['title'] = $val[1]; // $parm[$val[0]] = $val[1]; } } return $parm; }
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 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_redirect_convert() { $argv = func_get_args(); $argc = func_num_args(); $field = array('caption', 'url', 'img'); for ($i = 0; $i < $argc; $i++) { ${$field}[$i] = Utility::htmlsc($argv[$i], ENT_QUOTES); } if (empty($url)) { return 'usage: #redirect(caption, url, img)'; } if (empty($caption)) { $caption = 'no title'; } if (!empty($img)) { $caption = '<img src="' . $img . '" alt="' . $caption . '" title="' . $caption . '" />'; } return Inline::setLink($caption, $url, null, 'noreferer', true); }
public function setPattern($arr, $page) { list(, $alias, , $name, $this->anchor) = $this->splice($arr); if (empty($name) && empty($this->anchor)) { return FALSE; } if (empty($name) || !Utility::isWikiName($name)) { if (empty($alias)) { $alias = $name . $this->anchor; } if (!empty($name)) { $name = self::getFullname($name, $page); if (!empty($name) && !Factory::Wiki($name)->isValied()) { return FALSE; } } } return parent::setParam($page, $name, null, 'pagename', $alias); }
public static function check($postdata) { global $akismet_api_key; $akismet = new ZendService\Akismet($akismet_api_key, Router::get_script_absuri()); if ($akismet->verifyKey($akismet_api_key)) { // 送信するデーターをセット $akismet_post = array('user_ip' => Utility::getRemoteIp(), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null, 'comment_type' => 'comment', 'comment_author' => isset($vars['name']) ? $vars['name'] : self::DEFAULT_USER_NAME); if ($use_spam_check['akismet'] === 2) { $akismet_post['comment_content'] = $postdata; } else { // 差分のみをAkismetに渡す $akismet_post['comment_content'] = $addedata; } if ($akismet->isSpam($akismet_post)) { Utility::dieMessage('Writing was limited by Akismet (Blocking SPAM).', $_title['prohibit'], 400); } } else { Utility::dieMessage('Akismet API key does not valied.', 500); } }
function auth($vars) { if (!isset($vars['sig'])) { return array('has_error' => 'true', 'message' => 'Signature is not found.'); } if (!isset($vars['token'])) { return array('has_error' => 'true', 'message' => 'Token is not found.'); } if (isset($vars['userdata'])) { $this->response['userdata'] = Utility::decode($vars['userdata']); } $query = array(); static $keys = array('app_key', 'userhash', 'token', 't', 'v', 'userdata'); foreach ($keys as $key) { if (!isset($vars[$key])) { continue; } $query[$key] = $vars[$key]; } $api_sig = $this->make_hash($query); if ($api_sig !== $vars['sig']) { return array('has_error' => 'true', 'message' => 'Comparison error of signature.'); } // ログオンしてから 10分経過している場合には、タイムアウトとする $time_out = UTIME - self::LIVEDOOR_TIMEOUT; if ($vars['t'] < $time_out) { return array('has_error' => 'true', 'message' => 'The time-out was done.'); } if (LIVEDOOR_PERMS !== 'id') { return array('has_error' => 'false', 'message' => ''); } $post = array('app_key' => $this->app_key, 'format' => 'xml', 'token' => $vars['token'], 't' => UTIME, 'v' => self::LIVEDOOR_VERSION); $post['sig'] = $this->make_hash($post); $data = http_request(self::LIVEDOOR_URL_GETID, 'POST', '', $post); if ($data['rc'] != 200) { return array('has_error' => 'true', 'message' => $data['rc']); } $this->responce_xml_parser($data['data']); $has_error = $this->response['error'] == 0 ? 'false' : 'true'; return array('has_error' => $has_error, 'message' => $this->response['message']); }
/** * ファイル一覧 */ public static function getPages($pattern = '') { $ret = array(); // 継承元のクラス名を取得(PHPは、__CLASS__で派生元のクラス名が取得できない) $class = get_called_class(); // クラスでディレクトリが定義されていないときは処理しない。(AuthFile.phpなど) if (empty($class::$dir)) { return array(); } foreach (self::exists() as $file) { $matches = array(); if (preg_match(self::$pattern, $file, $matches)) { if (!isset($matches[3])) { $matches[3] = 0; } if ($matches[3] === 'log') { continue; } $ret[Utility::decode($matches[1])][][$matches[3]] = Utility::decode($matches[2]); } } return $ret; }
function plugin_tooltip_inline($args) { $args = func_get_args(); $glossary = array_pop($args); $term = array_shift($args); if (empty($glossary)) { $glossary = Glossary::getGlossary($term); // $debug .= "B=$glossary/"; if ($glossary === FALSE) { $glossary = plugin_tooltip_get_page_title($term); if ($glossary === FALSE) { $glossary = ''; } } } $s_glossary = Utility::htmlsc($glossary); $page = Utility::stripBracket($term); $wiki = Factory::Wiki($page); if ($wiki->isValied() && $wiki->isReadable()) { return '<abbr class="glossary" title="' . $s_glossary . ' ' . $wiki->passage(false, false) . '"><a href="' . $wiki->uri() . '">' . $term . '</a></abbr>'; } return '<abbr title="' . $s_glossary . '">' . $term . '</abbr>'; }
/** * コンストラクタ * @param string $page ページ名 */ public function __construct($page = null) { if (empty($page)) { throw new Exception('BackupFile::__construct(): Page name is missing!'); } if (!is_string($page)) { throw new Exception('BackupFile::__construct(): Page name must be string!'); } global $do_backup, $cycle, $maxage; if (Auth::check_role('readonly') || !$do_backup) { return; } // バックアップのページ名 $this->page = $page; // バックアップの拡張子 if (function_exists('lzf_compress')) { // lzfが使用出来る場合 $this->ext = '.lzf'; } else { if (function_exists('bzcompress')) { // bz2が使用出来る場合 $this->ext = '.bz2'; } else { if (function_exists('gzcompress')) { $this->ext = '.gz'; } } } // バックアップの世代間の区切りの正規表現 $this->splitter_reglex = '/^(' . preg_quote(self::SPLITTER) . '\\s\\d+(\\s(\\d+)|))$/'; // バックアップの名前(拡張子抜き) $this->name = self::$dir . Utility::encode($page); // バックアップの最終更新日時 $this->time = $this->has() ? filemtime($this->filename) : UTIME; // このhasBackup()でファイル名($this->file)も定義 parent::__construct($this->name . $this->ext); }
public static function convert($line, $link = TRUE, $enc = TRUE) { if ($enc) { $line = preg_replace("/&/", "&", $line); $line = Utility::htmlsc($line); } // インライン・プラグイン $pattern = '/&(\\w+)(?:\\(((?:(?!\\)[;{]).)*)\\))?(?:\\{((?:(?R)|(?!};).)*)\\})?;/'; $line = preg_replace_callback($pattern, array(&$this, 'convert_plugin'), $line); // ルールの変換 $line = guiedit_make_line_rules($line); // 文字サイズの変換 $pattern = "/<span\\s(style=\"font-size:(\\d+)px|class=\"size([1-7])).*?>/"; $line = preg_replace_callback($pattern, array(&$this, 'convert_size'), $line); // 色の変換 $pattern = "/<sapn\\sstyle=\"color:([#0-9a-z]+)(; background-color:([#0-9a-z]+))?\">/"; $line = preg_replace_callback($pattern, array(&$this, 'convert_color'), $line); // 注釈 $line = preg_replace("/\\(\\(((?:(?R)|(?!\\)\\)).)*)\\)\\)/", "<img alt=\"Note\" title=\"\$1\" />", $line); // 参照文字 $line = preg_replace('/&(#?[a-z0-9]+);/', "&\$1;", $line); // 上付き文字 $line = preg_replace('/SUP{(.*?)}/', "<sup>\$1</sup>", $line); // 下付き文字・添え字 $line = preg_replace('/SUB{(.*?)}/', "<sub>\$1</sub>", $line); // リンク if ($link) { $pattern = "/\\(\\(((?:(?R)|(?!\\)\\)).)*)\\)\\)/"; $replace = "<img alt=\"Note\" title=\"\$1\" />"; $line = $this->make_link($line); } if (preg_match("/^<br\\s\\/>\$/", $line)) { $line .= "\n "; } return $line; }
function plugin_panel_convert() { $title = $body = ''; $type = ''; $num_of_arg = func_num_args(); $args = func_get_args(); switch ($num_of_arg) { default: return '<p class="alert alert-warning">#panel(title[,type]){{body}}</p>'; break; case 1: $body = $args[0]; break; case 2: $title = $args[0]; $body = $args[1]; break; case 3: $title = $args[0]; $type = $args[1]; $body = $args[2]; break; } if (preg_match('/^(primary|info|warning|danger)$/', $type) === 0) { $type = 'default'; } $ret[] = '<div class="panel panel-' . $type . '">'; if (!empty($title)) { $ret[] = '<div class="panel-heading">' . Utility::htmlsc($title) . '</div>'; } else { $body = str_replace(array(chr(0xd) . chr(0xa), chr(0xd), chr(0xa)), "\n", $body); } $ret[] = '<div class="panel-body">' . RendererFactory::factory($body) . '</div>'; $ret[] = '</div>'; return join("\n", $ret); }
/** * Get Vote Form HTML for convert plugin * * @static * @param array $votes * @param integer $vote_id vote form id * @global $vars * @global $vars['page'] * @global $defaultpage * @global $digest * @var $options 'readonly' * @var $options 'addchoice' * @uses get_script_uri() * @return string */ function get_vote_form_convert($votes, $vote_id) { // Initilization global $vars, $defaultpage; global $digest; $page = isset($vars['page']) ? $vars['page'] : $defaultpage; $script = $this->options['readonly'] ? '' : get_script_uri(); $submit = $this->options['readonly'] ? 'hidden' : 'submit'; $anchor = $this->get_anchor('convert', $vote_id); // Header $form[] = '<div class="table_wrapper">'; if (!$this->options['readonly']) { $form[] = '<form class="vote_form" action="' . get_script_uri() . '" method="post">'; $form[] = '<input type="hidden" name="cmd" value="vote" />'; $form[] = '<input type="hidden" name="pcmd" value="convert" />'; $form[] = '<input type="hidden" name="refer" value="' . htmlsc($page) . '" />'; $form[] = '<input type="hidden" name="vote_id" value="' . htmlsc($vote_id) . '" />'; $form[] = '<input type="hidden" name="digest" value="' . htmlsc($digest) . '" />'; } $form[] = '<table class="table plugin-vote-table" summary="vote" id="' . $anchor . '" data-pagenate="false">'; $form[] = '<thead>'; $form[] = '<tr>'; $form[] = '<th>' . T_('Selection') . '</th>'; $form[] = '<th>' . T_('Points') . '</th>'; $form[] = $this->options['readonly'] ? null : '<th>' . T_('Vote') . '</th>'; $form[] = '</tr>'; $form[] = '</thead>'; // Body $form[] = '<tbody>'; foreach ($votes as $choice_id => $vote) { list($choice, $count) = $vote; $form[] = '<tr>' . "\n"; $form[] = '<td class="vote_choise_td">' . InlineFactory::factory($choice) . '</td>'; $form[] = '<td class="vote_count_td"><var>' . Utility::htmlsc($count) . '</var></td>'; $form[] = $this->options['readonly'] ? null : '<td class="vote_form_td"><input type="submit" class="btn btn-secondary" name="' . $this->encode_choice($choice_id) . '" value="' . T_('Vote') . '" /></td>'; $form[] = '</tr>'; } $form[] = '</tbody>'; // add choice if ($this->options['addchoice'] && !$this->options['readonly']) { $choice_id++; $choice_key = $this->encode_choice($choice_id); $form[] = '<tfoot>'; $form[] = '<tr>'; $form[] = '<th colspan="2">'; $form[] = '<input type="text" style="width:90%;" name="addchoice" value="" placeholder="' . T_('Item name') . '" class="form-control" />'; $form[] = '</th>'; $form[] = '<th>'; $form[] = '<input type="' . $submit . '" class="btn btn-primary" name="' . $choice_key . '" value="' . T_('Add') . '" class="submit" />'; $form[] = '</th>'; $form[] = '</tr>'; $form[] = '</tfoot>'; } // Footer $form[] = '</table>'; if (!$this->options['readonly']) { $form[] = '</form>'; } $form[] = '</div>'; return join("\n", $form); }
function plugin_help_action() { global $help_page; Utility::redirect(Factory::Wiki('Help')->uri()); }
function plugin_recent_convert() { global $vars, $date_format, $link_compact, $page_title; // , $_recent_plugin_frame; static $exec_count = 1; global $cache; if (empty($vars['page'])) { return null; } $recent_lines = PLUGIN_RECENT_DEFAULT_LINES; $args = func_get_args(); if (!empty($args)) { if (isset($args[1]) || !is_numeric($args[0])) { return PLUGIN_RECENT_USAGE . '<br />'; } $recent_lines =& $args[0]; } if ($exec_count++ > PLUGIN_RECENT_EXEC_LIMIT) { return '<div class="alert alert-warning">#recent(): You called me too much.</div>' . "\n"; } $date = ''; $items = array(); $lines = Recent::get(); if ($lines !== null) { $count = count($lines) < $recent_lines ? count($lines) : $recent_lines; $i = 0; foreach ($lines as $page => $time) { $wiki = Factory::Wiki($page); if (!$wiki->isReadable()) { continue; } //if (! $wiki->isHidden()) continue; if ($i > $count) { break; } $s_page = Utility::htmlsc($page); $_date = get_date($date_format, $time); if (!IS_MOBILE) { if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[$_date][] = ' <li>' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . $wiki->passage(false, true) : ''; $items[$_date][] = ' <li><a href="' . $wiki->uri() . '" title="' . $s_page . $passage . '">' . $s_page . '</a></li>'; } } else { if ($date !== $_date) { // New day $date = $_date; $items[] = '<li data-role="list-divider">' . $date . '</li>'; } if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[] = ' <li data-theme="e">' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . '<span class="ui-li-count">' . $wiki->passage(false, false) . '</span>' : ''; $items[] = ' <li><a href="' . $wiki->uri() . '" data-transition="slide">' . $s_page . $passage . '</a></li>'; } } $i++; } unset($lines, $i); } $_recent_title = sprintf(T_('recent(%d)'), $count); if (!IS_MOBILE) { // End of the day $ret[] = '<div class="plugin-recent">'; $ret[] = '<h5>' . $_recent_title . '</h5>'; $ret[] = '<div class="hslice" id="webslice">'; $ret[] = '<span class="entry-title" style="display:none;">' . $page_title . '</span>'; $ret[] = '<div class="entry-content">'; $ret[] = '<ul class="list-unstyled">'; foreach ($items as $date => $entries) { $ret[] = '<li><strong>' . $date . '</strong><ul>'; foreach ($entries as $entry) { $ret[] = $entry; } $ret[] = '</ul></li>'; } $ret[] = '</ul>'; $ret[] = '</div>'; $ret[] = '</div>'; $ret[] = '</div>'; return join("\n", $ret); } else { return '<ul data-role="listview" data-dividertheme="b">' . "\n" . '<li data-theme="a">' . $_recent_title . '</li>' . "\n" . join("\n", $items) . '</ul>' . "\n"; } }
function plugin_guiedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $vars; global $load_template_func, $whatsnew; global $_button; global $notimeupdate; global $js_tags, $link_tags, $js_blocks; global $guiedit_use_fck; $script = get_script_uri(); // Newly generate $digest or not if ($digest === FALSE) { $digest = md5(get_source($page, TRUE, TRUE)); } $s_id = isset($vars['id']) ? Utility::htmlsc($vars['id']) : ''; if (!$guiedit_use_fck) { $body = edit_form($page, $postdata, $digest, $b_template); $pattern = "/(<input\\s+type=\"hidden\"\\s+name=\"cmd\"\\s+value=\")edit(\"\\s*\\/?>)/"; $replace = "\$1guiedit\$2\n" . ' <input type="hidden" name="id" value="' . $s_id . '" />' . ' <input type="hidden" name="text" value="1" />'; $body = preg_replace($pattern, $replace, $body); return $body; } // require_once(GUIEDIT_CONF_PATH . 'guiedit.ini.php'); // フォームの値の設定 $s_digest = Utility::htmlsc($digest); $s_page = Utility::htmlsc($page); $s_original = Utility::htmlsc($vars['original']); $s_ticket = md5(MUTIME); if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) { // BugTrack/95 fix Problem: browser RSS request with session $_SESSION[$s_ticket] = md5(get_ticket() . $digest); $_SESSION['origin' . $s_ticket] = md5(get_ticket() . str_replace("\r", '', $s_original)); } // テンプレート $template = ''; if ($load_template_func) { global $guiedit_non_list; $pages = array(); foreach (get_existpages() as $_page) { if ($_page == $whatsnew || check_non_list($_page)) { continue; } foreach ($guiedit_non_list as $key) { $pos = strpos($_page . '/', $key . '/'); if ($pos !== FALSE && $pos == 0) { continue 2; } } $_s_page = Utility::htmlsc($_page); $pages[$_page] = ' <option value="' . $_s_page . '">' . $_s_page . '</option>'; } ksort($pages); $s_pages = join("\n", $pages); $template = <<<EOD <select name="template_page"> \t<option value="">-- {$_button['template']} --</option> {$s_pages} </select> <br /> EOD; } // チェックボックス「タイムスタンプを変更しない」 $add_notimestamp = ''; if ($notimeupdate != 0) { $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; // if ($notimeupdate == 2) { if ($notimeupdate == 2 && Auth::check_role('role_contents_admin')) { $add_notimestamp = ' ' . '<input type="password" name="pass" size="12" />' . "\n"; } $add_notimestamp = '<input type="checkbox" name="notimestamp" ' . 'id="_edit_form_notimestamp" value="true"' . $checked_time . ' />' . "\n" . ' ' . '<label for="_edit_form_notimestamp"><span class="small">' . $_button['notchangetimestamp'] . '</span></label>' . "\n" . $add_notimestamp . ' '; } // フォーム $body = <<<EOD <div id="guiedit"> \t<form id="guiedit_form" action="{$script}" method="post" style="margin-bottom:0px;"> \t{$template} \t\t<input type="hidden" name="cmd" value="guiedit" /> \t\t<input type="hidden" name="page" value="{$s_page}" /> \t\t<input type="hidden" name="digest" value="{$s_digest}" /> \t\t<input type="hidden" name="ticket" value="{$s_ticket}" /> \t\t<input type="hidden" name="id" value="{$s_id}" /> \t\t<textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> \t\t<textarea name="msg" id="editor"></textarea> \t\t<div class="pull-left"> \t\t<button type="submit" name="write" accesskey="s" class="btn btn-primary">{$_button['update']}</button> \t\t<button type="button" name="preview" accesskey="p" class="btn btn-secondary">{$_button['preview']}</button> \t\t{$add_notimestamp} \t\t</div> \t</form> \t<form action="{$script}" method="post"> \t\t<input type="hidden" name="cmd" value="guiedit" /> \t\t<input type="hidden" name="page" value="{$s_page}" /> \t\t<input type="submit" name="cancel" value="{$_button['cancel']}" class="btn btn-warning" accesskey="c" /> \t</form> </div> EOD; $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/ckeditor.js', 'defer' => 'defer'); $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/ckeditor/adapters/jquery.js', 'defer' => 'defer'); $js_tags[] = array('type' => 'text/javascript', 'src' => COMMON_URI . 'js/plugin/guiedit/guiedit.js', 'defer' => 'defer'); return $body; }