function checkban(string $login, bool $connect = false) : bool
{
    global $session;
    $accounts = db_prefix('accounts');
    $bans = db_prefix('accounts');
    $today = date('Y-m-d');
    $sql = db_query("SELECT lastip, uniquid, banoverride, superuser FROM {$accounts}\n        WHERE login = '******'");
    $row = db_fetch_assoc($sql);
    if ($row['banoverride'] || $row['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
        return false;
    }
    db_free_result($sql);
    $sql = db_query("SELECT * FROM {$bans}\n        WHERE (\n            (ipfilter = '{$row['lastip']}' OR ipfilter = '{$_SERVER['REMOTE_ADDR']}')\n            OR (uniqueid = '{$row['uniqueid']}' OR uniqueid = '{$_COOKIE['lgi']}')\n        )\n        AND (banexpire = '000-00-00' OR banexpire >= '{$today}')");
    if (db_num_rows($sql) > 0) {
        if ($connect) {
            $session = [];
            tlschema('ban');
            $session['message'] .= translate_inline('`n`4You fall under a ban currently in place on this website:');
            while ($row = db_fetch_assoc($sql)) {
                $session['message'] .= "`n{$row['banreason']}`n";
                if ($row['banexpire'] == '0000-00-00') {
                    $session['message'] .= translate_inline("`\$This ban is permanent!`0");
                } else {
                    $session['message'] .= sprintf_translate("`^This ban will be removed `\$after`^ %s.`0", date("M d, Y", strtotime($row['banexpire'])));
                }
                db_query("UPDATE {$bans}\n                    SET lasthit = '{$today} 00:00:00'\n                    WHERE ipfilter = '{$row['ipfilter']}'\n                    AND uniqueid = '{$row['uniqueid']}'\n                    ");
            }
            $session['message'] .= translate_inline("`n`4If you wish, you may appeal your ban with the petition link.");
            tlschema();
            header('Location: home.php');
        }
        return true;
    }
    return false;
}
function friendlist_unignore()
{
    global $session;
    $ac = httpget('ac');
    $ignored = rexplode(get_module_pref('ignored', 'friendlist', $ac));
    $iveignored = rexplode(get_module_pref('iveignored'));
    if (in_array($ac, $iveignored)) {
        $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid={$ac} AND locked=0";
        $result = db_query($sql);
        if (db_num_rows($result) > 0) {
            $row = db_fetch_assoc($result);
            $info = sprintf_translate("%s`Q has been removed from your list.", $row['name']);
            require_once "lib/systemmail.php";
            $t = array("`\$Ignore List Removal");
            $mailmessage = array("%s`0`@ has removed you from %s ignore list.", $session['user']['name'], $session['user']['sex'] ? translate_inline("her") : translate_inline("his"));
            systemmail($ac, $t, $mailmessage);
        } else {
            $info = translate_inline("That user no longer exists...");
        }
    }
    $ignored = array_diff($ignored, array($session['user']['acctid']));
    $ignored = rimplode($ignored);
    set_module_pref('ignored', $ignored, 'friendlist', $ac);
    if (in_array($ac, $iveignored)) {
        $iveignored = array_diff($iveignored, array($ac));
        $iveignored = rimplode($iveignored);
        set_module_pref('iveignored', $iveignored);
    }
    output_notl($info);
}
function relativedate(string $indate) : string
{
    $lastOn = round((strtotime('now') - strtotime($indate)) / 86400, 0) . 'days';
    tlschema('datetime');
    if (substr($lastOn, 0, 2) == '1 ') {
        $lastOn = translate_inline('1 day');
    } else {
        if (date('Y-m-d', strtotime($lastOn)) == date('Y-m-d')) {
            $lastOn = translate_inline('Today');
        } else {
            if (date('Y-m-d', strtotime($lastOn)) == date('Y-m-d', strtotime('-1 day'))) {
                $lastOn = translate_inline('Yesterday');
            } else {
                if (strpos($indate, '0000-00-00') !== false) {
                    $lastOn = translate_inline('Never');
                } else {
                    $lastOn = sprintf_translate('%s days', round((strtotime('now') - strtotime($indate)) / 86400, 0));
                    rawoutput(tlbutton_clear());
                }
            }
        }
    }
    tlschema();
    return $lastOn;
}
function commentarylocs()
{
    global $comsecs, $session;
    if (is_array($comsecs) && count($comsecs)) {
        return $comsecs;
    }
    $vname = getsetting("villagename", LOCATION_FIELDS);
    $iname = getsetting("innname", LOCATION_INN);
    tlschema("commentary");
    $comsecs['village'] = sprintf_translate("%s Square", $vname);
    if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
        $comsecs['superuser'] = translate_inline("Grotto");
    }
    $comsecs['shade'] = translate_inline("Land of the Shades");
    $comsecs['grassyfield'] = translate_inline("Grassy Field");
    $comsecs['inn'] = "{$iname}";
    $comsecs['motd'] = translate_inline("MotD");
    $comsecs['veterans'] = translate_inline("Veterans Club");
    $comsecs['hunterlodge'] = translate_inline("Hunter's Lodge");
    $comsecs['gardens'] = translate_inline("Gardens");
    $comsecs['waiting'] = translate_inline("Clan Hall Waiting Area");
    if (getsetting("betaperplayer", 1) == 1 && @file_exists("pavilion.php")) {
        $comsecs['beta'] = translate_inline("Pavilion");
    }
    tlschema();
    // All of the ones after this will be translated in the modules.
    $comsecs = modulehook("moderate", $comsecs);
    rawoutput(tlbutton_clear());
    return $comsecs;
}
function switch_dohook($hook, $args)
{
    switch ($hook) {
        case 'charstats':
            global $SCRIPT_NAME, $session;
            if ($SCRIPT_NAME == 'village.php' && $session['user']['specialinc'] == '') {
                addcharstat("Vital Info");
                addcharstat(sprintf_translate("<a href='login.php?op=logout'>%s</a>", "`%Log Out"), sprintf_translate("<a href='runmodule.php?module=switch' style='font-weight: bold;'>%s</a>", appoencode('`%Switch')));
                addnav('', 'login.php?op=logout');
                addnav('', 'runmodule.php?module=switch');
            }
            break;
    }
    return $args;
}
function changelog_dohook($hook, $args)
{
    switch ($hook) {
        case 'header-modules':
            $module = httppost('module') ?: httpget('module');
            $op = httpget('op');
            if ($module != '') {
                if (substr($op, -1) == 'e') {
                    $op = substr($op, 0, -1);
                } else {
                    if ($op == 'mass') {
                        $method = array_keys(httpallpost())[1];
                        if (substr($method, -1) == 'e') {
                            $method = substr($method, 0, -1);
                        }
                        $op = "mass {$method}";
                        $plural = 's';
                    }
                }
                require_once 'lib/gamelog.php';
                if (is_array($module)) {
                    $lastModule = array_pop($module);
                    $module = implode(', ', $module);
                    $module .= ",`@ and `^{$lastModule}";
                }
                gamelog(sprintf_translate('`Q%sed`@ the `^%s`@ module%s.', $op, $module, $plural), get_module_setting('category'));
            }
            break;
        case 'village':
            if (get_module_setting('infonav')) {
                addnav($args['infonav']);
                addnav('View Changelog', 'runmodule.php?module=changelog&ret=village');
            }
            break;
        case 'header-about':
            addnav('About LoGD');
            addnav('View Changelog', 'runmodule.php?module=changelog&ret=about');
            break;
        case 'newday-runonce':
            $gamelog = db_prefix('gamelog');
            $date = date('Y-m-d H:i:s', strtotime('now'));
            $category = get_module_setting('category');
            db_query("UPDATE {$gamelog} SET date = '{$date}' WHERE category = '{$category}'");
            break;
    }
    return $args;
}
function getmountname()
{
    global $playermount;
    tlschema("mountname");
    $name = '';
    $lcname = '';
    if (isset($playermount['mountname'])) {
        $name = sprintf_translate("Your %s", $playermount['mountname']);
        $lcname = sprintf_translate("your %s", $playermount['mountname']);
    }
    tlschema();
    if (isset($playermount['newname']) && $playermount['newname'] != "") {
        $name = $playermount['newname'];
        $lcname = $playermount['newname'];
    }
    return array($name, $lcname);
}
function checkban($login = false)
{
    global $session;
    if (isset($session['banoverride']) && $session['banoverride']) {
        return false;
    }
    if ($login === false) {
        $ip = $_SERVER['REMOTE_ADDR'];
        $id = $_COOKIE['lgi'];
    } else {
        $sql = "SELECT lastip,uniqueid,banoverride,superuser FROM " . db_prefix("accounts") . " WHERE login='******'";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        if ($row['banoverride'] || $row['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
            $session['banoverride'] = true;
            return false;
        }
        db_free_result($result);
        $ip = $row['lastip'];
        $id = $row['uniqueid'];
    }
    $sql = "SELECT * FROM " . db_prefix("bans") . " where ((substring('{$ip}',1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (uniqueid='{$id}' AND uniqueid<>'')) AND (banexpire='0000-00-00' OR banexpire>='" . date("Y-m-d") . "')";
    $result = db_query($sql);
    if (db_num_rows($result) > 0) {
        $session = array();
        tlschema("ban");
        $session['message'] .= translate_inline("`n`4You fall under a ban currently in place on this website:`n");
        while ($row = db_fetch_assoc($result)) {
            $session['message'] .= $row['banreason'] . "`n";
            if ($row['banexpire'] == '0000-00-00') {
                $session['message'] .= translate_inline("  `\$This ban is permanent!`0");
            } else {
                $session['message'] .= sprintf_translate("  `^This ban will be removed `\$after`^ %s.`0", date("M d, Y", strtotime($row['banexpire'])));
            }
            $sql = "UPDATE " . db_prefix("bans") . " SET lasthit='" . date("Y-m-d H:i:s") . "' WHERE ipfilter='{$row['ipfilter']}' AND uniqueid='{$row['uniqueidid']}'";
            db_query($sql);
            $session['message'] .= "`n";
        }
        $session['message'] .= translate_inline("`4If you wish, you may appeal your ban with the petition link.");
        tlschema();
        header("Location: index.php");
        exit;
    }
    db_free_result($result);
}
function apply_clan_buff_for_one()
{
    global $session;
    strip_buff("clanbuff");
    strip_buff("clanbuff2");
    strip_buff("clanbuff3");
    if (get_module_setting("allowatk") && get_module_objpref("clans", $session['user']['clanid'], "atkactive")) {
        $atkmod = 1 + get_module_setting("eatkbase") + get_module_objpref("clans", $session['user']['clanid'], "atklevel") * get_module_setting("eatkinc");
    } else {
        $atkmod = 1;
    }
    if (get_module_setting("allowdef") && get_module_objpref("clans", $session['user']['clanid'], "defactive")) {
        $defmod = 1 + get_module_setting("edefbase") + get_module_objpref("clans", $session['user']['clanid'], "deflevel") * get_module_setting("edefinc");
    } else {
        $defmod = 1;
    }
    if (get_module_setting("allowdrain") && get_module_objpref("clans", $session['user']['clanid'], "drainactive")) {
        $lifetap = get_module_setting("edrainbase") + get_module_objpref("clans", $session['user']['clanid'], "drainlevel") * get_module_setting("edraininc");
    } else {
        $lifetap = 0;
    }
    $allowinpvp = get_module_setting("allowinpvp");
    $allowintrain = get_module_setting("allowintrain");
    if (get_module_setting("allowult") && get_module_objpref("clans", $session['user']['clanid'], "ultactive")) {
        $rounds = -1;
    } else {
        $rounds = get_module_setting("eroundbase") + get_module_objpref("clans", $session['user']['clanid'], "roundlevel") * get_module_setting("eroundinc");
    }
    if (get_module_setting("allowthorn") && get_module_objpref("clans", $session['user']['clanid'], "thornactive")) {
        $damageshield = get_module_setting("ethornbase") + get_module_objpref("clans", $session['user']['clanid'], "thornlevel") * get_module_setting("ethorninc");
    } else {
        $damageshield = 0;
    }
    if (get_module_setting("allowregen") && get_module_objpref("clans", $session['user']['clanid'], "regenactive")) {
        $regen = get_module_setting("eregenbase") + get_module_objpref("clans", $session['user']['clanid'], "regenlevel") * get_module_setting("eregeninc");
    } else {
        $regen = 0;
    }
    apply_buff("clanbuff", array("name" => "`^Clan Aura`0", "atkmod" => $atkmod, "defmod" => $defmod, "lifetap" => $lifetap, "effectmsg" => sprintf_translate("`6Your Clan Aura allows you to absorb `^{damage}`6 of the damage you dealt to {badguy}!"), "allowinpvp" => $allowinpvp, "allowintrain" => $allowintrain, "rounds" => $rounds, "roundmsg" => "Your Clan's Aura strengthens you!", "schema" => "module-clanbuffs"));
    apply_buff("clanbuff2", array("damageshield" => $damageshield, "effectmsg" => sprintf_translate("`6Your Clan Aura allows you to reflect `^{damage}`6 of the damage you received {badguy}!"), "allowinpvp" => $allowinpvp, "allowintrain" => $allowintrain, "rounds" => $rounds, "schema" => "module-clanbuffs"));
    apply_buff("clanbuff3", array("regen" => $regen . "*<level>", "effectmsg" => sprintf_translate("`6Your Clan Aura allows you to regenerate `^{damage}`6 damage!"), "allowinpvp" => $allowinpvp, "allowintrain" => $allowintrain, "rounds" => $rounds, "schema" => "module-clanbuffs"));
}
/**
 * Adds a news item for the current user
 *
 * @param string $text Line of text for the news.
 * @param array $options List of options, including replacements, to modify the acctid, date, or hide from biographies.
 * @todo Change the date format from Y-m-d to Y-m-d H:i:s.
 */
function addnews(string $text = '', array $options = [])
{
    global $translation_namespace, $session;
    $options = modulehook('addnews', $options);
    $news = db_prefix('news');
    $replacements = [];
    foreach ($options as $key => $val) {
        if (is_numeric($key)) {
            array_push($replacements, $val);
        }
    }
    $text = sprintf_translate($text, $replacements);
    $date = $options['date'] ?? date('Y-m-d');
    $acctid = $options['acctid'] ?? $session['user']['acctid'];
    if (!$options['hide']) {
        $sql = db_query("INSERT INTO {$news} (newstext, newsdate, accountid, tlschema)\n            VALUES ('{$text}', '{$date}', '{$acctid}', '{$translation_namespace}')");
    } else {
        $sql = db_query("INSERT INTO {$news} (newstext, newsdate, tlschema)\n            VALUES ('{$text}', '{$date}', '{$translation_namespace}')");
    }
}
function friendlist_deny()
{
    global $session;
    $ignored = rexplode(get_module_pref('ignored'));
    $friends = rexplode(get_module_pref('friends'));
    $request = rexplode(get_module_pref('request'));
    $ac = httpget('ac');
    $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid={$ac} AND locked=0";
    $result = db_query($sql);
    if (in_array($ac, $friends)) {
        $info = translate_inline("That user has been removed.");
        require_once "lib/systemmail.php";
        $t = "`\$Friend List Removal";
        $mailmessage = array("%s`0`@ has deleted you from %s Friend List.", $session['user']['name'], $session['user']['sex'] ? translate_inline("her") : translate_inline("his"));
        $friends = array_diff($friends, array($ac));
        $friends = rimplode($friends);
        set_module_pref('friends', $friends);
        $act = $session['user']['acctid'];
        $friends = rexplode(get_module_pref('friends', 'friendlist', $ac));
        $friends = array_diff($friends, array($act));
        $friends = rimplode($friends);
        set_module_pref('friends', $friends, 'friendlist', $ac);
        invalidatedatacache("friendliststat-" . $session['user']['acctid']);
        invalidatedatacache("friendliststat-" . $ac);
    } else {
        $info = translate_inline("That user has been denied.");
        require_once "lib/systemmail.php";
        $t = "`\$Friend Request Denied";
        $mailmessage = array("%s`0`@ has denied you your Friend Request.", $session['user']['name']);
        $request = array_diff($request, array($ac));
        $request = rimplode($request);
        set_module_pref('request', $request);
    }
    if (db_num_rows($result) > 0) {
        systemmail($ac, $t, $mailmessage);
        $row = db_fetch_assoc($result);
        $info = sprintf_translate("%s has been removed", $row['name']);
    }
    output_notl($info);
}
function namecolor_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "pointsdesc":
            $args['count']++;
            $format = $args['format'];
            $str = translate("A colored name costs %s points for the first change and %s points for subsequent changes.");
            $str = sprintf($str, get_module_setting("initialpoints"), get_module_setting("extrapoints"));
            output($format, $str, true);
            break;
        case "lodge":
            // if (get_module_pref("boughtbefore")){
            // $cost = get_module_setting("extrapoints");
            // } else {
            // $cost = get_module_setting("initialpoints");
            // }
            // addnav(array("Colorize Name (%s points)", $cost), "runmodule.php?module=namecolor&op=namechange");
            addnav("Name Colour Changes");
            $costfirst = get_module_setting("initialpoints");
            $costsub = get_module_setting("extrapoints");
            $costperm = get_module_setting("permanent");
            $hasperm = get_module_pref("permanent");
            if ($hasperm) {
                addnav("Set Custom Name Colours (free)", "runmodule.php?module=namecolor&op=namechange");
            } else {
                if (get_module_pref("boughtbefore")) {
                    $cost = get_module_setting("extrapoints");
                } else {
                    $cost = get_module_setting("initialpoints");
                }
                $cost = sprintf_translate("%s points", $cost);
                addnav(array("Set Custom Name Colours (%s)", $cost), "runmodule.php?module=namecolor&op=namechange");
                addnav(array("Get unlimited Name Colour changes (%s points)", $costperm), "runmodule.php?module=namecolor&op=permanent");
            }
            break;
    }
    return $args;
}
function friendlist_accept()
{
    global $session;
    $ignored = rexplode(get_module_pref('ignored'));
    $request = rexplode(get_module_pref('request'));
    $friends = rexplode(get_module_pref('friends'));
    $ac = httpget('ac');
    if (in_array($ac, $ignored)) {
        $info = translate_inline("This user has ignored you.");
    } elseif (in_array($ac, $friends)) {
        $info = translate_inline("This user is already in your list.");
    } elseif (in_array($ac, $request)) {
        $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid={$ac} AND locked=0";
        $result = db_query($sql);
        if (db_num_rows($result) > 0) {
            $row = db_fetch_assoc($result);
            invalidatedatacache("friendliststat-" . $session['user']['acctid']);
            invalidatedatacache("friendliststat-" . $ac);
            $friends[] = $ac;
            $info = sprintf_translate("%s`Q has been added to your list.", $row['name']);
            require_once "lib/systemmail.php";
            $t = "`\$Friend Request Accepted";
            $mailmessage = array("%s`0`@ has accepted your Friend Request.", $session['user']['name']);
            systemmail($ac, $t, $mailmessage);
            $friends = rimplode($friends);
            set_module_pref('friends', $friends);
            $friends = rexplode(get_module_pref('friends', 'friendlist', $ac));
            $friends[] = $session['user']['acctid'];
            $friends = rimplode($friends);
            set_module_pref('friends', $friends, 'friendlist', $ac);
            $request = array_diff($request, array($ac));
            $request = rimplode($request);
            set_module_pref('request', $request);
        } else {
            $info = translate_inline("That user no longer exists...");
        }
    }
    output_notl($info);
}
function blurry_dohook($hook, $args)
{
    switch ($hook) {
        case 'everyfooter-loggedin':
            global $navbysection;
            $drunkeness = get_module_pref('drunkeness');
            if (file_exists('modules/drinks/drunkenize.php') && $drunkeness != 0) {
                require_once 'modules/drinks/drunkenize.php';
                foreach ($navbysection as $section => $navs) {
                    for ($i = 0; $i < count($navs); $i++) {
                        // Support to fix villagenav() and other arrayed navigation titles.
                        if (is_array($navs[$i][0])) {
                            $navs[$i][0] = sprintf_translate($navs[$i][0]);
                        }
                        if (strpos($navs[$i][0], '?') !== false) {
                            $navTitle = explode('?', $navs[$i][0]);
                            if (count($navTitle) > 2) {
                                $navTitle[2] = drinks_drunkenize($navTitle[2], $drunkeness);
                                $navTitle[2] = str_replace('*hic*', '', $navTitle[2]);
                            } else {
                                $navTitle[1] = drinks_drunkenize($navTitle[1], $drunkeness);
                                $navTitle[1] = str_replace('*hic*', '', $navTitle[1]);
                            }
                            $navTitle[1] = str_replace('*hic*', '', $navTitle[1]);
                            $navTitle = implode('?', $navTitle);
                            $navbysection[$section][$i][0] = stripslashes($navTitle);
                            unset($navTitle);
                        } else {
                            $navbysection[$section][$i][0] = drinks_drunkenize($navs[$i][0], $drunkeness);
                        }
                    }
                }
            }
            break;
    }
    return $args;
}
}
addnav("Game Settings");
addnav("Standard settings", "configuration.php");
addnav("", $REQUEST_URI);
module_editor_navs('settings', 'configuration.php?op=modulesettings&module=');
if ($op == "") {
    $enum = "enumpretrans";
    require_once "lib/datetime.php";
    $details = gametimedetails();
    $offset = getsetting("gameoffsetseconds", 0);
    for ($i = 0; $i <= 86400 / getsetting("daysperday", 4); $i += 300) {
        $off = $details['realsecstotomorrow'] - ($offset - $i);
        if ($off < 0) {
            $off += 86400;
        }
        $x = strtotime("+" . $off . " secs");
        $str = sprintf_translate("In %s at %s (+%s)", reltime($x), date("h:i a", $x), date("H:i", $i));
        $enum .= ",{$i},{$str}";
    }
    rawoutput(tlbutton_clear());
    $setup = array("Game Setup,title", "loginbanner" => "Login Banner (under login prompt: 255 chars)", "maxonline" => "Max # of players online (0 for unlimited), int", "allowcreation" => "Allow creation of new characters,bool", "gameadminemail" => "Admin Email", "emailpetitions" => "Should submitted petitions be emailed to Admin Email address?,bool", "Enter languages here like this: `i(shortname 2 chars) comma (readable name of the language)`i and continue as long as you wish,note", "serverlanguages" => "Languages available on this server", "defaultlanguage" => "Default Language,enum," . getsetting("serverlanguages", "en,English,fr,Français,dk,Danish,de,Deutsch,es,Español,it,Italian"), "edittitles" => "Should DK titles be editable in user editor,bool", "motditems" => "How many items should be shown on the motdlist,int", "Main Page Display,title", "homeskinselect" => "Should the skin selection widget be shown?,bool", "homecurtime" => "Should the current realm time be shown?,bool", "homenewdaytime" => "Should the time till newday be shown?,bool", "homenewestplayer" => "Should the newest player be shown?,bool", "defaultskin" => "What skin should be the default?,theme", "impressum" => "Tell the world something about the person running this server. (e.g. name and address),textarea", "Beta Setup,title", "beta" => "Enable beta features for all players?,bool", "betaperplayer" => "Enable beta features per player?,bool", "Account Creation,title", "defaultsuperuser" => "Flags automatically granted to new players,bitfield," . ($session['user']['superuser'] | SU_ANYONE_CAN_SET) . " ," . SU_INFINITE_DAYS . ",Infinite Days," . SU_VIEW_SOURCE . ",View Source Code," . SU_DEVELOPER . ",Developer Super Powers (special inc list; god mode; auto defeat master; etc)," . SU_DEBUG_OUTPUT . ",Debug Output", "newplayerstartgold" => "Amount of gold to start a new character with,int", "maxrestartgold" => "Maximum amount of gold a player will get after a dragonkill,int", "maxrestartgems" => "Maximum number of gems a player will get after a dragonkill,int", "requireemail" => "Require users to enter their email address,bool", "requirevalidemail" => "Require users to validate their email address,bool", "blockdupeemail" => "One account per email address,bool", "spaceinname" => "Allow spaces in user names,bool", "allowoddadminrenames" => "Allow admins to enter 'illegal' names in the user editor,bool", "selfdelete" => "Allow player to delete their character,bool", "Commentary/Chat,title", "soap" => "Clean user posts (filters bad language and splits words over 45 chars long),bool", "maxcolors" => "Max # of color changes usable in one comment,range,5,40,1", "postinglimit" => "Limit posts to let one user post only up to 50% of the last posts (else turn it off),bool", "Place names and People names,title", "villagename" => "Name for the main village", "innname" => "Name of the inn", "barkeep" => "Name of the barkeep", "barmaid" => "Name of the barmaid", "bard" => "Name of the bard", "clanregistrar" => "Name of the clan registrar", "deathoverlord" => "Name of the death overlord", "Referral Settings,title", "refereraward" => "How many points will be awarded for a referral?,int", "referminlevel" => "What level does the referral need to reach to credit the referer?,int", "Random events,title", "forestchance" => "Chance for Something Special in the Forest,range,0,100,1", "villagechance" => "Chance for Something Special in any village,range,0,100,1", "innchance" => "Chance for Something Special in the Inn,range,0,100,1", "gravechance" => "Chance for Something Special in the Graveyard,range,0,100,1", "gardenchance" => "Chance for Something Special in the Gardens,range,0,100,1", "Paypal,title", "paypalemail" => "Email address of Admin's paypal account", "paypalcurrency" => "Currency type", "paypalcountry-code" => "What country's predominant language do you wish to have displayed in your PayPal screen?,enum\n\t\t,US,United States,DE,Germany,AI,Anguilla,AR,Argentina,AU,Australia,AT,Austria,BE,Belgium,BR,Brazil,CA,Canada\n\t\t,CL,Chile,C2,China,CR,Costa Rica,CY,Cyprus,CZ,Czech Republic,DK,Denmark,DO,Dominican Republic\n\t\t,EC,Ecuador,EE,Estonia,FI,Finland,FR,France,GR,Greece,HK,Hong Kong,HU,Hungary,IS,Iceland,IN,India\n\t\t,IE,Ireland,IL,Israel,IT,Italy,JM,Jamaica,JP,Japan,LV,Latvia,LT,Lithuania,LU,Luxembourg,MY,Malaysia\n\t\t,MT,Malta,MX,Mexico,NL,Netherlands,NZ,New Zealand,NO,Norway,PL,Poland,PT,Portugal,SG,Singapore,SK,Slovakia\n\t\t,SI,Slovenia,ZA,South Africa,KR,South Korea,ES,Spain,SE,Sweden,CH,Switzerland,TW,Taiwan,TH,Thailand,TR,Turkey\n\t\t,GB,United Kingdom,UY,Uruguay,VE,Venezuela", "paypaltext" => "What text should be displayed as item name in the donations screen(player name will be added after it)?", "(standard: 'Legend of the Green Dragon Site Donation from',note", "General Combat,title", "autofight" => "Allow fighting multiple rounds automatically,bool", "autofightfull" => "Allow fighting until fight is over,enum,0,Never,1,Always,2,Only when not allowed to flee", "Training,title", "automaster" => "Masters hunt down truant students,bool", "multimaster" => "Can players gain multiple levels (challenge multiple masters) per game day?,bool", "displaymasternews" => "Display news if somebody fought his master?,bool", "Clans,title", "allowclans" => "Enable Clan System?,bool", "goldtostartclan" => "Gold to start a clan,int", "gemstostartclan" => "Gems to start a clan,int", "officermoderate" => "Can clan officers who are also moderators moderate their own clan even if they cannot moderate all clans?,bool", "New Days,title", "daysperday" => "Game days per calendar day,range,1,6,1", "specialtybonus" => "Extra daily uses in specialty area,range,0,5,1", "newdaycron" => "Let the newday-runonce run via a cronjob,bool", "The directory is necessary! Do not forget to set the correct one in cron.php in your main game folder!!! ONLY experienced admins should use cron jobbing here,note", "`bAlso make sure you setup a cronjob on your machine using confixx/plesk/cpanel or any other admin panel pointing to the cron.php file in your main folder`b,note", "If you do not know what a Cronjob is... leave it turned off. If you want to know more... check out: <a href='http://wiki.dragonprime.net/index.php?title=Cronjob'>http://wiki.dragonprime.net/index.php?title=Cronjob</a>,note", "resurrectionturns" => "Modify (+ or -) the number of turns deducted after a resurrection as an absolute (number) or relative (number followed by %),text", "Forest,title", "turns" => "Forest Fights per day,range,5,30,1", "dropmingold" => "Forest Creatures drop at least 1/4 of max gold,bool", "suicide" => "Allow players to Seek Suicidally?,bool", "suicidedk" => "Minimum DKs before players can Seek Suicidally?,int", "forestgemchance" => "Player will find a gem one in X times,range,10,100,1", "disablebonuses" => "Should monsters which get buffed with extra HP/Att/Def get a gold+exp bonus?,bool", "forestexploss" => "What percentage of experience should be lost?,range,10,100,1", "Multiple Enemies,title", "multifightdk" => "Multiple monsters will attack players above which amount of dragonkills?,range,8,50,1", "multichance" => "The chance for an attack from multiple enemies is,range,0,100,1", "addexp" => "Additional experience (%) per enemy during multifights?,range,0,15", "instantexp" => "During multi-fights hand out experience instantly?,bool", "maxattacks" => "How many enemies will attack per round (max. value),range,1,10", "allowpackofmonsters" => "Allow multiple monsters of the same type to appear in a battle?,bool", "Random values for type of seeking is added to random base.,note", "multibasemin" => "The base number of multiple enemies at minimum is,range,1,100,2", "multibasemax" => "The base number of multiple enemies at maximum is,range,1,100,3", "multislummin" => "The number of multiple enemies at minimum for slumming is,range,0,100,0", "multislummax" => "The number of multiple enemies at maximum for slumming is,range,0,100,1", "multithrillmin" => "The number of multiple enemies at minimum for thrill seeking is,range,0,100,1", "multithrillmax" => "The number of multiple enemies at maximum for thrill seeking is,range,0,100,2", "multisuimin" => "The number of multiple enemies at minimum for suicide is,range,0,100,2", "multisuimax" => "The number of multiple enemies at maximum for suicide is,range,0,100,4", "Stables,title", "allowfeed" => "Does Merick have feed onhand for creatures,bool", "Companions/Mercenaries,title", "enablecompanions" => "Enable the usage of companions,bool", "companionsallowed" => "How many companions are allowed per player,int", "Modules my alter this value on a per player basis!,note", "companionslevelup" => "Are companions allowed to level up?,bool", "Bank Settings,title", "fightsforinterest" => "Max forest fights remaining to earn interest?,range,0,10,1", "maxinterest" => "Max Interest Rate (%),range,5,10,1", "mininterest" => "Min Interest Rate (%),range,0,5,1", "maxgoldforinterest" => "Over what amount of gold does the bank cease paying interest? (0 for unlimited),int", "borrowperlevel" => "Max player can borrow per level (val * level for max),range5,200,5", "allowgoldtransfer" => "Allow players to transfer gold,bool", "transferperlevel" => "Max player can receive from a transfer (val * level),range,5,100,5", "mintransferlev" => "Min level a player (0 DK's) needs to transfer gold,range,1,5,1", "transferreceive" => "Total transfers a player can receive in one day,range,0,5,1", "maxtransferout" => "Amount player can transfer to others (val * level),range,5,100,5", "innfee" => "Fee for express inn payment (x or x%),int", "Mail Settings,title", "mailsizelimit" => "Message size limit per message,int", "inboxlimit" => "Limit # of messages in inbox,int", "oldmail" => "Automatically delete old messages after (days),int", "superuseryommessage" => "Warning to give when attempting to YoM an admin?", "onlyunreadmails" => "Only unread mail count towards the inbox limit?,bool", "PvP,title", "pvp" => "Enable Slay Other Players,bool", "pvpday" => "Player Fights per day,range,1,10,1", "pvpimmunity" => "Days that new players are safe from PvP,range,1,5,1", "pvpminexp" => "Experience below which player is safe from PvP,int", "pvpattgain" => "Percent of victim experience attacker gains on win,floatrange,.25,20,.25", "pvpattlose" => "Percent of experience attacker loses on loss,floatrange,.25,20,.25", "pvpdefgain" => "Percent of attacker experience defender gains on win,floatrange,.25,20,.25", "pvpdeflose" => "Percent of experience defender loses on loss,floatrange,.25,20,.25", "Content Expiration,title", "expirecontent" => "Days to keep comments and news?  (0 = infinite),int", "expiretrashacct" => "Days to keep never logged-in accounts? (0 = infinite),int", "expirenewacct" => "Days to keep 1 level (0 dragon) accounts? (0 =infinite),int", "expireoldacct" => "Days to keep all other accounts? (0 = infinite),int", "LOGINTIMEOUT" => "Seconds of inactivity before auto-logoff,int", "High Load Optimization,title", "This has been moved to the dbconnect.php,note", "LoGDnet Setup,title", "(LoGDnet requires your PHP configuration to have file wrappers enabled!!),note", "logdnet" => "Register with LoGDnet?,bool", "serverurl" => "Server URL", "serverdesc" => "Server Description (75 chars max)", "logdnetserver" => "Master LoGDnet Server (default http://logdnet.logd.com/)", "curltimeout" => "How long we wait for responses from logdnet.logd.com (in seconds),range,1,10,1|2", "Game day Setup,title", "dayduration" => "Day Duration,viewonly", "curgametime" => "Current game time,viewonly", "curservertime" => "Current Server Time,viewonly", "lastnewday" => "Last new day,viewonly", "nextnewday" => "Next new day,viewonly", "gameoffsetseconds" => "Real time to offset new day,{$enum}", "Translation Setup,title", "enabletranslation" => "Enable the use of the translation engine,bool", "It is strongly recommended to leave this feature turned on.,note", "cachetranslations" => "Cache the translations (datacache must be turned on)?,bool", "permacollect" => "Permanently collect untranslated texts (overrides the next settings!),bool", "collecttexts" => "Are we currently collecting untranslated texts?,viewonly", "tl_maxallowed" => "Collect untranslated texts if you have fewer player than this logged in. (0 never collects),int", "charset" => "Which charset should be used for htmlentities?", "Error Notification,title", "Note: you MUST have data caching turned on if you want to use this feature.  Also the first error within any 24 hour period will not generate a notice; I'm sorry: that's really just how it is for technical reasons.,note", "show_notices" => "Show PHP Notice output?,bool", "notify_on_warn" => "Send notification on site warnings?,bool", "notify_on_error" => "Send notification on site errors?,bool", "notify_address" => "Address to notify", "notify_every" => "Only notify every how many minutes for each distinct error?,int", "Miscellaneous Settings,title", "allowspecialswitch" => "The Barkeeper may help you to switch your specialty?,bool", "maxlistsize" => "Maximum number of items to be shown in the warrior list,int");
    $secstonewday = secondstonextgameday($details);
    $useful_vals = array("dayduration" => round($details['dayduration'] / 60 / 60, 0) . " hours", "curgametime" => getgametime(), "curservertime" => date("Y-m-d h:i:s a"), "lastnewday" => date("h:i:s a", strtotime("-{$details['realsecssofartoday']} seconds")), "nextnewday" => date("h:i:s a", strtotime("+{$details['realsecstotomorrow']} seconds")) . " (" . date("H\\h i\\m s\\s", $secstonewday) . ")");
    loadsettings();
    $vals = $settings + $useful_vals;
    rawoutput("<form action='configuration.php?op=save' method='POST'>");
    addnav("", "configuration.php?op=save");
    showform($setup, $vals);
    rawoutput("</form>");
}
page_footer();
    $sql = "SELECT acctid,name,login,alive,hitpoints,location,race,sex,level,laston,loggedin,lastip,uniqueid FROM " . db_prefix("accounts") . " WHERE locked=0 {$search} ORDER BY level DESC, dragonkills DESC, login ASC {$limit}";
    $result = db_query($sql);
}
if ($session['user']['loggedin']) {
    $search = translate_inline("Search by name: ");
    $search2 = translate_inline("Search");
    rawoutput("<form action='list.php?op=search' method='POST'>{$search}<input name='name'><input type='submit' class='button' value='{$search2}'></form>");
    addnav("", "list.php?op=search");
}
$max = db_num_rows($result);
if ($max > getsetting("maxlistsize", 100)) {
    output("`\$Too many names match that search.  Showing only the first %s.`0`n", getsetting("maxlistsize", 100));
    $max = getsetting("maxlistsize", 100);
}
if ($page == "" && $op == "") {
    $title .= sprintf_translate(" (%s warriors)", $max);
}
output_notl("`c`b" . $title . "`b");
$alive = translate_inline("Alive");
$level = translate_inline("Level");
$name = translate_inline("Name");
$loc = translate_inline("Location");
$race = translate_inline("Race");
$sex = translate_inline("Sex");
$last = translate_inline("Last On");
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>", true);
rawoutput("<tr class='trhead'><td>{$alive}</td><td>{$level}</td><td>{$name}</td><td>{$loc}</td><td>{$race}</td><td>{$sex}</td><td>{$last}</tr>");
$writemail = translate_inline("Write Mail");
$alive = translate_inline("`1Yes`0");
$dead = translate_inline("`4No`0");
$unconscious = translate_inline("`6Unconscious`0");
        } else {
            villagenav();
        }
        if ($session['user']['hitpoints'] <= 0) {
            output("`n`n`&Using a bit of cloth nearby, you manage to staunch your wounds so that you do not die as well.");
            $session['user']['hitpoints'] = 1;
        }
    } elseif ($defeat) {
        $killedin = $badguy['location'];
        $taunt = select_taunt_array();
        // This is okay because system mail which is all it's used for is
        // not translated
        $handled = pvpdefeat($badguy, $killedin, $taunt, $options);
        // Handled will be true if a module has already done the addnews or
        // whatever was needed.
        if (!$handled) {
            if ($killedin == $iname) {
                addnews(sprintf_translate("`%%s`5 has been slain while breaking into the inn room of `^%s`5 in order to attack them.`n%s`0", $session['user']['name'], $badguy['creaturename'], $taunt));
            } else {
                addnews(sprintf_translate("`%%s`5 has been slain while attacking `^%s`5 in the fields of `&%s`5.`n%s`0", $session['user']['name'], $badguy['creaturename'], $killedin, $taunt));
            }
        }
    } else {
        $extra = "";
        if (httpget('inn')) {
            $extra = "?inn=1";
        }
        fightnav(false, false, "pvp.php{$extra}");
    }
}
page_footer();
    }
    $pageoffset *= $playersperpage;
    $from = $pageoffset + 1;
    $to = min($pageoffset + $playersperpage, $totalplayers);
}
$limit = " LIMIT {$pageoffset},{$playersperpage} ";
addnav("Pages");
for ($i = 0; $i < $totalplayers; $i += $playersperpage) {
    addnav(array("Page %s (%s-%s)", $i / $playersperpage + 1, $i + 1, min($i + $playersperpage, $totalplayers)), "runmodule.php?module=marriage&op=newlyweds&page=" . ($i / $playersperpage + 1));
}
if ($page == "" && $action == "") {
    $title = translate_inline("Married Warriors Currently Online");
    $sql = "SELECT a.name as name,b.name as partnername,a.acctid as acctid,a.login as login,a.alive as alive,a.location as location,a.race as race,a.sex as sex,a.marriedto as marriedto,a.laston as laston,a.loggedin as loggedin,a.lastip as lastip,a.uniqueid as uniqueid FROM " . db_prefix("accounts") . " as a LEFT JOIN " . db_prefix("accounts") . " as b ON a.marriedto=b.acctid WHERE a.locked=0 AND (a.marriedto<>0 AND a.marriedto<>4294967295) AND a.loggedin=1 AND a.laston>'" . date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " seconds")) . "' ORDER BY a.level DESC, a.dragonkills DESC, a.login ASC";
    $result = db_query_cached($sql, "marriage-marriedonline");
} else {
    $title = sprintf_translate("Married Warriors in the realm (Page %s: %s-%s of %s)", $pageoffset / $playersperpage + 1, $from, $to, $totalplayers);
    rawoutput(tlbutton_clear());
    $sql = "SELECT a.name as name,b.name as partnername,a.acctid as acctid,a.login as login,a.alive as alive,a.location as location,a.race as race,a.sex as sex,a.marriedto as marriedto,a.laston as laston,a.loggedin as loggedin,a.lastip as lastip,a.uniqueid as uniqueid FROM " . db_prefix("accounts") . " as a LEFT JOIN " . db_prefix("accounts") . " as b ON a.marriedto=b.acctid WHERE a.locked=0 AND (a.marriedto<>0 AND a.marriedto<>4294967295) {$search}" . "ORDER BY a.level DESC, a.dragonkills DESC, a.login ASC {$limit}";
    $result = db_query_cached($sql, "marriage-marriedrealm{$page}");
}
$max = db_num_rows($result);
if ($max > 100) {
    output("`\$Too many names match that.  Showing only the first 100.`0`n");
    $max = 100;
}
output_notl("`c`b" . $title . "`b");
$alive = translate_inline("Alive");
$name = translate_inline("Name");
$clan = translate_inline("Clan");
$loc = translate_inline("Location");
$race = translate_inline("Race");
function settings_run()
{
    global $session;
    $op = httpget('op');
    $category = stripslashes(rawurldecode(httpget('cat'))) ?: 'Account';
    page_header("Settings - {$category}");
    switch ($op) {
        case 'save':
            $accounts = db_prefix('accounts');
            $post = httpallpost();
            unset($post['showFormTabIndex']);
            foreach ($post as $key => $val) {
                $post[$key] = stripcslashes($val);
            }
            $post['oldvalues'] = json_decode($post['oldvalues'], true);
            foreach ($post['oldvalues'] as $key => $val) {
                $post['oldvalues'][$key] = stripslashes($val);
            }
            $post = modulehook('prefs-change', $post);
            if ($post['return'] != '') {
                $return = $post['return'];
                unset($post['return']);
            }
            //Fix template changes.
            if (md5(md5($post['oldpass'])) == $session['user']['password'] && $post['newpass'] != '') {
                require_once 'lib/systemmail.php';
                $newPass = md5(md5($post['newpass']));
                db_query("UPDATE {$accounts}\n                    SET password = '******'\n                    WHERE acctid = '{$session['user']['acctid']}'");
                systemmail($session['user']['acctid'], 'Account Settings', "`@Your password was changed successfully!");
            }
            unset($post['newpass']);
            unset($post['oldpass']);
            foreach ($post as $key => $val) {
                if ($key == 'bio' && $val != $post['oldvalues']['bio']) {
                    $session['user']['bio'] = $val;
                } else {
                    if (!is_array($val) && $val != $post['oldvalues'][$key]) {
                        if (strpos($key, '__user') || strpos($key, '__check')) {
                            $moduleKey = explode('__', $key);
                            set_module_pref($moduleKey[1], $val, $moduleKey[0]);
                            unset($moduleKey);
                        } else {
                            $session['user']['prefs'][$key] = $val;
                        }
                    }
                }
            }
            $prefs = @serialize($session['user']['prefs']);
            db_query("UPDATE {$accounts} SET prefs = '{$prefs}'\n                WHERE acctid = '{$session['user']['acctid']}'");
            redirect("runmodule.php?module=settings&cat={$return}&save=true");
            addnav('Go back', 'runmodule.php?module=settings');
            break;
        default:
            $modules = db_prefix('modules');
            $userprefs = db_prefix('module_userprefs');
            $rewrite = trim(get_module_setting('rewrite'));
            $rewrite = json_decode($rewrite, true);
            $languages = getsetting('serverlanguages', 'en, English');
            $prefs = $session['user']['prefs'];
            $prefs['bio'] = $session['user']['bio'];
            $prefs['template'] = $_COOKIE['template'] ?: getsetting('defaultskin', 'jade.htm');
            $prefs['email'] = $session['user']['emailaddress'];
            $prefsFormat = ['Account' => ['bio' => 'Short biography, textarea', 'newpass' => 'New password, password', 'oldpass' => 'If you are changing your password&comma; type your old one, password', 'email' => 'Email, text'], 'Display' => ['template' => 'Skin, theme', 'language' => 'Which language do you prefer?, enum, ' . $languages, 'timestamp' => 'Show timestamps in commentary?, enum, 0, None, 1, Real Time, 2, Relative Time'], 'Game Behavior' => ['emailonmail' => 'Receive emails when you receive a mail?, bool', 'systemmail' => 'Receive emails for system messages?, bool', 'Be sure to check your email\'s spam folder and add our email as a trusted sender!, note', 'dirtyemail' => 'Allow profanity in mail?, bool', 'timeoffset' => sprintf_translate('Hours to offset time (currently %s)?, int', date($prefs['timeformat'], strtotime('now') + $prefs['timeoffset'] * 3600)), 'ihavenocheer' => 'Disable holiday text?, bool', 'nojump' => 'Disable jumping to the commentary when posting or refreshing?, bool']];
            if (count(explode(',', $languages)) < 3) {
                unset($prefs['Display']['language']);
            }
            $prefsFormat = modulehook('prefs-format', $prefsFormat);
            $prefsTemp = [];
            $modulesFound = [];
            $sql = db_query("SELECT modulename, formalname FROM {$modules}\n                WHERE infokeys LIKE '%|prefs|%'\n                AND active = 1\n                ORDER BY modulename");
            while ($row = db_fetch_assoc($sql)) {
                $formal = $row['formalname'];
                $modulesFound[$row['modulename']] = true;
                if (module_status($row['modulename']) == MODULE_FILE_NOT_PRESENT) {
                    foreach ($rewrite as $key => $moduleName) {
                        if ($moduleName == $formal || strpos($key, $row['modulename']) !== false) {
                            unset($rewrite[$key]);
                        }
                    }
                    set_module_setting('rewrite', json_encode($rewrite));
                } else {
                    $prefsTemp[$formal] = get_module_info($row['modulename'])['prefs'];
                }
                unset($prefsTemp[$formal][0]);
                foreach ($prefsTemp[$formal] as $setting => $description) {
                    $description = explode('|', $description)[0];
                    if (strpos($setting, 'user_') === false) {
                        unset($prefsTemp[$formal][$setting]);
                    } else {
                        $structuredKey = "{$row['modulename']}__{$setting}";
                        if ($rewrite[$structuredKey] != $formal) {
                            $prefsTemp[$rewrite[$structuredKey]][$structuredKey] = $description;
                        } else {
                            $prefsTemp[$formal][$structuredKey] = $description;
                        }
                        unset($prefsTemp[$formal][$setting]);
                    }
                }
                if (count($prefsTemp[$formal]) == 0) {
                    unset($prefsTemp[$formal]);
                    unset($modulesFound[$row['modulename']]);
                }
            }
            foreach ($modulesFound as $name => $true) {
                $sql = db_query("SELECT modulename, setting, value FROM {$userprefs}\n                    WHERE modulename = '{$name}'\n                    AND (setting LIKE 'user_%' OR setting LIKE 'check_%')\n                    AND userid = '{$session['user']['acctid']}'\n                    ");
                while ($row = db_fetch_assoc($sql)) {
                    $prefs["{$row['modulename']}__{$row['setting']}"] = $row['value'];
                }
            }
            $prefsFormat = array_merge_recursive($prefsFormat, $prefsTemp);
            $prefsFormat = modulehook('prefs-format', $prefsFormat);
            require_once 'lib/villagenav.php';
            villagenav();
            addnav('Refresh', 'runmodule.php?module=settings');
            addnav('Categories');
            foreach (array_keys($prefsFormat) as $int => $name) {
                addnav($name, "runmodule.php?module=settings&cat=" . rawurlencode($name));
            }
            output("`c`b`i`Q{$category} Settings`b`i`c");
            if (httpget('save')) {
                output("`@`iYour Settings have been saved!`i`n");
            }
            rawoutput("<form action='runmodule.php?module=settings&op=save' method = 'POST'>");
            require_once 'lib/showform.php';
            showform($prefsFormat[$category], $prefs);
            rawoutput(sprintf("<input type='hidden' name='oldvalues' value='%s' />", json_encode($prefs)));
            rawoutput("<input type='hidden' name='return' value='{$category}' />");
            rawoutput("</form>");
            rawoutput("<script type='text/javascript'>\n                document.getElementsByName('template')[0].onchange = function () {\n                    var index = this.selectedIndex;\n                    var selection = this.children[index].value;\n                    document.cookie = 'template=' + selection + ';expires=86400';\n                }\n\n                </script>");
            addnav('', 'runmodule.php?module=settings&op=save');
            break;
    }
    page_footer();
}
<?php

