예제 #1
0
function user_create($p_username, $p_password, $p_email, $p_access_level = null, $p_enabled = true, $p_protected = false)
{
    if (false !== user_get_info(user_where_username_equals($p_username))) {
        echo "<p>Duplicate user.</p>";
        return false;
    }
    if (false !== user_get_info(user_where_email_equals($p_email))) {
        echo "<p>Duplicate email.</p>";
        return false;
    }
    if (null === $p_access_level) {
        $p_access_level = REGISTERED;
        # @@@@ Move to config.
    }
    $c_username = db_prepare_string($p_username);
    $c_email = db_prepare_string($p_email);
    $c_encrypted_password = db_prepare_string(access_encrypt_password($p_password));
    $c_enabled = db_prepare_int($p_enabled);
    $c_protected = db_prepare_int($p_protected);
    $t_seed = $p_email . $p_username;
    $t_cookie_string = create_cookie_string($t_seed);
    $c_cookie_string = db_prepare_string($t_cookie_string);
    $query = "INSERT INTO phpWN_user_table (username, password, email, cookie_string, access_level, enabled, protected)\r\n\t\t\t\t\tVALUES ('{$c_username}', '{$c_encrypted_password}', '{$c_email}', '{$c_cookie_string}', {$p_access_level}, {$c_enabled}, {$c_protected})";
    $result = mysql_query($query);
    return false !== $result;
}
예제 #2
0
// dodane w celu lepszej integracji z mantisem (zrodlo: software 2.0)
if ($perm == "1") {
    $f_access_level = 70;
} else {
    if ($perm == "2") {
        $f_access_level = 55;
    } else {
        if ($perm == "3") {
            $f_access_level = 25;
        } else {
            if ($perm == "4") {
                $f_access_level = 0;
            } else {
                if ($perm == "5") {
                    $f_access_vele = 90;
                } else {
                    $f_access_level = 0;
                }
            }
        }
    }
}
# create the almost unique string for each user then insert into the table
$t_cookie_string = create_cookie_string();
$query = "INSERT\n    \t\tINTO {$g_mantis_user_table}\n    \t\t( id, username, email, realname, password, date_created, last_visit,\n    \t\taccess_level, enabled, protected, cookie_string )\n\t\t\tVALUES\n\t\t\t( {$num}, '{$f_username}', '{$f_email}', '{$f_realname}' ,'{$f_password}', NOW(), NOW(),\n\t\t\t'{$f_access_level}', '{$f_enabled}', '{$f_protected}', '{$t_cookie_string}')";
$result = db_query($query);
# Use this for MS SQL: SELECT @@IDENTITY AS 'id'
$t_user_id = $num;
# Create preferences
$query = "INSERT\n    \t\tINTO {$g_mantis_user_pref_table}\n    \t\t(id, user_id, project_id,\n    \t\tadvanced_report, advanced_view, advanced_update,\n    \t\trefresh_delay, redirect_delay,\n    \t\temail_on_new, email_on_assigned,\n    \t\temail_on_feedback, email_on_resolved,\n    \t\temail_on_closed, email_on_reopened,\n    \t\temail_on_bugnote, email_on_status,\n    \t\temail_on_priority, language)\n    \t\tVALUES\n    \t\t(null, '{$t_user_id}', '0000000',\n    \t\t'{$g_default_advanced_report}', '{$g_default_advanced_view}', '{$g_default_advanced_update}',\n    \t\t'{$g_default_refresh_delay}', '{$g_default_redirect_delay}',\n    \t\t'{$g_default_email_on_new}', '{$g_default_email_on_assigned}',\n    \t\t'{$g_default_email_on_feedback}', '{$g_default_email_on_resolved}',\n    \t\t'{$g_default_email_on_closed}', '{$g_default_email_on_reopened}',\n    \t\t'{$g_default_email_on_bugnote}', '{$g_default_email_on_status}',\n    \t\t'{$g_default_email_on_priority}', '{$g_default_language}')";
$result = db_query($query);
예제 #3
0
function signup_user($p_username, $p_email = false)
{
    global $g_use_ldap_email, $g_mantis_user_table, $g_default_new_account_access_level, $g_mantis_user_pref_table, $g_default_advanced_report, $g_default_advanced_view, $g_default_advanced_update, $g_default_refresh_delay, $g_default_redirect_delay, $g_default_email_on_new, $g_default_email_on_assigned, $g_default_email_on_feedback, $g_default_email_on_resolved, $g_default_email_on_closed, $g_default_email_on_reopened, $g_default_email_on_bugnote, $g_default_email_on_status, $g_default_email_on_priority, $g_default_language;
    if (false == $p_email && ON == $g_use_ldap_email) {
        $p_email = get_user_info("{$p_username}", "email");
    }
    $t_seed = $p_email ? $p_email : $p_username;
    # Create random password
    $t_password = create_random_password($t_seed);
    # Use a default access level
    # create the almost unique string for each user then insert into the table
    $t_cookie_string = create_cookie_string($t_seed);
    $t_password2 = process_plain_password($t_password);
    $query = "INSERT INTO {$g_mantis_user_table}\n\t\t\t\t( id, username, email, password, date_created, last_visit,\n\t\t\t\tenabled, protected, access_level, login_count, cookie_string )\n\t\t\t\tVALUES\n\t\t\t\t( null, '{$p_username}', '{$p_email}', '{$t_password2}', NOW(), NOW(),\n\t\t\t\t1, 0, {$g_default_new_account_access_level}, 0, '{$t_cookie_string}')";
    $result = db_query($query);
    if (!$result) {
        return false;
    }
    # Create preferences for the user
    $t_user_id = db_insert_id();
    $query = "INSERT INTO {$g_mantis_user_pref_table}\n\t\t\t\t(id, user_id, advanced_report, advanced_view, advanced_update,\n\t\t\t\trefresh_delay, redirect_delay,\n\t\t\t\temail_on_new, email_on_assigned,\n\t\t\t\temail_on_feedback, email_on_resolved,\n\t\t\t\temail_on_closed, email_on_reopened,\n\t\t\t\temail_on_bugnote, email_on_status,\n\t\t\t\temail_on_priority, language)\n\t\t\t\tVALUES\n\t\t\t\t(null, '{$t_user_id}', '{$g_default_advanced_report}',\n\t\t\t\t'{$g_default_advanced_view}', '{$g_default_advanced_update}',\n\t\t\t\t'{$g_default_refresh_delay}', '{$g_default_redirect_delay}',\n\t\t\t\t'{$g_default_email_on_new}', '{$g_default_email_on_assigned}',\n\t\t\t\t'{$g_default_email_on_feedback}', '{$g_default_email_on_resolved}',\n\t\t\t\t'{$g_default_email_on_closed}', '{$g_default_email_on_reopened}',\n\t\t\t\t'{$g_default_email_on_bugnote}', '{$g_default_email_on_status}',\n\t\t\t\t'{$g_default_email_on_priority}', '{$g_default_language}')";
    $result = db_query($query);
    if (!$result) {
        return false;
    }
    # Send notification email
    if ($p_email) {
        email_signup($t_user_id, $t_password);
    }
    return $t_cookie_string;
}