コード例 #1
0
ファイル: Lang.php プロジェクト: logue/pukiwiki_adv
 public static function setLanguage()
 {
     global $language_considering_setting_level;
     global $language;
     global $public_holiday_guest_view;
     $language = self::getLanguage($language_considering_setting_level);
     // LANG - Internal content encoding ('en', 'ja', or ...)
     define('LANG', $language);
     // Set COOKIE['lang']
     $parsed_url = parse_url(Router::get_script_absuri());
     $path = $parsed_url['path'];
     if (($pos = strrpos($path, '/')) !== FALSE) {
         $path = substr($path, 0, $pos + 1);
     }
     setcookie('lang', $language, 0, $path);
     $_COOKIE['lang'] = $language;
     // PUBLIC HOLIDAY
     // Installation person's calendar is adopted.
     $_c = explode('_', $public_holiday_guest_view ? $language : DEFAULT_LANG);
     define('COUNTRY', $_c[1]);
     unset($_c);
     // I18N
     if (extension_loaded('intl')) {
         Locale::setDefault($language);
     }
     // LOCALE Name specified by GETTEXT().
     define('DOMAIN', 'pukiwiki');
     // LOCALE Name specified by SETLOCALE().
     defined('PO_LANG') or define('PO_LANG', $language);
     // 'en_US', 'ja_JP'
     // PHP mbstring process.
     self::setMbstring($language);
 }
