$query_s = $_SERVER['QUERY_STRING'];
$query_s = urldecode(rawurldecode($query_s));

if (count($args = explode("help=",$query_s))>1)
{
$args = explode(“/”,$args[count($args)-1]);
$help = $args[count($args)-1];
}

$path = ‘/var/geas/dgd/mud/d/System/doc/help/general/’;

if (!isset($help))
{
$lines = get_dirlist($path);
$text = ”;
$index = 0;

foreach ($lines as $line_num => $line)
{
global $text, $index;

if (strlen($line) < strlen($path)+2)
continue;

$fname = substr($line,strlen($path)+2);

if ($text == '')
{
$text = '

‘;
}

if ($index == 0)
{
$text = $text.’

‘;
}

$text = $text.’

‘;

if ($index == 3)
{
$text = $text.’

‘;
$index = 0;
continue;
}

$index++;
}

$text = ‘In the game you can access these help-pages by typing:
“help <filename>” – for example: “help aid”
‘.$text.’

‘.$fname.’

‘;
}
else
{
$text = ‘
‘;

if (is_file($path.$help))
$l = file ($path.$help);

$ind = 0;

if (count($l)>0)
{
while (strlen($l[count($l)-1]) < 2)
unset ($l[count($l)-1]);

foreach ($l as $l_n=> $ll)
{
$pieces = explode (“<", $ll);

if (count($pieces)>1)
$ll = implode(“<”,$pieces);

$pieces = explode (“>”, $ll);

if (count($pieces)>1)
$ll = implode(“>”,$pieces);

$key = stristr($ll,”NAME”);

if (strstr($ll,”NAME”) || strstr($ll,”NOTA BENE”) || strstr($ll,”SYNOPSIS”) ||
strstr($ll,”EXAMPLE”) || strstr($ll,”SEE ALSO”) || strstr($ll,”NOTE”) ||
strstr($ll,”DESCRIPTION”) || strstr($ll,”OPTIONS”))
{
$text = $text.’‘.$ll.’‘;

if (strstr($ll,”SEE ALSO”))
$ind = 1;
}
else if ($ind == 1)
{
$pieces = explode (“,”, $ll);
$ll = implode(“”,$pieces);
$pieces = explode (” “, $ll);

foreach ($pieces as $l_x=> $p)
{
if ($p == ”)
{
$text = $text.” “;
continue;
}

if ($pieces[count($pieces)-1] == $p)
$text = $text.’‘.$p.’‘;
else
$text = $text.’‘.$p.’, ‘;
}
}
else
$text = $text.$ll;
}

$text = ‘

'.$text.'

‘;
}
}

echo $text;

function get_dirlist($start_dir)
{
exec(“ls -R $start_dir/”,$f_list);
$dir_str = $start_dir;
$filelist[0] = $start_dir;
$i = 1;

for ($count=0; $count {
if ($f_list[$count] == "")
continue;

if (substr($f_list[$count],strlen($f_list[$count])-1,1) == ":")
{
$dir_str = substr($f_list[$count],0,strlen($f_list[$count])-1);
$filelist[$i] = $dir_str;
$i++;
}
else
{
$file_str = "$dir_str/$f_list[$count]";

if (is_file($file_str))
{
$filelist[$i] = $file_str;
$i++;
}
}
}

return $filelist;
}

?>