$dgllogin="/usr/games/lib/dgamelaunch/dgl-login";
$nhrcpath="/usr/games/lib/dgamelaunch/rcfiles/";
$menucolor=array();
$configs=array();
$values=array();
$helptxt=array();
$menucolor_values=array("black", "red", "green", "brown", "blue", "magenta", "cyan", "gray", "orange", "lightgreen", "yellow", "lightblue", "lightmagenta", "lightcyan", "white");
$menucolor_mods=array("bold", "dim", "underline", "blink", "inverse");
function parse_options($line, $authoritative){/*{{{*/
global $configs;
$items=split(",", $line);
foreach ($items as $item){
$type="bool";
$value="yes";
if (preg_match("/^(no|!)/", $item)){
$value="no";
$item=preg_replace("/^(no|!)/", "", $item);
} elseif (preg_match("/(:|=)(.*)/", $item, $matches)){
$type="text";
$value=$matches[2];
$item=preg_replace("/\s*(:|=).*$/", "", $item);
}
$item=preg_replace("/\n/", "", $item);
if ($authoritative == 1){
$config=array();
$config["name"]=$item;
$config["type"]=$type;
$config["value"]=$value;
$configs[$item]=$config;
} else {
if (!$configs[$item]){
#echo "EEP! Unknown variable: $item
";
} else {
$configs[$item]["value"]=$value;
}
}
}
}/*}}}*/
function parse_menucolor($line){/*{{{*/
global $menucolor;
global $menucolor_values;
$items=split("=", $line);
$mod=split("&", $items[1]);
$x=0;
while ($x < sizeof($mod)){
$mod[$x]=preg_replace("/\n/", "", $mod[$x]);
$x++;
}
$item=array();
$item["text"]=$items[0];
$item["color"]=$mod[0];
$found=0;
foreach ($menucolor_values as $color){
if ($item["color"] == $color)
$found=1;
}
if ($found == 0){
$item["color"] = "gray";
} else {
$x = 0;
while ($x < sizeof($mod) - 1){
$mod[$x] = $mod[$x+1];
$x++;
}
$mod[sizeof($mod)-1] = "";
}
$item["modifier"]=$mod;
$menucolor[]=$item;
}/*}}}*/
function parse_line($line, $authoritative){/*{{{*/
if (preg_match("/^OPTIONS=/", $line)){
parse_options(preg_replace("/^OPTIONS=/i", "", $line), $authoritative);
} elseif (preg_match("/^BOULDER=(.*)/i", $line, $matches)){
parse_options("boulder:".$matches[1],0);
} elseif (preg_match("/^MENUCOLOR=/i", $line)){
parse_menucolor(preg_replace("/^MENUCOLOR=/i", "", $line));
} else {
echo "EEP! Don't know how to handle: '$line'
";
}
}/*}}}*/
function read_file($filename, $authoritative){/*{{{*/
if (!($rc = @fopen($filename, "r"))){
die ("Can't open $filename");
}
while (!feof($rc)) {
$line = fgets($rc, 4096);
$line = preg_replace("/#.*$/", "", $line);
if (!preg_match("/^\s*$/", $line))
parse_line($line, $authoritative);
}
fclose($rc);
}/*}}}*/
function read_values($filename){/*{{{*/
global $values;
if (!($rc = @fopen($filename, "r"))){
die ("Can't open $filename");
}
while (!feof($rc)) {
$line = fgets($rc, 4096);
$line = preg_replace("/#.*$/", "", $line);
$line = preg_replace("/\n/", "", $line);
if (!preg_match("/^\s*$/", $line)){
$items=split(":", $line);
$item=strtolower($items[0]);
$items=split(";", $items[1]);
if ($items[1]){
$x=0;
$list=array();
while ($x < sizeof($items)){
$list[]=split(",", $items[$x]);
$x++;
}
$values[$item]=$list;
} else {
$items=split(",", $items[0]);
$values[$item]=$items;
}
}
}
fclose($rc);
}/*}}}*/
function read_helptxt($filename) {/*{{{*/
global $helptxt;
if (!($rc = @fopen($filename, "r"))){
die ("Can't open $filename");
}
while (!feof($rc)) {
$line = fgets($rc, 4096);
$items = split("\|", $line);
$helptxt[$items[0]] = $items[1];
}
}/*}}}*/
function output_field($config){/*{{{*/
global $values;
global $helptxt;
if ($values[$config["name"]]){
echo "