コード例 #2
0
function print_form_string($list)
{
    global $vars;
    $form_string[] = '<form action="' . Router::get_script_uri() . '" method="post" class="form-inline">';
    $form_string[] = '<fieldset>';
    $form_string[] = '<legend>' . T_('Page name') . '</legend>';
    if ($list['directory']) {
        $form_string[] = '<div class="form-group">';
        $form_string[] = '<select name="directory" class="form-control">';
        foreach ($list['directory'] as $dir) {
            $form_string[] = '<option>' . Utility::htmlsc($dir) . '/</option>';
        }
        $form_string[] = '</select>';
        $form_string[] = '</div>';
    }
    $form_string[] = '<input type="hidden" name="cmd" value="newpage_subdir" />';
    $form_string[] = isset($vars['page']) ? '<input type="hidden" name="refer" value="' . $vars['page'] . '" />' : null;
    $form_string[] = '<div class="form-group">';
    $form_string[] = '<input type="text" name="page" size="30" value="" class="form-control" />';
    $form_string[] = '</div>';
    $form_string[] = '<input type="submit" class="btn btn-primary" value="' . T_('New') . '" />';
    $form_string[] = '</fieldset>';
    $form_string[] = '</form>';
    if (isset($list['warning']) && $list['warning']) {
        $form_string[] = '<p>';
        foreach ($list['warning'] as $warning) {
            $form_string[] = $warning;
        }
        $form_string[] = '</p>';
    }
    return join("\n", $form_string);
}
コード例 #3
0
ファイル: livedoor.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_livedoor_inline()
{
    global $vars, $auth_api, $_livedoor_msg;
    if (!$auth_api['livedoor']['use']) {
        return $_livedoor_msg['msg_invalid'];
    }
    $obj = new AuthLivedoor();
    $name = $obj->getSession();
    if (!empty($name['api']) && $obj->auth_name !== $name['api']) {
        return;
    }
    if (isset($name['livedoor_id'])) {
        /*
        $logout_url = $script.'?plugin=livedoor';
        if (! empty($vars['page'])) {
        	$logout_url .= '&amp;page='.rawurlencode($vars['page']).'&amp;logout';
        }
        */
        $logout_url = Router::get_cmd_uri('livedoor', $vars['page']) . '&amp;logout';
        return sprintf($_livedoor_msg['msg_logined'], $name['livedoor_id']) . '(<a href="' . $logout_url . '">' . $_livedoor_msg['msg_logout'] . '</a>)';
    }
    $auth_key = Auth::get_user_name();
    if (!empty($auth_key['nick'])) {
        return $_livedoor_msg['msg_livedoor'];
    }
    $login_url = plugin_livedoor_jump_url(1);
    return '<a href="' . $login_url . '">' . $_livedoor_msg['msg_livedoor'] . '</a>';
}
コード例 #4
0
ファイル: multilang.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_multilang_inline_link($option, $args)
{
    global $vars;
    $body = array();
    $page = isset($vars['page']) ? $vars['page'] : '';
    $obj_l2c = new Lang2Country();
    foreach ($args as $arg) {
        $arg = htmlsc($arg);
        @(list($lang, $style) = explode('\\+', $arg));
        // en_US=English+flag=us
        @(list($lang, $title) = explode('=', $lang));
        @(list($style, $country) = explode('=', $style));
        if ($style != 'text') {
            // flag or text : default is flag
            if (empty($country)) {
                @(list($lng, $country) = explode('_', $lang));
                // en_US -> en, US
                if (empty($country)) {
                    $country = $obj_l2c->getLang2Country(strtolower($lng));
                }
            }
            if (!empty($country)) {
                $country = strtolower($country);
                $title = '<span class="flag flag-' . $country . '" title="' . $title . '" ></span>';
            }
        }
        array_push($body, '<a href="' . Router::get_cmd_uri('multilang', $page, null, array('lang' => $lang)) . '" rel="alternate" hreflang="' . strtolower(str_replace('_', '-', $lang)) . '">' . $title . '</a>');
    }
    if ($option == 'delim') {
        // default: nodelim
        return PLUGIN_MULTILANG_INLINE_BEFORE . join(PLUGIN_MULTILANG_INLINE_DELIMITER, $body) . PLUGIN_MULTILANG_INLINE_AFTER;
    }
    return '<span class="multilang">' . join(' ', $body) . '</span>';
}
コード例 #5
0
function plugin_csv2newpage_convert()
{
    global $vars, $_csv2newpage_messages;
    static $numbers = array();
    $page = $vars['page'];
    if (!isset($numbers[$page])) {
        $numbers[$page] = 0;
    }
    $csv2newpage_no = $numbers[$page]++;
    $newpage = '';
    $upload = 0;
    $config_name = 'default';
    $args = func_get_args();
    if (count($args) == 0) {
        return '<p>no option of config_name</p>';
    }
    $config_name = array_shift($args);
    if ($args[0] == 'upload') {
        array_shift($args);
        $upload = 1;
        $start_line_no = array_shift($args);
    }
    if (count($args) == 0) {
        return '<p>no parameter for CSV fields</p>';
    }
    $config = new Config('plugin/tracker/' . $config_name);
    if (!$config->read()) {
        return "<p>config file '" . Utility::htmlsc($config_name) . "' not found.</p>";
    }
    $config->config_name = $config_name;
    if (!exist_plugin('tracker')) {
        return '<p>The tracker plugin is not found.</p>';
    }
    $fields = plugin_tracker_get_fields($page, $page, $config);
    $form = array();
    $ct = 0;
    $form[] = '<input type="hidden" name="cmd" value="csv2newpage" />';
    $form[] = '<input type="hidden" name="_refer" value="' . Utility::htmlsc($page) . '" />';
    $form[] = '<input type="hidden" name="_config" value="' . Utility::htmlsc($config->config_name) . '" />';
    foreach ($args as $name) {
        $ct++;
        $s_name = Utility::htmlsc($name);
        $form[] = '<input type="hidden" name="csv_field' . $ct . '" value="' . $s_name . '" />' . "\n";
    }
    if ($upload) {
        $form[] = '<input type="hidden" name="_upload" value="' . $upload . '" />';
        $form[] = '<input type="hidden" name="start_line_no" value="' . $start_line_no . '" />';
        return plugin_csv2newpage_showform(join("\n", $form));
    }
    $ret[] = '<form action="' . Router::get_script_uri() . '" method="post" class="plugin-csv2newpage-form">';
    $ret[] = '<input type="hidden" name="cmd" value="csv2newpage" />';
    $ret[] = '<input type="hidden" name="_refer" value="' . Utility::htmlsc($page) . '" />';
    $ret[] = '<input type="hidden" name="_config" value="' . Utility::htmlsc($config->config_name) . '" />';
    $ret[] = '<input type="hidden" name="_csv2newpage_no" value="' . $csv2newpage_no . '" />';
    $ret[] = Utility::htmlsc($_csv2newpage_messages['title_text']);
    $ret[] = '<input class="btn btn-primary" type="submit" value="' . Utility::htmlsc($_csv2newpage_messages['btn_submit']) . '" />';
    $ret[] = '</form>';
    return join("\n", $ret);
}
コード例 #6
0
ファイル: unfreeze.inc.php プロジェクト: logue/pukiwiki_adv
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));
}
コード例 #7
0
ファイル: search.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_search_action()
{
    global $post, $vars;
    global $_search_msg, $_LANG;
    /*
    	if (isset($vars['update_index'])){
    		PukiWiki\SearchLucene::updateIndex();
    		return array('msg'=>'done.');
    	}
    */
    if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
        $s_word = isset($post['word']) ? htmlsc($post['word']) : '';
    } else {
        $s_word = isset($vars['word']) ? htmlsc($vars['word']) : '';
    }
    if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        die_message('Search words too long');
    }
    $type = isset($vars['type']) ? $vars['type'] : '';
    $base = isset($vars['base']) ? $vars['base'] : '';
    $format = isset($vars['format']) ? $vars['format'] : 'html';
    switch ($format) {
        case 'xml':
            // OpenSearch
            // http://www.opensearch.org/
            global $site_name, $notify_from, $shortcut_icon;
            $ret = array('<?xml version="1.0" encoding="UTF-8"?>', '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">', '<ShortName>' . $_search_msg['title_search'] . ' - ' . $site_name . '</ShortName>', '<Description>' . $_search_msg['title_search'] . ' - ' . $site_name . '</Description>', '<Contact>' . $notify_from . '</Contact>', '<Image height="16" width="16" type="image/x-icon">data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2FBP%2F8%2BjT%2F7%2BdK%2F%2F38M%2F%2F%2F%2Fw0AAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2FC%2F%2F%2B%2FTH%2F7%2BdK%2F%2Fv4N%2F%2F%2F%2FwUAAAAA%2F%2F%2F%2FBf%2Ft5IH%2F5djE%2F%2FLsn%2F7u5pT63tKe%2BNzLkOjFmnnq27p%2B%2BOfXk%2Fnl06z%2B7eOV%2F%2FLsn%2F%2Fm2cD%2F6%2BGM%2F%2F%2F%2FBv%2F072P%2F5til%2F%2F%2F%2FGfz4%2BB%2FrqJOE9qBr7vukUv3%2FzoL%2F%2F%2Bao%2F%2Fznsv7337j4662LwPXWyyX%2F%2F%2F8Y%2F%2Bfbmv%2Fz7XD%2F7uaJ%2F%2FDohf%2F%2F%2FwH729Ib9loZzv97Jv7%2Fo0v%2F%2F%2BOt%2F%2F%2Fmrf%2F%2F0oD%2F%2F9KC%2F%2Fm3bu3vsZopAAAAAP%2Fw6H7%2F7uaQ%2FvHpgP%2Fy7JL%2F9vQW%2F1kvvf9UEef%2Fhj7v%2F%2FPP9%2F%2F95Pv%2F9df7%2F7FQ%2Bf%2BxUPT%2F0IPq%2F8V3xf%2F69RT%2F8uyR%2FvHphv%2F28Vr%2F9vGB%2F6qWsf9jK%2Bb%2FhEjm%2F7iF5v%2F16Ob%2F59Ln%2F9iw5%2F%2BZL%2Bf%2Fnzvm%2F%2Bq15v%2B1Zeb%2Bxp6x%2F%2Fbygf%2F07mf%2F%2F%2F8R%2FvHqkP68p9f%2FoW7o%2F4BL5v%2BCROb%2FfCrm%2F4Al5v%2BRPOb%2FvIXm%2F9Sp5v%2Fuxeb%2FsnHn%2F8Ci3f7x6o7%2F%2F%2F8XAAAAAP%2F38lz9o4Tu%2F9K28%2F%2FUs%2Bb%2FYxrm%2F3os5v%2BWSeb%2F1LPm%2F%2F%2F%2F5v%2F%2F%2Feb%2F9Nfm%2F9Wy8v%2BceO7%2F9fBoAAAAAAAAAAD%2F%2BfZD%2Brig8%2F%2FRtvH%2F8OLv%2F5dg5v%2BOSub%2FnFjm%2F8KW5v%2F%2F%2F%2Bb%2F%2F%2F7m%2F%2FPg7v%2FMqfH%2FsZnz%2F%2FfzTQAAAAD%2F%2F%2F8J%2F%2FDpku2EZcL8up71%2F%2BfW8v%2FUu%2B7%2Fp3Dm%2F6hw5v%2FKo%2Bb%2F4s7m%2F8ip7f%2FkzvP%2FzbD1%2FXxazP%2Fw6ZH%2F%2F%2F8O%2F%2Fn1SP%2F18ILtooy19Zt16v%2FUvfL%2Fz7Xy%2F9G07%2F%2FDmub%2F1bnm%2F%2FDn7v%2Fw4%2FL%2F38jy%2FYhb6%2FeTfbn%2F9fCB%2F%2FfyVf%2Fy63v%2F9O6N%2FPX1Hed%2BW7z%2BuZjq%2F%2Bja9P%2Fo2PH%2F4c3y%2F9i%2F8v%2Ft3%2FL%2F4s%2F0%2FKV%2B6%2BlUL8f77%2B0c%2F%2FTujf%2Fy64H%2F7OKA%2F%2FTvhv%2F%2F%2FwL35OAa9rmgwP%2F58On%2B7eL2%2F%2Bre%2BP7j1Pj%2B4M72%2BrCN6uNeOcb22dQi%2F%2F%2F%2FAf%2F074H%2F7OKG%2F%2FLsbf%2Fs4qj%2F%2F%2F8J%2F%2F%2F%2FDv3y8EX84tbL%2Fenh2v7m2vn93s%2F6%2BMq42%2FS6p8z77OhM%2F%2F%2F%2FD%2F%2F%2F%2Fwj%2F7eSc%2F%2FHqev%2F%2F%2Fwn%2F6NyN%2F%2BjcvP%2Fw6KH%2F8ema%2F%2B%2Fmk%2F%2Fv54%2F%2F%2B%2Fk2%2F%2Fv6MP%2Fv54z%2F7%2BaU%2F%2FDpmf%2Fw6KH%2F6d65%2FubZmP%2F%2F%2FwwAAAAA%2F%2F%2F%2FBf%2F59UP%2B7eNl%2FvPtVv%2F%2F%2Fx7%2F%2F%2F8CAAAAAAAAAAD%2F%2F%2F8C%2F%2F%2F%2FG%2F%2F07lP%2B7eNl%2F%2Fj0R%2F%2F%2F%2FwcAAAAAg8GsQQAArEEAAKxBAASsQQAArEEAAKxBAACsQYABrEGAAaxBAACsQQAArEEAAKxBAACsQQAArEEAAKxBgYGsQQ%3D%3D</Image>', '<Language>' . DEFAULT_LANG . '</Language>', '<InputEncoding>UTF-8</InputEncoding>', '<OutputEncoding>UTF-8</OutputEncoding>', '<Url type="text/html" method="' . (!PLUGIN_SEARCH_DISABLE_GET_ACCESS ? 'get' : 'post') . '" template="' . Router::get_script_uri() . '">', '<Param name="cmd" value="search" />', '<Param name="encode_hint" value="' . PKWK_ENCODING_HINT . '" />', '<Param name="type" value="AND" />', '<Param name="word" value="{searchTerms}" />', '</Url>', '<Url type="application/x-suggestions+json" template="' . Router::get_cmd_uri('list', null, null, array('type' => 'json')) . '&amp;word={searchTerms}" />', '<moz:SearchForm>' . Router::get_cmd_uri('search') . '</moz:SearchForm>', '</OpenSearchDescription>');
            header('Content-Type:application/opensearchdescription+xml');
            echo join("\n", $ret);
            exit;
            break;
        default:
            if ($s_word !== '') {
                // Search
                $msg = str_replace('$1', $s_word, $_search_msg['title_result']);
                $body = Search::do_search($vars['word'], $type, FALSE, $base);
            } else {
                // Init
                unset($vars['word']);
                // Stop using $_msg_word at lib/html.php
                $msg = $_search_msg['title_search'];
                $body = '<p>' . $_search_msg['msg_searching'] . '</p>' . "\n";
            }
            // Show search form
            $bases = $base == '' ? array() : array($base);
            $body .= plugin_search_search_form($s_word, $type, $bases);
            break;
    }
    return array('msg' => $msg, 'body' => $body);
}
コード例 #8
0
ファイル: DiffFile.php プロジェクト: logue/pukiwiki_adv
 /**
  * 書き込み
  * @global boolean $notify
  * @global boolean $notify_diff_only
  * @param string $str
  */
 public function set($diffdata = '', $keeptimestamp = false)
 {
     global $notify, $notify_diff_only, $notify_subject;
     // 差分を作成
     //$diff = new Diff(WikiFactory::Wiki($this->page)->source(true), explode("\n",$postdata));
     //$str = $diff->getDiff();
     if ($notify) {
         $str = $notify_diff_only ? preg_replace('/^[^-+].*\\n/m', '', $diffdata) : $diffdata;
         $summary = array('ACTION' => 'Page update', 'PAGE' => &$page, 'URI' => Router::get_script_uri() . '?' . rawurlencode($page), 'USER_AGENT' => TRUE, 'REMOTE_ADDR' => TRUE);
         Mailer::notify($notify_subject, $str, $summary) or Utility::dieMessage('Mailer::notify(): Failed');
     }
     parent::set($diffdata);
 }
