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


PHP user_permissions函数代码示例

本文整理汇总了PHP中user_permissions函数的典型用法代码示例。如果您正苦于以下问题:PHP user_permissions函数的具体用法?PHP user_permissions怎么用?PHP user_permissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: modcp_can_manage_user

/**
 * Check if the current user has permission to perform a ModCP action on another user
 *
 * @param int The user ID to perform the action on.
 * @param int the moderators user ID
 * @return boolean True if the user has necessary permissions
 */
function modcp_can_manage_user($uid)
{
    global $mybb;
    $user_permissions = user_permissions($uid);
    // Current user is only a local moderator or use with ModCP permissions, cannot manage super mods or admins
    if ($mybb->usergroup['issupermod'] == 0 && ($user_permissions['issupermod'] == 1 || $user_permissions['cancp'] == 1)) {
        return false;
    } else {
        if ($user_permissions['cancp'] == 1 && ($mybb->usergroup['cancp'] != 1 || is_super_admin($uid) && !is_super_admin($mybb->user['uid']))) {
            return false;
        }
    }
    return true;
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:21,代码来源:functions_modcp.php

示例2: automedia_flv

function automedia_flv($message)
{
    global $mybb, $db, $post, $postrow, $pmid, $memprofile, $width, $height;
    /**
     *Example:
     *www.gugelproductions.de/blog/wp-content/fltest.flv
    */
    if (preg_match('<a href=\\"(http://)?(www.)?(.*)\\.flv\\">isU', $message)) {
        if (THIS_SCRIPT == "private.php") {
            $priv = intval($pmid);
            $query = $db->simple_select("privatemessages", "fromid", "pmid='{$priv}'");
            $privuid = $db->fetch_array($query);
            $puid = intval($privuid['fromid']);
        } else {
            if (THIS_SCRIPT == "usercp.php") {
                $puid = intval($mybb->user['uid']);
            } else {
                if (THIS_SCRIPT == "member.php") {
                    $puid = intval($memprofile['uid']);
                } else {
                    if (THIS_SCRIPT == "printthread.php") {
                        $puid = intval($postrow['uid']);
                    } else {
                        $puid = intval($post['uid']);
                    }
                }
            }
        }
        //Get the posters usergroup
        $permissions = user_permissions($puid);
        switch ($mybb->settings['av_flashadmin']) {
            case "admin":
                if ($permissions['cancp'] == 1) {
                    $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.flv)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object id=\"flowplayer\" width=\"{$width}\" height=\"{$height}\" data=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" type=\"application/x-shockwave-flash\"><param name=\"movie\" value=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value='config={\"clip\":{\"url\":\"\$2\$3\$4/\$5\",\"autoPlay\":false}}' /></object></div>", $message);
                }
                break;
            case "mods":
                if ($permissions['cancp'] == 1 || $permissions['canmodcp'] == 1) {
                    $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.flv)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object id=\"flowplayer\" width=\"{$width}\" height=\"{$height}\" data=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" type=\"application/x-shockwave-flash\"><param name=\"movie\" value=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value='config={\"clip\":{\"url\":\"\$2\$3\$4/\$5\",\"autoPlay\":false}}' /></object></div>", $message);
                }
                break;
            case "all":
                $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.flv)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object id=\"flowplayer\" width=\"{$width}\" height=\"{$height}\" data=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" type=\"application/x-shockwave-flash\"><param name=\"movie\" value=\"{$mybb->settings['bburl']}/inc/plugins/automedia/mediaplayer/flowplayer-3.2.7.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value='config={\"clip\":{\"url\":\"\$2\$3\$4/\$5\",\"autoPlay\":false}}' /></object></div>", $message);
                break;
        }
    }
    return $message;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:48,代码来源:flv.php

示例3: automedia_swf