$fail = 0;
$last = date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " sec"));
if (is_module_active("pvpimmunity") && !get_module_pref("check_willing", "pvpimmunity")) {
    $fail = 1;
}
if (!$fail) {
    $typeid = get_module_setting("typeid", $args['type']);
    if ($session['user']['location'] == $args['location'] && get_module_objpref("dwellingtypes", $typeid, "pvp", "dwellings_pvp") && !get_module_objpref("dwellings", $args['dwid'], "bought", "dwellings_pvp") && $session['user']['playerfights'] > 0 && $args['status'] == 1) {
        $top = $session['user']['level'] + get_module_objpref("dwellingtypes", $typeid, "top-band", "dwellings_pvp");
        $bottom = $session['user']['level'] - get_module_objpref("dwellingtypes", $typeid, "bottom-band", "dwellings_pvp");
        $sql = "SELECT count(acctid) AS count FROM " . db_prefix("accounts") . " \r\n\t\t\t\t\tINNER JOIN " . db_prefix("module_userprefs") . " \r\n\t\t\t\t\tON acctid=userid \r\n\t\t\t\t\tWHERE (level>={$bottom} && level<={$top})\r\n\t\t\t\t\tAND (laston < '{$last}' OR loggedin=0)\r\n\t\t\t\t\tAND (pvpflag < '{$pvptimeout}')\r\n\t\t\t\t\tAND (alive=1) AND (locked=0) AND (slaydragon=0)\r\n\t\t\t\t\tAND modulename='dwellings'\r\n\t\t\t\t\tAND setting='dwelling_saver' \r\n\t\t\t\t\tAND value='{$args['dwid']}'";
        $res = db_query($sql);
        $row = db_fetch_assoc($res);
        $dwid = $args['dwid'];
        if ($row['count'] > 0) {
            $p = httpget('page');
            $s = httpget('sortby');
            $sh = httpget('showonly');
            $o = httpget('order');
            $temp = sprintf_translate("Slay (%s)", $row['count']);
            rawoutput("<a href='runmodule.php?module=dwellings_pvp&op=attack_list&dwid={$dwid}&typeid={$typeid}&p={$p}&s={$s}&sh={$sh}&o={$o}'>{$temp}</a><br>");
            addnav("", "runmodule.php?module=dwellings_pvp&op=attack_list&dwid={$dwid}&typeid={$typeid}&p={$p}&s={$s}&sh={$sh}&o={$o}");
        } else {
            // output_notl("`c`i");
            // output("None");
            // output_notl("`i`c`0");
        }
    }
}
function mountform($mount)
{
    // Let's sanitize the data
    if (!isset($mount['mountname'])) {
        $mount['mountname'] = "";
    }
    if (!isset($mount['mountid'])) {
        $mount['mountid'] = "";
    }
    if (!isset($mount['mountdesc'])) {
        $mount['mountdesc'] = "";
    }
    if (!isset($mount['mountcategory'])) {
        $mount['mountcategory'] = "";
    }
    if (!isset($mount['mountlocation'])) {
        $mount['mountlocation'] = 'all';
    }
    if (!isset($mount['mountdkcost'])) {
        $mount['mountdkcost'] = 0;
    }
    if (!isset($mount['mountcostgems'])) {
        $mount['mountcostgems'] = 0;
    }
    if (!isset($mount['mountcostgold'])) {
        $mount['mountcostgold'] = 0;
    }
    if (!isset($mount['mountfeedcost'])) {
        $mount['mountfeedcost'] = 0;
    }
    if (!isset($mount['mountforestfights'])) {
        $mount['mountforestfights'] = 0;
    }
    if (!isset($mount['newday'])) {
        $mount['newday'] = "";
    }
    if (!isset($mount['recharge'])) {
        $mount['recharge'] = "";
    }
    if (!isset($mount['partrecharge'])) {
        $mount['partrecharge'] = "";
    }
    if (!isset($mount['mountbuff'])) {
        $mount['mountbuff'] = array();
    }
    if (!isset($mount['mountactive'])) {
        $mount['mountactive'] = 0;
    }
    if (!isset($mount['mountbuff']['name'])) {
        $mount['mountbuff']['name'] = "";
    }
    if (!isset($mount['mountbuff']['roundmsg'])) {
        $mount['mountbuff']['roundmsg'] = "";
    }
    if (!isset($mount['mountbuff']['wearoff'])) {
        $mount['mountbuff']['wearoff'] = "";
    }
    if (!isset($mount['mountbuff']['effectmsg'])) {
        $mount['mountbuff']['effectmsg'] = "";
    }
    if (!isset($mount['mountbuff']['effectnodmgmsg'])) {
        $mount['mountbuff']['effectnodmgmsg'] = "";
    }
    if (!isset($mount['mountbuff']['effectfailmsg'])) {
        $mount['mountbuff']['effectfailmsg'] = "";
    }
    if (!isset($mount['mountbuff']['rounds'])) {
        $mount['mountbuff']['rounds'] = 0;
    }
    if (!isset($mount['mountbuff']['atkmod'])) {
        $mount['mountbuff']['atkmod'] = "";
    }
    if (!isset($mount['mountbuff']['defmod'])) {
        $mount['mountbuff']['defmod'] = "";
    }
    if (!isset($mount['mountbuff']['invulnerable'])) {
        $mount['mountbuff']['invulnerable'] = "";
    }
    if (!isset($mount['mountbuff']['regen'])) {
        $mount['mountbuff']['regen'] = "";
    }
    if (!isset($mount['mountbuff']['minioncount'])) {
        $mount['mountbuff']['minioncount'] = "";
    }
    if (!isset($mount['mountbuff']['minbadguydamage'])) {
        $mount['mountbuff']['minbadguydamage'] = "";
    }
    if (!isset($mount['mountbuff']['maxbadguydamage'])) {
        $mount['mountbuff']['maxbadguydamage'] = "";
    }
    if (!isset($mount['mountbuff']['mingoodguydamage'])) {
        $mount['mountbuff']['mingoodguydamage'] = "";
    }
    if (!isset($mount['mountbuff']['maxgoodguydamage'])) {
        $mount['mountbuff']['maxgoodguydamage'] = "";
    }
    if (!isset($mount['mountbuff']['lifetap'])) {
        $mount['mountbuff']['lifetap'] = "";
    }
    if (!isset($mount['mountbuff']['damageshield'])) {
        $mount['mountbuff']['damageshield'] = "";
    }
    if (!isset($mount['mountbuff']['badguydmgmod'])) {
        $mount['mountbuff']['badguydmgmod'] = "";
    }
    if (!isset($mount['mountbuff']['badguyatkmod'])) {
        $mount['mountbuff']['badguyatkmod'] = "";
    }
    if (!isset($mount['mountbuff']['badguydefmod'])) {
        $mount['mountbuff']['badguydefmod'] = "";
    }
    rawoutput("<form action='mounts.php?op=save&id={$mount['mountid']}' method='POST'>");
    rawoutput("<input type='hidden' name='mount[mountactive]' value=\"" . $mount['mountactive'] . "\">");
    addnav("", "mounts.php?op=save&id={$mount['mountid']}");
    rawoutput("<table>");
    rawoutput("<tr><td nowrap>");
    output("Mount Name:");
    rawoutput("</td><td><input name='mount[mountname]' value=\"" . htmlentities($mount['mountname'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Description:");
    rawoutput("</td><td><input name='mount[mountdesc]' value=\"" . htmlentities($mount['mountdesc'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Category:");
    rawoutput("</td><td><input name='mount[mountcategory]' value=\"" . htmlentities($mount['mountcategory'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Availability:");
    rawoutput("</td><td nowrap>");
    // Run a modulehook to find out where stables are located.  By default
    // they are located in 'Degolburg' (ie, getgamesetting('villagename'));
    // Some later module can remove them however.
    $vname = getsetting('villagename', LOCATION_FIELDS);
    $locs = array($vname => sprintf_translate("The Village of %s", $vname));
    $locs = modulehook("stablelocs", $locs);
    $locs['all'] = translate_inline("Everywhere");
    ksort($locs);
    reset($locs);
    rawoutput("<select name='mount[mountlocation]'>");
    foreach ($locs as $loc => $name) {
        rawoutput("<option value='{$loc}'" . ($mount['mountlocation'] == $loc ? " selected" : "") . ">{$name}</option>");
    }
    rawoutput("<tr><td nowrap>");
    output("Mount Cost (DKs):");
    rawoutput("</td><td><input name='mount[mountdkcost]' value=\"" . htmlentities((int) $mount['mountdkcost'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Cost (Gems):");
    rawoutput("</td><td><input name='mount[mountcostgems]' value=\"" . htmlentities((int) $mount['mountcostgems'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Cost (Gold):");
    rawoutput("</td><td><input name='mount[mountcostgold]' value=\"" . htmlentities((int) $mount['mountcostgold'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Mount Feed Cost`n(Gold per level):");
    rawoutput("</td><td><input name='mount[mountfeedcost]' value=\"" . htmlentities((int) $mount['mountfeedcost'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Delta Forest Fights:");
    rawoutput("</td><td><input name='mount[mountforestfights]' value=\"" . htmlentities((int) $mount['mountforestfights'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='5'></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("`bMount Messages:`b");
    rawoutput("</td><td></td></tr><tr><td nowrap>");
    output("New Day:");
    rawoutput("</td><td><input name='mount[newday]' value=\"" . htmlentities($mount['newday'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='40'></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Full Recharge:");
    rawoutput("</td><td><input name='mount[recharge]' value=\"" . htmlentities($mount['recharge'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='40'></td></tr>");
    rawoutput("<tr><td nowrap>");
    output("Partial Recharge:");
    rawoutput("</td><td><input name='mount[partrecharge]' value=\"" . htmlentities($mount['partrecharge'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='40'></td></tr>");
    rawoutput("<tr><td valign='top' nowrap>");
    output("Mount Buff:");
    rawoutput("</td><td>");
    output("Buff name:");
    rawoutput("<input name='mount[mountbuff][name]' value=\"" . htmlentities($mount['mountbuff']['name'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("`bBuff Messages:`b`n");
    output("Each round:");
    rawoutput("<input name='mount[mountbuff][roundmsg]' value=\"" . htmlentities($mount['mountbuff']['roundmsg'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Wear off:");
    rawoutput("<input name='mount[mountbuff][wearoff]' value=\"" . htmlentities($mount['mountbuff']['wearoff'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Effect:");
    rawoutput("<input name='mount[mountbuff][effectmsg]' value=\"" . htmlentities($mount['mountbuff']['effectmsg'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Effect No Damage:");
    rawoutput("<input name='mount[mountbuff][effectnodmgmsg]' value=\"" . htmlentities($mount['mountbuff']['effectnodmgmsg'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Effect Fail:");
    rawoutput("<input name='mount[mountbuff][effectfailmsg]' value=\"" . htmlentities($mount['mountbuff']['effectfailmsg'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("(message replacements: {badguy}, {goodguy}, {weapon}, {armor}, {creatureweapon}, and where applicable {damage}.)`n");
    output("`n`bEffects:`b`n");
    output("Rounds to last (from new day):");
    rawoutput("<input name='mount[mountbuff][rounds]' value=\"" . htmlentities((int) $mount['mountbuff']['rounds'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Player Atk mod:");
    rawoutput("<input name='mount[mountbuff][atkmod]' value=\"" . htmlentities($mount['mountbuff']['atkmod'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Player Def mod:");
    rawoutput("<input name='mount[mountbuff][defmod]' value=\"" . htmlentities($mount['mountbuff']['defmod'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Player is invulnerable (1 = yes, 0 = no):");
    rawoutput("<input name='mount[mountbuff][invulnerable]' value=\"" . htmlentities($mount['mountbuff']['invulnerable'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size=50><br/>");
    output("Regen:");
    rawoutput("<input name='mount[mountbuff][regen]' value=\"" . htmlentities($mount['mountbuff']['regen'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Minion Count:");
    rawoutput("<input name='mount[mountbuff][minioncount]' value=\"" . htmlentities($mount['mountbuff']['minioncount'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Min Badguy Damage:");
    rawoutput("<input name='mount[mountbuff][minbadguydamage]' value=\"" . htmlentities($mount['mountbuff']['minbadguydamage'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Max Badguy Damage:");
    rawoutput("<input name='mount[mountbuff][maxbadguydamage]' value=\"" . htmlentities($mount['mountbuff']['maxbadguydamage'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Min Goodguy Damage:");
    rawoutput("<input name='mount[mountbuff][mingoodguydamage]' value=\"" . htmlentities($mount['mountbuff']['mingoodguydamage'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Max Goodguy Damage:");
    rawoutput("<input name='mount[mountbuff][maxgoodguydamage]' value=\"" . htmlentities($mount['mountbuff']['maxgoodguydamage'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'><br/>");
    output("Lifetap:");
    rawoutput("<input name='mount[mountbuff][lifetap]' value=\"" . htmlentities($mount['mountbuff']['lifetap'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Damage shield:");
    rawoutput("<input name='mount[mountbuff][damageshield]' value=\"" . htmlentities($mount['mountbuff']['damageshield'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Badguy Damage mod:");
    rawoutput("<input name='mount[mountbuff][badguydmgmod]' value=\"" . htmlentities($mount['mountbuff']['badguydmgmod'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Badguy Atk mod:");
    rawoutput("<input name='mount[mountbuff][badguyatkmod]' value=\"" . htmlentities($mount['mountbuff']['badguyatkmod'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("Badguy Def mod:");
    rawoutput("<input name='mount[mountbuff][badguydefmod]' value=\"" . htmlentities($mount['mountbuff']['badguydefmod'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\" size='50'>");
    output("(multiplier)`n");
    output("`bOn Dynamic Buffs`b`n");
    output("`@In the above, for most fields, you can choose to enter valid PHP code, substituting <fieldname> for fields in the user's account table.`n");
    output("Examples of code you might enter:`n");
    output("`^<charm>`n");
    output("round(<maxhitpoints>/10)`n");
    output("round(<level>/max(<gems>,1))`n");
    output("`@Fields you might be interested in for this: `n");
    output_notl("`3name, sex `7(0=male 1=female)`3, specialty `7(DA=darkarts MP=mystical TS=thief)`3,`n");
    output_notl("experience, gold, weapon `7(name)`3, armor `7(name)`3, level,`n");
    output_notl("defense, attack, alive, goldinbank,`n");
    output_notl("spirits `7(-2 to +2 or -6 for resurrection)`3, hitpoints, maxhitpoints, gems,`n");
    output_notl("weaponvalue `7(gold value)`3, armorvalue `7(gold value)`3, turns, title, weapondmg, armordef,`n");
    output_notl("age `7(days since last DK)`3, charm, playerfights, dragonkills, resurrections `7(times died since last DK)`3,`n");
    output_notl("soulpoints, gravefights, deathpower `7(%s favor)`3,`n", getsetting("deathoverlord", '`$Ramius'));
    output_notl("race, dragonage, bestdragonage`n`n");
    output("You can also use module preferences by using <modulename|preference> (for instance '<specialtymystic|uses>' or '<drinks|drunkeness>'`n`n");
    output("`@Finally, starting a field with 'debug:' will enable debug output for that field to help you locate errors in your implementation.");
    output("While testing new buffs, you should be sure to debug fields before you release them on the world, as the PHP script will otherwise throw errors to the user if you have any, and this can break the site at various spots (as in places that redirects should happen).");
    rawoutput("</td></tr></table>");
    $save = translate_inline("Save");
    rawoutput("<input type='submit' class='button' value='{$save}'></form>");
}
function healnav($companions, $texts, $schemas)
{
    global $session;
    tlschema($schemas['healnav']);
    addnav($texts['healnav']);
    tlschema();
    $healable = false;
    foreach ($companions as $name => $companion) {
        if (isset($companion['cannotbehealed']) && $companion['cannotbehealed'] == true) {
        } else {
            $pointstoheal = $companion['maxhitpoints'] - $companion['hitpoints'];
            if ($pointstoheal > 0) {
                $healable = true;
                $costtoheal = round(log($session['user']['level'] + 1) * ($pointstoheal + 10) * 1.33);
                if ($session['user']['gold'] >= $costtoheal) {
                    addnav(array("%s`0 (`^%s Gold`0)", $companion['name'], $costtoheal), "mercenarycamp.php?op=heal&name=" . rawurlencode($name) . "&cost={$costtoheal}");
                } else {
                    addnav(array("%s`0 (`\$Not enough gold`0)", $companion['name']), "mercenarycamp.php?op=heal&name=" . rawurlencode($name) . "&cost=notenough");
                }
            }
        }
    }
    if ($healable == true) {
        tlschema($schemas['healtext']);
        if (is_array($texts['healtext'])) {
            foreach ($texts['healtext'] as $healtext) {
                output_notl(sprintf_translate($healtext));
            }
        } else {
            output($texts['healtext']);
        }
        tlschema();
    }
}
<?php

$passcost = (int) get_module_setting("pointsreq");
$shopname = get_module_setting("shopname");
$pointsavailable = $session['user']['donation'] - $session['user']['donationspent'];
switch (httpget('what')) {
    case "buypass":
        if ($passcost == 0) {
            $pts = translate_inline('is free');
        } elseif ($passcost == 1) {
            $pts = translate_inline('costs `^1`& donation point');
        } else {
            $pts = sprintf_translate('costs `^%s`& donation points', $passcost);
        }
        output("`7J. C. Petersen glances at you for a moment, sizing you up. After a moment, he nods.`n`n");
        output("`&\"A pass to visit `3%s`& %s.", $shopname, $pts);
        if ($pointsavailable < $passcost) {
            output(" `&I'm afraid, however, you don't have enough to afford it,\" he says.`0`n`n");
            addnav("L?Return to the Lodge", "lodge.php");
        } else {
            output(" `&Interested?\" `7he asks you, holding up a shimmering green token.`0`n`n");
            addnav("Yes", $from . "op=lodge&what=bought");
            addnav("No", "lodge.php");
        }
        break;
    case "bought":
        $session['user']['donationspent'] += $passcost;
        set_module_pref("pass", 1);
        output("`7J. C. makes a note on a ledger and then hands you the shimmering green token.`n`n");
        output("`&\"The pass is good for as long as you have it,\" `7he says.");
        output(" `&\"You'll find `3%s`& in `^%s`& by the way.\"`0`n`n", $shopname, get_module_setting('shoploc'));
     } elseif ($gems > 0 && $gold <= 0) {
         output_notl($e[7], $registrar, $gems);
     } else {
         output_notl($e[6], $registrar, $gold, $gems);
     }
     output_notl($e[8], $registrar);
     addnav("Return to the Lobby", "clan.php");
 } else {
     /*//*/
     $args = array("ocn" => $ocn, "ocs" => $ocs, "clanname" => $clanname, "clanshort" => $clanshort);
     /*//*/
     $args = modulehook("process-createclan", $args);
     /*//*/
     if (isset($args['blocked']) && $args['blocked']) {
         /*//*/
         output_notl(sprintf_translate($args['blockmsg']));
         /*//*/
         clanform();
         /*//*/
         addnav("Return to the Lobby", "clan.php");
         /*//*/
     } else {
         $sql = "INSERT INTO " . db_prefix("clans") . " (clanname,clanshort) VALUES ('{$clanname}','{$clanshort}')";
         db_query($sql);
         $id = db_insert_id();
         $session['user']['clanid'] = $id;
         $session['user']['clanrank'] = CLAN_LEADER + 1;
         //+1 because he is the founder
         $session['user']['clanjoindate'] = date("Y-m-d H:i:s");
         $session['user']['gold'] -= $gold;
         $session['user']['gems'] -= $gems;
function racekittymorph_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "Kittania";
    $race = "Kittymorph";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racekittymorph") {
                if ($session['user']['location'] == $args['old']) {
                    $session['user']['location'] = $args['new'];
                }
                $sql = "UPDATE " . db_prefix("accounts") . " SET location='" . addslashes($args['new']) . "' WHERE location='" . addslashes($args['old']) . "'";
                db_query($sql);
                if (is_module_active("cities")) {
                    $sql = "UPDATE " . db_prefix("module_userprefs") . " SET value='" . addslashes($args['new']) . "' WHERE modulename='cities' AND setting='homecity'" . "AND value='" . addslashes($args['old']) . "'";
                    db_query($sql);
                }
            }
            break;
        case "chooserace":
            if ($session['user']['dragonkills'] == 0) {
                break;
            }
            output("`0You smile, and turn around to show the gatekeeper your tail.  <a href='newday.php?setrace={$race}{$resline}'>\"Um... notice anything unusual?\"</a>`n`n", true);
            addnav("`&Kittymorph`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("\"`6Oh, I see, right,`0\" says the gatekeeper, looking down at his ledger.  \"`6A kittymorph, then, okay, let's see, here...  Kay, eye, tee, ee, em, oh, are, eff.  Kittymorph.`0\"  He looks up again.  \"`6Um.  You can turn around again, now.`0\"`n`nYou oblige.  \"`#Sorry.`0\"`n`n\"`6Don't worry about it.  Have you always been like this?`0\"`n`n\"`#Since I was a kitten,`0\" you reply.  \"`#I don't know what that crazy woman back there was talking about; she says I fell out of a plane and hit my head.  Rubbish.`0\"`n`n\"`6Of course,`0\" says the gatekeeper, smiling.  \"`6You would have landed on your feet, wouldn't you?`0\"`n`n\"`#That's right.  Although...`0\"  You look down, puzzled.  \"`#Some things just don't add up...`0\" you mutter.`n`n\"`6Well, don't worry,`0\" says the gatekeeper.  \"`6Just head into town and get some nice clothes, and you'll sort everything out, I'm sure.  If you wear clothes, that is.`0\"`n`nYou grin.  \"`#When it suits me.`0\"  You saunter off through the gates.  You don't really know how to walk any other way.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "alternativeresurrect":
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                racekittymorph_checkcity();
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('kittymorph3', array("name" => "KittyMorph Bonus: Travelling Speed", "class" => "Travelling", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph4', array("name" => "KittyMorph Bonus: Cooking and Carcass Cleaning Expertise", "class" => "Meat", "costmod" => 0.7, "expmod" => 1.2, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph1', array("name" => "KittyMorph Penalty: Hunting Indifference", "class" => "Hunting", "costmod" => 1.1, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph2', array("name" => "KittyMorph Penalty: Combat Indifference", "class" => "Combat", "costmod" => 1.1, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph5', array("name" => "KittyMorph Penalty: Technical Ineptitude", "class" => "ScrapBots", "costmod" => 1.1, "expmod" => 0.8, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "KittyMorph Bonus: Classy Insults Proficiency", "action" => "Insults - Classy", "costmod" => 0.9, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceconfusing', array("name" => "KittyMorph Bonus: Confusing Insults Proficiency", "action" => "Insults - Confusing", "costmod" => 0.5, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //combat buffs
                apply_buff("racialbenefit1", array("name" => "`7KittyMorph Penalty: Slender`0", "defmod" => "0.8", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racekittymorph"));
                apply_buff("racialbenefit2", array("name" => "`7KittyMorph Bonus: Claws`0", "atkmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racekittymorph"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racekittymorph_checkcity();
                if ($session['user']['armordef'] == 0) {
                    apply_buff("nudekitty", array("name" => "`7KittyMorph Bonus: Nude Fighting`0", "badguyatkmod" => 0.7, "badguydefmod" => 0.7, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "roundmsg" => "Because you are fighting completely starkers, {badguy} is hilariously distracted and cannot attack or defend as effectively!", "expireafterfight" => 1, "schema" => "module-racekittymorph"));
                }
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race) {
                if (!$session['user']['alive']) {
                    debug($args['creatureexp']);
                    $args['creatureexp'] = round($args['creatureexp'] * 1.3);
                    debug($args['creatureexp']);
                }
            }
            break;
        case "validforestloc":
        case "validlocation":
            if (is_module_active("cities")) {
                $args[$city] = "village-{$race}";
            }
            break;
        case "moderate":
            if (is_module_active("cities")) {
                tlschema("commentary");
                $args["village-{$race}"] = sprintf_translate("City of %s", $city);
                tlschema();
            }
            break;
        case "villagetext":
            racekittymorph_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of Kittania.  Though officially registered as a city, it only earned that title because there were so many sentient creatures living there.`n`nIn reality, the city is a very basic affair, little more than a pack living together in common conditions.  Kittymorphs are a little too lazy to build much.`n");
                $args['schemas']['text'] = "module-racekittymorph";
                $args['clock'] = "`n`0From the position of the sun in the sky, you reckon it's about `&%s`0.`n";
                $args['schemas']['clock'] = "module-racekittymorph";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`n`0Scrawled in dust on the floor is the current date, `&%s`0, `&%s %s %s`0.`n";
                    $args['schemas']['calendar'] = "module-racekittymorph";
                }
                $args['title'] = array("%s, Home of the Kittymorphs", $city);
                $args['schemas']['title'] = "module-racekittymorph";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racekittymorph";
                $args['talk'] = "`n`&Nearby some kittymorphs talk:`n";
                $args['schemas']['talk'] = "module-racekittymorph";
                $new = get_module_setting("newest-{$city}", "cities");
                if ($new != 0) {
                    $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$new}'";
                    $result = db_query_cached($sql, "newest-{$city}");
                    $row = db_fetch_assoc($result);
                    $args['newestplayer'] = $row['name'];
                    $args['newestid'] = $new;
                } else {
                    $args['newestplayer'] = $new;
                    $args['newestid'] = "";
                }
                if ($new == $session['user']['acctid']) {
                    $args['newest'] = "`n`0As you wander your new home, you feel your jaw dropping at the wonderful smells around you.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, jaw agape and buck naked, is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racekittymorph";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racekittymorph";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Toothclaw Close";
                $args['marketnav'] = "The Cul-De-Sac of Sparkly Things";
                $args['tavernnav'] = "Distraction Avenue";
                $args['schemas']['gatenav'] = "module-racekittymorph";
                unblocknav("stables.php");
            }
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racekittymorph";
            $args['desc'] = array("`6Just next door to the Clan Halls, a rather basic-looking set of stables has been erected.`n`n", array("As you head inside, you notice an obvious lack of the typical stable smell.  Apparently KittyMorphs, for all their laziness, like to keep things clean.`n`n\"`^Well hello there!  What can I do for you, my good %s?`6\" asks a grey-furred KittyMorph male whose name you're absolutely `icertain`i is not \"Mike.\"", translate_inline($session['user']['sex'] ? 'lady' : 'man', 'stables')));
            $args['schemas']['desc'] = "module-racekittymorph";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racekittymorph";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racekittymorph";
            $args['nosuchbeast'] = "`6\"`^Hmm.  Not heard of that one,`6\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racekittymorph";
            $args['toolittle'] = "`6Mike looks over the handful of currency you offered.  \"`^Aha.  Well, the price for this %s, you see, was actually `&%s `^Requisition  and `%%s`^ cigarettes.  Maybe you miscounted?`6\"";
            $args['schemas']['toolittle'] = "module-racekittymorph";
            $args['replacemount'] = "`6You sadly watch Mike lead your %s`6 away, along with your cigarettes.  However, when he returns, he brings with him a nice new `&%s`6 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racekittymorph";
            $args['newmount'] = "`6You hand over your currency.  Within moments, you become the proud recipient of a lovely new `&%s`6!";
            $args['schemas']['newmount'] = "module-racekittymorph";
            $args['confirmsale'] = "`n`n`6Mike eyes your mount up and down, checking it over carefully.  \"`^Yes, yes, that's a really nice example, right there - are you quite sure you want to part with it?`6\"";
            $args['schemas']['confirmsale'] = "module-racekittymorph";
            $args['mountsold'] = "`6With but a single tear, you hand your %s`6 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racekittymorph";
            $args['offer'] = "`n`n`6Mike offers you `&%s`6 Requisition and `%%s`6 Cigarettes for %s`6.";
            $args['schemas']['offer'] = "module-racekittymorph";
            break;
    }
    return $args;
}
     foreach ($texts['desc'] as $description) {
         output_notl(sprintf_translate($description));
     }
 } else {
     output($texts['desc']);
 }
 tlschema();
 $sql = "SELECT max(level) AS level FROM " . db_prefix("armor") . " WHERE level<=" . $session['user']['dragonkills'];
 $result = db_query($sql);
 $row = db_fetch_assoc($result);
 $sql = "SELECT * FROM " . db_prefix("armor") . " WHERE level={$row['level']} ORDER BY value";
 $result = db_query($sql);
 tlschema($schemas['tradein']);
 if (is_array($texts['tradein'])) {
     foreach ($texts['tradein'] as $description) {
         output_notl(sprintf_translate($description));
     }
 } else {
     output($texts['tradein']);
 }
 tlschema();
 $aname = translate_inline("`bName`b");
 $adef = translate_inline("`bDefense`b");
 $acost = translate_inline("`bCost`b");
 rawoutput("<table border='0' cellpadding='0'>");
 rawoutput("<tr class='trhead'><td>");
 output_notl($aname);
 rawoutput("</td><td align='center'>");
 output_notl($adef);
 rawoutput("</td><td align='right'>");
 output_notl($acost);
 if (!is_array($session['user']['dragonpoints'])) {
     $session['user']['dragonpoints'] = array();
 }
 invalidatedatacache("charlisthomepage");
 invalidatedatacache("list.php-warsonline");
 $session['user']['laston'] = date("Y-m-d H:i:s");
 // Handle the change in number of users online
 translator_check_collect_texts();
 // Let's throw a login module hook in here so that modules
 // like the stafflist which need to invalidate the cache
 // when someone logs in or off can do so.
 modulehook("player-login");
 if ($session['user']['loggedin']) {
     $session['allowednavs'] = unserialize($session['user']['allowednavs']);
     $link = "<a href='" . $session['user']['restorepage'] . "'>" . $session['user']['restorepage'] . "</a>";
     $str = sprintf_translate("Sending you to %s, have a safe journey", $link);
     header("Location: {$session['user']['restorepage']}");
     saveuser();
     echo $str;
     exit;
 }
 db_query("UPDATE " . db_prefix("accounts") . " SET loggedin=" . true . ", laston='" . date("Y-m-d H:i:s") . "' WHERE acctid = " . $session['user']['acctid']);
 $session['user']['loggedin'] = true;
 $location = $session['user']['location'];
 if ($session['user']['location'] == $iname) {
     $session['user']['location'] = $vname;
 }
 if ($session['user']['restorepage'] > "") {
     redirect($session['user']['restorepage']);
 } else {
     if ($location == $iname) {
function racezombie_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "New Pittsburgh";
    $race = "Zombie";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racezombie") {
                if ($session['user']['location'] == $args['old']) {
                    $session['user']['location'] = $args['new'];
                }
                $sql = "UPDATE " . db_prefix("accounts") . " SET location='" . addslashes($args['new']) . "' WHERE location='" . addslashes($args['old']) . "'";
                db_query($sql);
                if (is_module_active("cities")) {
                    $sql = "UPDATE " . db_prefix("module_userprefs") . " SET value='" . addslashes($args['new']) . "' WHERE modulename='cities' AND setting='homecity'" . "AND value='" . addslashes($args['old']) . "'";
                    db_query($sql);
                }
            }
            break;
        case "chooserace":
            if ($session['user']['dragonkills'] == 0) {
                break;
            }
            output("`0<a href='newday.php?setrace={$race}{$resline}'>\"BRAAAAAAAAAAAAINS.\"</a>`n`n", true);
            addnav("`0Zombie`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("`0The hairy man nods.  \"`6All right, all right, a simple \"I'm a zombie\" would have done.`0\"  He looks down and writes in his ledger.  \"`6Zed, oh, em, bee, why.  Zombie.  There.`0\"`n`nYou give the man a sheepish look.  \"`#I didn't actually mean to say that.  It just slipped out.`0\"`n`nHe smiles.  \"`6That's okay, I know how it is.  So, how did you get here?`0\"`n`n\"`#As far as I know, it was on a jet PLAAAAAAAAINS oh God!`0\"  You clap your hands over your mouth.`n`nThe gatekeeper chuckles.  \"`6Works every time.`0\"`n`nYou scowl at him.  \"`#Get on with the form.`0\"`n`n\"`6So, have you been a zombie all your life?`0\"`n`nYou pause.  \"`#I think so.  I mean...  Growing up, I think I played with the other zombie kids in zombie school, but...  Hmm.  It's amazing that there would have `ibeen`i a zombie school in the first place.`0\"  You give the man a very serious look.  \"`#This really doesn't make much sense at all, does it?`0\"`n`n\"`6Few things do around here, sunshine.  Do yourself a favour and don't think about it too much.  Unless you want your head to explode.`0\"`n`nThe word rushes up your throat like vomit.  \"`#BRAAAAAAAAAINS!`0\"`n`n\"`6Yes, that's right, brains.  Lovely juicy brains, splattering around all over the shop.  Yum!`0\"`n`nYou scowl at the gatekeeper while convulsing again, your mouth operating of its own accord.  \"`#BRAAAAAAAAAINS you know, that's really not funny.`0\"`n`n\"`6I know.  I shouldn't make fun.  It's a tough life for zombies.  You have it very hard, don't you?  Bits falling off all the time?  Uncontrollable larynx and primeval, base reactions if something sets you off?`0\"`n`n\"`#That's not true.`0\"  You shoot the gatekeeper a withering glare.  \"`#You've just been perpetuating the tired old Zombie stereotype.  And I, for one, am sick of the constant prejudice that comes from people like you.`0\"`n`n\"`6All right, all right, I meant no offense.  I was just having a little joke.`0\"`n`nGrudgingly, you remember your manners.  \"`#Apology accepted.  I didn't mean to get angry.  It's just hard, you know?`0\"`n`n\"`6I know,`0\" says the gatekeeper with a twinkle in his eye.  \"`6You don't need to explain.`0\"`n`n\"`#EXPLAAAAAAAAAAAAAAAAAAINS!  Oh, `ifuck you`i.`0\"  You storm off towards the gate.`n`nBehind you, the gatekeeper cries \"`6You know what, I think it might rain!`0\"`n`n\"`#RAAAAAAAAAINS!`0\" says your mouth.  \"`3`iFuck you, old man,`i`0\" says your internal monologue.  \"`3`iFuck you and your tasty, tasty brains.`i`0\"");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "alternativeresurrect":
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                racezombie_checkcity();
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('Zombie2', array("name" => "Zombie Bonus: Combat Endurance", "class" => "Combat", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie1', array("name" => "Zombie Bonus: Hunting Endurance", "class" => "Hunting", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie8', array("name" => "Zombie Bonus: Carcass Cleaning Skills", "action" => "Cleaning the Carcass", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie0', array("name" => "Zombie Penalty: Slow of Mind", "class" => "Global", "costmod" => 1, "expmod" => 0.8, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie3', array("name" => "Zombie Penalty: Slow-Moving", "class" => "Travelling", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie4', array("name" => "Zombie Penalty: Scavenging Slowness", "action" => "Scavenging for Scrap", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie5', array("name" => "Zombie Penalty: Metalwork Ineptitude", "action" => "Metalworking", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie6', array("name" => "Zombie Penalty: Soldering Ineptitude", "action" => "Soldering", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie7', array("name" => "Zombie Penalty: Programming Ineptitude", "action" => "Programming", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie9', array("name" => "Zombie Penalty: Cooking Ineptitude", "action" => "Cooking", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "Zombie Bonus: Insults Proficiency", "class" => "Insults", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //Combat Buffs
                apply_buff("racialbenefit1", array("name" => "`0Zombie Bonus: No Pain`0", "defmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racezombie"));
                apply_buff("racialbenefit2", array("name" => "`0Zombie Bonus: Leathery Fists`0", "atkmod" => "1.1", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racezombie"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racezombie_checkcity();
                $args['creaturegold'] = round($args['creaturegold'] * 1.2, 0);
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race && $session['user']['alive'] == false) {
                if (!$session['user']['alive']) {
                    $args['creatureexp'] = round($args['creatureexp'] * 0.8);
                }
            }
            break;
        case "validforestloc":
        case "validlocation":
            if (is_module_active("cities")) {
                $args[$city] = "village-{$race}";
            }
            break;
        case "moderate":
            if (is_module_active("cities")) {
                tlschema("commentary");
                $args["village-{$race}"] = sprintf_translate("City of %s", $city);
                tlschema();
            }
            break;
        case "villagetext":
            racezombie_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of New Pittsburgh.  This place used to be populated almost entirely by humans, but... well, you know zombies.`n`nThe stench of rotten flesh hangs in the air, and cries of \"BRAAAAAINS\" can be heard every now and then.`n`nYou notice a group of zombies conversing in grunts and moans around an old horse trough, idly picking at the flappy bits of skin on their necks.`n");
                $args['schemas']['text'] = "module-racezombie";
                $args['clock'] = "`n`0From the strength of the overpowering odour, you reason that it is approximately `0%s`0.`n";
                $args['schemas']['clock'] = "module-racezombie";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`n`0Written in blood on a nearby wall is `0%s`0, `0%s %s %s`0.`n";
                    $args['schemas']['calendar'] = "module-racezombie";
                }
                $args['title'] = array("%s, Home of the Zombies", $city);
                $args['schemas']['title'] = "module-racezombie";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racezombie";
                $args['talk'] = "`n`0Nearby some zombies talk:`n";
                $args['schemas']['talk'] = "module-racezombie";
                $new = get_module_setting("newest-{$city}", "cities");
                if ($new != 0) {
                    $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$new}'";
                    $result = db_query_cached($sql, "newest-{$city}");
                    $row = db_fetch_assoc($result);
                    $args['newestplayer'] = $row['name'];
                    $args['newestid'] = $new;
                } else {
                    $args['newestplayer'] = $new;
                    $args['newestid'] = "";
                }
                if ($new == $session['user']['acctid']) {
                    $args['newest'] = "`n`0As you wander your new home, you feel your jaw dropping at the wonderful smells around you.  The smells of BRAAAAAAINS.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, jaw agape and eyeballs swivelling in their sockets, is `0%s`0.";
                }
                $args['schemas']['newest'] = "module-racezombie";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racezombie";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Brains Avenue";
                $args['marketnav'] = "Shiny Street";
                $args['tavernnav'] = "Hugs Boulevard";
                $args['schemas']['gatenav'] = "module-racezombie";
                unblocknav("stables.php");
            }
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racezombie";
            $args['desc'] = array("`0Just next door to the Clan Halls, a scruffy-looking warehouse has been erected.  It looks pretty similar to the other buildings - blood splattered along every wall, groups of undead monsters shambling around, cries of \"BRAAAAAAAAINS!\" emanating from within - you know, the usual.  You head inside.`n`n", array("As you venture inside the building, a young Zombie woman shuffles towards you on her one good leg.  \"`^Good day to you, %s - my name is Mike, and what may I do for you today?`0\" You reason that \"Mike\" must be short for \"Michelle\" or something - or perhaps this whole franchise thing is going a bit too far.", translate_inline($session['user']['sex'] ? 'madam' : 'sir', 'stables')));
            $args['schemas']['desc'] = "module-racezombie";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racezombie";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racezombie";
            $args['nosuchbeast'] = "`0\"`^I'm sorry, I've never heard of such a thing,`0\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racezombie";
            $args['toolittle'] = "`0Mike looks over the handful of currency you offered.  \"`^Hmm.  Well, you see, the price for this %s was actually `0%s `^Requisition tokens and `%%s`^ cigarettes.  My apologies for any misunderstandings.`0\"";
            $args['schemas']['toolittle'] = "module-racezombie";
            $args['replacemount'] = "`0You sadly watch Mike lead your %s`0 away, along with your cigarettes.  However, when she returns, she brings with her a nice new `0%s`0 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racezombie";
            $args['newmount'] = "`0You hand over your currency.  Within moments, you become the proud recipient of a lovely new `0%s`0!";
            $args['schemas']['newmount'] = "module-racezombie";
            $args['confirmsale'] = "`n`n`0Mike eyes your mount up and down, checking it over carefully.  \"`^My, this is indeed a fine specimen.  Are you quite sure you wish to part with it?`0\"";
            $args['schemas']['confirmsale'] = "module-racezombie";
            $args['mountsold'] = "`0With but a single tear, you hand your %s`0 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racezombie";
            $args['offer'] = "`n`n`0Mike offers you `0%s`0 Requisition and `%%s`0 Cigarettes for %s`0.";
            $args['schemas']['offer'] = "module-racezombie";
            break;
    }
    return $args;
}
while ($row = db_fetch_assoc($result)) {
    $liftban = translate_inline("Lift&nbsp;ban");
    $showuser = translate_inline("Click&nbsp;to&nbsp;show&nbsp;users");
    rawoutput("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'>");
    rawoutput("<td><a href='user.php?op=delban&ipfilter=" . URLEncode($row['ipfilter']) . "&uniqueid=" . URLEncode($row['uniqueid']) . "'>");
    output_notl("%s", $liftban, true);
    rawoutput("</a>");
    addnav("", "user.php?op=delban&ipfilter=" . URLEncode($row['ipfilter']) . "&uniqueid=" . URLEncode($row['uniqueid']));
    rawoutput("</td><td>");
    output_notl("`&%s`0", $row['banner']);
    rawoutput("</td><td>");
    output_notl("%s", $row['ipfilter']);
    output_notl("%s", $row['uniqueid']);
    rawoutput("</td><td>");
    // "43200" used so will basically round to nearest day rather than floor number of days
    $expire = sprintf_translate("%s days", round((strtotime($row['banexpire']) + 43200 - strtotime("now")) / 86400, 0));
    if (substr($expire, 0, 2) == "1 ") {
        $expire = translate_inline("1 day");
    }
    if (date("Y-m-d", strtotime($row['banexpire'])) == date("Y-m-d")) {
        $expire = translate_inline("Today");
    }
    if (date("Y-m-d", strtotime($row['banexpire'])) == date("Y-m-d", strtotime("1 day"))) {
        $expire = translate_inline("Tomorrow");
    }
    if ($row['banexpire'] == "0000-00-00") {
        $expire = translate_inline("Never");
    }
    output_notl("%s", $expire);
    rawoutput("</td><td>");
    output_notl("%s", $row['banreason']);
        $session['user']['dragonkills']++;
        output("`&With a mighty final blow, `@The Green Dragon`& lets out a tremendous bellow and falls at your feet, dead at last.");
        addnews(sprintf_translate("`&%s has slain the hideous creature known as `@The Green Dragon`&.  All across the land, people rejoice!", $session['user']['name']));
        tlschema("nav");
        addnav("Continue", "dragon.php?op=prologue1&flawless={$flawless}");
        tlschema();
    } else {
        if ($defeat) {
            tlschema("nav");
            addnav("Daily news", "news.php");
            tlschema();
            $taunt = select_taunt_array();
            if ($session['user']['sex']) {
                addnews(sprintf_translate("`%%s`5 has been slain when she encountered `@The Green Dragon`5!!!  Her bones now litter the cave entrance, just like the bones of those who came before.`n%s", $session['user']['name'], $taunt));
            } else {
                addnews(sprintf_translate("`%%s`5 has been slain when he encountered `@The Green Dragon`5!!!  His bones now litter the cave entrance, just like the bones of those who came before.`n%s", $session['user']['name'], $taunt));
            }
            $session['user']['alive'] = false;
            debuglog("lost {$session['user']['gold']} gold when they were slain");
            $session['user']['gold'] = 0;
            $session['user']['hitpoints'] = 0;
            output("`b`&You have been slain by `@The Green Dragon`&!!!`n");
            output("`4All gold on hand has been lost!`n");
            output("You may begin fighting again tomorrow.");
            page_footer();
        } else {
            fightnav(true, false);
        }
    }
}
page_footer();