예제 #1
0
function plugin_attachref_init()
{
    global $_string;
    $messages = array('_attachref_messages' => array('msg_upload' => T_("Upload to \$1"), 'msg_maxsize' => T_("Maximum file size is <var>%s</var>."), 'msg_adminpass' => T_("Administrator password"), 'msg_password' => T_("password"), 'msg_file' => T_("Attach file"), 'btn_upload' => T_("Upload"), 'btn_submit' => T_("[Upload]"), 'msg_title' => T_("Attach and Ref to \$1"), 'msg_title_collided' => $_string['title_collided'], 'msg_collided' => $_string['msg_collided']));
    PluginRenderer::getPluginInfo('attach', true);
    if (!exist_plugin('attach') or !function_exists('attach_upload')) {
        return array('msg' => 'attach.inc.php not found or not correct version.');
    }
    set_plugin_messages($messages);
}
예제 #2
0
 public function __toString()
 {
     $body = empty($this->body) ? null : InlineFactory::factory($this->body);
     $str = FALSE;
     // Try to call the plugin
     $str = PluginRenderer::executePluginInline($this->name, $this->param, $body);
     if ($str !== FALSE) {
         return $str;
         // Succeed
     } else {
         // No such plugin, or Failed
         $body = (empty($body) ? '' : '{' . $body . '}') . ';';
         return parent::setLineRules(Utility::htmlsc('&' . $this->plain) . $body);
     }
 }
예제 #3
0
 public function __toString()
 {
     $body = empty($this->body) ? '' : InlineFactory::factory($this->body);
     return PluginRenderer::executePluginInline($this->name, $this->param, $body);
 }
예제 #4
0
 /**
  * インラインプラグイン処理メソッド
  */
 static function convert_plugin($matches)
 {
     $aryargs = !empty($matches[2]) ? explode(',', $matches[2]) : array();
     $name = strtolower($matches[1]);
     $body = empty($matches[3]) ? '' : $matches[3];
     //	プラグインが存在しない場合はそのまま返す。
     // if (!file_exists(PLUGIN_DIR . $name . '.inc.php')) {
     if (!PluginRenderer::hasPlugin($name)) {
         return $matches[0];
     }
     switch ($name) {
         case 'aname':
             return '<a name="' . $aryargs[0] . '">' . $body . '</a>';
         case 'br':
             return '<br />';
         case 'color':
             $color = $aryargs[0];
             $bgcolor = $aryargs[1];
             if ($body == '') {
                 return '';
             }
             if ($color != '' && !preg_match('/^(#[0-9a-f]+|[\\w-]+)$/i', $color)) {
                 return $body;
             }
             if ($bgcolor != '' && !preg_match('/^(#[0-9a-f]+|[\\w-]+)$/i', $bgcolor)) {
                 return $body;
             }
             if ($color != '') {
                 $color = 'color:' . $color;
             }
             if ($bgcolor != '') {
                 $bgcolor = ($color ? '; ' : '') . 'background-color:' . $bgcolor;
             }
             return '<span style="' . $color . $bgcolor . '">' . $this->convert($body, TRUE, FALSE) . '</span>';
         case 'sup':
         case 'sub':
             return '<' . $name . '>' . $body . '</' . $name . '>';
         case 'size':
             $size = $aryargs[0];
             if ($size == '' || $body == '') {
                 return '';
             }
             if (!preg_match('/^\\d+$/', $size)) {
                 return $body;
             }
             return '<span style="font-size:' . $size . 'px;line-height:130%">' . $this->convert($body, TRUE, FALSE) . "</span>";
         case 'ref':
             return guiedit_convert_ref($aryargs, FALSE);
     }
     if ($body) {
         $pattern = array("%%", "''", "[[", "]]", "{", "|", "}");
         $replace = array("&#037;&#037;", "&#039;&#039;", "&#091;&#091;", "&#093;&#093;", "&#123;", "&#124;", "&#125;");
         $body = str_replace($pattern, $replace, $body);
     }
     $inner = '&' . $matches[1] . ($matches[2] ? '(' . $matches[2] . ')' : '') . ($body ? '{' . $body . '}' : '') . ';';
     $style = UA_NAME == MSIE ? '' : ' style="cursor:default"';
     return '<span class="plugin text-primary" contenteditable="false"' . $style . '>' . $inner . '</span>';
 }
