Beispiel #1
0
function exist_plugin($name)
{
    global $vars;
    static $exist = array(), $count = array();
    $name = strtolower($name);
    if (isset($exist[$name])) {
        if (++$count[$name] > PKWK_PLUGIN_CALL_TIME_LIMIT) {
            die('Alert: plugin "' . htmlspecialchars($name) . '" was called over ' . PKWK_PLUGIN_CALL_TIME_LIMIT . ' times. SPAM or someting?<br />' . "\n" . '<a href="' . get_script_uri() . '?cmd=edit&amp;page=' . rawurlencode($vars['page']) . '">Try to edit this page</a><br />' . "\n" . '<a href="' . get_script_uri() . '">Return to frontpage</a>');
        }
        return $exist[$name];
    }
    // namespace が使える場合のみ foo/bar を受け付ける
    $regex = '/^\\w{1,64}(?:\\/\\w{1,64})?$/';
    if (version_compare(PHP_VERSION, 5.3, '<')) {
        $regex = '/^\\w{1,64}$/';
    }
    if (preg_match($regex, $name) && file_exists(PLUGIN_DIR . $name . '.inc.php')) {
        $exist[$name] = TRUE;
        $count[$name] = 1;
        require_once PLUGIN_DIR . $name . '.inc.php';
        return TRUE;
    } else {
        $exist[$name] = FALSE;
        $count[$name] = 1;
        return FALSE;
    }
}
function plugin_relink_callback($matches)
{
    $atag = $matches[1];
    $img = empty($matches[2]) ? '' : $matches[2];
    // image tag
    preg_match_all('/([^\\s^\\"]+)=\\"([^\\"]+)\\"/', $atag, $amatches);
    for ($i = 0; $i < count($amatches[0]); $i++) {
        $attr[$amatches[1][$i]] = $amatches[2][$i];
    }
    $parse_url = parse_url($attr['href']);
    $scheme = isset($parse_url['scheme']) ? $parse_url['scheme'] : '';
    $path = isset($parse_url['path']) ? $parse_url['path'] : '';
    $query = isset($parse_url['query']) ? $parse_url['query'] : '';
    $fragment = isset($parse_url['fragment']) ? '#' . $parse_url['fragment'] : '';
    $script = get_script_uri();
    $is_ext = $scheme && substr($attr['href'], 0, strlen($script)) !== $script;
    if ($is_ext && (!$img || $img && PLUGIN_RELINK_ADD_EXTERNAL_CLASS_TO_IMAGE_LINK)) {
        switch ($scheme) {
            case 'mailto':
                $attr['class'] = 'mail';
                break;
            case 'file':
                $attr['class'] = 'file';
                break;
            default:
                $attr['class'] = 'external';
        }
    }
    if (!$is_ext) {
        $attr['href'] = $path . ($query ? '?' . $query : '') . $fragment;
        if (isset($attr['rel'])) {
            unset($attr['rel']);
        }
        /*if (PLUGIN_RELINK_REWRITE_URL_TYPE && $query &&
        			strpos($query, 'cmd=') === FALSE && strpos($query, 'plugin=') === FALSE)
        		{
        			$s_path = substr($path, 0, strrpos($path, '/') + 1); // cut index.php
        			switch (PLUGIN_RELINK_REWRITE_URL_TYPE) {
        				case 1:
        					$attr['href'] = $s_path . $query . $fragment;
        					break;
        				case 2:
        					$attr['href'] = $s_path . str_replace('%2F', '/', $query) . '/' . $fragment;
        					break;
        				case 3:
        					$attr['href'] = $s_path . $query . '.html' . $fragment;
        					break;
        				case 4:
        					$attr['href'] = $s_path . str_replace('%2F', '/', $query) . '.html' . $fragment;
        					break;
        			}
        		}*/
    }
    $ret = '<a';
    foreach ($attr as $key => $val) {
        $ret .= ' ' . $key . '="' . $val . '"';
    }
    $ret .= '>' . $img;
    return $ret;
}
Beispiel #3
0
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;
}
Beispiel #4
0
function plugin_lookup_convert()
{
    global $vars;
    static $id = 0;
    $num = func_num_args();
    if ($num == 0 || $num > 3) {
        return PLUGIN_LOOKUP_USAGE;
    }
    $args = func_get_args();
    $interwiki = htmlsc(trim($args[0]));
    $button = isset($args[1]) ? trim($args[1]) : '';
    $button = $button != '' ? htmlsc($button) : 'lookup';
    $default = $num > 2 ? htmlsc(trim($args[2])) : '';
    $s_page = htmlsc($vars['page']);
    ++$id;
    $script = get_script_uri();
    $ret = <<<EOD
<form action="{$script}" method="post">
 <div>
  <input type="hidden" name="plugin" value="lookup" />
  <input type="hidden" name="refer"  value="{$s_page}" />
  <input type="hidden" name="inter"  value="{$interwiki}" />
  <label for="_p_lookup_{$id}">{$interwiki}:</label>
  <input type="text" name="page" id="_p_lookup_{$id}" size="30" value="{$default}" />
  <input type="submit" value="{$button}" />
 </div>
</form>
EOD;
    return $ret;
}
function plugin_nego_link($nego, &$linkstr)
{
    global $vars;
    $linkstr = $linkstr === '' ? htmlspecialchars($nego) : $linkstr;
    $url = get_script_uri() . '?cmd=nego' . '&nego=' . $nego . '&page=' . rawurlencode($vars['page']);
    return '<a href="' . $url . '">' . $linkstr . '</a>';
}
Beispiel #6
0
function plugin_newpage_action()
{
    global $vars;
    $qm = get_qm();
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    if ($vars['page'] == '') {
        $retvars['msg'] = $qm->m['plg_newpage']['label'];
        $retvars['body'] = plugin_newpage_convert();
        if (preg_match('/id="([^"]+)"/', $retvars['body'], $ms)) {
            $domid = $ms[1];
            //jquery ライブラリの読み込み
            $qt = get_qt();
            $qt->setv('jquery_include', true);
            $addscript = <<<EOS
<script type="text/javascript">
jQuery(function(){
\tjQuery("#{$domid}").focus().select();
});
</script>
EOS;
            $qt->appendv_once('plugin_select_fsize', 'beforescript', $addscript);
        }
        return $retvars;
    } else {
        $page = strip_bracket($vars['page']);
        $r_page = rawurlencode(isset($vars['refer']) ? get_fullname($page, $vars['refer']) : $page);
        $r_refer = rawurlencode($vars['refer']);
        pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?cmd=read&page=' . $r_page . '&refer=' . $r_refer);
        exit;
    }
}
function plugin_approve_inline($name)
{
    global $vars;
    if ($name == '') {
        return '<p>approve(): empty name.</p>';
    }
    $config_path = PLUGIN_APPROVE_CONFIG_ROOT . $name;
    $config = new YamlConfig($config_path);
    if (!$config->read()) {
        return '<p>approve(): failed to load config. "' . $config_path . '"</p>';
    }
    $pattern = $config[PLUGIN_APPROVE_KEY_PATTERN];
    $page_regex = $config[PLUGIN_APPROVE_KEY_PAGE_REGEX];
    $label = isset($config[PLUGIN_APPROVE_KEY_LABEL]) ? $config[PLUGIN_APPROVE_KEY_LABEL] : PLUGIN_APPROVE_DEFAULT_LABEL;
    if ($pattern == '') {
        return '<p>approve(): empty pattern.</p>';
    }
    if ($page_regex == '') {
        return '<p>approve(): empty page_regex.</p>';
    }
    $page = $vars['page'];
    if ($page == '') {
        return '<p>approve(): empty page.</p>';
    }
    $source = get_source($page, FALSE, TRUE);
    $disabled = $page_regex != '' && !preg_match($page_regex, $page) || strpos($source, $pattern) === FALSE ? 'disabled' : '';
    $form = '';
    $form .= '<form action="' . get_script_uri() . '?cmd=approve" method="post">';
    $form .= '<input type="submit" name="submit" value="' . $label . '" ' . $disabled . ' />';
    $form .= '<input type="hidden" name="name"  value="' . $name . '" />';
    $form .= '<input type="hidden" name="_page"  value="' . $page . '" />';
    $form .= '</form>';
    return $form;
}
Beispiel #8
0
function plugin_newpage_convert()
{
    global $vars, $_newpage_messages;
    static $id = 0;
    // if (PKWK_READONLY) return ''; // Show nothing
    if (Auth::check_role('readonly')) {
        return '';
    }
    // Show nothing
    if (Auth::is_check_role(PKWK_CREATE_PAGE)) {
        return '';
    }
    $newpage = '';
    if (func_num_args()) {
        list($newpage) = func_get_args();
    }
    if (!preg_match('/^' . RendererDefines::BRACKETNAME_PATTERN . '$/', $newpage)) {
        $newpage = '';
    }
    $s_page = Utility::htmlsc(isset($vars['refer']) ? $vars['refer'] : '');
    $s_newpage = Utility::htmlsc($newpage);
    ++$id;
    $script = get_script_uri();
    $ret = <<<EOD
<form action="{$script}" method="post" class="form-inline plugin-newpage-form">
\t<input type="hidden" name="cmd" value="edit" />
\t<input type="hidden" name="refer"  value="{$s_page}" />
\t<div class="form-group">
\t\t<input type="text" class="form-control" name="page" id="p_newpage_{$id}" value="{$s_newpage}" size="30" placeholder="{$_newpage_messages['form_pagename']}" />
\t</div>
\t<input type="submit" value="{$_newpage_messages['btn_new']}" class="btn btn-primary" />
</form>
EOD;
    return $ret;
}
function plugin_html2pdf_get_request_uri($init_uri = '')
{
    if ($init_uri == '') {
        // Set automatically
        $msg = 'get_request_uri() failed: Please set $script at INI_FILE manually';
        if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'][0] == '/') {
            $url = SERVER_PORT == 443 ? 'https://' : 'http://';
            // scheme
            $url .= SERVER_NAME;
            // host
            $url .= SERVER_PORT == 80 ? '' : ':' . SERVER_PORT;
            // port
            $url .= $_SERVER['REQUEST_URI'];
        } else {
            global $vars;
            $url = get_script_uri() . '?';
            $queries = array();
            $queries[] = $vars['cmd'] != '' ? 'cmd=' . rawurlencode($vars['cmd']) : '';
            $queries[] = $vars['page'] != '' ? 'page=' . rawurlencode($vars['page']) : '';
            $url .= implode('&', $queries);
        }
        if (!is_url($url, TRUE)) {
            die_message($msg);
        }
    } else {
        // Set manually
        if (!is_url($init_uri, TRUE)) {
            die_message('$url: Invalid URI');
        }
        $url = $init_uri;
    }
    return $url;
}
Beispiel #10
0
function plugin_lookup_convert()
{
    global $vars;
    static $id = 0;
    $qm = get_qm();
    $num = func_num_args();
    if ($num == 0 || $num > 3) {
        return $qm->replace('fmt_err_cvt', 'lookup', $qm->m['plg_lookup']['err_usage']);
    }
    $args = func_get_args();
    $interwiki = htmlspecialchars(trim($args[0]));
    $button = isset($args[1]) ? trim($args[1]) : '';
    $button = $button != '' ? h($button) : $qm->m['plg_lookup']['btn_submit'];
    $default = $num > 2 ? h(trim($args[2])) : '';
    $s_page = h($vars['page']);
    ++$id;
    $script = get_script_uri();
    $ret = <<<EOD
<form action="{$script}" method="post">
 <div>
  <input type="hidden" name="plugin" value="lookup" />
  <input type="hidden" name="refer"  value="{$s_page}" />
  <input type="hidden" name="inter"  value="{$interwiki}" />
  <label for="_p_lookup_{$id}">{$interwiki}:</label>
  <input type="text" name="page" id="_p_lookup_{$id}" size="30" value="{$default}" />
  <input type="submit" value="{$button}" />
 </div>
</form>
EOD;
    return $ret;
}
Beispiel #11
0
function plugin_rss10_action()
{
    pkwk_headers_sent();
    header('Status: 301 Moved Permanently');
    header('Location: ' . get_script_uri() . '?cmd=rss&ver=1.0');
    // HTTP
    exit;
}
Beispiel #12
0
function plugin_recent_convert()
{
    global $vars, $date_format, $_recent_plugin_frame, $show_passage;
    static $exec_count = 1;
    $recent_lines = PLUGIN_RECENT_DEFAULT_LINES;
    if (func_num_args()) {
        $args = func_get_args();
        if (!is_numeric($args[0]) || isset($args[1])) {
            return PLUGIN_RECENT_USAGE . '<br />';
        } else {
            $recent_lines = $args[0];
        }
    }
    // Show only N times
    if ($exec_count > PLUGIN_RECENT_EXEC_LIMIT) {
        return '#recent(): You called me too much' . '<br />' . "\n";
    } else {
        ++$exec_count;
    }
    if (!file_exists(PLUGIN_RECENT_CACHE)) {
        return '#recent(): Cache file of RecentChanges not found' . '<br />';
    }
    // Get latest N changes
    $lines = file_head(PLUGIN_RECENT_CACHE, $recent_lines);
    if ($lines == FALSE) {
        return '#recent(): File can not open' . '<br />' . "\n";
    }
    $script = get_script_uri();
    $date = $items = '';
    foreach ($lines as $line) {
        list($time, $page) = explode("\t", rtrim($line));
        $_date = get_date($date_format, $time);
        if ($date != $_date) {
            // End of the day
            if ($date != '') {
                $items .= '</ul>' . "\n";
            }
            // New day
            $date = $_date;
            $items .= '<strong>' . $date . '</strong>' . "\n" . '<ul class="recent_list">' . "\n";
        }
        $s_page = htmlsc($page);
        if ($page == $vars['page']) {
            // No need to link to the page you just read, or notify where you just read
            $items .= ' <li>' . $s_page . '</li>' . "\n";
        } else {
            $r_page = rawurlencode($page);
            $passage = $show_passage ? ' ' . get_passage($time) : '';
            $items .= ' <li><a href="' . $script . '?' . $r_page . '"' . ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
        }
    }
    // End of the day
    if ($date != '') {
        $items .= '</ul>' . "\n";
    }
    return sprintf($_recent_plugin_frame, count($lines), $items);
}
Beispiel #13
0
 function PluginTag()
 {
     parent::Tag();
     static $conf = array();
     if (empty($conf)) {
         $conf['listcmd'] = get_script_uri() . '?cmd=lsx&amp;tag=';
     }
     $this->conf =& $conf;
 }