function automedia_swf($message)
{
    global $mybb, $db, $post, $postrow, $pmid, $memprofile, $width, $height;
    /**
     *Example:
     *http://www.arcadecabin.com/games/crazy-taxi.swf
    */
    if (preg_match('<a href=\\"(http://)?(www.)?(.*)\\.swf\\">isU', $message)) {
        if (THIS_SCRIPT == "private.php") {
            $priv = intval($pmid);
            $query = $db->simple_select("privatemessages", "fromid", "pmid='{$priv}'");
            $privuid = $db->fetch_array($query);
            $puid = intval($privuid['fromid']);
        } else {
            if (THIS_SCRIPT == "usercp.php") {
                $puid = intval($mybb->user['uid']);
            } else {
                if (THIS_SCRIPT == "member.php") {
                    $puid = intval($memprofile['uid']);
                } else {
                    if (THIS_SCRIPT == "printthread.php") {
                        $puid = intval($postrow['uid']);
                    } else {
                        $puid = intval($post['uid']);
                    }
                }
            }
        }
        //Get the posters usergroup
        $permissions = user_permissions($puid);
        switch ($mybb->settings['av_flashadmin']) {
            case "admin":
                if ($permissions['cancp'] == 1) {
                    $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.swf)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"\$2\$3\$4/\$5\" /><param name=\"menu\" value=\"true\" /><param name=\"autostart\" value=\"0\" /><embed src=\"\$2\$3\$4/\$5\" width=\"{$width}\" height=\"{$height}\" type=\"application/x-shockwave-flash\" menu=\"false\" autostart=\"false\"></embed></object></div>", $message);
                }
                break;
            case "mods":
                if ($permissions['cancp'] == 1 || $permissions['canmodcp'] == 1) {
                    $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.swf)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"\$2\$3\$4/\$5\" /><param name=\"menu\" value=\"true\" /><param name=\"autostart\" value=\"0\" /><embed src=\"\$2\$3\$4/\$5\" width=\"{$width}\" height=\"{$height}\" type=\"application/x-shockwave-flash\" menu=\"false\" autostart=\"false\"></embed></object></div>", $message);
                }
                break;
            case "all":
                $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(www.)?(.*)/([\\w/ &;%\\.-]+\\.swf)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object classid=\"CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"\$2\$3\$4/\$5\" /><param name=\"menu\" value=\"true\" /><param name=\"autostart\" value=\"0\" /><embed src=\"\$2\$3\$4/\$5\" width=\"{$width}\" height=\"{$height}\" type=\"application/x-shockwave-flash\" menu=\"false\" autostart=\"false\"></embed></object></div>", $message);
                break;
        }
    }
    return $message;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:48,代码来源:swf.php

示例4: error

