<?php
require_once('inc/db_connect.php');
require_once('inc/debug.php');
function config($key)
{
global $config;
if (array_key_exists($key, $config))
return $config[$key];
/* read configuration from database */
$options = db_query( "SELECT `key`, value FROM misc.config" );
while( $object = mysql_fetch_assoc( $options ) ) {
$config[$object['key']]=$object['value'];
}
DEBUG($config);
if (array_key_exists($key, $config))
return $config[$key];
else
logger(LOG_ERR, "inc/base", "config", "Request to read nonexistant config option »{$key}«.");
return NULL;
}
function redirect($target)
{
global $debugmode;
if (! $debugmode)
header("Location: {$target}");
die();
}
function my_server_id()
{
$uid = (int) $_SESSION['userinfo']['uid'];
$result = db_query("SELECT server FROM system.useraccounts WHERE uid={$uid}");
$r = mysql_fetch_assoc($result);
DEBUG($r);
return $r['server'];
}
function additional_servers()
{
$uid = (int) $_SESSION['userinfo']['uid'];
$result = db_query("SELECT server FROM system.user_server WHERE uid={$uid}");
$servers = array();
while ($s = mysql_fetch_assoc($result))