Пример #1
0
function plugin_group_convert()
{
    global $_group_msg;
    $auth_key = auth::get_user_info();
    if (empty($auth_key['group'])) {
        return '';
    }
    $argv = func_get_args();
    $i = count($argv);
    if ($i < 2) {
        return <<<EOD
<div>
        <label>{$_group_msg['group']}</label>:
        {$auth_key['group']}
</div>

EOD;
    }
    $msg = $argv[$i - 1];
    array_pop($argv);
    if (in_array($auth_key['group'], $argv)) {
        return convert_html(str_replace("\r", "\n", $msg));
    }
    return '';
}
Пример #2
0
function plugin_mypage_convert()
{
    global $_mypage_msg;
    @(list($is_page) = func_get_args());
    $is_page = empty($is_page) ? false : true;
    $auth_key = auth::get_user_info();
    // 認証確認
    if (empty($auth_key['key'])) {
        return '';
    }
    // マイページ利用の確認
    if (empty($auth_key['mypage'])) {
        return '';
    }
    // マイページの作成により制御
    // マイページ未作成の場合
    // is_page : true  -> プラグイン利用ページに遷移 -> #mypage(1)
    //         : false -> 新規作成画面に遷移         -> #mypage
    // The page cannot be prepared. -> ページの準備ができていません。
    if ($is_page && !is_page($auth_key['mypage'])) {
        return $_mypage_msg['msg_no_page'];
    }
    // 画面に誘導
    header('Location: ' . get_page_location_uri($auth_key['mypage']));
    // 誘導失敗時の対処(ブラウザによる)
    die_message($_mypage_msg['err_jump']);
}
Пример #3
0
function plugin_login_inline()
{
    if (PKWK_READONLY != ROLE_AUTH) {
        return '';
    }
    $auth_key = auth::get_user_info();
    // Offline
    if (empty($auth_key['key'])) {
        return plugin_login_auth_guide();
    }
    // Online
    return exist_plugin($auth_key['api']) ? do_plugin_inline($auth_key['api']) : '';
}
Пример #4
0
/**
 * Check if a page is configured to require authentication
 *
 * @param string $page
 * @return boolean
 */