コード例 #9
0
ファイル: AuthApi.php プロジェクト: logue/pukiwiki_adv
 /**
  * コンストラクタ
  */
 public function __construct()
 {
     global $adminpass, $vars;
     //	if (!isset($this->auth_name)) throw new Exception('$this->auth_name has not set.');
     // コールバック先のページ
     $page = isset($vars['page']) ? $vars['page'] : null;
     // 管理人のパスワードのハッシュを暗号/復号のキーとする
     list(, $salt) = Auth::passwd_parse($adminpass);
     // 暗号化/復号化用
     $this->bc = BlockCipher::factory('mcrypt', array('algo' => 'des', 'mode' => 'cfb', 'hash' => 'sha512', 'salt' => $salt));
     // コールバック先のURL。通常プラグインのコールバックアドレスが返される
     $this->callbackUrl = isset($this->auth_name) ? Router::get_resolve_uri($this->auth_name, $vars['page'], 'full') : null;
     // セッション名
     $this->session_name = self::SESSION_PREFIX . md5(Router::get_script_absuri() . session_id());
 }
コード例 #10
0
ファイル: links.inc.php プロジェクト: logue/pukiwiki_adv
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);
}
コード例 #11
0
ファイル: freeze.inc.php プロジェクト: logue/pukiwiki_adv
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));
}
コード例 #12
0
ファイル: jugemkey.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_jugemkey_convert()
{
    global $script, $vars, $auth_api, $_jugemkey_msg;
    if (!$auth_api['jugemkey']['use']) {
        return '<p>' . $_jugemkey_msg['msg_invalid'] . '</p>';
    }
    $obj = new AuthJugem();
    $name = $obj->getSession();
    if (isset($name['title'])) {
        // $name = array('title','ts','token');
        /*
        $logout_url = $script.'?plugin=jugemkey';
        if (! empty($vars['page'])) {
        	$logout_url .= '&amp;page='.rawurlencode($vars['page']).'&amp;logout';
        }
        */
        $logout_url = Router::get_cmd_uri('jugemkey', $vars['page']) . '&amp;logout';
        return <<<EOD
<div>
\t<label>JugemKey</label>:
\t{$name['title']}
\t(<a href="{$logout_url}">{$_jugemkey_msg['msg_logout']}</a>)
</div>

EOD;
    }
    // 他でログイン
    $auth_key = Auth::get_user_name();
    if (!empty($auth_key['nick'])) {
        return '';
    }
    // ボタンを表示するだけ
    $login_url = $script . '?cmd=jugemkey';
    if (!empty($vars['page'])) {
        $login_url .= '&amp;page=' . rawurlencode($vars['page']);
    }
    $login_url .= '&amp;login';
    return <<<EOD
<form action="{$login_url}" method="post">
\t<div>
\t\t<input type="submit" class="btn btn-success" value="{$_jugemkey_msg['btn_login']}" />
\t</div>
</form>

EOD;
}
コード例 #13
0
ファイル: Akismet.php プロジェクト: logue/pukiwiki_adv
 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);
     }
 }