예제 #5
0
 /**
  * QueryStringをパースし、$_GETに上書き
  * @return void
  */
 public static function parseArguments()
 {
     global $cookie, $get, $post, $method;
     global $defaultpage;
     $request = new Request();
     // GET, POST, COOKIE
     $get = $request->getQuery();
     $post = $request->getPost();
     $cookie = $request->getCookie();
     $method = $request->getMethod();
     $vars = array();
     if (strlen($get->toString()) > self::MAX_QUERY_STRING_LENGTH) {
         // Something nasty attack?
         self::dump('suspicious');
         self::dieMessage(_('Query string is too long.'));
     }
     if (count($get) === 0) {
         // Queryがない場合
         $get->set('page', $defaultpage);
     } else {
         if (count($get) === 1 && empty(array_values((array) $get)[0])) {
             // 配列の長さが1で最初の配列に値が存在しない場合はキーをページ名とする。
             $k = trim(array_keys((array) $get)[0]);
             $get->set('page', rawurldecode($_SERVER['QUERY_STRING']));
             unset($get[$k]);
         }
     }
     // 外部からの変数を$vars配列にマージする
     if (empty($post)) {
         $vars = (array) $get;
         // Major pattern: Read-only access via GET
     } else {
         if (empty($get)) {
             $vars = (array) $post;
             // Minor pattern: Write access via POST etc.
         } else {
             $vars = array_merge((array) $get, (array) $post);
             // Considered reliable than $_REQUEST
         }
     }
     //		var_dump($vars);
     //		die;
     if (!isset($vars['cmd'])) {
         $vars['cmd'] = 'read';
     }
     if (isset($vars['page']) && is_string($vars['page']) && preg_match(Wiki::INVALIED_PAGENAME_PATTERN, $vars['page']) === false) {
         // ページ名チェック
         self::dump('suspicious');
         die('Invalid page name.');
     }
     if (is_string($vars['cmd']) && preg_match(PluginRenderer::PLUGIN_NAME_PATTERN, $vars['cmd']) === false) {
         // 入力チェック: cmdの文字列は英数字以外ありえない
         self::dump('suspicious');
         die(sprintf('Plugin name %s is invalied or too long! (less than 64 chars)', $vars['cmd']));
     }
     // 文字コード変換
     // <form> で送信された文字 (ブラウザがエンコードしたデータ) のコードを変換
     // POST method は常に form 経由なので、必ず変換する
     if (isset($vars['encode_hint']) && !empty($vars['encode_hint'])) {
         // do_plugin_xxx() の中で、<form> に encode_hint を仕込んでいるので、
         // encode_hint を用いてコード検出する。
         // 全体を見てコード検出すると、機種依存文字や、妙なバイナリ
         // コードが混入した場合に、コード検出に失敗する恐れがある。
         $encode = mb_detect_encoding($vars['encode_hint']);
         mb_convert_variables(SOURCE_ENCODING, $encode, $vars);
     } else {
         // 全部まとめて、自動検出/変換
         mb_convert_variables(SOURCE_ENCODING, 'auto', $vars);
     }
     // 環境変数のチェック
     self::checkEnv($request->getEnv());
     switch ($method) {
         case Request::METHOD_POST:
             self::spamCheck($vars['cmd']);
             break;
         case Request::METHOD_OPTIONS:
         case Request::METHOD_PROPFIND:
         case Request::METHOD_DELETE:
         case 'MOVE':
         case 'COPY':
         case 'PROPPATCH':
         case 'MKCOL':
         case 'LOCK':
         case 'UNLOCK':
             // WebDAV
             $matches = array();
             foreach (self::$ua_dav as $pattern) {
                 if (preg_match('/' . $pattern . '/', $log_ua, $matches)) {
                     PluginRenderer::executePluginAction('dav');
                     exit;
                 }
             }
             break;
     }
     return $vars;
 }
예제 #6
0
function plugin_attach_action()
{
    global $vars, $_attach_messages, $_string;
    // Backward compatible
    if (isset($vars['openfile'])) {
        $vars['file'] = $vars['openfile'];
        $vars['pcmd'] = 'open';
    }
    if (isset($vars['delfile'])) {
        $vars['file'] = $vars['delfile'];
        $vars['pcmd'] = 'delete';
    }
    $pcmd = isset($vars['pcmd']) ? $vars['pcmd'] : NULL;
    $refer = isset($vars['refer']) ? $vars['refer'] : NULL;
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $page = isset($vars['page']) ? $vars['page'] : $refer;
    if (!empty($page)) {
        $wiki = Factory::Wiki($page);
        if ($wiki->isValied()) {
            // メソッドによってパーミッションを分ける
            if (in_array($pcmd, array('info', 'open', 'list'))) {
                // 読み込み許可
                $wiki->checkReadable();
            } else {
                // 書き込み許可があるか
                $wiki->checkEditable();
            }
        }
    }
    if (in_array($pcmd, array('delete', 'freeze', 'unfreeze'))) {
        if (Auth::check_role('readonly')) {
            Utility::dieMessage($_string['error_prohibit']);
        }
    }
    switch ($pcmd) {
        case 'info':
            return attach_info();
        case 'delete':
            return attach_delete();
        case 'open':
            return attach_open();
        case 'list':
            return attach_list($page);
        case 'freeze':
            return attach_freeze(TRUE);
        case 'unfreeze':
            return attach_freeze(FALSE);
        case 'rename':
            return attach_rename();
        default:
        case 'upload':
            return attach_showform();
        case 'form':
            return array('msg' => str_replace('$1', $refer, $_attach_messages['msg_upload']), 'body' => attach_form($refer));
        case 'post':
            return attach_upload($page, $pass);
        case 'progress':
            return PluginRenderer::getUploadProgress();
    }
    return empty($page) || !$wiki->isValied() ? attach_list() : attach_showform();
}
예제 #7
0
파일: Auth.php 프로젝트: logue/pukiwiki_adv
 /**
  * 認証されたAPIの情報を取得
  * @global type $auth_api
  * @global type $auth_wkgrp_user
  * @global type $defaultpage
  * @return array
  */
 static function get_auth_api_info()
 {
     global $auth_api, $auth_wkgrp_user, $defaultpage;
     $retval = array('role' => self::ROLE_GUEST, 'nick' => null, 'key' => null, 'api' => 'plus', 'group' => null, 'displayname' => null, 'home' => null, 'mypage' => null);
     foreach ($auth_api as $api => $val) {
         // どうしても必要な場合のみ開始
         if (!$val['use']) {
             continue;
         }
         break;
     }
     $obj = new AuthApi();
     $msg = $obj->getSession();
     if (isset($msg['api']) && $auth_api[$msg['api']]['use']) {
         if (PluginRenderer::hasPlugin($msg['api'])) {
             $call_func = 'plugin_' . $msg['api'] . '_get_user_name';
             $auth_key = $call_func();
             $auth_key['api'] = $msg['api'];
             if (empty($auth_key['nick'])) {
                 return $auth_key;
             }
             // 上書き・追加する項目
             if (!empty($auth_wkgrp_user[$auth_key['api']][$auth_key['key']])) {
                 $val =& $auth_wkgrp_user[$auth_key['api']][$auth_key['key']];
                 $auth_key['role'] = empty($val['role']) ? self::ROLE_ENROLLEE : $val['role'];
                 $auth_key['group'] = empty($val['group']) ? null : $val['group'];
                 $auth_key['displayname'] = empty($val['displayname']) ? null : $val['displayname'];
                 $auth_key['home'] = empty($val['home']) ? $defaultpage : $val['home'];
                 $auth_key['mypage'] = empty($val['mypage']) ? null : $val['mypage'];
             }
         }
     }
     return $auth_key;
 }
