if ($settings['maintenance'] == "1" && !iADMIN) {
    redirect(BASEDIR . "maintenance.php");
}
if (iMEMBER) {
    $result = dbquery("UPDATE " . DB_USERS . " SET user_lastvisit='" . time() . "', user_ip='" . USER_IP . "' WHERE user_id='" . (int) $userdata['user_id'] . "'");
}
if (!isset($_GET['pagenum']) || !isnum($_GET['pagenum'])) {
    $_GET['pagenum'] = 1;
}
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='" . $locale['xml_lang'] . "' lang='" . $locale['xml_lang'] . "'>\n";
echo "<head>\n<title>" . $settings['sitename'] . " " . $settings['sitetitle'] . "</title>\n";
echo "<meta http-equiv='Content-Type' content='text/html; charset=" . $locale['charset'] . "' />\n";
echo "<meta name='Language' content='" . $locale['xml_lang'] . "' />\n";
echo "<meta name='description' content='" . $settings['description'] . "' />\n";
echo "<meta name='keywords' content='" . $settings['keywords'] . "' />\n";
echo "<meta name='generator' content='Pimped-Fusion - Open Source Content Management System - v" . $settings['version_pimp'] . "' />\n";
echo "<link rel='stylesheet' href='" . load_css_file() . "' type='text/css' media='screen' />\n";
if (file_exists(IMAGES . "favicon.ico")) {
    echo "<link rel='shortcut icon' href='" . IMAGES . "favicon.ico' type='image/x-icon' />\n";
}
if (function_exists("get_head_tags")) {
    echo get_head_tags();
}
echo "<script type='text/javascript' src='" . INCLUDES_JS . "jscript.js'></script>\n";
echo "<script type='text/javascript' src='" . INCLUDES_JS . "jquery.js'></script>\n";
echo "<script type='text/javascript' src='" . INCLUDES_JS . "admin-msg.js'></script>\n";
require_once INCLUDES . "header_includes.php";
echo "</head>\n<body>\n";
require_once TEMPLATES . "panels.php";
ob_start();
/**
 * Returns a string containing the value that should be used for the theme_data column in the theme database table.
 * Includes contents of files loaded via @import
 *
 * @param array $theme_row is an associative array containing the theme's current database entry
 * @param mixed $stylesheet can either be the new content for the stylesheet or false to load from the standard file
 * @param string $root_path should only be used in case you want to use a different root path than "{$phpbb_root_path}styles/{$theme_row['theme_path']}"
 *
 * @return string Stylesheet data for theme_data column in the theme table
 */
function db_theme_data($theme_row, $stylesheet = false, $root_path = '')
{
    global $phpbb_root_path;
    if (!$root_path) {
        $root_path = $phpbb_root_path . 'styles/' . $theme_row['theme_path'];
    }
    if (!$stylesheet) {
        $stylesheet = '';
        if (file_exists($root_path . '/theme/stylesheet.css')) {
            $stylesheet = file_get_contents($root_path . '/theme/stylesheet.css');
        }
    }
    // Match CSS imports
    $matches = array();
    preg_match_all('/@import url\\(["\'](.*)["\']\\);/i', $stylesheet, $matches);
    if (sizeof($matches)) {
        foreach ($matches[0] as $idx => $match) {
            $stylesheet = str_replace($match, load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet);
        }
    }
    // adjust paths
    return str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet);
}