$plugins->run_hooks("reputation_start");
// Check if the reputation system is globally disabled or not.
if ($mybb->settings['enablereputation'] != 1) {
    error($lang->reputation_disabled);
}
// Does this user have permission to view the board?
if ($mybb->usergroup['canview'] != 1) {
    error_no_permission();
}
// If we have a specified incoming username, validate it and fetch permissions for it
$uid = $mybb->get_input('uid', MyBB::INPUT_INT);
$user = get_user($uid);
if (!$user) {
    error($lang->add_no_uid);
}
$user_permissions = user_permissions($uid);
$mybb->input['action'] = $mybb->get_input('action');
// Here we perform our validation when adding a reputation to see if the user
// has permission or not. This is done here to save duplicating the same code.
if ($mybb->input['action'] == "add" || $mybb->input['action'] == "do_add") {
    // This user doesn't have permission to give reputations.
    if ($mybb->usergroup['cangivereputations'] != 1) {
        $message = $lang->add_no_permission;
        if ($mybb->input['nomodal']) {
            eval("\$error = \"" . $templates->get("reputation_add_error_nomodal", 1, 0) . "\";");
        } else {
            eval("\$error = \"" . $templates->get("reputation_add_error", 1, 0) . "\";");
        }
        echo $error;
        exit;
    }
开发者ID:styv300,项目名称:ToRepublic2.5,代码行数:31,代码来源:reputation.php

示例5: verify_video_count

 /**
  * Verifies the video count.
  *
  * @return boolean True when valid, false when not valid.
  */
 function verify_video_count()
 {
     global $mybb, $db;
     $post =& $this->data;
     // Get the permissions of the user who is making this post or thread
     $permissions = user_permissions($post['uid']);
     // Check if this post contains more videos than the forum allows
     if ((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1) {
         // And count the number of video tags in the message.
         $video_count = substr_count($post['message'], "[video=");
         if ($video_count > $mybb->settings['maxpostvideos']) {
             // Throw back a message if over the count with the number of images as well as the maximum number of images per post.
             $this->set_error("too_many_videos", array(1 => $video_count, 2 => $mybb->settings['maxpostvideos']));
             return false;
         }
     }
 }
开发者ID:olada,项目名称:mybbintegrator,代码行数:22,代码来源:post.php

示例6: automedia_flash

 function automedia_flash()
 {
     global $mybb;
     // Get message for quick edit
     if ($mybb->input['do'] == "update_post") {
         $message = (string) $mybb->input['value'];
     } else {
         $message = $mybb->input['message'];
     }
     $permissions = user_permissions((int) $mybb->user['uid']);
     switch ($mybb->settings['av_flashadmin']) {
         case "admin":
             if ($permissions['cancp'] != 1) {
                 $message = preg_replace('#(http://)?(www.)?(.*)\\.flv#i', '[amoff]$1$2$3.flv[/amoff]', $message);
                 $message = preg_replace('#(http://)?(www.)?(.*)\\.swf#i', '[amoff]$1$2$3.swf[/amoff]', $message);
             }
             break;
         case "mods":
             if ($permissions['cancp'] != 1 && $permissions['canmodcp'] != 1) {
                 $message = preg_replace('#(http://)?(www.)?(.*)\\.flv#i', '[amoff]$1$2$3.flv[/amoff]', $message);
                 $message = preg_replace('#(http://)?(www.)?(.*)\\.swf#i', '[amoff]$1$2$3.swf[/amoff]', $message);
             }
             break;
     }
     return $message;
 }
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:26,代码来源:automedia_functions.php

示例7: get_user_info_func

function get_user_info_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $parser, $displaygroupfields;
    $lang->load("member");
    $input = Tapatalk_Input::filterXmlInput(array('user_name' => Tapatalk_Input::STRING, 'user_id' => Tapatalk_Input::INT), $xmlrpc_params);
    if ($mybb->usergroup['canviewprofiles'] == 0) {
        error_no_permission();
    }
    if (isset($input['user_id']) && !empty($input['user_id'])) {
        $uid = $input['user_id'];
    } elseif (!empty($input['user_name'])) {
        $query = $db->simple_select("users", "uid", "username='{$input['user_name_esc']}'");
        $uid = $db->fetch_field($query, "uid");
    } else {
        $uid = $mybb->user['uid'];
    }
    if ($mybb->user['uid'] != $uid) {
        $memprofile = get_user($uid);
    } else {
        $memprofile = $mybb->user;
    }
    if (!$memprofile['uid']) {
        error($lang->error_nomember);
    }
    // Get member's permissions
    $memperms = user_permissions($memprofile['uid']);
    if (!$memprofile['displaygroup']) {
        $memprofile['displaygroup'] = $memprofile['usergroup'];
    }
    // Grab the following fields from the user's displaygroup
    $displaygroupfields = array("title", "usertitle", "stars", "starimage", "image", "usereputationsystem");
    $displaygroup = usergroup_displaygroup($memprofile['displaygroup']);
    // Get the user title for this user
    unset($usertitle);
    unset($stars);
    if (trim($memprofile['usertitle']) != '') {
        // User has custom user title
        $usertitle = $memprofile['usertitle'];
    } elseif (trim($displaygroup['usertitle']) != '') {
        // User has group title
        $usertitle = $displaygroup['usertitle'];
    } else {
        // No usergroup title so get a default one
        $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
        while ($title = $db->fetch_array($query)) {
            if ($memprofile['postnum'] >= $title['posts']) {
                $usertitle = $title['title'];
                $stars = $title['stars'];
                $starimage = $title['starimage'];
                break;
            }
        }
    }
    // User is currently online and this user has permissions to view the user on the WOL
    $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
    $query = $db->simple_select("sessions", "location,nopermission", "uid='{$uid}' AND time>'{$timesearch}'", array('order_by' => 'time', 'order_dir' => 'DESC', 'limit' => 1));
    $session = $db->fetch_array($query);
    if (($memprofile['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $memprofile['uid'] == $mybb->user['uid']) && !empty($session)) {
        // Fetch their current location
        $lang->load("online");
        require_once MYBB_ROOT . "inc/functions_online.php";
        $activity = fetch_wol_activity($session['location'], $session['nopermission']);
        /*unset($activity['tid']);
          unset($activity['fid']);
          unset($activity['pid']);
          unset($activity['eid']);
          unset($activity['aid']);*/
        $location = strip_tags(build_friendly_wol_location($activity));
        $location_time = my_date($mybb->settings['timeformat'], $memprofile['lastactive']);
        $online = true;
    } else {
        $online = false;
    }
    // Get custom fields start
    $custom_fields_list = array();
    if ($memprofile['birthday']) {
        $membday = explode("-", $memprofile['birthday']);
        if ($memprofile['birthdayprivacy'] != 'none') {
            if ($membday[0] && $membday[1] && $membday[2]) {
                $lang->membdayage = $lang->sprintf($lang->membdayage, get_age($memprofile['birthday']));
                if ($membday[2] >= 1970) {
                    $w_day = date("l", mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]));
                    $membday = format_bdays($mybb->settings['dateformat'], $membday[1], $membday[0], $membday[2], $w_day);
                } else {
                    $bdayformat = fix_mktime($mybb->settings['dateformat'], $membday[2]);
                    $membday = mktime(0, 0, 0, $membday[1], $membday[0], $membday[2]);
                    $membday = date($bdayformat, $membday);
                }
                $membdayage = $lang->membdayage;
            } elseif ($membday[2]) {
                $membday = mktime(0, 0, 0, 1, 1, $membday[2]);
                $membday = date("Y", $membday);
                $membdayage = '';
            } else {
                $membday = mktime(0, 0, 0, $membday[1], $membday[0], 0);
                $membday = date("F j", $membday);
                $membdayage = '';
            }
        }
        if ($memprofile['birthdayprivacy'] == 'age') {
//.........这里部分代码省略.........
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:101,代码来源:get_user_info.php

示例8: ps_MakeTable

function ps_MakeTable()
{
    global $mybb, $db, $theme, $lang, $templates, $parser, $unviewables, $vcheck, $under_mod_forums_arr, $lightbulb, $unread_forums, $ps_align;
    $lang->load("prostats");
    $right_cols = $left_cols = $middle_cols = $extra_content = $extra_content_1_2 = $extra_content_3_4 = $extra_content_5_6 = $remote_msg = "";
    $num_columns = 3;
    $ps_align = $lang->settings['rtl'] ? "right" : "left";
    $ps_ralign = $lang->settings['rtl'] ? "left" : "right";
    //Highlighting under moderation posts
    $_psGU = ps_GetUnviewable("t");
    $unviewables = array('string' => $_psGU[0], 'array' => $_psGU[1]);
    $user_perms = user_permissions($mybb->user['uid']);
    if ($mybb->settings['ps_highlight']) {
        $_groups = $mybb->user['usergroup'];
        if (!empty($mybb->user['additionalgroups'])) {
            $_groups .= ",'{$mybb->user['additionalgroups']}'";
        }
        $_query1 = $db->simple_select("moderators", "*", "((id IN ({$_groups}) AND isgroup='1') OR (id='{$mybb->user['uid']}' AND isgroup='0'))");
        while ($results1 = $db->fetch_array($_query1)) {
            $parent_mod_forums[] = " parentlist LIKE '%" . $results1['fid'] . "%' ";
        }
        if (count($parent_mod_forums)) {
            $_query2 = $db->simple_select("forums", "fid", implode($parent_mod_forums, "OR"));
            while ($results2 = $db->fetch_array($_query2)) {
                $under_mod_forums_arr[] = $results2['fid'];
            }
            if (count($under_mod_forums_arr)) {
                $moderated_forums = implode($under_mod_forums_arr, ',');
                $vcheck = " OR t.fid IN (" . $moderated_forums . ") ";
            }
        }
    }
    if ($user_perms['issupermod'] == 1) {
        $vcheck = " OR '1'='1' ";
    }
    if ($mybb->settings['ps_latest_posts'] == 1) {
        $middle_cols = ps_GetNewestPosts($mybb->settings['ps_num_rows']);
        $num_columns = 4;
    }
    for ($i = 1; $i < 7; ++$i) {
        $extra_cell[$i] = $mybb->settings['ps_cell_' . $i];
    }
    $extra_row[1] = $extra_row[2] = $extra_row[3] = 2;
    $extra_cols = 3;
    if ($extra_cell[5] > 0) {
        $trow = "trow2";
        $extra_cols = 3;
        if ($extra_cell[6] == 0) {
            $extra_row[3] = 1;
            $single_extra_content = ps_GetExtraData($extra_cell[5], true);
            eval("\$extra_content_5_6 = \"" . $templates->get("prostats_onerowextra") . "\";");
        } else {
            $extra_content_one = ps_GetExtraData($extra_cell[5]);
            $extra_content_two = ps_GetExtraData($extra_cell[6]);
            eval("\$extra_content_5_6 = \"" . $templates->get("prostats_tworowextra") . "\";");
        }
    }
    if ($extra_cell[3] > 0) {
        $trow = "trow1";
        $extra_cols = 2;
        if ($extra_cell[4] == 0) {
            $extra_row[2] = 1;
            $single_extra_content = ps_GetExtraData($extra_cell[3], true);
            eval("\$extra_content_3_4 = \"" . $templates->get("prostats_onerowextra") . "\";");
        } else {
            $extra_content_one = ps_GetExtraData($extra_cell[3]);
            $extra_content_two = ps_GetExtraData($extra_cell[4]);
            eval("\$extra_content_3_4 = \"" . $templates->get("prostats_tworowextra") . "\";");
        }
    }
    if ($extra_cell[1] > 0) {
        $trow = "trow2";
        $extra_cols = 1;
        if ($extra_cell[2] == 0) {
            $extra_row[1] = 1;
            $single_extra_content = ps_GetExtraData($extra_cell[1], true);
            eval("\$extra_content_1_2 = \"" . $templates->get("prostats_onerowextra") . "\";");
        } else {
            $extra_content_one = ps_GetExtraData($extra_cell[1]);
            $extra_content_two = ps_GetExtraData($extra_cell[2]);
            eval("\$extra_content_1_2 = \"" . $templates->get("prostats_tworowextra") . "\";");
        }
    }
    if ($lang->settings['rtl']) {
        $extra_content = $extra_content_5_6 . $extra_content_3_4 . $extra_content_1_2;
        $mybb->settings['ps_latest_posts_pos'] ? $right_cols = $extra_content : ($left_cols = $extra_content);
    } else {
        $extra_content = $extra_content_1_2 . $extra_content_3_4 . $extra_content_5_6;
        $mybb->settings['ps_latest_posts_pos'] ? $left_cols = $extra_content : ($right_cols = $extra_content);
    }
    $prostats_content = $left_cols . $middle_cols . $right_cols;
    if ($mybb->settings['ps_trow_message'] != "") {
        $prostats_message = unhtmlentities(htmlspecialchars_uni($mybb->settings['ps_trow_message']));
        if ($mybb->settings['ps_trow_message_pos'] == 0) {
            eval("\$trow_message_top = \"" . $templates->get("prostats_message") . "\";");
        } else {
            eval("\$trow_message_down = \"" . $templates->get("prostats_message") . "\";");
        }
    }
    if ($mybb->settings['ps_surprise'] && $mybb->user['uid'] && $mybb->usergroup['cancp']) {
//.........这里部分代码省略.........
开发者ID:Sama34,项目名称:ProStats,代码行数:101,代码来源:prostats.php

示例9: accountswitcher_usercp


//.........这里部分代码省略.........
                        }
                    }
                    $as_usercp_users = eval($templates->render('accountswitcher_usercp_attached_users'));
                }
            }
        }
        $as_usercp = eval($templates->render('accountswitcher_usercp'));
        output_page($as_usercp);
        exit;
    }
    //########## ACTIONS ##########
    // Attach current user to another account
    if ($mybb->input['action'] == "as_attach" && $mybb->input['select'] == "attachme" && $mybb->request_method == "post") {
        verify_post_check($mybb->get_input('my_post_key'));
        // Check if current user is already attached
        if ($mybb->user['as_uid'] != 0) {
            error($lang->as_alreadyattached);
        }
        // Validate input
        $select = $db->escape_string($mybb->get_input('select'));
        $username = $db->escape_string($mybb->get_input('username'));
        $password = $db->escape_string($mybb->get_input('password'));
        // Get the target
        $targetUser = get_user_by_username($username);
        $target = get_user($targetUser['uid']);
        // User exist? Password correct?
        if (!$target) {
            error($lang->as_invaliduser);
        }
        if (validate_password_from_uid($target['uid'], $password) == false) {
            error($lang->as_invaliduser);
        }
        // Check targets permission and limit
        $permission = user_permissions((int) $target['uid']);
        // Count number of attached accounts
        $count = $eas->get_attached($target['uid']);
        // If other user is shared or already attached return
        if ($target['as_uid'] != 0 || $target['as_share'] != 0) {
            error($lang->as_alreadyattached);
        }
        // If target has permission
        if ($permission['as_canswitch'] == 0) {
            error($lang->as_usercp_nopermission);
        }
        if ($permission['as_limit'] != 0 && $count == $permission['as_limit']) {
            error($lang->as_limitreached);
        }
        // Set uid of the new master
        $as_uid = array("as_uid" => (int) $target['uid']);
        // Update database
        $db->update_query("users", $as_uid, "uid='" . (int) $mybb->user['uid'] . "'");
        $eas->update_accountswitcher_cache();
        redirect("usercp.php?action=as_edit", $lang->aj_attach_success);
    }
    // Detach current user from master
    if ($mybb->input['action'] == "as_detach" && $mybb->request_method == "post") {
        verify_post_check($mybb->get_input('my_post_key'));
        // Reset master uid
        $as_uid = array("as_uid" => 0);
        // Update database
        if ($db->update_query("users", $as_uid, "uid='" . (int) $mybb->user['uid'] . "'")) {
            $eas->update_accountswitcher_cache();
            // If user can use Enhanced Account Switcher stay here
            if ($mybb->usergroup['as_canswitch'] == 1) {
                redirect("usercp.php?action=as_edit", $lang->aj_update_success);
            }
开发者ID:ambsalinas,项目名称:anima,代码行数:67,代码来源:as_usercp.php

示例10: get_user

 }
 $uid = $mybb->get_input('uid', MyBB::INPUT_INT);
 if ($uid) {
     $memprofile = get_user($uid);
 } elseif ($mybb->user['uid']) {
     $memprofile = $mybb->user;
 } else {
     $memprofile = false;
 }
 if (!$memprofile) {
     error($lang->error_nomember);
 }
 $uid = $memprofile['uid'];
 $lang->profile = $lang->sprintf($lang->profile, $memprofile['username']);
 // Get member's permissions
 $memperms = user_permissions($memprofile['uid']);
 $lang->nav_profile = $lang->sprintf($lang->nav_profile, $memprofile['username']);
 add_breadcrumb($lang->nav_profile);
 $lang->users_forum_info = $lang->sprintf($lang->users_forum_info, $memprofile['username']);
 $lang->users_contact_details = $lang->sprintf($lang->users_contact_details, $memprofile['username']);
 if ($mybb->settings['enablepms'] != 0 && ($memprofile['receivepms'] != 0 && $memperms['canusepms'] != 0 && my_strpos("," . $memprofile['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false || $mybb->usergroup['canoverridepm'] == 1)) {
     $lang->send_pm = $lang->sprintf($lang->send_pm, $memprofile['username']);
 } else {
     $lang->send_pm = '';
 }
 $lang->away_note = $lang->sprintf($lang->away_note, $memprofile['username']);
 $lang->users_additional_info = $lang->sprintf($lang->users_additional_info, $memprofile['username']);
 $lang->users_signature = $lang->sprintf($lang->users_signature, $memprofile['username']);
 $lang->send_user_email = $lang->sprintf($lang->send_user_email, $memprofile['username']);
 $useravatar = format_avatar($memprofile['avatar'], $memprofile['avatardimensions']);
 eval("\$avatar = \"" . $templates->get("member_profile_avatar") . "\";");
开发者ID:nicopinto,项目名称:fantasitura.com,代码行数:31,代码来源:member.php

示例11: accountswitcher_pm_sent_alert

/**
 * Alert all attached accounts if one of them receives a new pm.
 *
 */
function accountswitcher_pm_sent_alert()
{
    global $mybb, $lang, $pm, $eas;
    if ($mybb->settings['aj_myalerts'] != 1 || !isset($mybb->settings['myalerts_perpage']) || $pm['saveasdraft'] == 1) {
        return;
    }
    if (!isset($lang->aj_newpm_switch_notice_one)) {
        $lang->load('accountswitcher');
    }
    // Get recipients
    if (is_array($pm['bcc'])) {
        $rec_users = array_merge($pm['to'], $pm['bcc']);
    } else {
        $rec_users = $pm['to'];
    }
    $pm_users = array_map("trim", $rec_users);
    // Alert Type
    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('accountswitcher_pm');
    $alerts = array();
    foreach ($pm_users as $recipient) {
        $count = 0;
        $pmuser = get_user_by_username($recipient);
        $user = get_user($pmuser['uid']);
        $accounts = $eas->accountswitcher_cache;
        if (is_array($accounts)) {
            // If recipient is master account send alerts to attached users
            foreach ($accounts as $key => $account) {
                if ($user['uid'] == $account['as_uid']) {
                    ++$count;
                    if ($count > 0) {
                        $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, 0);
                        $alert->setExtraDetails(array('uid' => (int) $user['uid'], 'message' => htmlspecialchars_uni($user['username'])));
                        $alerts[] = $alert;
                    }
                }
            }
        }
        // If there are no users attached to the current account but the current account is attached to another user
        if ($count == 0 && $user['as_uid'] != 0) {
            $master = get_user((int) $user['as_uid']);
            // Get the masters permission
            $permission = user_permissions($master['uid']);
            // If the master has permission to use the Enhanced Account Switcher, get the userlist
            if ($permission['as_canswitch'] == 1) {
                // If recipient is attached account, alert master account
                if ($master['uid'] == $user['as_uid']) {
                    $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $master['uid'], $alertType, 0);
                    $alert->setExtraDetails(array('uid' => (int) $user['uid'], 'message' => htmlspecialchars_uni($user['username'])));
                    $alerts[] = $alert;
                }
                if (is_array($accounts)) {
                    // If recipient has the same master account, send alert
                    foreach ($accounts as $key => $account) {
                        // Leave recipient out
                        if ($account['uid'] == $user['uid']) {
                            continue;
                        }
                        if ($master['uid'] == $account['as_uid']) {
                            $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, 0);
                            $alert->setExtraDetails(array('message' => htmlspecialchars_uni($user['username'])));
                            $alerts[] = $alert;
                        }
                    }
                }
            }
        }
        // If there are no users attached to the a recipient and the recipient isn't attached to another user
        if ($count == 0 && $user['as_uid'] == 0) {
            $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $user['uid'], $alertType, 0);
            $alert->setExtraDetails(array('message' => htmlspecialchars_uni($user['username'])));
            $alerts[] = $alert;
        }
        if (!empty($alerts)) {
            MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts);
        }
    }
}
开发者ID:ambsalinas,项目名称:anima,代码行数:81,代码来源:as_alerts.php