Beispiel #14
0
function plugin_yetlist_action()
{
    global $non_list;
    global $whatsdeleted;
    $qm = get_qm();
    $retval = array('msg' => $qm->m['plg_yetlist']['title'], 'body' => '');
    // Diff
    $pages = array_diff(get_existpages(CACHE_DIR, '.ref'), get_existpages());
    if (empty($pages)) {
        $retval['body'] = $qm->m['plg_yetlist']['err_notexist'];
        return $retval;
    }
    $empty = TRUE;
    // Load .ref files and Output
    $script = get_script_uri();
    $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="' . $script . '?' . $r_refer . '">' . htmlspecialchars($_refer) . '</a>';
            }
            $link_ref = join(' ', $link_refs);
            unset($link_refs);
            $s_page = htmlspecialchars($page);
            if (PKWK_READONLY) {
                $href = $s_page;
            } else {
                // Dangling link
                $href = '<span class="noexists">' . $s_page . '<a href="' . $script . '?cmd=edit&amp;page=' . rawurlencode($page) . '&amp;refer=' . $r_refer . '">' . $qm->m['fmt_symbol_noexists'] . '</a></span>';
            }
            $retval['body'] .= '<li>' . $href . ' <em>(' . $link_ref . ')</em></li>' . "\n";
        }
    }
    if ($empty) {
        $retval['body'] = $qm->m['plg_yetlist']['err_notexist'];
        return $retval;
    }
    if ($retval['body'] != '') {
        $retval['body'] = '<ul>' . "\n" . $retval['body'] . '</ul>' . "\n";
    }
    return $retval;
}
/**
 * Make a link to self-pukiwiki url by omitting pukiwiki url
 * so that it is not necessary to create InterWikiName for self-pukiwiki url
 *
 * @author     sonots
 * @license    http://www.gnu.org/licenses/gpl.html GPL v2
 * @version    $Id: intrawiki.inc.php,v 1.1 2007-06-10 11:14:46 sonots $
 * @package    plugin
 */