예제 #8
0
파일: Wiki.php 프로젝트: logue/pukiwiki_adv
 /**
  * ソース中のリンクを取得
  * @param $source Wikiソース
  * @return array
  */
 private static function getLinkList($source)
 {
     static $plugin_pattern, $replacement;
     // プラグインを無効化するためのマッチパターンを作成
     if (empty($plugin_pattern) || empty($replacement)) {
         foreach (PluginRenderer::getPluginList() as $plugin => $plugin_value) {
             if ($plugin === 'ref' || $plugin === 'attach' || $plugin === 'attachref') {
                 continue;
             }
             // ただしrefやattachは除外(あまりブロック型で使う人いないけどね)
             $plugin_pattern[] = '/^#' . $plugin . '\\(/i';
             $replacement[] = '#null(';
         }
     }
     $ret = array();
     // 1行づつ置き換え
     foreach ($source as $line) {
         $ret[] = preg_replace($plugin_pattern, $replacement, $line);
     }
     $links = array();
     // プラグインを無効化したソースをレンダリング
     $html = RendererFactory::factory($ret);
     // レンダリングしたソースからリンクを取得
     preg_match_all(self::HTML_URI_MATCH_PATTERN, $html, $links, PREG_PATTERN_ORDER);
     unset($html);
     return array_unique($links[1]);
 }
예제 #9
0
function plugin_login_action()
{
    global $vars, $_login_msg, $defaultpage;
    $api = isset($vars['api']) ? $vars['api'] : 'plus';
    $page = isset($vars['page']) ? $vars['page'] : $defaultpage;
    if ($api !== 'plus') {
        if (!PluginRenderer::hasPlugin($vars['api'])) {
            return;
        }
        $call_api = 'plugin_' . $vars['api'] . '_jump_url';
        Utility::redirect($call_api());
        exit;
    }
    $auth = Auth::authenticate();
    if ($auth === true) {
        // ログイン成功
        LogFactory::factory('login')->set();
        Utility::redirect(Factory::Wiki($page)->uri());
        exit;
    }
    return array('msg' => $_login_msg['err_auth'], 'body' => $_login_msg['err_auth_guide'], 'http_code' => 401);
}
예제 #10
0
/**
 * アクションプラグイン処理
 */
