<?php
//
// Checks to see if a user is an admin, returns true if they are, false if they are not.
//
function bco_is_admin()
{
global $cookie_name_user, $cookie_name_color, $user_array, $pg_result;
$query = "select id from users where lower(username)=lower('$user_array[username]') and";
$query .= " password='" . md5($user_array['password']) . "' and is_admin=1";
if (!$result = pg_query($pg_result, $query)) {
bco_error("Sorry. Admin query failed.<br />".pg_last_error($pg_result));
}
// We don't want this laying around.
unset($query);
if (pg_num_rows($result) != 1) {
unset($result);
return false;
} else {
return true;
}
}
//
// Set/unset sticky mode
//
function bco_sticky($id, $action)
{
if (!bco_thread_exists($id)) {
bco_error("Sorry, thread does not exist.");
}
switch ($action) {
case "set":
$query = "update subject_index set sticky='t' where id=$id";
if (!pg_query($query)) {
bco_error("Line " . __LINE__ . ": Sticky query failed.");
}
unset($query);
return true;
case "unset":
$query = "update subject_index set sticky='f' where id=$id";
if (!pg_query($query)) {
bco_error("Line " . __LINE__ . ": Sticky query failed.");
}
unset($query);
return true;
default:
return false;
}
}
//
// Set or unset lock on a thread.
// $id: the thread id
// $action: lock or unlock
//
function bco_set_lock($id, $action)
{
if (!bco_thread_exists($id)) {
bco_error("Sorry thread does not exist.");
}
switch ($action) {
case "lock":
$query = "update subject_index set locked=1 where id=$id";
if (!pg_query($query)) {
bco_error("Line " . __LINE__ . ": lock query failed.");
}
unset($query);
return true;
case "unlock":
$query = "update subject_index set locked=0 where id=$id";
if (!pg_query($query)) {
bco_error("Line " . __LINE__ . ": Lock query failed.");
}
unset($query);
return true;
default:
return false;
}
}
//
// Blocks a user from accessing the board.. uses userid and username to match against.
//
function bco_block_user($userid, $action)
{
if (!bco_user_exists($userid)) {
bco_error("User does not exist.");
}
switch ($action) {
case "ban":
$ban_value = 1;
break;
case "unban":
$ban_value = 0;
break;
default:
exit("No method passed to ban function.");
break;
}
if ($userid != '') {
$query = "update users set banned=$ban_value where id=$userid";
} else {
return false;
}
if (!pg_query($query)) {
bco_error("Ban query failed.");
} else {
unset($query);
return true;
}
}
//
// Change the default_color value in the config table.. takes a comma seperated array as an argument
//
function bco_change_default_colors($color_string)
{
if ($color_string == '') {
bco_error('$color_string is empty. That is bad.');
}
$query = "update bco_config set config_value='$color_string' where config_name='default_colors'";
if (!pg_query($query)) {
bco_error("Default color change query failed.");
} else {
return true;
}
}
//
// Show other usernames from the ip passed to the function
//
function bco_show_users_for_ip($ip_address)
{
if ($ip_address == '') {
bco_error("IP address is blanky!");
}
$query = '';
}
?>