コード例 #14
0
ファイル: filelist.inc.php プロジェクト: logue/pukiwiki_adv
function filelist_adm($pass)
{
    global $_filelist_msg;
    global $vars;
    $msg_pass = $_filelist_msg['msg_input_pass'];
    $btn = $_filelist_msg['btn_exec'];
    $body = "";
    if ($pass == '__nopass__') {
        $body .= "<p><strong>" . $_filelist_msg['msg_no_pass'] . "</strong></p>";
    }
    $script = Router::get_script_uri();
    $body .= <<<EOD
<fieldset>
\t<legend>{$msg_pass}</legend>
\t<form action="{$script}" method="post" class="form-inline plugin-filelist-form">
\t\t<input type="hidden" name="cmd" value="filelist" />
\t\t<input type="password" name="pass" size="12" class="form-control" />
\t\t<input type="submit" class="btn btn-primary" name="ok" value="{$btn}" />
\t</form>
</fieldset>
EOD;
    return array('msg' => $_filelist_msg['msg_H0_filelist'], 'body' => $body);
}
コード例 #15
0
ファイル: hatena.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_hatena_inline()
{
    global $script, $vars, $auth_api, $_hatena_msg;
    if (!$auth_api['hatena']['use']) {
        return $_hatena_msg['msg_invalid'];
    }
    $obj = new AuthHatena();
    $name = $obj->getSession();
    if (!empty($name['api']) && $obj->auth_name !== $name['api']) {
        return;
    }
    if (isset($name['name'])) {
        // $name = array('name','ts','image_url','thumbnail_url');
        $link = $name['name'] . '<img src="' . $name['thumbnail_url'] . '" alt="id:' . $name['name'] . '" />';
        $logout_url = Router::get_cmd_uri('hatena', null, null, array('page' => $vars['page'], 'logout' => 'true'));
        return sprintf($_hatena_msg['msg_logined'], $link) . '(<a href="' . $logout_url . '">' . $_hatena_msg['msg_logout'] . '</a>)';
    }
    $auth_key = Auth::get_user_name();
    if (!empty($auth_key['nick'])) {
        return $_hatena_msg['msg_hatena'];
    }
    return '<a href="' . $obj->make_login_link() . '">' . $_hatena_msg['msg_hatena'] . '</a>';
}
コード例 #16
0
ファイル: Recent.php プロジェクト: logue/pukiwiki_adv
 /**
  * Atom/rssを出力
  * string $page ページ名(ページ名が入っている場合はキャッシュは無効)
  * string $type rssかatomか。
  * boolean $force キャッシュ生成しない
  * return void
  */
 public static function getFeed($page = '', $type = 'rss', $force = false)
 {
     global $vars, $site_name, $site_logo, $modifier, $modifierlink, $_string, $cache;
     static $feed;
     // rss, atom以外はエラー
     if (!($type === 'rss' || $type === 'atom')) {
         throw new Exception('Recent::getFeed(): Unknown feed type.');
     }
     $content_type = $type === 'rss' ? 'application/rss+xml' : 'application/atom+xml';
     $body = '';
     if (empty($page)) {
         // recentキャッシュの更新チェック
         if ($cache['wiki']->getMetadata(self::RECENT_CACHE_NAME)['mtime'] > $cache['wiki']->getMetadata(self::FEED_CACHE_NAME)['mtime']) {
             $force = true;
         }
         if ($force) {
             // キャッシュ再生成
             unset($feed);
             $cache['wiki']->removeItem(self::FEED_CACHE_NAME);
         } else {
             if (!empty($feed)) {
                 // メモリにキャッシュがある場合
             } else {
                 if ($cache['wiki']->hasItem(self::FEED_CACHE_NAME)) {
                     // キャッシュから最終更新を読み込む
                     $feed = $cache['wiki']->getItem(self::FEED_CACHE_NAME);
                 }
             }
         }
     }
     if (empty($feed)) {
         // Feedを作る
         $feed = new Feed();
         // Wiki名
         $feed->setTitle($site_name);
         // Wikiのアドレス
         $feed->setLink(Router::get_script_absuri());
         // サイトのロゴ
         //$feed->setImage(array(
         //	'title'=>$site_name,
         //	'uri'=>$site_logo,
         //	'link'=>Router::get_script_absuri()
         //));
         // Feedの解説
         $feed->setDescription(sprintf($_string['feed_description'], $site_name));
         // Feedの発行者など
         $feed->addAuthor(array('name' => $modifier, 'uri' => $modifierlink));
         // feedの更新日時(生成された時間なので、この実装で問題ない)
         $feed->setDateModified(time());
         $feed->setDateCreated(time());
         // Feedの生成
         $feed->setGenerator(S_APPNAME, S_VERSION, 'http://pukiwiki.logue.be/');
         if (empty($page)) {
             // feedのアドレス
             // ※Zend\Feedの仕様上、&が自動的に&amp;に変更されてしまう
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&type=atom', 'atom');
             $feed->setFeedLink(Router::get_cmd_uri('feed'), 'rss');
             // PubSubHubbubの送信
             foreach (Ping::$pubsubhubbub_server as $uri) {
                 $feed->addHub($uri);
             }
         } else {
             $r_page = rawurlencode($page);
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&type=atom&refer=' . $r_page, 'atom');
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&refer=' . $r_page, 'rss');
         }
         $i = 0;
         // エントリを取得
         foreach (self::get() as $_page => $time) {
             // ページ名が指定されていた場合、そのページより下位の更新履歴のみ出力
             if (!empty($page) && strpos($_page, $page . '/') === false) {
                 continue;
             }
             $wiki = Factory::Wiki($_page);
             if ($wiki->isHidden()) {
                 continue;
             }
             $entry = $feed->createEntry();
             // ページのタイトル
             $entry->setTitle($wiki->title());
             // ページのアドレス
             $entry->setLink($wiki->uri());
             // ページの更新日時
             $entry->setDateModified($wiki->time());
             // ページの要約
             $entry->setDescription($wiki->description(self::FEED_ENTRY_DESCRIPTION_LENGTH));
             // 項目を追加
             $feed->addEntry($entry);
             $i++;
             if ($i >= self::RECENT_MAX_SHOW_PAGES) {
                 break;
             }
         }
         if (empty($page)) {
             // キャッシュに保存
             $cache['wiki']->setItem(self::FEED_CACHE_NAME, $feed);
         }
     }
     flush();
     $headers = Header::getHeaders($content_type);
     Header::writeResponse($headers, 200, $feed->export($type));
     //header('Content-Type: ' . $content_type);
     //echo $body;
     exit;
 }
コード例 #17
0
ファイル: Ping.php プロジェクト: logue/pukiwiki_adv
 /**
  * WeblogUpdatesPingの送信
  */
 protected function sendWeblogUpdatesPing()
 {
     global $site_name;
     $err = array();
     // XMLRpcリクエストオブジェクトを生成
     $request = new XmlRpcRequest();
     // weblogUpdates.pingをセット
     $request->setMethod('weblogUpdates.ping');
     // 送るパラメータ
     $request->setParams(array($site_name, Router::get_script_absuri(), $this->wiki->uri()));
     // 送信
     foreach ($this->weblog_updates_ping_server as $uri) {
         try {
             // Pingサーバーに接続
             $client = new XmlRpcClient($uri);
             // Pingの送信
             $client->doRequest($request);
         } catch (\Zend\XmlRpc\Client\Exception\FaultException $e) {
             $err[] = $e;
         }
         unset($client);
     }
     return $err;
 }