function plugin_logview_action()
{
    global $vars, $_logview_msg, $_logview_logname;
    global $sortable_tracker, $_LANG, $vars;
    static $count = 0;
    $kind = isset($vars['kind']) ? $vars['kind'] : null;
    $title = $kind !== null ? sprintf($_logview_msg['msg_title'], $kind) : $_LANG['skin']['log'];
    // タイトルを設定
    $page = isset($vars['page']) ? $vars['page'] : null;
    $ajax = isset($vars['ajax']) ? $vars['ajax'] : null;
    $is_role_adm = Auth::check_role('role_adm');
    // 設定を読む
    $log = Utility::loadConfig('config-log.ini.php');
    // ゲスト表示ができない場合は、認証を要求する
    if ($kind !== null && empty($log[$kind]['guest'])) {
        $obj = new Auth();
        $user = $obj->check_auth();
        if (empty($user)) {
            PluginRenderer::executePluginAction('login');
            unset($obj);
            return array('msg' => $title, 'body' => '<p class="alert-warning">' . $_logview_msg['msg_not_auth'] . '</p>');
        }
    }
    unset($obj);
    if (empty($page)) {
        return array('msg' => 'Page name is missing', 'body' => '<p class="alert-warning">Page name is missing.</p>');
    }
    $wiki = Factory::Wiki($page);
    if (!$wiki->isReadable()) {
        return array('msg' => 'not readable', 'body' => '<p class="alert-warning">You have no permission to read this log.</p>');
    }
    if ($kind === null) {
        if (!IS_MOBILE) {
            $body = '<div class="tabs" role="application">' . "\n";
            $body .= '<ul role="tablist">';
            $cnt = 0;
            foreach ($log as $key => $val) {
                $link_text = isset($_logview_logname[$key]) ? $_logview_logname[$key] : $key;
                if ($val['use'] === 1) {
                    $body .= '<li role="tab"><a href="' . $wiki->uri('logview', array('kind' => $key)) . '">' . $link_text . '</a></li>';
                }
                /*
                				else
                				{
                					$body .= '<li><a href="'.get_cmd_uri('logview',$page,null,array('kind'=>$key)).'" data-ajax="raw" data-disabled="true">'.$link_text.'</a></li>';
                				}
                */
            }
            $body .= '</ul></div>' . "\n";
            if ($kind === null) {
                return array('msg' => $title, 'body' => $body);
            }
            $body .= '<div class="no-js" role="tabpanel">';
            $nodata = $body . '<p>' . $_logview_msg['msg_nodata'] . '</p></div></div>';
        } else {
            $body = '<div data-role="controlgroup" data-type="horizontal">' . "\n";
            $cnt = 0;
            foreach ($log as $key => $val) {
                $link_text = isset($_LANG['skin']['log_' . $key]) ? $_LANG['skin']['log_' . $key] : $key;
                if ($val['use'] === 1) {
                    $body .= '<a href="' . $wiki->uri('logview', array('kind' => $key)) . '" data-role="button">' . $link_text . '</a>';
                }
                /*
                				else
                				{
                					$body .= '<a href="'.get_cmd_uri('logview',$page,null,array('kind'=>$key)).'" data-ajax="raw" data-disabled="true">'.$link_text.'</a>';
                				}
                */
            }
            $body .= '</div>' . "\n" . '<div class="ui-body ui-body-c"></div>';
            if ($kind === null) {
                return array('msg' => $title, 'body' => $body);
            }
        }
    } else {
        $body = '';
    }
    // 保存データの項目名を取得
    $logfile = LogFactory::factory($kind, $page);
    $view = $logfile->get_view_field();
    // 表示したい項目設定
    $count++;
    $body[] = '<div class="table_wrapper">';
    $body[] = '<table class="table table-bordered table_logview" data-pagenate="true">';
    $body[] = '<thead>';
    $body[] = '<tr>';
    $cols = 0;
    // タイトルの処理
    foreach ($view as $_view) {
        if ($_view === 'local_id' && $is_role_adm) {
            continue;
        }
        $body[] = '<th>' . $_logview_msg[$_view] . '</th>';
        $cols++;
    }
    $body[] = '</tr>';
    $body[] = '</thead>';
    $body[] = '<tbody>';
    $nodata = '<p class="alert alert-warning">' . $_logview_msg['msg_nodata'] . '</p>';
    // USER-AGENT クラス
    $obj_ua = new UserAgent(USE_UA_OPTION);
    $guess = $log['guess_user']['use'] ? LogFactory::factory('guess_user')->get() : LogFactory::factory('update', $page)->getSigunature();
    $ctr = 0;
    // データの編集
    $lines = $logfile->get();
    if (!$lines) {
        return array('msg' => $title, 'body' => $nodata);
    }
    foreach ($lines as $data) {
        if (!VIEW_ROBOTS && $obj_ua->is_robots($data['ua'])) {
            continue;
        }
        // ロボットは対象外
        $body[] = '<tr>';
        foreach ($view as $field) {
            switch ($field) {
                case 'ts':
                    // タイムスタンプ (UTIME)
                    $body[] = '<td>' . get_date('Y-m-d H:i:s', $data['ts']) . ' ' . get_passage($data['ts']) . '</td>';
                    break;
                case '@guess_diff':
                case '@diff':
                    // 差分内容
                    $update = $field == '@diff' ? true : false;
                    // FIXME: バックアップ/差分 なしの新規の場合
                    // バックアップデータの確定
                    $body[] = '<td class="style_td">';
                    $age = $logfile->get_backup_age($data['ts'], $update);
                    switch ($age) {
                        case -1:
                            // データなし
                            $body[] = '<a href="' . $wiki->uri() . '" rel="nofollow">none</a>';
                            break;
                        case 0:
                            // diff
                            $body[] = '<a href="' . ($logfile->diff_exist() ? $wiki->uri('diff') : $wiki->uri()) . '" rel="nofollow">now</a>';
                            break;
                        default:
                            // あり
                            $body[] = '<a class="ext" href="' . $wiki->uri('backup', null, array('age' => $age, 'action' => 'visualdiff')) . '" rel="nofollow">' . $age . '</a>';
                            break;
                    }
                    $body[] = '</td>';
                    break;
                case 'host':
                    // ホスト名 (FQDN)
                    $body[] = ' <td>';
                    if ($data['ip'] != $data['host']) {
                        // 国名取得
                        list($flag_icon, $flag_name) = $obj_ua->get_icon_flag($data['host']);
                        if (!empty($flag_icon) && $flag_icon != 'jp') {
                            $body[] = '<span class="flag flag-' . $flag_icon . '" title="' . $flag_name . '" ></span>';
                        }
                        // ドメイン取得
                        $domain = $obj_ua->get_icon_domain($data['host']);
                        if (!empty($domain)) {
                            //						$body .= '<img src="'.$path_domain.$domain.'.png"'.
                            //								' alt="'.$data['host'].'" title="'.$data['host'].'" />';
                            $body[] = '<span class="flag flag-' . $domain . '" title="' . $data['host'] . '" ></span>';
                        }
                    }
                    if ($data['ip'] !== '::1') {
                        $body[] = '<a href="http://robtex.com/ip/' . $data['ip'] . '.html" rel="external nofollow">' . $data['host'] . '</a></td>';
                    } else {
                        $body[] = $data['host'] . '</td>';
                    }
                    break;
                case '@guess':
                    // 推測
                    $body[] = '<td>' . Utility::htmlsc(logview_guess_user($data, $guess), ENT_QUOTES) . '</td>';
                    break;
                case 'ua':
                    // ブラウザ情報 (USER-AGENT)
                    $body[] = ' <td>';
                    $os = $obj_ua->get_icon_os($data['ua']);
                    if (!empty($os)) {
                        $body[] = '<span class="os os-' . $os . '" title="' . $os . '"></span>';
                    }
                    $browser = $obj_ua->get_icon_broeswes($data['ua']);
                    if (!empty($browser)) {
                        $body[] = '<span class="browser browser-' . $browser . '" title="' . Utility::htmlsc($data['ua'], ENT_QUOTES) . '"></span>';
                    }
                    $body[] = '</td>';
                    break;
                case 'local_id':
                    if ($is_role_adm) {
                        continue;
                    }
                default:
                    $body[] = '<td>' . Utility::htmlsc($data[$field], ENT_QUOTES) . '</td>';
            }
        }
        $body[] = '</tr>';
        $ctr++;
    }
    unset($obj_ua);
    if ($ctr == 0) {
        return array('msg' => $title, 'body' => $nodata);
    }
    $body[] = '</tbody>';
    $body[] = '</table>';
    $body[] = '</div>';
    switch ($kind) {
        case 'login':
        case 'check':
            $body .= logview_user_list($fld, $page, $kind);
            break;
    }
    if ($ajax !== 'raw') {
        $body[] = '</div>';
        $body[] = '</div>';
    } else {
        echo join("\n", $body);
        exit;
    }
    return array('msg' => $title, 'body' => join("\n", $body));
}
예제 #11
0
function plugin_pcomment_convert()
{
    global $vars;
    //	global $_pcmt_messages;
    $_pcmt_messages = array('msg_name' => T_('Name: '), 'btn_comment' => T_('Post Comment'), 'msg_comment' => T_('Comment: '), 'msg_recent' => T_('Show recent %d comments.'), 'msg_all' => T_('Go to the comment page.'), 'msg_none' => T_('No comment.'), 'err_pagename' => T_('[[%s]] : not a valid page name.'));
    $params = array('noname' => FALSE, 'nodate' => FALSE, 'below' => FALSE, 'above' => FALSE, 'reply' => FALSE, '_args' => array());
    $params = PluginRenderer::getPluginOption(func_get_args(), $params);
    //	var_dump($params);
    $vars_page = isset($vars['page']) ? $vars['page'] : '';
    $page = isset($params['_args'][1]) && !empty($params['_args'][1]) ? $params['_args'][0] : Utility::stripBracket(sprintf(PLUGIN_PCOMMENT_PAGE, $vars_page));
    $count = isset($params['_args'][0]) ? intval($params['_args'][0]) : 0;
    if ($count == 0) {
        $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
    }
    $_page = get_fullname(strip_bracket($page), $vars_page);
    $wiki = Factory::Wiki($_page);
    if (!$wiki->isValied()) {
        return sprintf($_pcmt_messages['err_pagename'], Utility::htmlsc($_page));
    }
    $dir = PLUGIN_COMMENT_DIRECTION_DEFAULT;
    if ($params['below']) {
        $dir = 0;
    } elseif ($params['above']) {
        $dir = 1;
    }
    list($comments, $digest) = plugin_pcomment_get_comments($_page, $count, $dir, $params['reply']);
    $form = array();
    // if (PKWK_READONLY) {
    if (!Auth::check_role('readonly') && isset($vars['page'])) {
        // Show a form
        $form[] = '<input type="hidden" name="cmd" value="pcomment" />';
        $form[] = '<input type="hidden" name="digest" value="' . $digest . '" />';
        $form[] = '<input type="hidden" name="refer"  value="' . Utility::htmlsc($vars_page) . '" />';
        $form[] = '<input type="hidden" name="page"   value="' . Utility::htmlsc($page) . '" />';
        $form[] = '<input type="hidden" name="nodate" value="' . Utility::htmlsc($params['nodate']) . '" />';
        $form[] = '<input type="hidden" name="dir"    value="' . $dir . '" />';
        $form[] = '<input type="hidden" name="count"  value="' . $count . '" />';
        $form[] = '<div class="row">';
        if ($params['noname'] === false) {
            $form[] = '<div class="col-md-3">';
            list($nick, $link, $disabled) = plugin_pcomment_get_nick();
            if ($params['reply']) {
                $form[] = '<div class="input-group">';
                $form[] = '<span class="input-group-addon">';
                $form[] = '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />';
                $form[] = '</span>';
            }
            $form[] = '<input type="text" name="name" value="' . $nick . '" ' . $disabled . ' class="form-control" size="' . PLUGIN_COMMENT_SIZE_NAME . '" placeholder="' . $_pcmt_messages['msg_name'] . '" />';
            if ($params['reply']) {
                $form[] = '</div>';
            }
            $form[] = '</div>';
            $form[] = '<div class="col-md-9">';
            $form[] = '<div class="input-group">';
        } else {
            $form[] = '<div class="col-md-12">';
            $form[] = '<div class="input-group">';
            if ($params['reply']) {
                $form[] = '<span class="input-group-addon">';
                $form[] = '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />';
                $form[] = '</span>';
            }
        }
        $form[] = '<textarea name="msg" cols="' . PLUGIN_COMMENT_SIZE_MSG . '" rows="1" class="form-control" placeholder="' . $_pcmt_messages['msg_comment'] . '"></textarea>';
        $form[] = '<span class="input-group-btn">';
        $form[] = '<button type="submit" class="btn btn-info">' . $_pcmt_messages['btn_comment'] . '</button>';
        $form[] = '</span>';
        $form[] = '</div>';
        $form[] = '</div>';
        $form[] = '</div>';
    }
    if (PKWK_READONLY == Auth::ROLE_AUTH) {
        exist_plugin('login');
        $form[] = do_plugin_inline('login');
    }
    if (!$wiki->has()) {
        $link = make_pagelink($_page);
        $recent = $_pcmt_messages['msg_none'];
    } else {
        $msg = !empty($_pcmt_messages['msg_all']) ? $_pcmt_messages['msg_all'] : $_page;
        $link = make_pagelink($_page, $msg);
        $recent = !empty($count) ? sprintf($_pcmt_messages['msg_recent'], $count) : '';
    }
    $string = !Auth::check_role('readonly') ? '<form action="' . get_script_uri() . '" method="post" class="plugin-pcomment-form form-inline" data-collision-check="false">' : '';
    $string .= $dir ? '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $comments . "\n" . join("\n", $form) : join("\n", $form) . "\n" . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $comments . "\n";
    $string .= !Auth::check_role('readonly') ? '</form>' : '';
    return IS_MOBILE ? '<div data-role="collapsible" data-theme="b" data-content-theme="d"><h4>' . $_pcmt_messages['msg_comment'] . '</h4>' . $string . '</div>' : '<div class="pcomment">' . $string . '</div>';
}
예제 #12
0
 /**
  * ページ出力の内容を生成
  * @return string
  */
 public function getContent()
 {
     global $_LINK, $info, $_LANG;
     global $site_name, $newtitle, $modifier, $modifierlink, $menubar, $sidebar, $headarea, $footarea, $navigation;
     $body = $this->body;
     // Linkタグ
     $_LINK = self::getLinkSet($this->page);
     // ページをコンストラクト
     $view = new View(THEME_NAME);
     // ページ名が指定されているか
     $view->is_page = isset($this->page);
     // readプラグイン(通常時動作)か?
     $view->is_read = $this->cmd === 'read';
     // ページが凍結されているか
     $view->is_freeze = isset($this->page) ? Factory::Wiki($this->page)->isFreezed() : false;
     if ($this->cmd === 'read') {
         // ページを読み込む場合
         global $adminpass, $_string, $menubar, $sidebar;
         // パスワードがデフォルトのままだった時に警告を出す
         if ($adminpass == '{x-php-md5}1a1dc91c907325c69271ddf0c944bc72' || $adminpass == '') {
             $body = '<p class="alert alert-danger"><span class="fa fa-exclamation-triangle"></span>' . '<strong>' . $_string['warning'] . '</strong> ' . $_string['changeadminpass'] . '</p>' . "\n" . $body;
         }
         // デバッグモード時に記載
         if (DEBUG === true && !empty($info)) {
             $body = '<div class="panel panel-info" id="pkwk-info">' . '<div class="panel-heading"><span class="fa fa-info-circle"></span>' . $_string['debugmode'] . '</div>' . "\n" . '<div class="panel-body">' . "\n" . '<ul>' . "\n" . '<li>' . join("</li>\n<li>", $info) . '</li>' . "\n" . '</ul></div></div>' . "\n\n" . $body;
         }
         // リファラーを保存
         Factory::Referer($this->page)->set();
         // 最終更新日
         $view->lastmodified = '<time datetime="' . Time::getZoneTimeDate('c', $this->wiki->time()) . '">' . Time::getZoneTimeDate('D, d M Y H:i:s T', $this->wiki->time()) . ' ' . $this->wiki->passage() . '</time>';
         // ページの添付ファイル
         $view->attaches = $this->getAttaches();
         // 関連リンク
         $view->related = $this->getRelated();
         // 注釈
         global $foot_explain;
         ksort($foot_explain, SORT_NUMERIC);
         $notes = count($foot_explain) !== 0 ? '<ul>' . join("\n", $foot_explain) . '</ul>' : '';
         // 検索語句をハイライト
         if (isset($vars['word'])) {
             $notes = self::hilightWord($vars['word'], $notes);
             $body = '<p class="alert alert-info">' . $_string['word'] . '<var>' . Utility::htmlsc($vars['word']) . '</var></p>' . "\n" . '<hr />' . "\n" . self::hilightWord($vars['word'], $body);
         }
         $view->notes = $notes;
         // モードによって、3カラム、2カラムを切り替える。
         $isExistSideBar = Factory::Wiki($sidebar)->has();
         // #nomenubarが指定されると$menubarはnullになる
         if (empty($menubar) && !$isExistSideBar) {
             $view->colums = View::CLASS_NO_COLUMS;
         } elseif (empty($menubar) || !$isExistSideBar) {
             $view->colums = View::CLASS_TWO_COLUMS;
         } else {
             $view->colums = View::CLASS_THREE_COLUMS;
         }
         $view->menubar = !empty($menubar) && Factory::Wiki($menubar)->has() ? PluginRenderer::executePluginBlock('menu') : null;
         $view->sidebar = $isExistSideBar ? PluginRenderer::executePluginBlock('side') : null;
         // ステータスアイコン
         if ($this->wiki->isFreezed()) {
             // 錠前マーク(フリーズされてる)
             $view->status = '<i class="fa fa-lock" title="Freezed" aria-hidden="true"></i>';
         } else {
             if (!$this->wiki->isEditable()) {
                 // 駐禁マーク(編集できない)
                 $view->status = '<i class="fa fa-ban" title="Not Editable" aria-hidden="true"></i>';
             } else {
                 // 鉛筆マーク(編集できる)
                 $view->status = '<i class="fa fa-pencil-square" title="Editable" aria-hidden="true"></i>';
             }
         }
     } else {
         // プラグインを実行する場合、大抵の場合メニューバーやサイドバーを表示しない
         $view->colums = View::CLASS_NO_COLUMS;
         // ステータスアイコンを歯車にする
         $view->status = '<i class="fa fa-cog" title="Function mode" aria-hidden="true"></i>';
     }
     // ナビバー
     $view->navibar = PluginRenderer::executePluginBlock('navibar', $view->conf['navibar']);
     // ツールバー
     $view->toolbar = PluginRenderer::executePluginBlock('toolbar', $view->conf['toolbar']);
     // <head>タグ内
     $view->head = self::getHead($view->conf);
     // ナビゲーション
     $view->navigation = Factory::Wiki($navigation)->has() ? PluginRenderer::executePluginBlock('suckerfish') : null;
     // ヘッドエリア
     $view->headarea = Factory::Wiki($headarea)->has() ? PluginRenderer::executePluginInline('headarea') : null;
     // フッターエリア
     $view->footarea = Factory::Wiki($footarea)->has() ? PluginRenderer::executePluginInline('footarea') : null;
     // パンくずリスト
     $view->topicpath = $this->getBreadcrumbs();
     // 中身
     $view->body = $body;
     // サイト名
     $view->site_name = $site_name;
     // ページ名
     $view->page = $this->page;
     // タイトル
     $view->title = !empty($newtitle) ? $newtitle : $this->title;
     // 管理人の名前
     $view->modifier = $modifier;
     // 管理人のリンク
     $view->modifierlink = $modifierlink;
     // JavaScript
     $view->js = $this->getJs();
     // 汎用ワード
     $view->strings = $_LANG;
     // 表示言語
     $view->lang = substr(LANG, 0, 2);
     // テーマディレクトリへの相対パス
     $view->path = SKIN_DIR . THEME_PLUS_NAME . (!IS_MOBILE ? PLUS_THEME : 'mobile') . '/';
     // リンク
     $view->links = $_LINK;
     // 処理にかかった所要時間
     $view->proc_time = $this->getProcessTime();
     // メモリ使用量
     $view->memory = $this->getMemoryUsage();
     // このへんにViewオブジェクトのキャッシュ処理を入れれば大幅に速くなるが・・・。
     return $view->__toString();
 }