示例12: verify_recipient

 /**
  * Verifies if an array of recipients for a private message are valid
  *
  * @return boolean True when valid, false when invalid.
  */
 function verify_recipient()
 {
     global $cache, $db, $mybb, $lang;
     $pm =& $this->data;
     $recipients = array();
     $invalid_recipients = array();
     // We have our recipient usernames but need to fetch user IDs
     if (array_key_exists("to", $pm)) {
         foreach (array("to", "bcc") as $recipient_type) {
             if (!isset($pm[$recipient_type])) {
                 $pm[$recipient_type] = array();
             }
             if (!is_array($pm[$recipient_type])) {
                 $pm[$recipient_type] = array($pm[$recipient_type]);
             }
             $pm[$recipient_type] = array_map('trim', $pm[$recipient_type]);
             $pm[$recipient_type] = array_filter($pm[$recipient_type]);
             // No recipients? Skip query
             if (empty($pm[$recipient_type])) {
                 if ($recipient_type == 'to' && !$pm['saveasdraft']) {
                     $this->set_error("no_recipients");
                     return false;
                 }
                 continue;
             }
             $recipientUsernames = array_map(array($db, 'escape_string'), $pm[$recipient_type]);
             $recipientUsernames = "'" . implode("','", $recipientUsernames) . "'";
             $query = $db->simple_select('users', '*', 'username IN(' . $recipientUsernames . ')');
             $validUsernames = array();
             while ($user = $db->fetch_array($query)) {
                 if ($recipient_type == "bcc") {
                     $user['bcc'] = 1;
                 }
                 $recipients[] = $user;
                 $validUsernames[] = $user['username'];
             }
             foreach ($pm[$recipient_type] as $username) {
                 if (!in_array($username, $validUsernames)) {
                     $invalid_recipients[] = $username;
                 }
             }
         }
     } else {
         foreach (array("toid", "bccid") as $recipient_type) {
             if (!isset($pm[$recipient_type])) {
                 $pm[$recipient_type] = array();
             }
             if (!is_array($pm[$recipient_type])) {
                 $pm[$recipient_type] = array($pm[$recipient_type]);
             }
             $pm[$recipient_type] = array_map('intval', $pm[$recipient_type]);
             $pm[$recipient_type] = array_filter($pm[$recipient_type]);
             // No recipients? Skip query
             if (empty($pm[$recipient_type])) {
                 if ($recipient_type == 'toid' && !$pm['saveasdraft']) {
                     $this->set_error("no_recipients");
                     return false;
                 }
                 continue;
             }
             $recipientUids = "'" . implode("','", $pm[$recipient_type]) . "'";
             $query = $db->simple_select('users', '*', 'uid IN(' . $recipientUids . ')');
             $validUids = array();
             while ($user = $db->fetch_array($query)) {
                 if ($recipient_type == "bccid") {
                     $user['bcc'] = 1;
                 }
                 $recipients[] = $user;
                 $validUids[] = $user['uid'];
             }
             foreach ($pm[$recipient_type] as $uid) {
                 if (!in_array($uid, $validUids)) {
                     $invalid_recipients[] = $uid;
                 }
             }
         }
     }
     // If we have one or more invalid recipients and we're not saving a draft, error
     if (count($invalid_recipients) > 0) {
         $invalid_recipients = implode(", ", array_map("htmlspecialchars_uni", $invalid_recipients));
         $this->set_error("invalid_recipients", array($invalid_recipients));
         return false;
     }
     $sender_permissions = user_permissions($pm['fromid']);
     // Are we trying to send this message to more users than the permissions allow?
     if ($sender_permissions['maxpmrecipients'] > 0 && count($recipients) > $sender_permissions['maxpmrecipients'] && $this->admin_override != true) {
         $this->set_error("too_many_recipients", array($sender_permissions['maxpmrecipients']));
     }
     // Now we're done with that we loop through each recipient
     foreach ($recipients as $user) {
         // Collect group permissions for this recipient.
         $recipient_permissions = user_permissions($user['uid']);
         // See if the sender is on the recipients ignore list and that either
         // - admin_override is set or
         // - sender is an administrator
//.........这里部分代码省略.........
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:101,代码来源:pm.php

示例13: is_moderator

/**
 * Checks if a moderator has permissions to perform an action in a specific forum
 *
 * @param int The forum ID (0 assumes global)
 * @param string The action tyring to be performed. (blank assumes any action at all)
 * @param int The user ID (0 assumes current user)
 * @return bool Returns true if the user has permission, false if they do not
 */
function is_moderator($fid = "0", $action = "", $uid = "0")
{
    global $mybb, $cache;
    if ($uid == 0) {
        $uid = $mybb->user['uid'];
    }
    if ($uid == 0) {
        return false;
    }
    $user_perms = user_permissions($uid);
    if ($user_perms['issupermod'] == 1) {
        return true;
    } else {
        if (!$fid) {
            $modcache = $cache->read('moderators');
            if (!empty($modcache)) {
                foreach ($modcache as $modusers) {
                    if (isset($modusers[$uid]) && $modusers[$uid]['mid']) {
                        return true;
                    }
                }
            }
            return false;
        } else {
            $modperms = get_moderator_permissions($fid, $uid);
            if (!$action && $modperms) {
                return true;
            } else {
                if ($modperms[$action] == 1) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:45,代码来源:functions.php

示例14: accountswitcher_switch

/**
 * The switch function deletes the mybbuser cookie, sets a new cookie for the selected account and starts a new session.
 * Function is called by ajax request and sends the new users post key.
 *
 */
function accountswitcher_switch()
{
    global $db, $mybb, $lang, $charset, $cache, $templates;
    if ($mybb->user['uid'] != 0 && isset($mybb->input['switchuser']) && $mybb->input['switchuser'] == 1 && $mybb->request_method == "post") {
        require_once MYBB_ROOT . "/inc/plugins/accountswitcher/class_accountswitcher.php";
        $eas = new AccountSwitcher($mybb, $db, $cache, $templates);
        // Get permissions for this user
        $userPermission = user_permissions($mybb->user['uid']);
        // Get permissions for the master. First get the master
        $master = get_user((int) $mybb->user['as_uid']);
        // Get his permissions
        $masterPermission = user_permissions($master['uid']);
        // If one of both has the permission allow to switch
        if ($userPermission['as_canswitch'] == 1 || $masterPermission['as_canswitch'] == 1) {
            if (!isset($lang->as_invaliduser)) {
                $lang->load("accountswitcher");
            }
            verify_post_check($mybb->get_input('my_post_key'));
            // Get user info
            $user = get_user($mybb->get_input('uid', MyBB::INPUT_INT));
            // Check if user exists
            if (!$user) {
                error($lang->as_invaliduser);
            }
            // Can the new account be shared?
            if ($user['as_share'] != 0 && $mybb->settings['aj_shareuser'] == 1) {
                // Account already used by another user?
                if ($user['as_shareuid'] != 0) {
                    log_moderator_action(array('uid' => $user['uid'], 'username' => $user['username']), $lang->aj_switch_invalid_log);
                    return;
                }
                // Account only shared by buddies?
                if ($user['as_buddyshare'] != 0) {
                    // No buddy - no switch
                    if ($user['buddylist'] != '') {
                        $buddylist = explode(",", $user['buddylist']);
                    }
                    if (empty($buddylist) || !empty($buddylist) && !in_array($mybb->user['uid'], $buddylist)) {
                        log_moderator_action(array('uid' => $user['uid'], 'username' => $user['username']), $lang->aj_switch_invalid_log);
                        return;
                    }
                }
                // Shared account is free - set share uid
                if ($user['as_shareuid'] == 0) {
                    $updated_shareuid = array("as_shareuid" => (int) $mybb->user['uid']);
                    $db->update_query("users", $updated_shareuid, "uid='" . (int) $user['uid'] . "'");
                    $eas->update_accountswitcher_cache();
                    $user['as_shareuid'] = (int) $mybb->user['uid'];
                }
            }
            // Make sure you can switch to an attached account only
            if ($user['as_uid'] == $mybb->user['uid'] || $user['as_uid'] != 0 && $user['as_uid'] == $mybb->user['as_uid'] || $user['uid'] == $mybb->user['as_uid'] || $user['as_shareuid'] == $mybb->user['uid'] || $user['uid'] == $mybb->user['as_shareuid']) {
                // Is the current account shared?
                if ($mybb->user['as_share'] != 0) {
                    // Account used by another user?
                    if ($mybb->user['as_shareuid'] == 0) {
                        log_moderator_action(array('uid' => $user['uid'], 'username' => $user['username']), $lang->aj_switch_invalid_log);
                        return;
                    }
                    // Reset share uid
                    if ($mybb->user['as_shareuid'] != 0) {
                        $updated_shareuid = array("as_shareuid" => 0);
                        $db->update_query("users", $updated_shareuid, "uid='" . (int) $mybb->user['uid'] . "'");
                        $eas->update_accountswitcher_cache();
                    }
                }
                // Log the old user out
                my_unsetcookie("mybbuser");
                my_unsetcookie("sid");
                if ($mybb->user['uid']) {
                    $time = TIME_NOW;
                    // Run this after the shutdown query from session system
                    $db->shutdown_query("UPDATE " . TABLE_PREFIX . "users SET lastvisit='{$time}', lastactive='{$time}' WHERE uid='{$mybb->user['uid']}'");
                    $db->delete_query("sessions", "sid = '{$session->sid}'");
                }
                // Now let the login datahandler do the work
                require_once MYBB_ROOT . "inc/datahandlers/login.php";
                $loginhandler = new LoginDataHandler("get");
                $mybb->input['remember'] = "yes";
                $loginhandler->set_data($user);
                $validated = $loginhandler->validate_login();
                $loginhandler->complete_login();
                // Create session for this user
                require_once MYBB_ROOT . "inc/class_session.php";
                $session = new session();
                $session->init();
                $mybb->session =& $session;
                $mybb->post_code = generate_post_check();
                // Send new users post code
                header("Content-type: text/plain; charset={$charset}");
                echo $mybb->post_code;
                exit;
            } else {
                log_moderator_action(array('uid' => $user['uid'], 'username' => $user['username']), $lang->aj_switch_invalid_log);
                error($lang->as_notattacheduser);
//.........这里部分代码省略.........
开发者ID:ambsalinas,项目名称:anima,代码行数:101,代码来源:as_functions.php

示例15: verify_image_count

 /**
  * Verifies the image count.
  *
  * @return boolean True when valid, false when not valid.
  */
 function verify_image_count()
 {
     global $mybb, $db;
     $post =& $this->data;
     // Get the permissions of the user who is making this post or thread
     $permissions = user_permissions($post['uid']);
     // Fetch the forum this post is being made in
     if (!$post['fid']) {
         $query = $db->simple_select('posts', 'fid', "pid = '{$post['pid']}'");
         $post['fid'] = $db->fetch_field($query, 'fid');
     }
     $forum = get_forum($post['fid']);
     // Check if this post contains more images than the forum allows
     if ($post['savedraft'] != 1 && $mybb->settings['maxpostimages'] != 0 && $permissions['cancp'] != 1) {
         require_once MYBB_ROOT . "inc/class_parser.php";
         $parser = new postParser();
         // Parse the message.
         $parser_options = array("allow_html" => $forum['allowhtml'], "allow_mycode" => $forum['allowmycode'], "allow_imgcode" => $forum['allowimgcode'], "filter_badwords" => 1);
         if ($post['options']['disablesmilies'] != 1) {
             $parser_options['allow_smilies'] = $forum['allowsmilies'];
         } else {
             $parser_options['allow_smilies'] = 0;
         }
         $image_check = $parser->parse_message($post['message'], $parser_options);
         // And count the number of image tags in the message.
         $image_count = substr_count($image_check, "<img");
         if ($image_count > $mybb->settings['maxpostimages']) {
             // Throw back a message if over the count with the number of images as well as the maximum number of images per post.
             $this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));
             return false;
         }
     }
 }
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:38,代码来源:post.php


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