コード例 #18
0
ファイル: qrcode.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_qrcode_inline()
{
    if (!extension_loaded('gd')) {
        return '<span class="ui-state-error">&amp;qrcode(): GD2 extention was not loaded!</span>';
    }
    /**
     * $s サイズ,
     * $e 訂正方法,
     * $v バージョン,
     * $n 分割数
     * $d バーコード化する文字列(Adv.版は非サポート)
     */
    switch (func_num_args()) {
        //		case 5:
        //			list($s,$e,$v,$n,$d) = func_get_args();
        //			break;
        case 4:
            list($s, $e, $v, $d) = func_get_args();
            break;
        case 3:
            list($s, $e, $d) = func_get_args();
            break;
        case 2:
            list($s, $d) = func_get_args();
            break;
        case 1:
            list($d) = func_get_args();
            break;
    }
    // thx, nanashi and customized
    $s = isset($s) && $s <= 0 ? intval($s) : 0;
    $v = isset($v) && !($v <= 0 && $v > PHPQRCode\Constants::QRSPEC_VERSION_MAX) ? intval($v) : PHPQRCode\Constants::QRSPEC_VERSION_MAX;
    //	$n = (isset($n) && !( $n <= 0 && $n > 16 )) ? intval($n) : 0;
    $e = Utility::htmlsc(isset($e) ? $e : 'M');
    if (empty($d)) {
        $d = $d = isset($vars['page']) ? Factory::Wiki($vars['page'])->getUri() : Router::get_cmd_uri();
    }
    // thx, nao-pon
    $d = str_replace('<br />', "\r\n", $d);
    $d = strip_tags($d);
    // docomo is s-jis encoding
    $d = mb_convert_encoding($d, 'SJIS', SOURCE_ENCODING);
    $result = array();
    $result[] = '<figure class="qrcode">';
    //if ($n < 2 || $n > 16) {
    $href = get_cmd_uri('qrcode', '', '', array('d' => $d, 's' => 9, 'v' => $v, 'e' => $e));
    $src = get_cmd_uri('qrcode', '', '', array('d' => $d, 's' => $s, 'v' => $v, 'e' => $e));
    $alt = defined('UA_MOBILE') && UA_MOBILE != 0 ? 'Mobile' : rawurlencode($d);
    $result[] = '<a href="' . $href . '"><img src="' . $src . '" alt="' . $alt . '" title="' . $alt . '" /></a>';
    /*
    }
     else {
    	// パリティを計算
    	$l=strlen($d);
    	if ($l>1){
    		$p=0;
    		$i=0;
    		while ($i<$l){
    			$p=($p ^ ord(substr($d,$i,1)));
    			$i++;
    		}
    	}
    	// 並べる(本来ならPNGを合成するのがきれいでしょうけどね)
    	$i=0;
    	for ($j=1;$j<=$n;$j++) {
    		$splitdata = substr($d,$i,ceil($l/$n));
    		$i += ceil($l/$n);
    		$src = get_cmd_uri('qrcode', '', '', array(
    			'd' => $splitdata,
    			's' => $s,
    			'v' => $v,
    			'e' => $e,
    			'm' => $j
    		));
    		$alt = (defined('UA_MOBILE') && UA_MOBILE != 0) ? 'Mobile' : rawurlencode($splitdata);
    
    		$result[] = '<img src="'.$src.'" alt="'.$alt.'" title="'.$alt.'" />';
    		unset($src);
    	}
    }
    */
    $result[] = '</figure>';
    return join("\n", $result);
}
コード例 #19
0
ファイル: PluginRenderer.php プロジェクト: logue/pukiwiki_adv
 /**
  * formタグに追加のフォームを挿入
  * @param type $retvar
  * @param type $plugin
  * @return type 
  */
 private static function addHiddenField($retvar, $plugin)
 {
     global $use_spam_check, $vars;
     // TODO:複数回実行される問題あり
     if (preg_match('/<form\\b(?:(?=(\\s+(?:method="([^"]*)"|enctype="([^"]*)")|action="([^"]*)"|data-collision-check="([^"]*)"|data-collision-check-strict="([^"]*)"|[^\\s>]+|\\s+))\\1)*>/i', $retvar, $matches) !== 0) {
         // action属性が、このスクリプト以外を指している場合処理しない
         if ($matches[4] === Router::get_script_uri()) {
             // Insert a hidden field, supports idenrtifying text enconding
             $hidden_field[] = '<!-- Additional fields START-->';
             $hidden_field[] = PKWK_ENCODING_HINT ? '<input type="hidden" name="encode_hint" value="' . PKWK_ENCODING_HINT . '" />' : null;
             if ($matches[2] !== 'get') {
                 // 利用者のホストチェック
                 $hidden_field[] = '<input type="hidden" name="ticket" value="' . md5(Utility::getTicket() . REMOTE_ADDR) . '" />';
                 // 多重投稿を禁止するオプションが有効かつ、methodがpostだった場合、PostIDを生成する
                 if (isset($use_spam_check['multiple_post']) && $use_spam_check['multiple_post'] === 1 && preg_match(self::IGNOLE_POSTID_CHECK_PATTERN, $plugin) !== 1) {
                     // from PukioWikio
                     $hidden_field[] = '<input type="hidden" name="postid" value="' . PostId::generate($plugin) . '" />';
                 }
                 // PHP5.4以降かつ、マルチパートの場合、進捗状況セッション用のフォームを付加する
                 if (ini_get('session.upload_progress.enabled') && isset($matches[3]) && $matches[3] === 'multipart/form-data') {
                     $hidden_field[] = '<input type="hidden" name="' . ini_get("session.upload_progress.name") . '" value="' . PKWK_WIKI_NAMESPACE . '" class="progress_session" />';
                 }
                 // ページ名が含まれていて、data-collision-checkがfalseでない場合、競合チェック用フォームを追記する
                 // data-collision-check="true"にするのは、pcomment.inc.phpのように別のWikiページを更新するプラグインの場合
                 // (これらの自動入力フォームは、常にフォームの先頭に挿入されるので、プラグイン側で重複するフォームがあったところで、
                 // HTML文法的に送られるフォームデーターはプラグインで指定された内容が優先されるためわざわざこんな小細工をしなかったところで実害はないが・・・。)
                 if (isset($vars['page']) && !(isset($matches[5]) && $matches[5] === 'false')) {
                     $wiki = Factory::Wiki($vars['page']);
                     $hidden_field[] = '<input type="hidden" name="digest" value="' . $wiki->digest() . '" />';
                     // 自動競合チェッカー
                     // data-collision-check-strict="true"を加えると、ページを送信した時点のオリジナルのソースも送信される。
                     // より精度の高い競合チェックを行うことができるが、データーが倍増するので、ページの編集フォーム以外ではあまり使うべきではない。
                     if (isset($matches[6]) && $matches[6] === 'true' && isset($vars['page']) && !empty($vars['page'])) {
                         $hidden_field[] = '<textarea style="display:none;width:0;height:0;" name="original">' . Utility::htmlsc($wiki->get(true)) . '</textarea>';
                     }
                 }
             }
             $hidden_field[] = '<!-- Additional fields END -->';
             $retvar = preg_replace('/<form[^>]*>/', '$0' . "\n" . join("\n", $hidden_field), $retvar);
         }
     }
     return $retvar;
 }