예제 #13
0
파일: View.php 프로젝트: logue/pukiwiki_adv
 /**
  * インライン型プラグインを実行
  * @param string $name プラグイン名
  * @param string $args プラグインに渡す引数
  * @return string
  */
 public function pluginInline($name, $args = '')
 {
     return PluginRenderer::executePluginInline($name, $args);
 }
예제 #14
0
 private static function &pluginDummy(&$root, $text)
 {
     $matches = array();
     if (preg_match('/^#([^\\(\\{]+)(?:\\(([^\\r]*)\\))?(\\{*)/', $text, $matches) && PluginRenderer::hasPluginMethod($matches[1], 'convert')) {
         $len = strlen($matches[3]);
         $body = array();
         if ($len === 0) {
             $ret = new BlockPluginDummy($matches);
             // Seems legacy block plugin
         } else {
             if (preg_match('/\\{{' . $len . '}\\s*\\r(.*)\\r\\}{' . $len . '}/', $text, $body)) {
                 $matches[2] .= "\r" . $body[1] . "\r";
                 $ret = new BlockPluginDummy($matches);
                 // Seems multiline-enabled block plugin
             }
         }
     }
     return $ret;
 }
예제 #15
0
 public function parse($lines)
 {
     $this->last =& $this;
     $matches = array();
     while (!empty($lines)) {
         $line = array_shift($lines);
         // Escape comments
         if (substr($line, 0, 2) === '//') {
             if ($this->is_guiedit) {
                 $this->comments[] = substr($line, 2);
                 $line = '___COMMENT___';
             } else {
                 continue;
             }
         }
         // Extend TITLE by miko
         if (preg_match('/^(TITLE):(.*)$/', $line, $matches)) {
             global $newtitle;
             static $newbase;
             if (!isset($newbase)) {
                 $newbase = trim(Utility::stripHtmlTags(RendererFactory::factory($matches[2])));
                 // For BugTrack/132.
                 $newtitle = Utility::htmlsc($newbase);
             }
             continue;
         }
         if (preg_match('/^(LEFT|CENTER|RIGHT|JUSTIFY):(.*)$/', $line, $matches)) {
             // <div style="text-align:...">
             $align = new Align(strtolower($matches[1]));
             $this->last = $this->last->add($align);
             if (empty($matches[2])) {
                 continue;
             }
             $line = $matches[2];
         }
         $line = rtrim($line, "\t\r\n\v");
         // スペース以外の空白文字をトリム
         // Empty
         if (empty($line)) {
             $this->last =& $this;
             continue;
         }
         // Horizontal Rule
         if (substr($line, 0, 4) == '----') {
             $hrule = new HRule($this, $line);
             $this->insert($hrule);
             continue;
         }
         // Multiline-enabled block plugin #plugin{{ ... }}
         if (preg_match('/^#[^{]+(\\{\\{+)\\s*$/', $line, $matches)) {
             $len = strlen($matches[1]);
             $line .= self::MULTILINE_DELIMITER;
             while (!empty($lines)) {
                 $next_line = preg_replace('/[' . self::MULTILINE_DELIMITER . '\\n]*$/', '', array_shift($lines));
                 if (preg_match('/\\}{' . $len . '}/', $next_line)) {
                     $line .= $next_line;
                     break;
                 } else {
                     $line .= $next_line .= self::MULTILINE_DELIMITER;
                 }
             }
         }
         // The first character
         $head = $line[0];
         // Heading
         if ($head === '*') {
             $heading = new Heading($this, $line);
             $this->insert($heading);
             continue;
         }
         // Pre
         if ($head === ' ' || $head === "\t") {
             $pre = new Pre($this, $line);
             $this->last = $this->last->add($pre);
             continue;
         }
         // CPre (Plus!)
         if (substr($line, 0, 2) === '# ' or substr($line, 0, 2) == "#\t") {
             $sharppre = new SharpPre($this, $line);
             $this->last = $this->last->add($sharppr);
             continue;
         }
         // Line Break
         if (substr($line, -1) === '~') {
             $line = substr($line, 0, -1) . "\r";
         }
         // Other Character
         if (gettype($this->last) === 'object') {
             switch ($head) {
                 case '-':
                     $content = new UList($this, $line);
                     break;
                 case '+':
                     $content = new OList($this, $line);
                     break;
                 case '>':
                 case '<':
                     $content = new Blockquote($this, $line);
                     break;
                     // ここからはファクトリークラスを通す
                 // ここからはファクトリークラスを通す
                 case ':':
                     $content = ElementFactory::factory('DList', $this, $line);
                     break;
                 case '|':
                     $content = ElementFactory::factory('Table', $this, $line);
                     break;
                 case ',':
                     $content = ElementFactory::factory('YTable', $this, $line);
                     break;
                 case '#':
                     if ($this->is_guiedit) {
                         $content = ElementFactory::factory('PluginDummy', $this, $line);
                     } else {
                         $content = ElementFactory::factory('Plugin', $this, $line);
                     }
                     break;
                 default:
                     $content = ElementFactory::factory('InlineElement', null, $line);
                     break;
             }
             // MathJax Expression
             if (PluginRenderer::hasPlugin('mathjax')) {
                 $end_mark = '';
                 // 開始行によって終了行を判定する
                 if (substr($line, 0, 2) === '\\[') {
                     $end_mark = '\\]';
                 } else {
                     if (substr($line, 0, 6) === '\\begin') {
                         $end_mark = '\\end';
                     }
                 }
                 if ($end_mark) {
                     while (!empty($lines)) {
                         if (strpos($line, $end_mark) !== false) {
                             break;
                         }
                         $next_line = preg_replace("/[\r\n]*\$/", '', array_shift($lines));
                         $line .= "\n" . ' ' . $next_line;
                     }
                     $mathjax = new BlockPlugin(array(null, 'mathjax', $line));
                     $this->last = $this->last->add($mathjax);
                     continue;
                 }
             }
             // Default
             $this->last = $this->last->add($content);
             unset($content);
             continue;
         }
     }
 }
