当前位置: 首页>>代码示例>>PHP>>正文


PHP auth::check_role方法代码示例

本文整理汇总了PHP中auth::check_role方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::check_role方法的具体用法?PHP auth::check_role怎么用?PHP auth::check_role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在auth的用法示例。


在下文中一共展示了auth::check_role方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_doc_ini_action

function plugin_doc_ini_action()
{
    global $script, $vars, $_doc_ini_msg;
    if (auth::check_role('role_adm_contents')) {
        die_message('NOT AUTHORIZED.');
    }
    if (empty($vars['page'])) {
        return;
    }
    if (!is_pagename($vars['page'])) {
        return '';
    }
    // Invalid page name;
    $action = empty($vars['action']) ? '' : $vars['action'];
    $retval = array();
    $msg_title = sprintf($_doc_ini_msg['msg_confirmation'], $vars['page']);
    if ($action === 'exec') {
        return plugin_doc_ini_exec($vars['page']);
    }
    $retval['body'] = <<<EOD
<form action="{$script}" method="post">
        <div>
\t{$msg_title}
                <input type="hidden" name="plugin" value="doc_ini" />
                <input type="hidden" name="action" value="exec" />
                <input type="hidden" name="page" value="{$vars['page']}" />
                <input type="submit" value="{$_doc_ini_msg['btn_exec']}" />
        </div>
</form>

EOD;
    $retval['msg'] = $_doc_ini_msg['title_confirmation'];
    return $retval;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:34,代码来源:doc_ini.inc.php

示例2: plugin_insert_convert

function plugin_insert_convert()
{
    global $script, $vars, $digest;
    static $numbers = array();
    $_btn_insert = _('add');
    // if (PKWK_READONLY) return ''; // Show nothing
    if (auth::check_role('readonly')) {
        return '';
    }
    // Show nothing
    if (!isset($numbers[$vars['page']])) {
        $numbers[$vars['page']] = 0;
    }
    $insert_no = $numbers[$vars['page']]++;
    $s_page = htmlspecialchars($vars['page']);
    $s_digest = htmlspecialchars($digest);
    $s_cols = INSERT_COLS;
    $s_rows = INSERT_ROWS;
    $string = <<<EOD
<form action="{$script}" method="post">
 <div>
  <input type="hidden" name="insert_no" value="{$insert_no}" />
  <input type="hidden" name="refer"  value="{$s_page}" />
  <input type="hidden" name="plugin" value="insert" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <textarea name="msg" rows="{$s_rows}" cols="{$s_cols}"></textarea><br />
  <input type="submit" name="insert" value="{$_btn_insert}" />
 </div>
</form>
EOD;
    return $string;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:32,代码来源:insert.inc.php

示例3: count_files

function count_files($no = 0, $pref = '')
{
    // 0:DATA, 1:TB, 2:Referer, 3: DIFF, 4:BKUP, 5:CTR
    static $dir = array(DATA_DIR, TRACKBACK_DIR, REFERER_DIR, DIFF_DIR, BACKUP_DIR, COUNTER_DIR);
    static $ext = array('.txt', '.txt', '.ref', '.txt', BACKUP_EXT, '.count');
    // コンテンツ管理者以上は、全てのファイルを対象にする
    if (!auth::check_role('role_adm_contents')) {
        $pages = get_existpages($dir[$no], $ext[$no]);
    } else {
        // 自分が閲覧できるページ数のみ戻す
        $pages = auth::get_existpages($dir[$no], $ext[$no]);
    }
    // 条件なし
    if (empty($pref)) {
        return count($pages);
    }
    // 指定文書のカウント
    $i = 0;
    foreach ($pages as $page) {
        if (strpos($page, $pref) === 0) {
            $i++;
        }
    }
    return $i;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:25,代码来源:count.inc.php

示例4: plugin_newpage_action

function plugin_newpage_action()
{
    global $vars;
    $_btn_edit = _('Edit');
    $_msg_newpage = _('New page');
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (auth::check_role('readonly')) {
        die_message(_('PKWK_READONLY prohibits editing'));
    }
    if (auth::is_check_role(PKWK_CREATE_PAGE)) {
        die_message(_('PKWK_CREATE_PAGE prohibits editing'));
    }
    if ($vars['page'] == '') {
        $retvars['msg'] = $_msg_newpage;
        $retvars['body'] = plugin_newpage_convert();
        return $retvars;
    } else {
        $page = strip_bracket($vars['page']);
        if (isset($vars['refer'])) {
            $r_page = get_fullname($page, $vars['refer']);
            $r_refer = 'refer=' . $vars['refer'];
        } else {
            $r_page = $page;
            $r_refer = '';
        }
        pkwk_headers_sent();
        header('Location: ' . get_page_location_uri($r_page, $r_refer));
        exit;
    }
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:30,代码来源:newpage.inc.php

示例5: plugin_version_value

function plugin_version_value()
{
    //	if (PKWK_SAFE_MODE) return '';
    if (auth::check_role('safemode')) {
        return '';
    }
    return S_VERSION;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:8,代码来源:version.inc.php

示例6: plugin_read_action

function plugin_read_action()
{
    global $vars, $_title_invalidwn, $_msg_invalidiwn;
    $page = isset($vars['page']) ? $vars['page'] : '';
    if (is_page($page)) {
        // ページを表示
        check_readable($page, true, true);
        header_lastmod($page);
        return array('msg' => '', 'body' => '');
        // } else if (! PKWK_SAFE_MODE && is_interwiki($page)) {
    } else {
        if (!auth::check_role('safemode') && is_interwiki($page)) {
            return do_plugin_action('interwiki');
            // InterWikiNameを処理
        } else {
            if (is_pagename($page)) {
                $realpages = get_autoaliases($page);
                if (count($realpages) == 1) {
                    $realpage = $realpages[0];
                    if (is_page($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        header('Location: ' . get_page_location_uri($realpage));
                        return;
                    } elseif (is_url($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        header('Location: ' . $realpage);
                        return;
                    } elseif (is_interwiki($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        $vars['page'] = $realpage;
                        return do_plugin_action('interwiki');
                        // header('Location');
                    } else {
                        // 存在しない場合、直接編集フォームに飛ばす // To avoid infinite loop
                        header('Location: ' . get_location_uri('edit', $realpage));
                        return;
                    }
                } elseif (count($realpages) >= 2) {
                    $body = '<p>';
                    $body .= _('This pagename is an alias to') . '<br />';
                    $link = '';
                    foreach ($realpages as $realpage) {
                        $link .= '[[' . $realpage . '>' . $realpage . ']]&br;';
                    }
                    $body .= make_link($link);
                    $body .= '</p>';
                    return array('msg' => _('Redirect'), 'body' => $body);
                }
                $vars['cmd'] = 'edit';
                return do_plugin_action('edit');
                // 存在しないので、編集フォームを表示
            } else {
                // 無効なページ名
                return array('msg' => $_title_invalidwn, 'body' => str_replace('$1', htmlspecialchars($page), str_replace('$2', 'WikiName', $_msg_invalidiwn)));
            }
        }
    }
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:58,代码来源:read.inc.php

示例7: plugin_server_convert

function plugin_server_convert()
{
    // if (PKWK_SAFE_MODE) return ''; // Show nothing
    if (auth::check_role('safemode')) {
        return '';
    }
    // Show nothing
    return '<dl>' . "\n" . '<dt>Server Name</dt>' . '<dd>' . SERVER_NAME . '</dd>' . "\n" . '<dt>Server Software</dt>' . '<dd>' . SERVER_SOFTWARE . '</dd>' . "\n" . '<dt>Server Admin</dt>' . '<dd>' . '<a href="mailto:' . SERVER_ADMIN . '">' . SERVER_ADMIN . '</a></dd>' . "\n" . '</dl>' . "\n";
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:9,代码来源:server.inc.php

示例8: plugin_phpinfo_action

function plugin_phpinfo_action()
{
    // if (auth::check_role('role_adm_contents') return '';
    if (auth::check_role('role_adm')) {
        return '';
    }
    phpinfo();
    die;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:9,代码来源:phpinfo.inc.php

示例9: plugin_yetlist_action

function plugin_yetlist_action()
{
    //	global $_title_yetlist, $_err_notexist, $_symbol_noexists, $non_list;
    global $_symbol_noexists, $non_list, $whatsdeleted;
    $retval = array('msg' => _('List of pages which have not yet been created.'), 'body' => '');
    // Diff
    $pages = array_diff(auth::get_existpages(CACHE_DIR, '.ref'), auth::get_existpages());
    if (empty($pages)) {
        $retval['body'] = _('All pages have been created.');
        return $retval;
    }
    $empty = TRUE;
    // Load .ref files and Output
    $refer_regex = '/' . $non_list . '|^' . preg_quote($whatsdeleted, '/') . '$/S';
    asort($pages, SORT_STRING);
    foreach ($pages as $file => $page) {
        $refer = array();
        foreach (file(CACHE_DIR . $file) as $line) {
            list($_page) = explode("\t", rtrim($line));
            $refer[] = $_page;
        }
        // Diff
        $refer = array_diff($refer, preg_grep($refer_regex, $refer));
        if (!empty($refer)) {
            $empty = FALSE;
            $refer = array_unique($refer);
            sort($refer, SORT_STRING);
            $r_refer = '';
            $link_refs = array();
            foreach ($refer as $_refer) {
                $r_refer = rawurlencode($_refer);
                $link_refs[] = '<a href="' . get_page_uri($_refer) . '">' . htmlspecialchars($_refer) . '</a>';
            }
            $link_ref = join(' ', $link_refs);
            unset($link_refs);
            $s_page = htmlspecialchars($page);
            //			if (PKWK_READONLY) {
            if (auth::check_role('readonly')) {
                $href = $s_page;
            } else {
                // Dangling link
                $href = '<span class="noexists">' . $s_page . '<a href="' . get_cmd_uri('edit', $page, '', 'refer=' . $r_refer) . '">' . $_symbol_noexists . '</a></span>';
            }
            $retval['body'] .= '<li>' . $href . ' <em>(' . $link_ref . ')</em></li>' . "\n";
        }
    }
    if ($empty) {
        $retval['body'] = $_err_notexist;
        return $retval;
    }
    if ($retval['body'] != '') {
        $retval['body'] = '<ul>' . "\n" . $retval['body'] . '</ul>' . "\n";
    }
    return $retval;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:55,代码来源:yetlist.inc.php

示例10: plugin_stationary_action

function plugin_stationary_action()
{
    // See above
    // if (PKWK_SAFE_MODE || PKWK_READONLY)
    if (auth::check_role('safemode') || auth::check_role('readonly')) {
        die_message('PKWK_SAFE_MODE or PKWK_READONLY prohibits this');
    }
    $msg = 'Message';
    $body = 'Message body';
    return array('msg' => htmlspecialchars($msg), 'body' => htmlspecialchars($body));
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:11,代码来源:stationary.inc.php

示例11: plugin_add_action

function plugin_add_action()
{
    global $get, $post, $vars;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page);
    $get['add'] = $post['add'] = $vars['add'] = TRUE;
    return array('msg' => _("Add to \$1"), 'body' => '<ul>' . "\n" . ' <li>' . _('Two and the contents of an input are added for a new-line to the contents of a page of present addition.') . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, ''));
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:12,代码来源:add.inc.php

示例12: ref_save

function ref_save($page)
{
    global $referer, $use_spam_check;
    // if (PKWK_READONLY || ! $referer || empty($_SERVER['HTTP_REFERER'])) return TRUE;
    if (auth::check_role('readonly') || !$referer || empty($_SERVER['HTTP_REFERER'])) {
        return TRUE;
    }
    $url = $_SERVER['HTTP_REFERER'];
    // Validate URI (Ignore own)
    $parse_url = parse_url($url);
    if ($parse_url === FALSE || !isset($parse_url['host']) || $parse_url['host'] == $_SERVER['HTTP_HOST']) {
        return TRUE;
    }
    // Blocking SPAM
    if ($use_spam_check['referer'] && SpamCheck($parse_url['host'])) {
        return TRUE;
    }
    if (!is_dir(REFERER_DIR)) {
        die('No such directory: REFERER_DIR');
    }
    if (!is_writable(REFERER_DIR)) {
        die('Permission denied to write: REFERER_DIR');
    }
    // Update referer data
    if (ereg("[,\"\n\r]", $url)) {
        $url = '"' . str_replace('"', '""', $url) . '"';
    }
    $data = ref_get_data($page, 3);
    $d_url = rawurldecode($url);
    if (!isset($data[$d_url])) {
        $data[$d_url] = array('', UTIME, 0, $url, 1);
    }
    $data[$d_url][0] = UTIME;
    $data[$d_url][2]++;
    $filename = ref_get_filename($page);
    $fp = fopen($filename, 'w');
    if ($fp === FALSE) {
        return FALSE;
    }
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($data as $line) {
        $str = trim(join(',', $line));
        if ($str != '') {
            fwrite($fp, $str . "\n");
        }
    }
    @flock($fp, LOCK_UN);
    fclose($fp);
    return TRUE;
}
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:52,代码来源:referer.php

示例13: plugin_showrss_action

function plugin_showrss_action()
{
    // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibit this');
    if (auth::check_role('safemode')) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    $body = '';
    foreach (array('xml', 'mbstring') as $extension) {
        ${$extension} = extension_loaded($extension) ? '&color(green){Found};' : '&color(red){Not found};';
        $body .= '| ' . $extension . ' extension | ' . ${$extension} . ' |' . "\n";
    }
    return array('msg' => 'showrss_info', 'body' => convert_html($body));
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:13,代码来源:showrss.inc.php

示例14: plugin_code_action

function plugin_code_action()
{
    global $vars;
    global $_source_messages;
    // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this');
    if (auth::check_role('safemode')) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    $vars['refer'] = $vars['page'];
    if (!is_page($vars['page']) || !check_readable($vars['page'], false, false)) {
        return array('msg' => $_source_messages['msg_notfound'], 'body' => $_source_messages['err_notfound']);
    }
    return array('msg' => $_source_messages['msg_title'], 'body' => plugin_code_convert('pukiwiki', join('', get_source($vars['page'])) . "\n"));
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:14,代码来源:code.inc.php

示例15: plugin_freeze_action

function plugin_freeze_action()
{
    global $script, $vars, $function_freeze;
    $_title_isfreezed = _(' $1 has already been frozen');
    $_title_freezed = _(' $1 has been frozen.');
    $_title_freeze = _('Freeze  $1');
    $_msg_invalidpass = _('Invalid password.');
    $_msg_freezing = _('Please input the password for freezing.');
    $_btn_freeze = _('Freeze');
    $page = isset($vars['page']) ? $vars['page'] : '';
    if (!$function_freeze || is_cantedit($page) || !is_page($page)) {
        return array('msg' => '', 'body' => '');
    }
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $msg = $body = '';
    if (is_freeze($page)) {
        // Freezed already
        $msg =& $_title_isfreezed;
        $body = str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_isfreezed);
    } else {
        if (!auth::check_role('role_adm_contents') || $pass !== NULL && pkwk_login($pass)) {
            // Freeze
            $postdata = get_source($page);
            array_unshift($postdata, "#freeze\n");
            file_write(DATA_DIR, $page, join('', $postdata), TRUE);
            // Update
            is_freeze($page, TRUE);
            $vars['cmd'] = 'read';
            $msg =& $_title_freezed;
            $body = '';
        } else {
            // Show a freeze form
            $msg =& $_title_freeze;
            $s_page = htmlspecialchars($page);
            $body = $pass === NULL ? '' : "<p><strong>{$_msg_invalidpass}</strong></p>\n";
            $body .= <<<EOD
<p>{$_msg_freezing}</p>
<form action="{$script}" method="post">
 <div>
  <input type="hidden"   name="cmd"  value="freeze" />
  <input type="hidden"   name="page" value="{$s_page}" />
  <input type="password" name="pass" size="12" />
  <input type="submit"   name="ok"   value="{$_btn_freeze}" />
 </div>
</form>
EOD;
        }
    }
    return array('msg' => $msg, 'body' => $body);
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:50,代码来源:freeze.inc.php


注:本文中的auth::check_role方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。