コード例 #20
0
ファイル: rename.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_rename_phase2($err = '')
{
    global $_rename_messages;
    $msg = plugin_rename_err($err);
    $page = plugin_rename_getvar('page');
    $refer = plugin_rename_getvar('refer');
    if ($page == '') {
        $page = $refer;
    }
    $msg_related = '';
    $related = plugin_rename_getrelated($refer);
    if (!empty($related)) {
        $msg_related = '<input type="checkbox" name="related" id="_p_rename_related" value="1" checked="checked" />' . '<label for="_p_rename_related">' . $_rename_messages['msg_do_related'] . '</label><br />';
    }
    $msg_rename = sprintf($_rename_messages['msg_rename'], make_pagelink($refer));
    $s_page = Utility::htmlsc($page);
    $s_refer = Utility::htmlsc($refer);
    $ret = array();
    $ret['msg'] = $_rename_messages['msg_title'];
    $script = Router::get_script_uri();
    $ret['body'] = <<<EOD
{$msg}
<fieldset>
\t<legend>{$msg_rename}</legend>
\t<form action="{$script}" method="post" class="plugin-rename-form">
\t\t<input type="hidden" name="cmd" value="rename" />
\t\t<input type="hidden" name="refer"  value="{$s_refer}" />
\t\t<div class="form-group">
\t\t\t<label for="_p_rename_newname">{$_rename_messages['msg_newname']}:</label>
\t\t\t<input type="text" name="page" id="_p_rename_newname" size="40" value="{$s_page}" class="form-control" />
\t\t</div>
\t\t{$msg_related}
\t\t<input type="submit" class="btn btn-warning" value="{$_rename_messages['btn_next']}" />
\t</form>
</fieldset>
EOD;
    if (!empty($related)) {
        $ret['body'] .= '<hr /><p>' . $_rename_messages['msg_related'] . '</p><ul>';
        sort($related, SORT_STRING);
        foreach ($related as $name) {
            $ret['body'] .= '<li>' . make_pagelink($name) . '</li>';
        }
        $ret['body'] .= '</ul>';
    }
    return $ret;
}
コード例 #21
0
ファイル: attach.inc.php プロジェクト: logue/pukiwiki_adv
function attach_form($page)
{
    global $_attach_messages;
    if (!ini_get('file_uploads')) {
        return '<p class="alert alert-warning">#attach(): <code>file_uploads</code> disabled.</p>';
    }
    if (!Factory::Wiki($page)->has()) {
        return '<p class="alert alert-warning">#attach(): No such page.</p>';
    }
    $attach_form[] = '<form enctype="multipart/form-data" action="' . Router::get_script_uri() . '" method="post" class="form-inline plugin-attach-form" data-collision-check="false">';
    $attach_form[] = '<input type="hidden" name="cmd" value="attach" />';
    $attach_form[] = '<input type="hidden" name="pcmd" value="post" />';
    $attach_form[] = '<input type="hidden" name="page" value="' . Utility::htmlsc($page) . '" />';
    $attach_form[] = '<input type="hidden" name="MAX_FILE_SIZE" value="' . PLUGIN_ATTACH_MAX_FILESIZE . '" />';
    $attach_form[] = '<div class="form-group">';
    $attach_form[] = '<label for="_p_attach_file" class="sr-only">' . $_attach_messages['msg_file'] . ':</label>';
    $attach_form[] = '<input type="file" name="' . PLUGIN_ATTACH_FILE_FIELD_NAME . '[]" id="_p_attach_file" class="form-control" multiple="multiple" />';
    $attach_form[] = '</div>';
    if ((PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) && Auth::check_role('role_contents_admin')) {
        $attach_form[] = '<div class="form-group">';
        $attach_form[] = '<input type="password" name="pass" size="8" class="form-control" />';
        $attach_form[] = '</div>';
    }
    $attach_form[] = '<button class="btn btn-primary" type="submit"><span class="fa fa-upload"></span>' . $_attach_messages['btn_upload'] . '</button>';
    $attach_form[] = '</form>';
    $attach_form[] = '<ul class="plugin-attach-ul">';
    $attach_form[] = (PLUGIN_ATTACH_PASSWORD_REQUIRE || PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY) && Auth::check_role('role_contents_admin') ? '<li>' . $_attach_messages[PLUGIN_ATTACH_UPLOAD_ADMIN_ONLY ? 'msg_adminpass' : 'msg_password'] . '</li>' : '';
    $attach_form[] = '<li>' . sprintf($_attach_messages['msg_maxsize'], '<var>' . number_format(PLUGIN_ATTACH_MAX_FILESIZE / 1024) . '</var>KB') . '</li>';
    $attach_form[] = '<li>' . $_attach_messages['msg_multiple'] . '</li>';
    $attach_form[] = '</ul>';
    return join("\n", $attach_form);
}
コード例 #22
0
ファイル: backup.inc.php プロジェクト: logue/pukiwiki_adv
/**
 * function plugin_backup_rollback($page, $age)
 */
function plugin_backup_rollback($page, $age)
{
    global $vars;
    global $_backup_messages;
    $passvalid = isset($vars['pass']) ? Auth::login($vars['pass']) : FALSE;
    if ($passvalid) {
        $backup = Factory::Backup($page);
        $backups = $backup->get($age);
        if (empty($backups)) {
            return array(sprintf($_backup_messages['title_backup_rollback'], $age), 'body' => $_backup_messages['msg_nobackup']);
            // Do nothing
        }
        $wiki = Factory::Wiki($page);
        // バックアップからロールバック(タイムスタンプを更新しない状態で)
        $wiki->set($backups['data']);
        // ファイルの更新日時をバックアップの時点にする
        $wiki->touch($backups['time']);
        //put_lastmodified();
        return array('msg' => $_backup_messages['title_backup_rollbacked'], 'body' => str_replace('$1', make_pagelink($page) . '(No. ' . $age . ')', $_backup_messages['msg_backup_rollbacked']));
    } else {
        $script = Router::get_script_uri();
        $s_page = htmlsc($page);
        $body = <<<EOD
<fieldset>
\t<legend>{$_backup_messages['msg_backup_adminpass']}</legend>
\t<form action="{$script}" method="post" class="plugin-backup-rollback-form form-inline">
\t\t<input type="hidden" name="cmd" value="backup" />
\t\t<input type="hidden" name="action" value="rollback" />
\t\t<input type="hidden" name="age" value="{$age}" />
\t\t<input type="hidden" name="page" value="{$s_page}" />
\t\t<div class="form-group">
\t\t\t<input type="password" name="pass" size="12" class="form-control" />
\t\t</div>
\t\t<input type="submit" name="ok" value="{$_backup_messages['btn_rollback']}" class="btn btn-warning" />
\t</form>
</legend>
EOD;
        return array('msg' => sprintf($_backup_messages['title_backup_rollback'], $age), 'body' => $body);
    }
}
コード例 #23
0
ファイル: Listing.php プロジェクト: logue/pukiwiki_adv
 /**
  * ページのリンクリストを作る
  * @param $pages ページ
  * @param $cmd 使用するプラグイン
  * @param boolean $with_filename ページのファイル名も表示する
  * @return string
  */
 private static function getPageLists($pages, $cmd = 'read', $with_filename = false)
 {
     $contents = array();
     // コンテンツ管理者以上は、: のページも閲覧可能
     $has_permisson = Auth::check_role('role_contents_admin');
     foreach ($pages as $page) {
         $wiki = Factory::Wiki($page);
         // 存在しない場合、当然スルー
         if (!$wiki->has()) {
             continue;
         }
         // 隠しページの場合かつ、隠しページを表示できる権限がない場合スルー
         if ($wiki->isHidden() && $has_permisson) {
             continue;
         }
         // 閲覧できる権限がない場合はスルー
         if (!$wiki->isReadable()) {
             continue;
         }
         $_page = Utility::htmlsc($page, ENT_QUOTES);
         if ($cmd !== 'attach') {
             $contents[] = IS_MOBILE ? '<li><a href="' . $wiki->uri($cmd) . '" data-transition="slide">' . $_page . '</a>' . '<span class="ui-li-count">' . $wiki->passage(false, false) . '</span></li>' : '<li><a href="' . $wiki->uri($cmd) . '">' . $_page . '</a> ' . $wiki->passage() . ($with_filename ? '<br /><var>' . Utility::htmlsc($wiki->filename) . '</var>' : '');
             '</li>';
         } else {
             $ret = array();
             $ret[] = '<li><a href="' . Router::get_cmd_uri('attach', null, null, array('page' => $page, 'ajax' => 'false')) . '">' . $_page . '</a> ';
             $attaches = $wiki->attach();
             if (count($attaches) !== 0) {
                 $ret[] = '<ul>';
                 foreach ($attaches as $filename => $files) {
                     $ret[] = '<li><a href="' . Router::get_cmd_uri('attach', null, null, array('refer' => $page, 'pcmd' => 'info', 'file' => $filename)) . '">' . Utility::htmlsc($filename) . '</a></li>';
                 }
                 $ret[] = '</ul>';
             }
             $ret[] = '</li>';
             $contents[] = join("\n", $ret);
         }
     }
     return $contents;
 }