예제 #16
0
 public function toString()
 {
     // Call #plugin
     return PluginRenderer::executePluginBlock($this->name, $this->param);
 }
예제 #17
0
function do_plugin_inline($name, $args = '', $body = '')
{
    return PluginRenderer::executePluginInline($name, $args, $body);
}
예제 #18
0
파일: init.php 프로젝트: logue/pukiwiki_adv
    PluginRenderer::executePluginBlock('protect', $plugin_arg);
}
if (!empty($cmd)) {
    if (!PluginRenderer::hasPluginMethod($cmd, 'action')) {
        // プラグインにactionが定義されてない場合
        Utility::dieMessage(sprintf($_string['plugin_not_implemented'], Utility::htmlsc($cmd)), 501);
    } else {
        // プラグインのactionを実行する。
        // 帰り値:array('title', 'body', 'http_code');
        $retvars = PluginRenderer::executePluginAction($cmd);
    }
}
if ($is_protect) {
    // Location で飛ぶようなプラグインの対応のため
    // 上のアクションプラグインの実行後に処理を実施
    PluginRenderer::executePluginBlock('protect');
    die('<var>PLUS_PROTECT_MODE</var> is set.');
}
///////////////////////////////////////
// Page output
$auth_key = Auth::get_user_info();
$base = $defaultpage;
if (!empty($auth_key['home']) && isset($vars['page']) && ($vars['page'] == $defaultpage || $vars['page'] == $auth_key['home'])) {
    // ログイン時のホームページを基準とする(実際はあまり使われてないが)
    $base = $defaultpage = $auth_key['home'];
} else {
    $base = isset($vars['page']) ? $vars['page'] : $defaultpage;
}
$s_base = Utility::htmlsc(Utility::stripBracket($base));
if (isset($retvars['msg']) && !empty($retvars['msg'])) {
    $title = str_replace('$1', $s_base, $retvars['msg']);