if (!isset($num_errors)) {
    $num_errors = 0;
}
if (!isset($num_alerts)) {
    $num_alerts = 0;
}
if (!empty($_GET['group_id'])) {
    $group_id = $_GET['group_id'];
} else {
    if (!empty($_POST['group_id'])) {
        $group_id = $_POST['group_id'];
    }
}
if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) {
    Get_Account_Id($sess_id, $account_id, $bd);
    $membership = Member_Role($group_id, $account_id, $bd);
    // If the user is actually owner of the group
    if (!($membership == 'O' || $membership != 'M')) {
        $error[$num_errors++] = "You are not moderator of this group.";
        include "groups.php";
        exit;
    }
    if (!empty($_POST['span_day'])) {
        $_POST['span'] = 'day';
    } else {
        if (!empty($_POST['span_week'])) {
            $_POST['span'] = 'week';
        } else {
            if (!empty($_POST['span_month'])) {
                $_POST['span'] = 'month';
            }
if (!empty($_GET['group_id'])) {
    $group_id = $_GET['group_id'];
} elseif (!empty($_POST['group_id'])) {
    $group_id = $_POST['group_id'];
}
if (!empty($_GET['account_id'])) {
    $member_id = $_GET['account_id'];
} else {
    if (!empty($_POST['account_id'])) {
        $member_id = $_POST['account_id'];
    }
}
if (Validate_Session($complete_sess_id, $_SERVER['REMOTE_ADDR'], $bd)) {
    Get_Account_Id($sess_id, $account_id, $bd);
    $membership = Member_Role($group_id, $account_id, $bd);
    $ch_membership = Member_Role($group_id, $member_id, $bd);
    // If the user is actually moderator or owner of the group
    if (!($membership == 'O' || $membership == 'M')) {
        $error[$num_errors++] = "You are not moderator of this group.";
        include "groups.php";
        exit;
    }
    if ($ch_membership == 'O') {
        $error[$num_errors++] = "The Owner membership may not be changed.";
        include "groups.php";
        exit;
    }
    if (!empty($_POST['modify'])) {
        Group_Change_Membership($group_id, $member_id, $_POST['membership'], $bd);
        $alert[$num_alerts++] = "Membership Changed Successfully";
        include "groups_members.php";