<commit_before><?php
include("defs.php3");

#
# No PAGEHEADER since we spit out a Location header later. See below.
# 

#
# Only known and logged in users can do this.
#
# Note different test though, since we want to allow logged in
# users with expired passwords to change them.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Admins can change status for other users.
#
if (!isset($target_uid)) {
    $target_uid = $uid;
}

#
# We need to know the real admin permission of the current user.
#
if (! ($CHECKLOGIN_STATUS & CHECKLOGIN_ISADMIN)) {
    USERERROR("You do not have permission to use this page!", 1);
}

if (!isset($adminoff) || ($adminoff != 0 && $adminoff != 1)) {
    USERERROR("Improper arguments!", 1);
}

DBQueryFatal("update users set adminoff=$adminoff where uid='$target_uid'");

#
# Spit out a redirect 
# 
header("Location: $TBBASE/showuser.php3?target_uid=$target_uid");

?>
<commit_msg>Make use of REFERRER  variable so that after clicking on adminmode button, you zap back to the page you were on. Much more convenient.<commit_after><?php
include("defs.php3");

#
# No PAGEHEADER since we spit out a Location header later. See below.
# 

#
# Only known and logged in users can do this.
#
# Note different test though, since we want to allow logged in
# users with expired passwords to change them.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Admins can change status for other users.
#
if (!isset($target_uid)) {
    $target_uid = $uid;
}

#
# We need to know the real admin permission of the current user.
#
if (! ($CHECKLOGIN_STATUS & CHECKLOGIN_ISADMIN)) {
    USERERROR("You do not have permission to use this page!", 1);
}

if (!isset($adminoff) || ($adminoff != 0 && $adminoff != 1)) {
    USERERROR("Improper arguments!", 1);
}

DBQueryFatal("update users set adminoff=$adminoff where uid='$target_uid'");

#
# Spit out a redirect 
#
if (isset($HTTP_REFERER) && strcmp($HTTP_REFERER, "")) {
    header("Location: $HTTP_REFERER");
}
else {
    header("Location: $TBBASE/showuser.php3?target_uid=$target_uid");
}

?>

{'fraction_non_alphanumeric': 0.13518789653489507, 'fraction_numerical': 0.005856515373352855, 'mean_word_length': 4.423280423280423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6393951', 'n_tokens_mistral': 701, 'n_tokens_neox': 677, 'n_words': 231}