示例#1
0
function get_user_privdesc(&$user)
{
    global $priv_list;
    $privs = array();
    $user_privs = $user['priv'];
    if (!is_array($user_privs)) {
        $user_privs = array();
    }
    $names = local_user_get_groups($user, true);
    foreach ($names as $name) {
        $group = getGroupEntry($name);
        $group_privs = $group['priv'];
        if (!is_array($group_privs)) {
            continue;
        }
        foreach ($group_privs as $pname) {
            if (in_array($pname, $user_privs)) {
                continue;
            }
            if (!$priv_list[$pname]) {
                continue;
            }
            $priv = $priv_list[$pname];
            $priv['group'] = $group['name'];
            $privs[] = $priv;
        }
    }
    foreach ($user_privs as $pname) {
        if ($priv_list[$pname]) {
            $privs[] = $priv_list[$pname];
        }
    }
    return $privs;
}
示例#2
0
function get_user_privdesc(&$user)
{
    global $priv_list;
    $privs = array();
    if (!isset($user['priv']) || !is_array($user['priv'])) {
        $user_privs = array();
    } else {
        $user_privs = $user['priv'];
    }
    $names = local_user_get_groups($user, true);
    foreach ($names as $name) {
        $group = getGroupEntry($name);
        if (isset($group['priv']) && is_array($group['priv'])) {
            foreach ($group['priv'] as $pname) {
                if (in_array($pname, $user_privs)) {
                    continue;
                }
                if (empty($priv_list[$pname])) {
                    continue;
                }
                $priv = $priv_list[$pname];
                $priv['group'] = $group['name'];
                $priv['id'] = $pname;
                $privs[] = $priv;
            }
        }
    }
    foreach ($user_privs as $pname) {
        if (!empty($priv_list[$pname])) {
            $priv_list[$pname]['id'] = $pname;
            $privs[] = $priv_list[$pname];
        }
    }
    legacy_html_escape_form_data($privs);
    return $privs;
}
 if (preg_match("/[^a-zA-Z0-9\\.\\-_]/", $_POST['usernamefld'])) {
     $input_errors[] = gettext("The username contains invalid characters.");
 }
 if (strlen($_POST['usernamefld']) > 16) {
     $input_errors[] = gettext("The username is longer than 16 characters.");
 }
 if ($_POST['passwordfld1'] && $_POST['passwordfld1'] != $_POST['passwordfld2']) {
     $input_errors[] = gettext("The passwords do not match.");
 }
 if (isset($_POST['ipsecpsk']) && !preg_match('/^[[:ascii:]]*$/', $_POST['ipsecpsk'])) {
     $input_errors[] = gettext("IPsec Pre-Shared Key contains invalid characters.");
 }
 /* Check the POSTed groups to ensure they are valid and exist */
 if (is_array($_POST['groups'])) {
     foreach ($_POST['groups'] as $newgroup) {
         if (empty(getGroupEntry($newgroup))) {
             $input_errors[] = gettext("One or more invalid groups was submitted.");
         }
     }
 }
 if (isset($id) && $a_user[$id]) {
     $oldusername = $a_user[$id]['name'];
 } else {
     $oldusername = "";
 }
 /* make sure this user name is unique */
 if (!$input_errors) {
     foreach ($a_user as $userent) {
         if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
             $input_errors[] = gettext("Another entry with the same username already exists.");
             break;