function iitems_superuser_item_menu()
{
    output("Select an item to edit, or create a new item.`n");
    massinvalidate("iitems");
    $sql = "SELECT id,localname,data FROM " . db_prefix("iitems");
    $result = db_query($sql);
    $allitems = array();
    $allkeys = array();
    $colcount = 0;
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $row = db_fetch_assoc($result);
        $item = unserialize($row['data']);
        $item['id'] = $row['id'];
        $allitems[$row['localname']] = $item;
        if (count($item) > $colcount) {
            $colcount = count($item);
        }
        foreach ($item as $key => $val) {
            $allkeys[$key] = 1;
        }
    }
    rawoutput("<table width=100% cellpadding=1 cellspacing=1 border=1><tr><td>Actions</td>");
    foreach ($allkeys as $key => $val) {
        rawoutput("<td>" . $key . "</td>");
    }
    rawoutput("</tr>");
    foreach ($allitems as $itemid => $vals) {
        rawoutput("<tr><td><a href=\"runmodule.php?module=iitems&op=superuser&superop=edit&id=" . $vals['id'] . "\">" . $vals['verbosename'] . " (" . $itemid . ")</a> (<a href=\"runmodule.php?module=iitems&op=superuser&superop=give&id=" . $itemid . "\">Give</a>) (<a href=\"runmodule.php?module=iitems&op=superuser&superop=delete&id=" . $vals['id'] . "\">Delete</a>) (<a href=\"runmodule.php?module=iitems&op=superuser&superop=copy&id=" . $vals['id'] . "\">Copy</a>)<br />");
        addnav("", "runmodule.php?module=iitems&op=superuser&superop=edit&id=" . $vals['id']);
        addnav("", "runmodule.php?module=iitems&op=superuser&superop=delete&id=" . $vals['id']);
        addnav("", "runmodule.php?module=iitems&op=superuser&superop=copy&id=" . $vals['id']);
        addnav("", "runmodule.php?module=iitems&op=superuser&superop=give&id=" . $itemid);
        foreach ($allkeys as $key => $val) {
            rawoutput("<td>");
            if ($key == "image") {
                rawoutput("<img src=\"images/iitems/" . $vals['image'] . "\">");
            } else {
                output_notl("%s", $allitems[$itemid][$key]);
            }
            rawoutput("</td>");
        }
        rawoutput("</tr>");
    }
    rawoutput("</table>");
}
function install_module($module, $force = true)
{
    global $mostrecentmodule, $session;
    $name = $session['user']['name'];
    if (!$name) {
        $name = '`@System`0';
    }
    require_once "lib/sanitize.php";
    if (modulename_sanitize($module) != $module) {
        output("Error, module file names can only contain alpha numeric characters and underscores before the trailing .php`n`nGood module names include 'testmodule.php', 'joesmodule2.php', while bad module names include, 'test.module.php' or 'joes module.php'`n");
        return false;
    } else {
        // If we are forcing an install, then whack the old version.
        if ($force) {
            $sql = "DELETE FROM " . db_prefix("modules") . " WHERE modulename='{$module}'";
            db_query($sql);
        }
        // We want to do the inject so that it auto-upgrades any installed
        // version correctly.
        if (injectmodule($module, true)) {
            // If we're not forcing and this is already installed, we are done
            if (!$force && is_module_installed($module)) {
                return true;
            }
            $info = get_module_info($module);
            //check installation requirements
            if (!module_check_requirements($info['requires'])) {
                output("`\$Module could not installed -- it did not meet its prerequisites.`n");
                return false;
            } else {
                $keys = "|" . join(array_keys($info), "|") . "|";
                $sql = "INSERT INTO " . db_prefix("modules") . " (modulename,formalname,moduleauthor,active,filename,installdate,installedby,category,infokeys,version,download,description) VALUES ('{$mostrecentmodule}','" . addslashes($info['name']) . "','" . addslashes($info['author']) . "',0,'{$mostrecentmodule}.php','" . date("Y-m-d H:i:s") . "','" . addslashes($name) . "','" . addslashes($info['category']) . "','{$keys}','" . addslashes($info['version']) . "','" . addslashes($info['download']) . "', '" . addslashes($info['description']) . "')";
                db_query($sql);
                $fname = $mostrecentmodule . "_install";
                if (isset($info['settings']) && count($info['settings']) > 0) {
                    foreach ($info['settings'] as $key => $val) {
                        if (is_array($val)) {
                            $x = explode("|", $val[0]);
                        } else {
                            $x = explode("|", $val);
                        }
                        if (isset($x[1])) {
                            $x[1] = trim($x[1]);
                            set_module_setting($key, $x[1]);
                            debug("Setting {$key} to default {$x[1]}");
                        }
                    }
                }
                if ($fname() === false) {
                    return false;
                }
                output("`^Module installed.  It is not yet active.`n");
                invalidatedatacache("inject-{$mostrecentmodule}");
                massinvalidate("moduleprepare");
                return true;
            }
        } else {
            output("`\$Module could not be injected.");
            output("Module not installed.");
            output("This is probably due to the module file having a parse error or not existing in the filesystem.`n");
            return false;
        }
    }
}
        if (substr($file, 0, strlen(DATACACHE_FILENAME_PREFIX)) == DATACACHE_FILENAME_PREFIX) {
            $fn = $datacachefilepath . "/" . $file;
            $fn = preg_replace("'//'", "/", $fn);
            $fn = preg_replace("'\\\\'", "\\", $fn);
            if (is_file($fn) && filemtime($fn) < strtotime("-24 hours")) {
                @unlink($fn);
            }
        }
    }
}
//Expire Chars
require_once "lib/expire_chars.php";
//Clean up old mails
$sql = "DELETE FROM " . db_prefix("mail") . " WHERE sent<'" . date("Y-m-d H:i:s", strtotime("-" . getsetting("oldmail", 14) . "days")) . "'";
db_query($sql);
massinvalidate("mail");
//Wipe the news entirely
$sql = "TRUNCATE TABLE " . db_prefix("news");
db_query($sql);
//wipe the contents of the whostyping table
$sql = "TRUNCATE TABLE " . db_prefix("whostyping");
db_query($sql);
if (getsetting("expirecontent", 180) > 0) {
    //Clean up debug log, moved from there
    $timestamp = date("Y-m-d H:i:s", strtotime("-" . round(getsetting("expirecontent", 180) / 10, 0) . " days"));
    $sql = "DELETE FROM " . db_prefix("debuglog") . " WHERE date <'{$timestamp}'";
    db_query($sql);
    gamelog("Cleaned up " . db_affected_rows() . " from " . db_prefix("debuglog") . " older than {$timestamp}.", 'maintenance');
    //Clean up game log
    $timestamp = date("Y-m-d H:i:s", strtotime("-1 month"));
    $sql = "DELETE FROM " . db_prefix("gamelog") . " WHERE date < '{$timestamp}' ";