コード例 #24
0
ファイル: Utility.php プロジェクト: logue/pukiwiki_adv
 /**
  * 編集画面を表示
  * @param string $page 編集しようとしているページ名
  * @param string $data 入力データー
  * @param boolean $show_template テンプレートを表示するか
  */
 public static function editForm($page, $data, $show_template = TRUE)
 {
     global $vars, $session;
     global $_button, $_string;
     global $notimeupdate, $load_template_func, $load_refer_related;
     if (empty($page)) {
         return self::dieMessage('Page name was not defined.');
     }
     $postdata = is_array($data) ? join("\n", $data) : $data;
     $original = isset($vars['original']) ? $vars['original'] : $postdata;
     // ticketは、PliginRenderer::addHiddenField()で自動挿入されるので、同じアルゴリズムでチケット名を生成
     $ticket_name = md5(Utility::getTicket() . REMOTE_ADDR);
     // BugTrack/95 fix Problem: browser RSS request with session
     $session->offsetSet('origin-' . $ticket_name, md5(self::getTicket() . str_replace("\r", '', $original)));
     $ret[] = '<form action="' . Router::get_script_uri() . '" role="form" method="post" class="form-edit" data-collision-check-strict="true">';
     $ret[] = '<input type="hidden" name="cmd" value="edit" />';
     $ret[] = '<input type="hidden" name="page" value="' . self::htmlsc($page) . '" />';
     $ret[] = isset($vars['id']) ? '<input type="hidden" name="id" value="' . self::htmlsc($vars['id']) . '" />' : null;
     if ($load_template_func && $show_template) {
         // ひな形を読み込む
         foreach (Listing::pages() as $_page) {
             $_w = Factory::Wiki($_page);
             if (!$_w->isEditable() || $_w->isHidden()) {
                 continue;
             }
             $_s_page = self::htmlsc($_page);
             $_pages[$_page] = '<option value="' . $_s_page . '">' . $_s_page . '</option>' . "\n";
         }
         // ナチュラルソート
         ksort($_pages, SORT_NATURAL);
         $ret[] = '<div class="form-inline">';
         $ret[] = '<div class="form-group">';
         $ret[] = '<select class="form-control" name="template_page" class="template">';
         $ret[] = '<option value="" disabled="disabled" selected="selected">-- ' . $_button['template'] . ' --</option>';
         $ret[] = join("\n", $_pages);
         $ret[] = '</select>';
         $ret[] = '</div>';
         $ret[] = '<button type="submit" class="btn btn-secondary" name="template" accesskey="l">' . $_button['load'] . '</button>';
         $ret[] = '</div>';
         unset($_s_page, $_w, $_pages);
     }
     // 編集フォーム
     $ret[] = '<textarea name="msg" id="msg" rows="15" class="form-control">' . self::htmlsc(($load_refer_related && isset($vars['refer']) && !empty($vars['refer']) ? '[[' . self::stripBracket($vars['refer']) . ']]' . "\n\n" : '') . $postdata) . '</textarea>';
     $ret[] = '<div class="form-inline">';
     if (IS_MOBILE) {
         // モバイル用
         $ret[] = '<input type="submit" id="btn_submit" name="write" value="' . $_button['update'] . '" data-icon="check" data-inline="true" data-theme="b" />';
         $ret[] = '<input type="submit" id="btn_preview" name="preview" value="' . $_button['preview'] . '" accesskey="p" data-icon="gear" data-inline="true" data-theme="e" />';
         $ret[] = '<input type="submit" id="btn_cancel" name="cancel" value="' . $_button['cancel'] . '" accesskey="c" data-icon="delete" data-inline="true" />';
         $ret[] = $notimeupdate === 2 && Auth::check_role('role_contents_admin') ? '<div data-role="fieldcontain">' : null;
         if ($notimeupdate !== 0 && Factory::Wiki($page)->isValied()) {
             // タイムスタンプを更新しないのチェックボックス
             $ret[] = '<input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true" ' . (isset($vars['notimestamp']) ? ' checked="checked"' : null) . ' />';
             $ret[] = '<label for="_edit_form_notimestamp" data-inline="true">' . $_button['notchangetimestamp'] . '</label>';
         }
         // 管理人のパス入力
         $ret[] = $notimeupdate == 2 && Auth::check_role('role_contents_admin') ? '<input type="password" name="pass" size="12"  data-inline="true" />' . "\n" . '</div>' : null;
         $ret[] = isset($vars['add']) ? '<input type="checkbox" name="add_top" value="true"' . (isset($vars['add']) ? ' checked="checked"' : '') . ' /><label for="add_top">' . $_button['addtop'] . '</label>' : null;
     } else {
         // 通常用
         $ret[] = '<button type="submit" class="btn btn-primary" name="write" accesskey="s"><span class="fa fa-check"></span>' . $_button['update'] . '</button>';
         $ret[] = isset($vars['add']) ? '<input type="checkbox" name="add_top" value="true"' . (isset($vars['add']) ? ' checked="checked"' : '') . ' /><label for="add_top">' . $_button['addtop'] . '</label>' : null;
         $ret[] = '<button type="submit" class="btn btn-secondary" name="preview" accesskey="p"><span class="fa fa-eye"></span>' . $_button['preview'] . '</button>';
         if ($notimeupdate !== 0 && Factory::Wiki($page)->isValied()) {
             // タイムスタンプを更新しないのチェックボックス
             $ret[] = '<div class="checkbox">';
             $ret[] = '<input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true"' . (isset($vars['notimestamp']) ? ' checked="checked"' : null) . ' />';
             $ret[] = '<label for="_edit_form_notimestamp">' . $_button['notchangetimestamp'] . '</label>';
             $ret[] = '</div>';
             //	$ret[] = '<div class="checkbox">';
             //	$ret[] = '<input type="checkbox" name="ping" id="_edit_form_ping" value="true"' . (isset($vars['ping']) ? ' checked="checked"' : null) . ' />';
             //	$ret[] = '<label for="_edit_form_ping">' . $_button['send_ping'] . '</label>';
             //	$ret[] = '</div>';
             //	$ret[] = '<div class="checkbox">';
             //	$ret[] = '<input type="checkbox" name="tweet" id="_edit_form_tweet" value="true"' . (isset($vars['tweet']) ? ' checked="checked"' : null) . ' />';
             //	$ret[] = '<label for="_edit_form_tweet"><span class="fa  fa-twitter"></span></label>';
             //	$ret[] = '</div>';
             //	$ret[] = '<div class="checkbox">';
             //	$ret[] = '<input type="checkbox" name="ping" id="_edit_form_fb" value="true"' . (isset($vars['facebook']) ? ' checked="checked"' : null) . ' />';
             //	$ret[] = '<label for="_edit_form_tweet"><span class="fa  fa-facebook"></span></label>';
             //	$ret[] = '</div>';
         }
         // 管理人のパス入力
         if ($notimeupdate === 2 && Auth::check_role('role_contents_admin')) {
             $ret[] = '<div class="form-group">';
             $ret[] = '<div class="input-group">';
             $ret[] = '<span class="input-group-addon"><span class="fa fa-key"></span></span>';
             $ret[] = '<input type="password" name="pass" class="form-control" size="12" placeholder="Password" />';
             $ret[] = '</div>';
             $ret[] = '</div>';
         }
         $ret[] = '<button type="submit" class="btn btn-warning" name="cancel" accesskey="c"><span class="fa fa-ban"></span>' . $_button['cancel'] . '</button>';
     }
     $ret[] = '</div>';
     $ret[] = '</form>';
     if (isset($vars['help'])) {
         // テキストの整形ルールを表示
         $rule_wiki = Factory::Wiki(self::RULE_PAGENAME);
         $ret[] = '<hr />';
         $ret[] = $rule_wiki->has() ? $rule_wiki->render() : '<p class="alert alert-warning">Sorry, page \'' . Utility::htmlsc(self::RULE_PAGENAME) . '\' unavailable.</p>';
     } else {
         $ret[] = '<ul><li><a href="' . Factory::Wiki($page)->uri('edit', array('help' => 'true')) . '" id="FormatRule">' . $_string['help'] . '</a></li></ul>';
     }
     return join("\n", $ret);
 }
