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;
        }
    }
}
     output_notl("`3%s`0", $moduleinfo[$i]['author'], true);
     rawoutput("</td><td valign='top'>");
     rawoutput($moduleinfo[$i]['category']);
     rawoutput("</td><td valign='top'>");
     rawoutput($moduleinfo[$i]['shortname'] . ".php");
     rawoutput("</td>");
     rawoutput("</tr>");
     if (isset($moduleinfo[$i]['requires']) && count($moduleinfo[$i]['requires'])) {
         rawoutput("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'>");
         rawoutput("<td>&nbsp;</td>");
         rawoutput("<td colspan='6'>");
         output("`bRequires:`b`n");
         reset($moduleinfo[$i]['requires']);
         while (list($key, $val) = each($moduleinfo[$i]['requires'])) {
             $info = explode("|", $val);
             if (module_check_requirements(array($key => $val))) {
                 output_notl("`@");
             } else {
                 output_notl("`\$");
             }
             if (isset($info[1])) {
                 output_notl("{$key} {$info[0]} -- {$info[1]}`n");
             } else {
                 output_notl("{$key} {$info[0]}`n");
             }
         }
         rawoutput("</td>");
         rawoutput("</tr>");
     }
     $count++;
 }