function plugin_intrawiki_inline()
{
    $args = func_get_args();
    if (count($args) < 2) {
        return 'intrawiki(): &amp;intrawiki(pukiwiki query){linkstr};';
    }
    $linkstr = array_pop($args);
    $query = array_shift($args);
    $href = get_script_uri() . '?' . htmlspecialchars($query);
    $linkstr = $linkstr !== '' ? $linkstr : htmlspecialchars($query);
    return '<a href="' . $href . '">' . $linkstr . '</a>';
}
Beispiel #16
0
function limit_plugin($name)
{
    global $vars;
    static $count = array();
    $name = strtolower($name);
    if (!isset($count[$name])) {
        $count[$name] = 1;
    }
    if (++$count[$name] > PKWK_PLUGIN_CALL_TIME_LIMIT) {
        die('Alert: plugin "' . htmlspecialchars($name) . '" was called over ' . PKWK_PLUGIN_CALL_TIME_LIMIT . ' times. SPAM or someting?<br />' . "\n" . '<a href="' . get_script_uri() . '?cmd=edit&amp;page=' . rawurlencode($vars['page']) . '">Try to edit this page</a><br />' . "\n" . '<a href="' . get_script_uri() . '">Return to frontpage</a>');
    }
    return TRUE;
}
Beispiel #17
0
function plugin_cmd_getlink($cmd, $page = '')
{
    global $vars;
    global $defaultpage, $whatsnew;
    if ($page == '') {
        $page = isset($vars['page']) ? $vars['page'] : $defaultpage;
    }
    $r_page = rawurlencode($page);
    $script = get_script_uri();
    $_LINK = array();
    // refer lib/html.inc.php
    // Future Work: Use only necessary one
    $_LINK['add'] = "{$script}?cmd=add&amp;page={$r_page}";
    $_LINK['backup'] = "{$script}?cmd=backup&amp;page={$r_page}";
    $_LINK['copy'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['diff'] = "{$script}?cmd=diff&amp;page={$r_page}";
    $_LINK['edit'] = "{$script}?cmd=edit&amp;page={$r_page}";
    $_LINK['filelist'] = "{$script}?cmd=filelist";
    $_LINK['freeze'] = "{$script}?cmd=freeze&amp;page={$r_page}";
    $_LINK['help'] = "{$script}?cmd=help";
    $_LINK['list'] = "{$script}?cmd=list";
    $_LINK['menu'] = "{$script}?{$menubar}";
    $_LINK['new'] = "{$script}?plugin=newpage&amp;refer={$r_page}";
    $_LINK['newsub'] = "{$script}?plugin=newpage_subdir&amp;directory={$r_page}";
    $_LINK['read'] = "{$script}?cmd=read&amp;page={$r_page}";
    $_LINK['rdf'] = "{$script}?cmd=rss&amp;ver=1.0";
    $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew);
    $_LINK['refer'] = "{$script}?plugin=referer&amp;page={$r_page}";
    $_LINK['reload'] = "{$script}?{$r_page}";
    $_LINK['rename'] = "{$script}?plugin=rename&amp;refer={$r_page}";
    $_LINK['print'] = "{$script}?plugin=print&amp;page={$r_page}";
    $_LINK['rss'] = "{$script}?cmd=rss";
    $_LINK['rss10'] = "{$script}?cmd=rss&amp;ver=1.0";
    // Same as 'rdf'
    $_LINK['rss20'] = "{$script}?cmd=rss&amp;ver=2.0";
    $_LINK['mixirss'] = "{$script}?cmd=mixirss";
    // Same as 'rdf' for mixi
    $_LINK['skeylist'] = "{$script}?cmd=skeylist&amp;page={$r_page}";
    $_LINK['linklist'] = "{$script}?cmd=linklist&amp;page={$r_page}";
    $_LINK['log_browse'] = "{$script}?cmd=logview&amp;kind=browse&amp;page={$r_page}";
    $_LINK['log_update'] = "{$script}?cmd=logview&amp;page={$r_page}";
    $_LINK['log_down'] = "{$script}?cmd=logview&amp;kind=download&amp;page={$r_page}";
    $_LINK['search'] = "{$script}?cmd=search";
    $_LINK['side'] = "{$script}?{$sidebar}";
    $_LINK['source'] = "{$script}?plugin=source&amp;page={$r_page}";
    $_LINK['template'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['top'] = "{$script}";
    return $_LINK[$cmd];
}
function plugin_monobook_login_inline()
{
    global $vars, $_monobook_login_messages;
    if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW']) && isset($_SERVER['HTTP_AUTHORIZATION'])) {
        list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
    }
    $auth_usr = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '';
    $r_page = empty($vars['page']) ? '' : '&amp;page=' . rawurlencode($vars['page']);
    $list_id = $auth_usr ? ' id="userpage"' : ' id="login"';
    $list_class = $auth_usr && $auth_usr === $vars['page'] ? ' class="active"' : '';
    $a_class = $auth_usr && !is_page($auth_usr) ? ' class="new"' : '';
    $title = $auth_usr ? htmlspecialchars($auth_usr) : $_monobook_login_messages['login'];
    $uri = get_script_uri() . '?' . ($auth_usr ? rawurlencode($auth_usr) : 'cmd=monobook_login' . $r_page);
    return '<li' . $list_id . $list_class . '><a' . $a_class . ' href="' . $uri . '">' . $title . '</a></li>';
}
function plugin_revert_getlink()
{
    global $vars, $plugin, $cantedit;
    static $link;
    if (isset($link)) {
        return $link;
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    $age = isset($vars['age']) ? (int) $vars['age'] : 0;
    $link = '';
    if ($page && !in_array($page, $cantedit) && ($plugin === 'backup' && $age > 0 || $plugin === 'diff' || $plugin === 'revert')) {
        $link = get_script_uri() . '?cmd=revert&amp;page=' . rawurlencode($page) . ($age ? '&amp;age=' . $age : '');
    }
    return $link;
}
function plugin_whiteflow_topicpath_inline()
{
    global $vars, $defaultpage, $title, $disp_mode;
    // disp_mode ?
    if ($title == $defaultpage || $vars["page"] == $defaultpage) {
        $val = '<a href="' . get_script_uri() . '">トップページ</a>';
        return $val . $disp_mode;
    }
    if (!exist_plugin_inline('topicpath')) {
        return;
    }
    $args = func_get_args();
    $val = call_user_func_array('plugin_topicpath_inline', $args);
    return $val . $disp_mode;
}
function plugin_monobook_navigation($wikinote, $tabs, $background)
{
    global $vars, $plugin, $_monobook_navigation_messages;
    if (!exist_plugin('monobook_getlink')) {
        die('monobook_getlink plugin not found');
    }
    do_plugin_init('monobook_navigation');
    $main_tabs = '';
    if ($wikinote->is_effect()) {
        $main_tabs = str_replace(array('<ul class="wikinote">', '</ul>', "\n"), '', $wikinote->show_tabs(array(array('cmd' => 'main', 'label' => $_monobook_navigation_messages['article']), array('cmd' => 'note', 'label' => $_monobook_navigation_messages['discuss']))));
    }
    $sub_tabs = '';
    $selected_flag = FALSE;
    foreach ($tabs as $tab) {
        if ($tab === 'edit' && is_freeze($vars['page']) && !in_array('source', $tabs)) {
            $tab = 'source';
        }
        if ($tab === 'edit' && $plugin === 'paraedit') {
            $tab = 'paraedit';
        }
        if ($tab === 'edit' && exist_plugin('revert') && plugin_revert_getlink()) {
            $tab = 'revert';
        }
        list($link, $selected) = plugin_monobook_getlink($tab, $_monobook_navigation_messages, TRUE);
        if (!$link) {
            continue;
        }
        if ($selected) {
            $sub_tabs .= '<li class="selected">' . $link . '</li>';
            $selected_flag = TRUE;
        } else {
            $sub_tabs .= '<li>' . $link . '</li>';
        }
    }
    if (!$selected_flag) {
        $link = plugin_monobook_getlink('nowplugin', $_monobook_navigation_messages);
        if (!$main_tabs) {
            if ($link) {
                $sub_tabs = '<li class="selected" id="separate">' . $link . '</li>' . $sub_tabs;
            } else {
                $sub_tabs = '<li class="selected"><a href="' . get_script_uri() . strrchr($_SERVER['REQUEST_URI'], '?') . '">' . $_monobook_navigation_messages['undefined'] . '</a></li>';
            }
        } elseif ($main_tabs && !arg_check('read') && $link) {
            $sub_tabs = '<li class="selected">' . $link . '</li>' . $sub_tabs;
        }
    }
    return '<div id="navigator"><ul' . $background . '>' . $main_tabs . $sub_tabs . '</ul></div>' . "\n";
}
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_script_uri() . '?' . rawurlencode($realpage));
                        return;
                    } else {
                        // 存在しない場合、直接編集フォームに飛ばす // To avoid infinite loop
                        header('Location: ' . get_script_uri() . '?cmd=edit&page=' . rawurlencode($realpage));
                        return;
                    }
                } elseif (count($realpages) >= 2) {
                    $body = '<p>';
                    $body .= _('This pagename is an alias to') . '<br />';
                    foreach ($realpages as $realpage) {
                        $body .= make_pagelink($realpage) . '<br />';
                    }
                    $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_grepall_get_form($msg = "")
{
    $form = '';
    $form .= '<form action="' . get_script_uri() . '?cmd=grep " method="post">' . "\n";
    $form .= '<div>' . "\n";
    $form .= ' <input type="hidden" name="pcmd"  value="grep" />' . "\n";
    $form .= ' <input type="text" name="page" size="24" value="" /> Page Name<br />' . "\n";
    $form .= ' <input type="text" name="filter" size="24" value="" /> Filter Pages (Regular Expression)<br />' . "\n";
    $form .= ' <input type="text" name="grep" size="24" value="" /> Search String (Regular Expression)<br />' . "\n";
    $form .= ' <input type="submit" name="submit" value="Grep All!" /><br />' . "\n";
    $form .= '</div>' . "\n";
    $form .= '</form>' . "\n";
    if ($msg != '') {
        $msg = '<p><strong>' . $msg . '</strong></p>';
    }
    return $msg . $form;
}
function plugin_rewritemap_url($page)
{
    global $defaultpage;
    $script = get_script_uri();
    $baseurl = substr($script, 0, strrpos($script, '/')) . '/';
    if ($page == $defaultpage) {
        return $baseurl;
    }
    $alias = plugin_rewritemap_get_alias($page);
    if (empty($alias)) {
        if (exist_plugin('statichtml')) {
            $alias = PluginStatichtml::encode($page);
        } else {
            $alias = str_replace('%2F', '/', rawurlencode($page));
        }
    }
    return $baseurl . $alias . PLUGIN_REWRITEMAP_POSTFIX;
}
function plugin_diag_convert() {
    global $vars;

    if (!mk_dir()) {
        return 'Error(C): Fail mkdir()';
    }
    if (func_num_args() != 2) {
        return 'Error(C): The number of arguments is illegal.';
    }
    $args = func_get_args();
    $type = $args[0];
    $code = end($args);
    if ($type !== 'block' && $type !== 'nw' && $type !== 'seq' && $type !== 'act') {
        return 'Error(C): The value of the argument is illegal.';
    }

    return '<div align="center"><img src="'.get_script_uri().'?plugin=diag&type='.$type.'&code='.urlencode($code).'" /></div>';
}
Beispiel #26
0
function plugin_newpage_action()
{
    global $vars, $_btn_edit, $_msg_newpage;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    if ($vars['page'] == '') {
        $retvars['msg'] = $_msg_newpage;
        $retvars['body'] = plugin_newpage_convert();
        return $retvars;
    } else {
        $page = strip_bracket($vars['page']);
        $r_page = rawurlencode(isset($vars['refer']) ? get_fullname($page, $vars['refer']) : $page);
        $r_refer = rawurlencode($vars['refer']);
        pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?cmd=read&page=' . $r_page . '&refer=' . $r_refer);
        exit;
    }
}
Beispiel #27
0
 /**
  * Display a password form
  *
  * @param $msg error message or some messages
  * @return string form html
  */
 function display_password_form($message = "")
 {
     $cmd = $this->plugin;
     $pcmd = 'clean';
     $form = array();
     $form[] = '<form action="' . get_script_uri() . '?cmd=' . $cmd . '" method="post">';
     $form[] = '<div>';
     $form[] = ' <input type="hidden" name="pcmd" value="' . $pcmd . '" />';
     if (!is_admin(null, $this->conf['use_session'], $this->conf['through_if_admin'])) {
         $form[] = '<p style="color:red;font-size:14px">ページを開いただけでは、作業は行われません。<br />以下にパスワードを入力し、実行をクリックしてください。</p> <input type="password" name="pass" size="24" value="" /> ' . _('管理者パスワード') . '<br />';
     }
     $form[] = ' <input type="submit" name="submit" value="実行する" /><br />';
     $form[] = '</div>';
     $form[] = '</form>';
     $form = implode("\n", $form);
     if ($message != '') {
         $message = '<p><b>' . htmlspecialchars($message) . '</b></p>';
     }
     return $message . $form;
 }
Beispiel #28
0
function exist_plugin($name)
{
    global $vars;
    static $exist = array(), $count = array();
    $name = strtolower($name);
    if (isset($exist[$name])) {
        if (++$count[$name] > PKWK_PLUGIN_CALL_TIME_LIMIT) {
            die('Alert: plugin "' . htmlsc($name) . '" was called over ' . PKWK_PLUGIN_CALL_TIME_LIMIT . ' times. SPAM or someting?<br />' . "\n" . '<a href="' . get_script_uri() . '?cmd=edit&amp;page=' . rawurlencode($vars['page']) . '">Try to edit this page</a><br />' . "\n" . '<a href="' . get_script_uri() . '">Return to frontpage</a>');
        }
        return $exist[$name];
    }
    if (preg_match('/^\\w{1,64}$/', $name) && file_exists(PLUGIN_DIR . $name . '.inc.php')) {
        $exist[$name] = TRUE;
        $count[$name] = 1;
        require_once PLUGIN_DIR . $name . '.inc.php';
        return TRUE;
    } else {
        $exist[$name] = FALSE;
        $count[$name] = 1;
        return FALSE;
    }
}
function plugin_kisekae_inline()
{
    global $vars;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $args = func_get_args();
    $skin_name = array_pop($args);
    if (count($args) === 0) {
        return 'kisekae(): no argument(s).';
    }
    $skin_file = array_shift($args);
    $skin_name = $skin_name === '' ? htmlspecialchars($skin_file) : $skin_name;
    if (preg_match('#(^|/)\\.\\./#', $skin_file)) {
        return 'kisekae(): Skin file must not include ../';
    } elseif (!preg_match('#\\.skin\\.php$#', $skin_file)) {
        return 'kisekae(): Skin file must have .skin.php extension.';
    } elseif (!file_exists(SKIN_DIR . $skin_file)) {
        return 'kisekae(): Skin file ' . htmlspecialchars($skin_file) . ' does not exist. ';
    }
    $body = '<span class="kisekae">';
    $body .= '<a href="' . get_script_uri() . '?cmd=kisekae&amp;page=' . rawurlencode($page) . '&amp;skin=' . rawurlencode($skin_file) . '">' . $skin_name . '</a>';
    $body .= '</span>';
    return $body;
}
/**
 * A central function for settings the credentials for both subscription & purchase 
 * objects with the PayPal_Digital_Goods_Configuration registry class.
 */
function set_credentials()
{
    /*
    PayPal_Digital_Goods_Configuration::username( 'your_api_username' );
    PayPal_Digital_Goods_Configuration::password( 'your_api_password' );
    PayPal_Digital_Goods_Configuration::signature( 'your_api_signature' );
    */
    PayPal_Digital_Goods_Configuration::username('digita_1308916325_biz_api1.gmail.com');
    PayPal_Digital_Goods_Configuration::password('1308916362');
    PayPal_Digital_Goods_Configuration::signature('AFnwAcqRkyW0yPYgkjqTkIGqPbSfAyVFbnFAjXCRltVZFzlJyi2.HbxW');
    PayPal_Digital_Goods_Configuration::return_url(get_script_uri('return.php?paypal=paid'));
    PayPal_Digital_Goods_Configuration::cancel_url(get_script_uri('return.php?paypal=cancel'));
    PayPal_Digital_Goods_Configuration::business_name('Demo Store');
    PayPal_Digital_Goods_Configuration::notify_url(get_script_uri('return.php?paypal=notify'));
    // Uncomment the line below to switch to the live PayPal site
    //PayPal_Digital_Goods_Configuration::environment( 'live' );
    if (PayPal_Digital_Goods_Configuration::username() == 'your_api_username' || PayPal_Digital_Goods_Configuration::password() == 'your_api_password' || PayPal_Digital_Goods_Configuration::signature() == 'your_api_signature') {
        exit('You must set your API credentials in ' . __FILE__ . ' for this example to work.');
    }
}