コード例 #25
0
ファイル: Wiki.php プロジェクト: logue/pukiwiki_adv
 /**
  * 差分から追加されたリンクと削除されたリンクを取得しURIBLチェック
  * @param object $diff
  * @return type
  */
 private function checkUriBl($diff)
 {
     // 変数の初期化
     $links = $added = $removed = array();
     // 差分から追加行と削除行を取得
     foreach ($diff->getSes() as $key => $line) {
         if ($key === $diff::SES_ADD) {
             $added[] = $line;
         } else {
             if ($key === $diff::SES_DELETE) {
                 $removed[] = $line;
             }
         }
     }
     // それぞれのリンクの差分を取得
     $links = array_diff(self::getLinkList($added), self::getLinkList($removed));
     unset($added, $removed);
     // 自分自身へのリンクを除外
     $links = preg_grep('/^(?!' . preg_quote(Router::get_script_absuri(), '/') . '\\?)./', $links);
     // ホストのみ取得
     foreach ($links as $temp_uri) {
         $temp_uri_info = parse_url($temp_uri);
         if (empty($temp_uri_info['host'])) {
             continue;
         }
         $uri_filter = new UriFilter($temp_uri_info['host']);
         if ($uri_filter->checkHost()) {
             return 'uribl';
         }
         if ($uri_filter->isListedNSBL()) {
             return 'nsbl';
         }
     }
     return false;
 }
コード例 #26
0
ファイル: Referer.php プロジェクト: logue/pukiwiki_adv
 /**
  * リンク元にアクセスして自サイトへのアドレスが存在するかのチェック
  * @return boolean
  */
 private function is_not_valid_referer()
 {
     static $condition;
     // 本来は正規化されたアドレスでチェックするべきだろうが、
     // めんどうだからスクリプトのアドレスを含むかでチェック
     // global $vars;
     // $script = get_page_absuri(isset($vars['page']) ? $vars['page'] : '');
     if (empty($condition)) {
         $parse_url = Router::get_script_uri();
         $condition = $parse_url['host'] . $parse_url['path'];
         // QueryStringは評価しない。
     }
     $response = ClientStatic::get($this->referer);
     if (!$response->isSuccess()) {
         return true;
     }
     $dom = new Query($response->getBody());
     $results = $dom->execute('a[href=^"' . $condition . '"]');
     foreach ($results as $element) {
         // hrefがhttpから始まるaタグを走査
         if (preg_match('/' . $condition . '/i', $element->href) !== 0) {
             return false;
             break;
         }
     }
     return true;
 }
コード例 #27
0
ファイル: Header.php プロジェクト: logue/pukiwiki_adv
 /**
  * ヘッダー配列を取得
  * @param string $content_type Mimeタイプ
  * @param int $modified 更新日時。通常はfilemtimeの値
  * @param int $exprire 有効期限。デフォルトは1週間
  * @return array
  */
 public static function getHeaders($content_type = self::DEFAULT_CONTENT_TYPE, $modified = 0, $expire = 604800)
 {
     global $lastmod, $vars, $_SERVER;
     // これまでのヘッダーを取得
     $headers = function_exists('getallheaders') ? getallheaders() : array();
     $headers['Content-Type'] = $content_type;
     $headers['Content-Language'] = substr(str_replace('_', '-', LANG), 0, 2);
     // 更新日時をチェック
     if ($modified !== 0) {
         // http://firegoby.jp/archives/1730
         $last_modified = gmdate('D, d M Y H:i:s', $modified);
         $etag = md5($last_modified);
         $headers['Cache-Control'] = 'private';
         $headers['Pragma'] = 'cache';
         $headers['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT';
         $headers['Last-Modified'] = $last_modified;
         $headers['ETag'] = $etag;
         if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $last_modified || isset($_SERVER['HTTP_IF_NONE_MATCH']) && preg_match('/' . $etag . '/', $_SERVER['HTTP_IF_NONE_MATCH'])) {
             self::WriteResponse($headers, Response::STATUS_CODE_304, null);
             exit;
         }
         //		header('If-Modified-Since: ' . $last_modified );
     } else {
         // PHPで動的に生成されるページはキャシュすべきではない
         $headers['Cache-Control'] = $headers['Pragma'] = 'no-cache';
         $headers['Expires'] = 'Sat, 26 Jul 1997 05:00:00 GMT';
     }
     // RFC2616
     // http://sonic64.com/2004-02-06.html
     $headers['Vary'] = self::getLanguageHeaderVary();
     if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('/\\b(gzip|deflate|compress)\\b/i', $_SERVER['HTTP_ACCEPT_ENCODING'], $matches)) {
         $headers['Vary'] .= ',Accept-Encoding';
     }
     // HTTP access control
     // JSON脆弱性対策(Adv.では外部にAjax APIを提供することを考慮しない)
     // https://developer.mozilla.org/ja/HTTP_Access_Control
     $headers['Access-Control-Allow-Origin'] = Router::get_script_uri();
     // Content Security Policy
     // https://developer.mozilla.org/ja/Security/CSP/Using_Content_Security_Policy
     //$headers['Content-Security-Policy'] ='default-src \'self\' \'unsafe-inline\' ' . Render::JQUERY_CDN . ' ' . Render::BOOTSTRAP_CDN . '; img-src *;';
     // IEの自動MIME type判別機能を無効化する
     // http://msdn.microsoft.com/ja-jp/ie/dd218497.aspx
     $headers['X-Content-Type-Options'] = 'nosniff';
     // クリックジャッキング対策(IFRAME呼び出しは禁止!)
     // https://developer.mozilla.org/ja/The_X-FRAME-OPTIONS_response_header
     $headers['X-Frame-Options'] = 'deny';
     // XSS脆弱性対策(これでいいのか?)
     // http://msdn.microsoft.com/ja-jp/ie/dd218482
     $headers['X-XSS-Protection'] = '1; mode=block';
     // PingBack
     if ($vars['cmd'] === 'read' && isset($vars['page'])) {
         $headers['X-Pingback'] = Router::get_cmd_uri('xmlrpc');
     }
     return $headers;
 }
コード例 #28
0
 public function open_close($mode, $edit)
 {
     $button_name = array('lock' => T_('Locked'), 'unlock' => T_('Unlocked'));
     if ($mode == 'lock') {
         $edit = 'on';
         $table_mod = 'unlock';
     } else {
         $edit = 'off';
         $table_mod = 'lock';
     }
     $ret = array();
     $ret[] = '<div class="pull-right" id="TableEdit2TableNumber' . $this->count . '">';
     $ret[] = '<a href="' . Router::get_cmd_uri('table_edit2', null, null, array('refer' => $this->page, 'table_mod' => $table_mod, 'table_num' => $this->count, 'encode_hint' => PKWK_ENCODING_HINT)) . '" class="btn btn-secondary" nofollow="nofollow" data-ajax="false" title="' . $button_name[$table_mod] . '"><span class="fa fa-' . $table_mod . '"></span></a>';
     $ret[] = $this->set_csv;
     $ret[] = '</div>';
     $ret[] = '<div class="clearfix"></div>';
     return join("\n", $ret);
 }
コード例 #29
0
ファイル: legacy.php プロジェクト: logue/pukiwiki_adv
function basepagename($str)
{
    return Router::getBasePageName($str);
}
コード例 #30
0
ファイル: amazon.inc.php プロジェクト: logue/pukiwiki_adv
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'));
}