本文整理汇总了PHP中auth_isadmin函数的典型用法代码示例。如果您正苦于以下问题:PHP auth_isadmin函数的具体用法?PHP auth_isadmin怎么用?PHP auth_isadmin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auth_isadmin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: credit_html_select_user
/**
* Get HTML component select all users
*
* @return string HTML component select
*/
function credit_html_select_user()
{
global $user_config;
if (auth_isadmin()) {
$admins = user_getallwithstatus(2);
$users = user_getallwithstatus(3);
}
$subusers = user_getsubuserbyuid($user_config['uid']);
if (count($admins) > 0) {
$option_user .= '<optgroup label="' . _('Administrators') . '">';
foreach ($admins as $admin) {
$option_user .= '<option value="' . $admin['uid'] . '">' . $admin['name'] . ' (' . $admin['username'] . ') - ' . _('Administrator') . '</option>';
}
$option_user .= '</optgroup>';
}
if (count($users) > 0) {
$option_user .= '<optgroup label="' . _('Users') . '">';
foreach ($users as $user) {
$option_user .= '<option value="' . $user['uid'] . '">' . $user['name'] . ' (' . $user['username'] . ') - ' . _('User') . '</option>';
}
$option_user .= '</optgroup>';
}
if (count($subusers) > 0) {
$option_user .= '<optgroup label="' . _('Subusers') . '">';
foreach ($subusers as $subuser) {
$option_user .= '<option value="' . $subuser['uid'] . '">' . $subuser['name'] . ' (' . $subuser['username'] . ') - ' . _('Subuser') . '</option>';
}
$option_user .= '</optgroup>';
}
$select_user = '<select multiple name="uids[]" id="playsms-credit-select-user">' . $option_user . '</select>';
return $select_user;
}
示例2: siteexport_add_page_export
function siteexport_add_page_export(&$event)
{
global $ID;
if ($this->getConf('allowallusers') || auth_isadmin() || auth_ismanager()) {
$event->data['items'][] = '<li>' . tpl_link(wl($ID, array('do' => 'siteexport_addpage')), '<span>Export Page</span>', 'class="action siteexport_addpage" title="Add page"', 1) . '</li>';
}
}
示例3: info
/**
* Create the detail info for a single plugin
*
* @param Doku_Event $event
* @param $param
*/
public function info(Doku_Event &$event, $param)
{
global $USERINFO;
global $INPUT;
if ($event->data != 'plugin_extension') {
return;
}
$event->preventDefault();
$event->stopPropagation();
if (empty($_SERVER['REMOTE_USER']) || !auth_isadmin($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
http_status(403);
echo 'Forbidden';
exit;
}
header('Content-Type: text/html; charset=utf-8');
$ext = $INPUT->str('ext');
if (!$ext) {
echo 'no extension given';
return;
}
/** @var helper_plugin_extension_extension $extension */
$extension = plugin_load('helper', 'extension_extension');
$extension->setExtension($ext);
/** @var helper_plugin_extension_list $list */
$list = plugin_load('helper', 'extension_list');
echo $list->make_info($extension);
}
示例4: piwik_code
/**
* Injects the necessary trackingcodes for piwik tracking (v2.x) into DOM
* like specified in the plugin manager fields
*/
function piwik_code()
{
global $conf;
if (isset($conf['plugin']['piwik2']['js_tracking_code'])
|| (isset($conf['plugin']['piwik2']['img_tracking_code']))
) {
// Config does not contain keys if they are default;
// so check whether they are set & to non-default value
// default 0, so check if it's not set or 0
if (!isset($conf['plugin']['piwik2']['track_admin_user']) || $conf['plugin']['piwik2']['track_admin_user'] == 0) {
if (isset($_SERVER['REMOTE_USER']) && auth_isadmin()) { return; }
}
// default 1, so check if it's set and 0
if (isset($conf['plugin']['piwik2']['track_user']) && $conf['plugin']['piwik2']['track_user'] == 0) {
if (isset($_SERVER['REMOTE_USER'])) { return; }
}
//changes made by Marcel Lange (info@bravehartk2.de)
$trackingCode = (isset($conf['plugin']['piwik2']['js_tracking_code']))? $conf['plugin']['piwik2']['js_tracking_code'] : '';
if(isset($conf['plugin']['piwik2']['use_img_tracking']) && $conf['plugin']['piwik2']['use_img_tracking'] == 1 && isset($conf['plugin']['piwik2']['img_tracking_code'])){
$trackingCode = $conf['plugin']['piwik2']['img_tracking_code'];
}
ptln($trackingCode);
} else {
// Show configuration tip for admin
if (isset($_SERVER['REMOTE_USER']) && auth_isadmin()) {
msg('Please configure the piwik2 plugin');
}
}
}
示例5: doDownload
public function doDownload($filename)
{
if (!auth_isadmin()) {
throw new Exception('you must have AUTH_ADMIN permissions to download backup');
}
Backup::downloadFile($filename);
}
示例6: delAcl
/**
* Remove an entry from ACL config
*
* @param string $scope
* @param string $user
* @throws RemoteAccessDeniedException
* @return bool
*/
public function delAcl($scope, $user)
{
if (!auth_isadmin()) {
throw new RemoteAccessDeniedException('You are not allowed to access ACLs, superuser permission is required', 114);
}
/** @var admin_plugin_acl $apa */
$apa = plugin_load('admin', 'acl');
return $apa->_acl_del($scope, $user);
}
示例7: handle_header
/**
* Adds the preview parameter to the stylesheet loading in non-js mode
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_header(Doku_Event &$event, $param)
{
global $ACT;
global $INPUT;
if ($ACT != 'admin' || $INPUT->str('page') != 'styling') {
return;
}
if (!auth_isadmin()) {
return;
}
// set preview
$len = count($event->data['link']);
for ($i = 0; $i < $len; $i++) {
if ($event->data['link'][$i]['rel'] == 'stylesheet' && strpos($event->data['link'][$i]['href'], 'lib/exe/css.php') !== false) {
$event->data['link'][$i]['href'] .= '&preview=1&tseed=' . time();
}
}
}
示例8: info
/**
* Create the detail info for a single plugin
*
* @param Doku_Event $event
* @param $param
*/
public function info(Doku_Event &$event, $param)
{
global $USERINFO;
global $INPUT;
if ($event->data != 'plugin_extension') {
return;
}
$event->preventDefault();
$event->stopPropagation();
if (empty($_SERVER['REMOTE_USER']) || !auth_isadmin($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
http_status(403);
echo 'Forbidden';
exit;
}
$ext = $INPUT->str('ext');
if (!$ext) {
http_status(400);
echo 'no extension given';
return;
}
/** @var helper_plugin_extension_extension $extension */
$extension = plugin_load('helper', 'extension_extension');
$extension->setExtension($ext);
$act = $INPUT->str('act');
switch ($act) {
case 'enable':
case 'disable':
$json = new JSON();
$extension->{$act}();
//enables/disables
$reverse = $act == 'disable' ? 'enable' : 'disable';
$return = array('state' => $act . 'd', 'reverse' => $reverse, 'label' => $extension->getLang('btn_' . $reverse));
header('Content-Type: application/json');
echo $json->encode($return);
break;
case 'info':
default:
/** @var helper_plugin_extension_list $list */
$list = plugin_load('helper', 'extension_list');
header('Content-Type: text/html; charset=utf-8');
echo $list->make_info($extension);
}
}
示例9: handle_ajax_call_acl
/**
* AJAX call handler for ACL plugin
*
* @param Doku_Event $event event object by reference
* @param mixed $param empty
* @return void
*/
public function handle_ajax_call_acl(Doku_Event &$event, $param)
{
if ($event->data !== 'plugin_acl') {
return;
}
$event->stopPropagation();
$event->preventDefault();
global $ID;
global $INPUT;
if (!auth_isadmin()) {
echo 'for admins only';
return;
}
if (!checkSecurityToken()) {
echo 'CRSF Attack';
return;
}
$ID = getID();
/** @var $acl admin_plugin_acl */
$acl = plugin_load('admin', 'acl');
$acl->handle();
$ajax = $INPUT->str('ajax');
header('Content-Type: text/html; charset=utf-8');
if ($ajax == 'info') {
$acl->_html_info();
} elseif ($ajax == 'tree') {
$ns = $INPUT->str('ns');
if ($ns == '*') {
$ns = '';
}
$ns = cleanID($ns);
$lvl = count(explode(':', $ns));
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = $acl->_get_tree($ns, $ns);
foreach (array_keys($data) as $item) {
$data[$item]['level'] = $lvl + 1;
}
echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), array($acl, '_html_li_acl'));
}
}
示例10: defined
<?php
defined('_SECURE_') or die('Forbidden');
// sms_command bin path should be secured from unwanted access
$plugin_config['sms_command']['bin'] = '/var/lib/playsms/sms_command';
// set to TRUE will allow regular users in playSMS to access this feature
// since 1.0 by default its FALSE (read: https://github.com/antonraharja/playSMS/pull/146)
$plugin_config['sms_command']['allow_user_access'] = FALSE;
if (auth_isadmin() || $plugin_config['sms_command']['allow_user_access']) {
// insert to left menu array
$menutab = $core_config['menutab']['features'];
$menu_config[$menutab][] = array("index.php?app=main&inc=feature_sms_command&op=sms_command_list", _('Manage command'));
}
示例11: header
}
header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $_REQUEST['id']));
exit;
break;
case "toggle_status":
$search = array('id' => $_REQUEST['id'], 'registry_family' => 'sender_id');
foreach (registry_search_record($search) as $row) {
$status = $row['registry_value'] == 0 ? 1 : 0;
$items[$row['registry_key']] = $status;
registry_update($row['uid'], 'features', 'sender_id', $items);
}
$_SESSION['dialog']['info'][] = ($status == 1 ? _('Sender ID is now approved') : _('Sender ID is now disabled')) . ' (' . _('Sender ID') . ': ' . $row['registry_key'] . ')';
header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_list'));
exit;
break;
case "sender_id_delete":
$nav = themes_nav_session();
$search = themes_search_session();
$ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
$uid = auth_isadmin() && $data_sender_id[0]['uid'] ? $data_sender_id[0]['uid'] : $user_config['uid'];
registry_remove($uid, 'features', 'sender_id', $data_sender_id[0]['registry_key']);
registry_remove($uid, 'features', 'sender_id_description', $data_sender_id[0]['registry_key']);
$default_sender_id = sender_id_default_get($uid);
if (strtoupper($data_sender_id[0]['registry_key']) == strtoupper($default_sender_id)) {
sender_id_default_set($data_sender_id[0]['uid'], '');
}
$_SESSION['dialog']['info'][] = _('Sender ID has been removed') . ' (' . _('Sender ID') . ': ' . $data_sender_id[0]['registry_key'] . ')';
header("Location: " . _u($ref));
exit;
break;
}
示例12: sender_id_update
/**
* Update sender ID
*
* @param integer $uid
* User ID
* @param string $sender_id
* Sender ID
* @param string $sender_id_description
* Sender ID description
* @param integer $isdefault
* Flag 1 for default sender ID
* @param integer $isapproved
* Flag 1 for approved sender ID
* @return boolean TRUE when new sender ID has been updated
*/
function sender_id_update($uid, $sender_id, $sender_id_description = '', $isdefault = '_', $isapproved = '_')
{
global $user_config;
if (sender_id_check($uid, $sender_id)) {
$default = '_';
if ($isdefault !== '_') {
$default = (int) $isdefault ? 1 : 0;
}
if ($isapproved !== '_') {
if (auth_isadmin()) {
$approved = (int) $isapproved ? 1 : 0;
$data_sender_id = array($sender_id => $approved);
}
}
$sender_id_description = trim($sender_id_description) ? trim($sender_id_description) : $sender_id;
$data_description = array($sender_id => $sender_id_description);
$uid = auth_isadmin() && $uid ? $uid : $user_config['uid'];
if ($uid) {
if ($data_sender_id) {
registry_update($uid, 'features', 'sender_id', $data_sender_id);
}
registry_update($uid, 'features', 'sender_id_desc', $data_description);
} else {
// unknown error
return FALSE;
}
// set default
if ($default !== '_') {
if (auth_isadmin() && $default && $approved) {
// set default if isadmin, default and approved
sender_id_default_set($uid, $sender_id);
} else {
// set to empty (remove default)
sender_id_default_set($uid, '');
}
}
return TRUE;
} else {
// not found
return FALSE;
}
}
示例13: dba_count
$keywords = $search['dba_keywords'];
$count = dba_count(_DB_PREF_ . '_tblUser', $conditions, $keywords);
$nav = themes_nav($count, "index.php?app=main&inc=core_user&route=subuser_mgmnt&op=subuser_list");
$extras = array('ORDER BY' => 'register_datetime DESC, username', 'LIMIT' => $nav['limit'], 'OFFSET' => $nav['offset']);
$list = dba_search(_DB_PREF_ . '_tblUser', '*', $conditions, $keywords, $extras);
if ($err = $_SESSION['error_string']) {
$content = "<div class=error_string>{$err}</div>";
}
$content .= "\n\t\t\t<h2>" . _('Manage subuser') . "</h2>\n\t\t\t<h3>" . _('List of subusers') . "</h3>\n\t\t\t<p>" . $search['form'] . "</p>\t\t\t\n\t\t\t<div class=actions_box>\n\t\t\t\t<div class=pull-left>\n\t\t\t\t\t<a href=\"" . _u('index.php?app=main&inc=core_user&route=subuser_mgmnt&op=subuser_add') . "\">" . $icon_config['add'] . "</a>\n\t\t\t\t</div>\n\t\t\t\t<div class=pull-right>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=table-responsive>\n\t\t\t<table class=playsms-table-list>\n\t\t\t<thead><tr>\n\t\t\t\t<th width='20%'>" . _('Registered') . "</th>\n\t\t\t\t<th width='15%'>" . _('Username') . "</th>\n\t\t\t\t<th width='20%'>" . _('Name') . "</th>\n\t\t\t\t<th width='15%'>" . _('Mobile') . "</th>\n\t\t\t\t<th width='15%'>" . _('Credit') . "</th>\n\t\t\t\t<th width='15%'>" . _('Action') . "</th>\n\t\t\t</tr></thead>\n\t\t\t<tbody>";
$j = $nav['top'];
for ($i = 0; $i < count($list); $i++) {
$action = "";
// login as
if ($list[$i]['uid'] != $user_config['uid']) {
$main_config = $core_config['main'];
if (!$main_config['disable_login_as'] || auth_isadmin()) {
$action = "<a href=\"" . _u('index.php?app=main&inc=core_user&route=subuser_mgmnt&op=login_as&uname=' . $list[$i]['username']) . "\">" . $icon_config['login_as'] . "</a>";
}
}
// subuser preferences
$action .= "<a href=\"" . _u('index.php?app=main&inc=core_user&route=user_pref&op=user_pref&uname=' . $list[$i]['username']) . "\">" . $icon_config['user_pref'] . "</a>";
// subuser configurations
$action .= "<a href=\"" . _u('index.php?app=main&inc=core_user&route=user_config&op=user_config&uname=' . $list[$i]['username']) . "\">" . $icon_config['user_config'] . "</a>";
if ($list[$i]['uid'] != '1' || $list[$i]['uid'] != $user_config['uid']) {
if (user_banned_get($list[$i]['uid'])) {
// unban
$action .= "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to unban subuser")) . " " . $list[$i]['username'] . " ?','" . _u('index.php?app=main&inc=core_user&route=subuser_mgmnt&op=subuser_unban&uname=' . $list[$i]['username']) . "')\">" . $icon_config['unban'] . "</a>";
$banned_icon = $icon_config['ban'];
} else {
// ban
$action .= "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to ban subuser")) . " " . $list[$i]['username'] . " ?','" . _u('index.php?app=main&inc=core_user&route=subuser_mgmnt&op=subuser_ban&uname=' . $list[$i]['username']) . "')\">" . $icon_config['ban'] . "</a>";
示例14: auth_aclcheck
/**
* Returns the maximum rights a user has for
* the given ID or its namespace
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $id page ID
* @param string $user Username
* @param array $groups Array of groups the user is in
* @return int permission level
*/
function auth_aclcheck($id, $user, $groups)
{
global $conf;
global $AUTH_ACL;
// if no ACL is used always return upload rights
if (!$conf['useacl']) {
return AUTH_UPLOAD;
}
//make sure groups is an array
if (!is_array($groups)) {
$groups = array();
}
//if user is superuser or in superusergroup return 255 (acl_admin)
if (auth_isadmin($user, $groups)) {
return AUTH_ADMIN;
}
$user = auth_nameencode($user);
//prepend groups with @ and nameencode
$cnt = count($groups);
for ($i = 0; $i < $cnt; $i++) {
$groups[$i] = '@' . auth_nameencode($groups[$i]);
}
$ns = getNS($id);
$perm = -1;
if ($user || count($groups)) {
//add ALL group
$groups[] = '@ALL';
//add User
if ($user) {
$groups[] = $user;
}
//build regexp
$regexp = join('|', $groups);
} else {
$regexp = '@ALL';
}
//check exact match first
$matches = preg_grep('/^' . preg_quote($id, '/') . '\\s+(' . $regexp . ')\\s+/', $AUTH_ACL);
if (count($matches)) {
foreach ($matches as $match) {
$match = preg_replace('/#.*$/', '', $match);
//ignore comments
$acl = preg_split('/\\s+/', $match);
if ($acl[2] > AUTH_DELETE) {
$acl[2] = AUTH_DELETE;
}
//no admins in the ACL!
if ($acl[2] > $perm) {
$perm = $acl[2];
}
}
if ($perm > -1) {
//we had a match - return it
return $perm;
}
}
//still here? do the namespace checks
if ($ns) {
$path = $ns . ':\\*';
} else {
$path = '\\*';
//root document
}
do {
$matches = preg_grep('/^' . $path . '\\s+(' . $regexp . ')\\s+/', $AUTH_ACL);
if (count($matches)) {
foreach ($matches as $match) {
$match = preg_replace('/#.*$/', '', $match);
//ignore comments
$acl = preg_split('/\\s+/', $match);
if ($acl[2] > AUTH_DELETE) {
$acl[2] = AUTH_DELETE;
}
//no admins in the ACL!
if ($acl[2] > $perm) {
$perm = $acl[2];
}
}
//we had a match - return it
return $perm;
}
//get next higher namespace
$ns = getNS($ns);
if ($path != '\\*') {
$path = $ns . ':\\*';
if ($path == ':\\*') {
$path = '\\*';
}
} else {
//.........这里部分代码省略.........
示例15: isAuthorized
/**
* Checks if current user is authorized according to given rule.
*
* The rule is a comma-separated list of usernames and groups (after
* preceeding @ character), e.g.
*
* admin,@user
*
* authorizing user admin and every user in group "user".
*
* @param string $rule rule describing authorizations
* @return boolean true if current user is authorized, false otherwise
*/
protected function isAuthorized($rule)
{
global $USERINFO;
if (auth_isadmin()) {
return true;
}
if ($rule) {
$granted = true;
foreach (explode(',', $rule) as $role) {
$role = trim($role);
if ($role === '') {
continue;
}
if (!strcasecmp($role, '@ALL')) {
return true;
}
if (!strcasecmp($role, '@NONE')) {
return false;
}
if ($_SERVER['REMOTE_USER']) {
if ($role[0] == '!') {
$role = substr($role, 1);
$match = false;
} else {
$match = true;
}
if ($role[0] == '@') {
if (in_array(substr($role, 1), $USERINFO['grps'])) {
if ($match && $granted) {
return true;
}
if (!$match) {
$granted = false;
}
}
} else {
if ($role == $_SERVER['REMOTE_USER']) {
if ($match && $granted) {
return true;
}
if (!$match) {
$granted = false;
}
}
}
}
}
}
return false;
}