function plugin_approve_is_edit_authed($page)
{
    global $edit_auth, $edit_auth_pages, $auth_method_type;
    if (!$edit_auth) {
        return FALSE;
    }
    $target_str = '';
    if ($auth_method_type == 'pagename') {
        $target_str = $page;
        // Page name
    } else {
        if ($auth_method_type == 'contents') {
            $target_str = join('', get_source($page));
            // Its contents
        }
    }
    $auth_key = auth::get_user_info();
    $user = $auth_key['key'];
    if ($user == '') {
        return FALSE;
    }
    foreach ($edit_auth_pages as $regexp => $users) {
        if (preg_match($regexp, $target_str)) {
            return in_array($user, explode(',', $users)) ? TRUE : FALSE;
        }
    }
    return FALSE;
}
Пример #5
0
}
// Location で飛ぶようなプラグインの対応のため
// 上のアクションプラグインの実行後に処理を実施
if ($is_protect) {
    if (exist_plugin_convert('protect')) {
        do_plugin_convert('protect');
    }
    die('PLUS_PROTECT_MODE is set.');
}
// WebDAV
if (is_webdav() && exist_plugin('dav')) {
    do_plugin_action('dav');
    exit;
}
// Set Home
$auth_key = auth::get_user_info();
if (!empty($auth_key['home'])) {
    if ($base == $defaultpage || $base == $auth_key['home']) {
        $base = $defaultpage = $auth_key['home'];
    }
}
// Page output
$title = htmlspecialchars(strip_bracket($base));
$page = make_search($base);
if (isset($retvars['msg']) && $retvars['msg'] != '') {
    $title = str_replace('$1', $title, $retvars['msg']);
    $page = str_replace('$1', $page, $retvars['msg']);
}
if (isset($retvars['body']) && $retvars['body'] != '') {
    $body =& $retvars['body'];
} else {
Пример #6
0
 /**
  *ページの管理権限を取得
  * @return boolean
  */
 public static function is_page_auth($page, $auth_flag, $auth_pages, $uname, $gname = '')
 {
     global $auth_method_type;
     static $info;
     if (!$auth_flag) {
         return true;
     }
     if (!isset($info)) {
         $info = auth::get_user_info();
     }
     $target_str = '';
     switch ($auth_method_type) {
         case self::AUTH_METHOD_PAGENAME:
             $target_str = $page;
             break;
         case self::AUTH_METHOD_CONTENTS:
             $target_str = Factory::Wiki($page)->get();
             break;
     }
     $user_list = $group_list = $role = null;
     foreach ($auth_pages as $key => $val) {
         if (preg_match($key, $target_str)) {
             if (is_array($val)) {
                 $user_list = empty($val['user']) ? null : explode(',', $val['user']);
                 $group_list = empty($val['group']) ? null : explode(',', $val['group']);
                 $role = empty($val['role']) ? null : $val['role'];
             } else {
                 $user_list = empty($val) ? null : explode(',', $val);
             }
             break;
         }
     }
     // No limit
     if (empty($user_list) && empty($group_list) && empty($role)) {
         return true;
     }
     // 未認証者
     if (empty($uname)) {
         return false;
     }
     // ユーザ名検査
     if (!empty($user_list) && in_array($uname, $user_list)) {
         return true;
     }
     // グループ検査
     if (!empty($group_list) && !empty($gname) && in_array($gname, $group_list)) {
         return true;
     }
     // role 検査
     if (!empty($role) && !auth::is_check_role($role)) {
         return true;
     }
     return false;
 }
Пример #7
0
function read_auth($page, $auth_flag = TRUE, $exit_flag = TRUE)
{
    global $read_auth, $read_auth_pages, $auth_api, $defaultpage, $_title;
    if (!$read_auth) {
        return true;
    }
    $info = auth::get_user_info();
    if (!empty($info['key']) && auth::is_page_readable($page, $info['key'], $info['group'])) {
        return true;
    }
    if (!$auth_api['plus']['use']) {
        return auth::is_page_readable($page, '', '');
    }
    $auth_func_name = get_auth_func_name();
    // 未認証時で認証不要($auth_flag)であっても、制限付きページかの判定が必要
    if ($auth_flag && !$auth_func_name($page, $auth_flag, $exit_flag, $read_auth_pages, $_title['cannotread'])) {
        return false;
    }
    return auth::is_page_readable($page, '', '');
    if ($exit_flag) {
        // 無応答
        header('Location: ' . get_page_location_uri($defaultpage));
        die;
    }
    return false;
}
Пример #8
0
function plugin_recent_convert()
{
    global $vars, $date_format, $show_passage;
    // , $_recent_plugin_frame;
    static $exec_count = 1;
    $_recent_plugin_frame_s = _('recent(%d)');
    $_recent_plugin_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_recent_plugin_frame_s);
    $recent_lines = PLUGIN_RECENT_DEFAULT_LINES;
    if (func_num_args()) {
        $args = func_get_args();
        if (!is_numeric($args[0]) || isset($args[1])) {
            return PLUGIN_RECENT_USAGE . '<br />';
        } else {
            $recent_lines = $args[0];
        }
    }
    // Show only N times
    if ($exec_count > PLUGIN_RECENT_EXEC_LIMIT) {
        return '#recent(): You called me too much' . '<br />' . "\n";
    } else {
        ++$exec_count;
    }
    if (!file_exists(PLUGIN_RECENT_CACHE)) {
        return '#recent(): Cache file of RecentChanges not found' . '<br />';
    }
    // Get latest N changes
    $lines = file_head(PLUGIN_RECENT_CACHE, $recent_lines);
    if ($lines == FALSE) {
        return '#recent(): File can not open' . '<br />' . "\n";
    }
    $auth_key = auth::get_user_info();
    $date = $items = '';
    foreach ($lines as $line) {
        list($time, $page) = explode("\t", rtrim($line));
        if (!auth::is_page_readable($page, $auth_key['key'], $auth_key['group'])) {
            continue;
        }
        $_date = get_date($date_format, $time);
        if ($date != $_date) {
            // End of the day
            if ($date != '') {
                $items .= '</ul>' . "\n";
            }
            // New day
            $date = $_date;
            $items .= '<strong>' . $date . '</strong>' . "\n" . '<ul class="recent_list">' . "\n";
        }
        $s_page = htmlspecialchars($page);
        if ($page === $vars['page']) {
            // No need to link to the page you just read, or notify where you just read
            $items .= ' <li>' . $s_page . '</li>' . "\n";
        } else {
            $passage = $show_passage ? ' ' . get_passage($time) : '';
            $items .= ' <li><a href="' . get_page_uri($page) . '"' . ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
        }
    }
    // End of the day
    if ($date != '') {
        $items .= '</ul>' . "\n";
    }
    return sprintf($_recent_plugin_frame, count($lines), $items);
}
Пример #9
0
 function get_existpages($dir = DATA_DIR, $ext = '.txt')
 {
     $rc = array();
     // ページ名の取得
     $pages = get_existpages($dir, $ext);
     // ユーザ名取得
     $auth_key = auth::get_user_info();
     // コンテンツ管理者以上は、: のページも閲覧可能
     $is_colon = auth::check_role('role_adm_contents');
     // 役割の取得
     // $now_role = auth::get_role_level();
     foreach ($pages as $file => $page) {
         if (!auth::is_page_readable($page, $auth_key['key'], $auth_key['group'])) {
             continue;
         }
         if (substr($page, 0, 1) != ':') {
             $rc[$file] = $page;
             continue;
         }
         // colon page
         if ($is_colon) {
             continue;
         }
         $rc[$file] = $page;
     }
     return $rc;
 }