<?php

/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright:  2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: install.php,v 1.24.2.17 2004/09/19 09:35:42 ajvwaay Exp $



/************************************************************************/
/* MyPHPNuke: Web Portal System                                         */
/* ====================================                                 */
/*                                                                      */
/* Copyright (c) 2001 by the myPHPNuke development team                 */
/* http://www.myphpnuke.com                                             */
/************************************************************************/
/************************//* Modified version of: */
/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi                                */
/*  (fbc@mandrakesoft.com)                                              */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute                  */
/* it and/or modify                                                     */
/* it under the terms of the GNU General Public                         */
/* License as published by                                              */
/* the Free Software Foundation; either version 2 of                    */
/* the License.                                                         */
/************************************************************************/
/* Change Log   */
/************************************************************************/
/* 07-06-2001:niceguyeddie - Fixed typo in line 758                     */
/* 16-07-2001:Dave Starling - heavily modified to fit in with mpn       */
/* 20-09-2001:trini0/alexdupre - Install 1.8.8/Upgrade 1.8.5 - 1.8.7    */
/*      to 1.8.8.  Made textarea with copyright/credits readonly,       */
/*  took out 2nd SouthKorea reference in the flags & country list,      */
/*      took out old nuke function, have the script generate            */
/*      new config.php file if it doesn't exist, and also               */
/*      update the old config.php and the ability to have prefixes      */
/*  in database creation & a little tidying up.                         */
/************************************************************************/
/*

MyPHPNuke Install Script.

This script will set the database up, and do the basic configurations of the script.  Once this script has run, please delete this file from your root directory.  There is a security risk if you keep this file around.

The MyPHPNuke project is free software released under the GNU License.  Please read the credits file for more information on who has made this project possible.

*/

error_reporting  (E_ERROR | E_WARNING | E_PARSE);
define( '_MAINFILE_', (bool)TRUE );
//New in 188_8 since fixpack 2: set hardcoded table type at creation time to prevent from creation of unsupported table types
//like InnoDB at newer mySQL 4.0.x servers where an admin may have set the default table type to something different from
//myISAM.
$table_type='myISAM';

require_once './core_Constants.php';

if ( (bool)FALSE === function_exists( 'version_compare' ) )
{
    $msg = '<h1>Inadequate PHP Version.</h1><br /><h2>You must have a PHP version greater than or equal to<br />PHP 4.2.0 in order to run this software.</h2>';

    exit( $msg );
}

// Kiril: Security Check For Improperly Formed URI's

checkInstallRequest();

/* BEGIN 188_8 PATCHES */

// Kiril: Extract super globals into global namspace if registered globals is OFF.

$register_globals = @ini_get( 'register_globals' );

if ( empty( $register_globals ) || ! strcasecmp( $register_globals, 'off' ) || ! strcasecmp( $register_globals, 'false' ) )
{
    if ( ! empty( $_REQUEST ) ){ extract( $_REQUEST ); }
    if ( ! empty( $_COOKIE ) ) { extract( $_COOKIE ); }
    if ( ! empty( $_SERVER ) ) { extract( $_SERVER ); }
}

function checkInstallRequest()
{
    $uri = parse_url( $_SERVER['REQUEST_URI'] );

    if ( isset( $uri['query'] ) )
    {
         $arg_parts = explode( '&' , $uri['query'] );

         foreach( $arg_parts AS $v )
         {
            if ( 0 !== preg_match( '/[^a-z0-9=]/', $v ) || ! strpos( $v, '=' ) )
            {
                exit( '<h1>!! ACCESS DENIED !!</h1>' );
            }
        }
    }

    return;
}

/* END 188_8 PATCHES */

$tarray = array(
    "4nstats_datecnt", 
    "4nstats_hourcnt", 
    "4nstats_monthcnt", 
    "4nstats_weekcnt",
    "access", 
    "authors", 
    "autonews", 
    "banner", 
    "bannerclient", 
    "bannerfinish",
    "blocks", 
    "categories", 
    "chatboxII", 
    "click", 
    "comments", 
    "contactbook",
    "counter", 
    "downloads_categories", 
    "downloads_downloads", 
    "downloads_editorials",
    "downloads_modrequest", 
    "downloads_newdownload", 
    "downloads_subcategories",
    "downloads_votedata", 
    "ephem", 
    "eventcal", 
    "faqanswer", 
    "faqcategories",
    "forumconfig", 
    "forummods", 
    "forums", 
    "forumtopics",
    "gallery_categories",
    "gallery_comments", 
    "gallery_media_class", 
    "gallery_media_types",
    "gallery_pictures", 
    "gallery_pictures_newpicture", 
    "gallery_rate_check",
    "gallery_template_types", 
    "guestbook", 
    "headlines", 
    "lastseen", 
    "image_dirs",
    "links_categories",
    "links_editorieals", 
    "links_links", 
    "links_modrequest", 
    "links_newlink",
    "links_subcategories", 
    "links_votedata", 
    "mymsg2", 
    "poll_data",
    "poll_desc", 
    "pollcomments", 
    "popsettings", 
    "posts", 
    "priv_msgs", 
    "queue", 
    "quotes",
    "rand_banners", 
    "ranks", 
    "referer", 
    "related", 
    "reviews", 
    "reviews_add", 
    "reviews_comments",
    "reviews_main", 
    "seccont", 
    "sections", 
    "session",
    "smiles", 
    "stories", 
    "stories_cat", 
    "topics",
    "updatelog", 
    "users", 
    "users_status", 
    "visits_control", 
    "visits_counter", 
    "visits_system",
    "yp_brokenlink", 
    "yp_bussiness", 
    'yp_businesstxt', 
    "yp_categories", 
    "yp_modrequest", 
    "yp_votedata"
    );

// DATABASE CONNECTION //
function connect_db($dbhost, $dbuname, $dbpass)
{
    $result = @mysql_connect($dbhost, $dbuname, $dbpass);

    if ($result === FALSE)
    {
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}

// HEADER //
function make_header() {
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>MyPHPNuke <?php echo "" . _MPN_VERSION_ . ""; ?> Custom Installation</title>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <meta name="AUTHOR" content="MyPHPNuke">
    <meta name="GENERATOR" content="MyPHPNuke -- http://www.myphpnuke.com">
    <style type="text/css">

    <!--

        body {
            background: #C6C6D8;
            color: #000000;
            font-size: 1.0em;
            font-family: Verdana, Tahoma, sans-serif;
            text-decoration: none;
            margin-left: auto;
            margin-right: auto;
            text-align: center;
        }

        p, em, .mpn-title, .mpnpage-title, .mpn-normal {
            display: block;
            text-align: center;
            margin-left: auto;
            margin-right: auto;
        }

        td, p, a:link, a:active, a:visited, a:hover, .mpn-normal {
            font-size: 0.9em;
        }

        td, p, a:link, a:active, a:visited, .mpn-title, .mpnpage-title, .mpn-normal, .mpn-sub, em {
            color: inherit;
            background-color: transparent;
            text-decoration: none;
            font-family: Verdana, Tahoma, sans-serif;
        }

        a:hover {
            color: #80FFFF;
            text-decoration: underline;
            background-color: transparent;
        }

        .mpnpage-title {
            font-size: 1.3em;
            font-weight: bold;
            letter-spacing: 3px;
            margin-top: 20px;

        }

        .mpn-title {
            font-weight: bold;
            font-size: 1.1em;
        }

        .mpn-sub {
            font-size: 0.9em;
        }

        em {
            color: #FF0000;
            font-size: 1.1em;
            font-weight: bold;
        }

        div {
            width: 80%;
            margin-top: auto;
            margin-bottom: auto;
            margin-left: auto;
            margin-right: auto;
            padding: 15px;
            background-color: #BABEBE;
            color: inherit;
            text-align: center;
            border: 1px #000000 groove;
        }

        div.info {
            width: 65%;
            margin-left: auto;
            margin-right: auto;
            padding: 5px;
            background-color: #AAAAB6;
            color: #400040;
            border: 1px #A5A7EF ridge;
        }

        div.dblist {
            width: auto;
            margin-left: 20%;
            text-align: left;
            font-size: 0.9em;
            border: 0px;
        }

        .left {
            text-align: left;
        }


    -->
    </style>
    </head>

    <body>

        <p class="mpnpage-title">MyPHPNuke <?php echo "" . _MPN_VERSION_ . ""; ?> Installation</p>
        <div class="info">
            <p>At any time that you get stuck, please visit our support forums at:<br /><a href="http://www.myphpnuke.com/" target="_blank">www.myphpnuke.com</a></p>
        </div><br /><div>
    <?php
}

// FOOTER //
function make_footer() {
    ?>
    </div>
        <center>
            <br /><br /><p class="title">Thank you for trying MyPHPNuke and welcome to our community.</p><br /><br />
        </center>

    </body>
    </html>
    <?php
}

// Get Started and show the General Public License.
function show_license() {
    make_header();
    echo '<br><p>This script will install the MyPHPNuke database and help you set up the variables that you need to get started.<br /><br />You will be taken through a variety of pages, each page sets a different portion of the script.  We estimate that this entire process will take about five (5) minutes.';
    echo '<br /><br /><p class="mpn-title">Our License</p><hr width="80%" /><p>Please read through the GNU General Public License.<br /><br />MyPHPNuke is developed as free software, but there are certain requirements for distributing and editing.</p><br /><br />' . "\n";
    echo '<center><form action="' . $PHP_SELF . '" method="post">' . "\n";
    echo '' . "\n";
    echo '<textarea name="license" cols=50 rows=8 readonly>' . "\n";
    include('docs/COPYING.txt');
    echo '</textarea><br><br>' . "\n";
    if (check_environment())
    {
        echo '<input type="submit" name="op" value="Next" onClick=\'alert("PLEASE BACKUP YOUR DATA.\n\nThe upgrade portion is for standard installs only.  Nothing is implied for hacked versions of myPHPNuke.\n\nEnjoy using MPN.")\';>' . "\n";
    }
    else
    {
        echo '<p>Please consult with the <a href="http://www.myphpnuke.com/manual188/" target="_blank">MPN Manual</a> for more details.<br>' . "\n";
        echo 'If you\'re still having problems after addressing the displayed errors, post a request for help at <a href="http://www.myphpnuke.com/forum.php" target="_blank">myPHPNuke.com</a></p>' . "\n";
    }

    echo '</form></center>' . "\n";
    echo '<br><br>' . "\n";
    make_footer();
}

// Check Environment //
function check_environment()
{
    $pass = TRUE;

    /* CHECK FOR MYSQL EXTENTION */
    if (!extension_loaded('mysql'))
    {
        echo '<br /><em>Your server doesn\'t seem to have mySQL installed.<br />Contact your System Admin to fix this issue</em><br /><br />';
        $pass = FALSE;
    }

     /* CHECK MYSQL SERVER VERSION_ */
    $version = explode('.', mysql_get_client_info());
    if (!is_array($version) || ($version[0] <= 3 && $version[1] < 23))
    {
        echo '<br /><em>Your mySQL server seems not capable to support myPHPNuke.<br />Please upgrade to at least mySQL version 3.23.xx</em><br /><br />';
        $pass = FALSE;
    }

    /* CHECK TO SEE IF THE SCRIPT CAN WRITE TO ADMIN/ORIGINAL */
    if (!is_writeable('./admin/original') || (@file_exists('./admin/original/config.php') && !is_writable('./admin/original/config.php')))
    {
        echo '<br /><em>The script doesn\'t have enough permissions to write to<br /></em><br /><b>admin/original OR admin/original/config.php</b><br /><br />';
        $pass = FALSE;
    }

    /* CHECK TO SEE IF THE SCRIPT CAN WRITE TO ADMIN/MYPHPNUKE */
    if (!is_writeable('admin/myphpnuke') || (@file_exists('admin/myphpnuke/config.php') && !is_writable('admin/myphpnuke/config.php')))
    {
        echo '<br /><em>The script doesn\'t have enough permissions to write to<br /></em><br /><b>admin/myphpnuke OR admin/myphpnuke/config.php</b><br /><br />';
        $pass = FALSE;
    }

    /* CHECK TO SEE IF THE SCRIPT CAN WRITE TO DBCONF.PHP */
    if (!is_writeable('dbconf.php'))
    {
        echo '<br /><em>The script doesn\'t have enough permissions to write to<br /></em><br /><b>dbconf.php</b><br /><br />';
        $pass = FALSE;
    }

     /* CHECK TO SEE IF THE SCRIPT CAN WRITE TO dbconfig.php */
    if (!is_writeable('./admin/original/dbconfig.php'))
    {
        echo '<br /><em>The script doesn\'t have enough permissions to write to<br /></em><br /><b>admin/original/dbconfig.php</b><br /><br />';
        $pass = FALSE;
    }

    return $pass;
}

// GET DB INFO //
function get_dbinfo() {
    make_header();
    ?>
    <p class="mpn-title">Preliminary Info</p><hr width="80%" /><p>Please enter your DB info.  If you do not have root access to your DB (virtual hosting, etc), you will need to make your database before your proceed on.<br /><br />A good rule of thumb, if you cannot create databases through phpMyAdmin because of virtual hosting or security on mySQL, then this script will not be able to create the db for you.<br /><br />This script will still be able to fill the database tables so you need to complete the install. </p><br /><br /><p class="mpn-title">Your Database Information</p>
    <center>
        <form action="<?php $PHP_SELF ?>" method="post">
            <table>
                <tr><td align="right">DB Host</td>
                    <td><input type="text" name="dbhost" size=30 maxlength=80 value="localhost"></td></tr>
                    <tr><td align="right">DB User Name</td>
                    <td><input type="text" name="dbuname" size=30 maxlength=80 value=""></td></tr>
                    <tr><td align="right">DB Password</td>
                    <td><input type="text" name="dbpass" size=30 maxlength=80 value=""></td></tr>
                    <tr><td align="right">DB Name</td>
                    <td><input type="text" name="dbname" size=30 maxlength=80 value=""></td></tr>
                    <tr><td align="right">Table Prefix</td>
                    <td><input type="text" name="prefix" size=30 maxlength=80 value="mpn"></td></tr>

            </table>
            <br /><input type="submit" name="op" value="Submit">
        </form>
    </center>

    <?php
    make_footer();
}

// CONFIRMATION DB PAGE //
function confirm_db($dbhost, $dbuname, $dbpass, $dbname, $prefix) {
    global $tarray;
    make_header();
    if ($dbname == "" || $dbhost == "" || $dbuname == "" || $prefix == "") {
        die ("<em>You failed to include important information </em><br /><br />");
    } else { ?>
        <br /><br /><p class="mpn-title">DB Info</p><hr width="80%" /><p>This script will now attempt to make the database required for MyPHPNuke to operate.<br /><br />Please, look over the information and make sure that it is correct.</p><br /><br />



    <?php
    echo "<center>";

    echo "<p><b>You have entered the following information:</b></p><br />";

    echo "<table class=\"mpn-sub\" width=\"50%\" border=1><tr>";
        echo "<td width=\"50%\">DB Host</td><td width=\"50%\">$dbhost</td></tr>";
        echo "<tr><td width=\"50%\">DB User Name</td><td width=\"50%\">$dbuname</td></tr>";
        echo "<tr><td width=\"50%\">DB Password</td><td width=\"50%\">"; if (!$dbpass) { echo "&nbsp;"; } else { echo "$dbpass"; } echo "</td></tr>";
        echo "<tr><td width=\"50%\">DB Name</td><td width=\"50%\">$dbname</td></tr>";
        echo "<tr><td width=\"50%\">Table Prefix</td><td width=\"50%\">$prefix</td></tr>";

    echo "</table><br />";

    echo "<p>If everything looks OK, let's continue...</p><br />";
    echo "</center>";

    echo "<p class='mpn-title'>Now on with the new Database</p><hr width='80%' />";

    echo "<p>These are the tables that will be made in the database.  Before you move to the next step, please mark whether you have made the database already, or you want the script to make it for you.<br /><br /><em>Please note</em><br />You will more than likely need root access to your SQL server for this script to make the database.  If you are unsure if you have the rights to make the database, or don't know whether you have root access or not, assume that you don't, and make the database as instructed by your host.  The table information will be filled in after, and this should be the only outside step that you have to make.</p><br /><br /><p class='mpn-title'>Tables to be Created</p><br>";

    // time to display the table data
    $prefix = $prefix."_";
    echo "<center>";
        echo "<table border=1>";
            foreach($tarray as $table) {
                echo "<tr><td class=\"mpn-sub\" align='left'>".$prefix.$table."</td></tr>";
            }
        echo "</table><br><br>";
    echo "</center>";
    ?>
    <center>
        <p><em>Remember</em><br />If you do not have root access you need to make the db manually.  The install script will make the tables for you.  If you have already made the DB, just hit the Make Tables button and the tables will be made automatically.</p>

        <form action="<?php $PHP_SELF ?>" method="post">
            <table width="60%">
                <tr>
                    <td align="center">
                        <b>Check to create a new database:</b>&nbsp;<input type=checkbox name="dbmake">
                    </td>
                </tr><tr>
                    <td align="center"><br />
                        <input type="hidden" name="dbhost" value="<?php echo $dbhost;?>">
                        <input type="hidden" name="dbuname" value="<?php echo $dbuname;?>">
                        <input type="hidden" name="dbpass" value="<?php echo $dbpass;?>">
                        <input type="hidden" name="dbname" value="<?php echo $dbname;?>">
                        <input type="hidden" name="prefix" value="<?php echo $prefix;?>">
                        <input type="submit" name="op" value="Make_Tables">
                    </td>
                </tr>
            </table>
        </form>
    </center><br /><br />

    <?php
    }
    make_footer();
}

// MAKE THE DB HERE //
function make_db($dbhost, $dbuname, $dbpass, $dbname, $prefix, $dbmake) {
    global $table_type;
    make_header();

    $dbmessage1 = "<b>already exists</b>.<br />";
    $dbmessage2 = "<b>created</b>.<br />";

    echo '<center><br /><br />';

    $error = -1;

    if (connect_db($dbhost, $dbuname, $dbpass) !== TRUE)
    {
        $error = mysql_errno();
    }

    if (isset($dbmake) && $dbmake == 'on' && $error == -1)
    {
        $result = mysql_query('CREATE DATABASE ' . $dbname);
        if ($result === false)
        {
            $error = mysql_errno();
        }
        else
        {
            $result2 = @mysql_select_db($dbname);
            if ($result2 === FALSE)
            {
                $error = mysql_error();
            }
            else
            {
                echo '<em>Database ' . $dbname . ' has been created!</em><br /><hr width="80%" /><br />';
            }
        }
    }

    if (is_null( $dbmake ) && $dbmake != 'on' && $error == -1)
    {
        $result = @mysql_select_db($dbname);
        if ($result === FALSE)
        {
            $error = mysql_errno();
        }
        else
        {
            echo '<em>Assuming Database ' . $dbname . ' already exists.</em><br />Proceeding...<hr width="80%" /><br />';
        }
    }

    if (isset( $error ) && $error != -1)
    {
        switch( $error )
        {
            case 1007:
            echo '<em>Database ' . $dbname . ' already exists.</em><br />';
            echo 'Please uncheck the "<b>Check to create a new database</b>" box on the previous page.<br /><br />';
            echo '<a href="javascript:history.go(-1)">Go Back</a><br />';
            break;

            case 1044:
            case 1045:
            echo '<em>Database Access Denied.</em><br />Please double check your database settings.<br /><br />';
            echo '<a href="javascript:history.go(-2)">Go Back</a><br />';
            break;

            case 1049:
            echo '<em>Database ' . $dbname . ' doesn\'t seem to exist.</em><br />';
            echo 'Please try again.  If the problem persists, manually create the database using the dump file under the sql folder.<br /><br />';
            echo '<a href="javascript:history.go(-1)">Go Back</a><br />';
            break;

            default:
            echo '<em>Unknown Fatal Error.</em>';
            echo '<br /><br />' . mysql_error();
            break;
        }

        exit;
    }

    echo "<p class='mpn-title'>Database Query Summary</p><hr width='80%' /><br />";
    echo "<div class='dblist'>";

    $table = $prefix."4nstats_datecnt";
    $tabledef = "date varchar(8) NOT NULL default '', ";
    $tabledef .= "hits tinyint(2) unsigned NOT NULL default '0'";
    $tablecomment = "COMMENT='Statistics module: count per date'";
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."4nstats_hourcnt";
    $tabledef = "hour tinyint(2) unsigned NOT NULL default '0', ";
    $tabledef .= "hits int(10) unsigned NOT NULL default '0'";
    $tablecomment = "COMMENT='Statistics module: count per hour'";
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."4nstats_monthcnt";
    $tabledef = "month tinyint(2) unsigned NOT NULL default '0', ";
    $tabledef .= "hits int(10) unsigned NOT NULL default '0'";
    $tablecomment = "COMMENT='Statistics module: count per hour'";
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."4nstats_weekcnt";
    $tabledef = "weekday tinyint(1) unsigned NOT NULL default '0', ";
    $tabledef .= "hits int(10) unsigned NOT NULL default '0'";
    $tablecomment = "COMMENT='Statistics module: count per week'";
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."access";
    $tabledef = "access_id int(2) NOT NULL auto_increment, ";
    $tabledef .= "access_title varchar(20) default NULL, ";
    $tabledef .= "PRIMARY KEY  (access_id)";
    $tablecomment = "COMMENT='Forum module: access titles'";
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."authors";
    $tabledef = "aid varchar(30) NOT NULL default '', ";
    $tabledef .= "name varchar(50) default NULL, ";
    $tabledef .= "url varchar(60) default NULL, ";
    $tabledef .= "email varchar(60) default NULL, ";
    $tabledef .= "pwd varchar(40) default NULL, ";
    $tabledef .= "counter int(11) NOT NULL default '0', ";
    $tabledef .= "radminarticle tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radmintopic tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminleft tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminright tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminuser tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminmain tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminsurvey tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminsection tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminlink tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminephem tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminhead tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminfaq tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radmindownload tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminforum tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminreviews tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminguestbook tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminpartner tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminmpn tinyint(2) NOT NULL default '0', ";
    $tabledef .= "radminsuper tinyint(2) NOT NULL default '1', ";
    $tabledef .= "uid int(11) NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (aid), KEY idxauthorscounterdesc (counter)";
    $tablecomment = "COMMENT='Core system: admins and authors'";

    if ( ! mysql_query( "CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment" ) )
    {
        @mysql_query( "ALTER TABLE ".$table." DROP COLUMN radminfilem" );
        @mysql_query( 'ALTER TABLE ' . $table . ' ADD uid int(11) NOT NULL AFTER radminsuper' );

        echo $table . ' ' . $dbmessage1;
    }
    else
    {
        echo "".$table." $dbmessage2";
    }


    $table = $prefix."autonews";
    $tabledef = "anid int(11) NOT NULL auto_increment, ";
    $tabledef .= "catid int(11) NOT NULL default '0', ";
    $tabledef .= "aid varchar(30) NOT NULL default '', ";
    $tabledef .= "title varchar(80) NOT NULL default '', ";
    $tabledef .= "time varchar(19) NOT NULL default '', ";
    $tabledef .= "hometext text NOT NULL, ";
    $tabledef .= "bodytext text NOT NULL, ";
    $tabledef .= "topic int(3) NOT NULL default '1', ";
    $tabledef .= "informant varchar(25) NOT NULL default '', ";
    $tabledef .= "notes text NOT NULL, ";
    $tabledef .= "ihome int(1) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (anid), KEY idxautonewstimedesc (time)";
    $tablecomment = "COMMENT='Core system: automated news items'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
$query = "ALTER TABLE $table CHANGE informant informant varchar(25) NOT NULL";
@mysql_query($query);
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."banner";
    $tabledef = "bid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "imptotal int(11) NOT NULL default '0', ";
    $tabledef .= "impmade int(11) NOT NULL default '0', ";
    $tabledef .= "clicks int(11) NOT NULL default '0', ";
    $tabledef .= "imageurl varchar(255) NOT NULL default '', ";
    $tabledef .= "clickurl varchar(255) NOT NULL default '', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "PRIMARY KEY  (bid), ";
    $tabledef .= "KEY idxbannercid (cid), KEY idxbannerbidcid (bid,cid)";
    $tablecomment = "COMMENT='Banner module: banner details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."bannerclient";
    $tabledef = "cid int(11) NOT NULL auto_increment, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "contact varchar(60) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "login varchar(10) NOT NULL default '', ";
    $tabledef .= "passwd varchar(10) NOT NULL default '', ";
    $tabledef .= "extrainfo text NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (cid), KEY idxbannerclientlogin (login)";
    $tablecomment = "COMMENT='Banner module: customer details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."bannerfinish";
    $tabledef = "bid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "impressions int(11) NOT NULL default '0', ";
    $tabledef .= "clicks int(11) NOT NULL default '0', ";
    $tabledef .= "datestart datetime default NULL, ";
    $tabledef .= "dateend datetime default NULL, ";
    $tabledef .= "PRIMARY KEY  (bid), ";
    $tabledef .= "KEY idxbannerfinishcid (cid)";
    $tablecomment = "COMMENT='Banner module: finished banners'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."blocks";
    $tabledef = "bid int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "side tinyint(1) NOT NULL default '0', ";
    $tabledef .= "weight int(10) NOT NULL default '0', ";
    $tabledef .= "admin tinyint(1) NOT NULL default '0', ";
    $tabledef .= "position tinyint(1) NOT NULL default '0', ";
    $tabledef .= "visible tinyint(1) NOT NULL default '0', ";
    $tabledef .= "special int(10) NOT NULL default '0', ";
    $tabledef .= "title varchar(60) NOT NULL default '', ";
    $tabledef .= "content text NOT NULL, ";
    $tabledef .= "category tinyint(2) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (bid)";
    $tablecomment = "COMMENT='Core system: side blocks definitions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."categories";
    $tabledef = "cat_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "cat_title varchar(100) default NULL, ";
    $tabledef .= "PRIMARY KEY  (cat_id)";
    $tablecomment = "COMMENT='Core system: news categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."chatboxII";
    $tabledef = "username VARCHAR( 25 ) DEFAULT NULL, ";
    $tabledef .= "message VARCHAR( 75 ) DEFAULT NULL, ";
    $tabledef .= "date int(15) default NULL";
    $tablecomment = "COMMENT='Chat module: chat texts'";


    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
/* No need to alter the table, we always create a new table for chatboxII upon installation and an old table called
*  mpn_chatbox can be deleted. It's of no use to store the last 20 chatbox entries during an update from a very old
*  installation of myPHPNuke.
*         @mysql_query("ALTER TABLE ".$table." DROP COLUMN ip, DROP COLUMN id, DROP COLUMN dbname");
*/
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."click";
    $tabledef = "num int(10) NOT NULL auto_increment, ";
    $tabledef .= "hits int(10) NOT NULL default '0', ";
    $tabledef .= "url varchar(100) NOT NULL default '', ";
    $tabledef .= "image varchar(100) NOT NULL default '', ";
    $tabledef .= "text text NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (num), UNIQUE KEY num (num)";
    $tablecomment = "COMMENT='Banners module: number of clicks per URL'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."comments";
    $tabledef = "tid int(11) NOT NULL auto_increment, ";
    $tabledef .= "pid int(11) default '0', ";
    $tabledef .= "sid int(11) default '0', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "email varchar(60) default NULL, ";
    $tabledef .= "url varchar(255) default NULL, ";
    $tabledef .= "host_name varchar(60) default NULL, ";
    $tabledef .= "subject varchar(85) NOT NULL default '', ";
    $tabledef .= "comment text NOT NULL, ";
    $tabledef .= "score tinyint(4) NOT NULL default '0', ";
    $tabledef .= "reason tinyint(4) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (tid), ";
    $tabledef .= "KEY idxcommentspid (pid), ";
    $tabledef .= "KEY idxcommentsdatedesc (date), ";
    $tabledef .= "KEY idxcommentssid (sid), ";
    $tabledef .= "KEY idxcommentsdatetidpid (date,tid,pid), ";
    $tabledef .= "KEY idxcommentssidpid (sid,pid), ";
    $tabledef .= "KEY idxcommentstidsid (tid,sid), ";
    $tabledef .= "KEY idxcommentstiddescname (tid,name), ";
    $tabledef .= "KEY idxcommentsscorename (score,name), ";
    $tabledef .= "KEY idxcommentsscorehostname (score,host_name), ";
    $tabledef .= "KEY idxcommentspidsidsubject (pid,sid,subject)";
    $tablecomment = "COMMENT='News module: comments on news items'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."contactbook";
    $tabledef = "uid int(11) default NULL, ";
    $tabledef .= "contactid int(11) NOT NULL auto_increment, ";
    $tabledef .= "firstname varchar(50) default NULL, ";
    $tabledef .= "lastname varchar(50) default NULL, ";
    $tabledef .= "email varchar(255) default NULL, ";
    $tabledef .= "company varchar(255) default NULL, ";
    $tabledef .= "homeaddress varchar(255) default NULL, ";
    $tabledef .= "city varchar(80) default NULL, ";
    $tabledef .= "homephone varchar(255) default NULL, ";
    $tabledef .= "workphone varchar(255) default NULL, ";
    $tabledef .= "homepage varchar(255) default NULL, ";
    $tabledef .= "IM varchar(255) default NULL, ";
    $tabledef .= "events text, ";
    $tabledef .= "reminders int(11) default NULL, ";
    $tabledef .= "notes text, ";
    $tabledef .= "PRIMARY KEY  (contactid)";
    $tablecomment = "COMMENT='Webmail module: addressbook'";

    @mysql_query("ALTER TABLE contactbook RENAME ".$table."");
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."counter";
    $tabledef = "type varchar(80) NOT NULL default '', ";
    $tabledef .= "var varchar(80) NOT NULL default '', ";
    $tabledef .= "count int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "KEY idxcountertypedesc (type)";
    $tablecomment = "COMMENT='Statistics module: count pageviews per browser type'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_categories";
    $tabledef = "cid int(11) NOT NULL auto_increment, ";
    $tabledef .= "title varchar(50) NOT NULL default '', ";
    $tabledef .= "cdescription text NOT NULL, ";
    $tabledef .= "PRIMARY KEY (cid)";
    $tablecomment = "COMMENT='Downloads module: categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_downloads";
    $tabledef = "lid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(100) NOT NULL default '', ";
    $tabledef .= "email varchar(100) NOT NULL default '', ";
    $tabledef .= "hits int(11) NOT NULL default '0', ";
    $tabledef .= "submitter varchar(25) NOT NULL default '', ";
    $tabledef .= "downloadratingsummary double(6,4) NOT NULL default '0.0000', ";
    $tabledef .= "totalvotes int(11) NOT NULL default '0', ";
    $tabledef .= "totalcomments int(11) NOT NULL default '0', ";
    $tabledef .= "filesize int(11) NOT NULL default '0', ";
    $tabledef .= "version varchar(25) NOT NULL default '', ";
    $tabledef .= "homepage varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (lid)";
    $tablecomment = "COMMENT='Downloads module: download details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_editorials";
    $tabledef = "downloadid int(11) NOT NULL default '0', ";
    $tabledef .= "adminid varchar(30) NOT NULL default '', ";
    $tabledef .= "editorialtimestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "editorialtext text NOT NULL, ";
    $tabledef .= "editorialtitle varchar(100) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (downloadid)";
    $tablecomment = "COMMENT='Downloads module: editorial details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_modrequest";
    $tabledef = "requestid int(11) NOT NULL auto_increment, ";
    $tabledef .= "lid int(11) NOT NULL default '0', ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "modifysubmitter varchar(25) NOT NULL default '', ";
    $tabledef .= "brokendownload int(3) NOT NULL default '0', ";
    $tabledef .= "name varchar(100) NOT NULL default '', ";
    $tabledef .= "email varchar(100) NOT NULL default '', ";
    $tabledef .= "filesize int(11) NOT NULL default '0', ";
    $tabledef .= "version varchar(25) NOT NULL default '', ";
    $tabledef .= "homepage varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (requestid), ";
    $tabledef .= "UNIQUE KEY requestid (requestid)";
    $tablecomment = "COMMENT='Downloads module: modifcation requests'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_newdownload";
    $tabledef = "lid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "name varchar(100) NOT NULL default '', ";
    $tabledef .= "email varchar(100) NOT NULL default '', ";
    $tabledef .= "submitter varchar(25) NOT NULL default '', ";
    $tabledef .= "filesize int(11) NOT NULL default '0', ";
    $tabledef .= "version varchar(25) NOT NULL default '', ";
    $tabledef .= "homepage varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (lid)";
    $tablecomment = "COMMENT='Downloads module: new submitted, not yet approved downloads'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_subcategories";
    $tabledef = "sid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(50) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (sid)";
    $tablecomment = "COMMENT='Downloads module: subcategories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."downloads_votedata";
    $tabledef = "ratingdbid int(11) NOT NULL auto_increment, ";
    $tabledef .= "ratinglid int(11) NOT NULL default '0', ";
    $tabledef .= "ratinguser varchar(25) NOT NULL default '', ";
    $tabledef .= "rating int(11) NOT NULL default '0', ";
    $tabledef .= "ratinghostname varchar(60) NOT NULL default '', ";
    $tabledef .= "ratingcomments text NOT NULL, ";
    $tabledef .= "ratingtimestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "PRIMARY KEY  (ratingdbid)";
    $tablecomment = "COMMENT='Downloads module: voting details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."ephem";
    $tabledef = "eid int(11) NOT NULL auto_increment, ";
    $tabledef .= "did int(2) NOT NULL default '0', ";
    $tabledef .= "mid int(2) NOT NULL default '0', ";
    $tabledef .= "yid int(4) NOT NULL default '0', ";
    $tabledef .= "content text NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (eid), ";
    $tabledef .= "KEY idxephemdidmid (did,mid)";
    $tablecomment = "COMMENT='Ephemerids module: ephemerids details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."eventcal";
    $tabledef = "id int(6) NOT NULL auto_increment, ";
    $tabledef .= "date_from date NOT NULL default '0000-00-00', ";
    $tabledef .= "date_to date NOT NULL default '0000-00-00', ";
    $tabledef .= "eventname varchar(255) NOT NULL default '', ";
    $tabledef .= "eventdesc text NOT NULL, ";
    $tabledef .= "uid int(11) NOT NULL default '0', ";
    $tabledef .= "eventgo int(2) NOT NULL default '0', ";
    $tabledef .= "eventmail varchar(255) NOT NULL default '', ";
    $tabledef .= "eventweb varchar(255) NOT NULL default '', ";
    $tabledef .= "eventname1 varchar(255) NOT NULL default '', ";
    $tabledef .= "eventcatid int(6) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (id)";
    $tablecomment = "COMMENT='Event calendar module: calendar details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."faqanswer";
    $tabledef = "id tinyint(4) NOT NULL auto_increment, ";
    $tabledef .= "id_cat tinyint(4) default NULL, ";
    $tabledef .= "question varchar(255) default NULL, ";
    $tabledef .= "answer text, ";
    $tabledef .= "PRIMARY KEY  (id), ";
    $tabledef .= "KEY idxfaqansweridcat (id_cat), ";
    $tabledef .= "KEY idxfaqanswerididcat (id,id_cat)";
    $tablecomment = "COMMENT='FAQ module: questions and answers'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."faqcategories";
    $tabledef = "id_cat tinyint(3) NOT NULL auto_increment, ";
    $tabledef .= "categories varchar(255) default NULL, ";
    $tabledef .= "PRIMARY KEY  (id_cat)";
    $tablecomment = "COMMENT='FAQ module: categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }
    $table = $prefix."forumconfig";
    $tabledef = "allow_html int(2) default NULL, ";
    $tabledef .= "allow_bbcode int(2) default NULL, ";
    $tabledef .= "allow_sig int(2) default NULL, ";
    $tabledef .= "posts_per_page int(10) default NULL, ";
    $tabledef .= "hot_threshold int(10) default NULL, ";
    $tabledef .= "topics_per_page int(10) default NULL";
    $tablecomment = "COMMENT='Forum module: configuration details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."forummods";
    $tabledef = "forum_id int(10) NOT NULL default '0', ";
    $tabledef .= "user_id int(10) NOT NULL default '0'";
    $tablecomment = "COMMENT='Forum module: moderators per forum'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."forums";
    $tabledef = "forum_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "forum_name varchar(150) default NULL, ";
    $tabledef .= "forum_desc text, ";
    $tabledef .= "forum_access tinyint(1) default '1', ";
    $tabledef .= "forum_moderator int(10) default NULL, ";
    $tabledef .= "cat_id int(10) default NULL, ";
    $tabledef .= "forum_type tinyint(1) default '0', ";
    $tabledef .= "forum_pass varchar(60) default NULL, ";
    $tabledef .= "PRIMARY KEY (forum_id), ";
    $tabledef .= "KEY idxforumscatid (cat_id), ";
    $tabledef .= "KEY idxforums (forum_id,cat_id,forum_type,forum_access)";
    $tablecomment = "COMMENT='Forum module: forum descriptions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment"))
    {
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumsforumidcatidforummoderator');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumsforumidcatid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumsforumidforummoderator');

        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX idxforums (forum_id,cat_id,forum_type,forum_access)' );

        echo $table . $dbmessage1;
    }
    else
    {
        echo $table . $dbmessage2;
    }


    $table = $prefix."forumtopics";
    $tabledef = "topic_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "topic_title varchar(100) default NULL, ";
    $tabledef .= "topic_poster int(10) default NULL, ";
    $tabledef .= "topic_time varchar(20) default NULL, ";
    $tabledef .= "topic_views int(10) NOT NULL default '0', ";
    $tabledef .= "forum_id int(10) default NULL, ";
    $tabledef .= "topic_status tinyint(1) NOT NULL default '0', ";
    $tabledef .= "topic_notify int(2) default '0', ";
    $tabledef .= "PRIMARY KEY  (topic_id), ";
    $tabledef .= "KEY forum_id (forum_id), ";
    $tabledef .= "KEY idxtopics (topic_id,topic_views,topic_poster), ";
    $tabledef .= "KEY idxtitletime (forum_id,topic_title,topic_time)";
    $tablecomment = "COMMENT='Forum module: topics'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment"))
    {
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumtopicsforumid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumtopicstopicidtopicposter');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxforumtopicstopictimedescforumidtopicposter');

        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX forum_id (forum_id)' );
        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX idxtopics (topic_id,topic_views,topic_poster)' );
        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX idxtitletime (forum_id,topic_title,topic_time)' );

        echo $table . $dbmessage1;
    }
    else
    {
        echo $table . $dbmessage2;
    }

    $table = $prefix."gallery_categories";
    $tabledef = "gallid int(3) NOT NULL auto_increment, ";
    $tabledef .= "gallname varchar(30) NOT NULL default '', ";
    $tabledef .= "gallimg varchar(50) NOT NULL default '', ";
    $tabledef .= "galloc longtext, ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "parent int(3) NOT NULL default '-1', ";
    $tabledef .= "visible tinyint(3) unsigned NOT NULL default '0', ";
    $tabledef .= "template int(10) unsigned NOT NULL default '2', ";
    $tabledef .= "numcol tinyint(3) unsigned NOT NULL default '3', ";
    $tabledef .= "total int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "lastadd date NOT NULL default '0000-00-00', ";
    $tabledef .= "PRIMARY KEY  (gallid), ";
    $tabledef .= "KEY gallid (gallid)";
    $tablecomment = "COMMENT='Gallery module: categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_comments";
    $tabledef = "cid int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "pid int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "comment varchar(255) NOT NULL default '', ";
    $tabledef .= "date datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "name varchar(255) default NULL, ";
    $tabledef .= "member tinyint(3) unsigned NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (cid)";
    $tablecomment = "COMMENT='Gallery module: comments'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_media_class";
    $tabledef = "id int(2) NOT NULL default '0', ";
    $tabledef .= "class varchar(10) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (id), ";
    $tabledef .= "UNIQUE KEY id (id)";
    $tablecomment = "COMMENT='Gallery module: media class definitions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_media_types";
    $tabledef = "extension varchar(10) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "filetype varchar(10) NOT NULL default '', ";
    $tabledef .= "displaytag text NOT NULL, ";
    $tabledef .= "thumbnail varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (extension)";
    $tablecomment = "COMMENT='Gallery module: media types'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_pictures";
    $tabledef = "pid int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "gid int(3) NOT NULL default '0', ";
    $tabledef .= "img varchar(255) NOT NULL default '', ";
    $tabledef .= "counter int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "submitter varchar(25) NOT NULL default 'Webmaster', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "votes int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "rate float NOT NULL default '0', ";
    $tabledef .= "extension varchar(10) NOT NULL default 'image', ";
    $tabledef .= "width smallint(5) unsigned NOT NULL default '0', ";
    $tabledef .= "height smallint(5) unsigned NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (pid), ";
    $tabledef .= "KEY pid (pid)";
    $tablecomment = "COMMENT='Gallery module: media details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_pictures_newpicture";
    $tabledef = "pid int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "gid int(3) NOT NULL default '0', ";
    $tabledef .= "img varchar(255) NOT NULL default '', ";
    $tabledef .= "counter int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "submitter varchar(25) NOT NULL default 'Webmaster', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "votes int(10) unsigned NOT NULL default '0', ";
    $tabledef .= "rate float NOT NULL default '0', ";
    $tabledef .= "extension varchar(10) NOT NULL default 'image', ";
    $tabledef .= "width smallint(5) unsigned NOT NULL default '0', ";
    $tabledef .= "height smallint(5) unsigned NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (pid), ";
    $tabledef .= "KEY pid (pid)";
    $tablecomment = "COMMENT='Gallery module: new submitted media, to be approved'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_rate_check";
    $tabledef = "ip varchar(20) NOT NULL default '', ";
    $tabledef .= "time varchar(14) NOT NULL default '', ";
    $tabledef .= "pid int(10) unsigned NOT NULL default '0'";
    $tablecomment = "COMMENT='Gallery module: store details about a rate submitter'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."gallery_template_types";
    $tabledef = "id int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "title varchar(255) NOT NULL default '', ";
    $tabledef .= "type tinyint(3) unsigned NOT NULL default '2', ";
    $tabledef .= "templateCategory longtext NOT NULL, ";
    $tabledef .= "templatePictures longtext NOT NULL, ";
    $tabledef .= "templateCSS longtext, ";
    $tabledef .= "PRIMARY KEY  (id)";
    $tablecomment = "COMMENT='Gallery module: template types'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."guestbook";
    $tabledef = "guest_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "guest_title varchar(100) default NULL, ";
    $tabledef .= "guest_body text NOT NULL, ";
    $tabledef .= "guest_poster int(10) default NULL, ";
    $tabledef .= "guest_time varchar(20) default NULL, ";
    $tabledef .= "guest_views int(10) NOT NULL default '0', ";
    $tabledef .= "guest_image varchar(100) default NULL, ";
    $tabledef .= "guest_ip varchar(16) default NULL, ";
    $tabledef .= "PRIMARY KEY  (guest_id)";
    $tablecomment = "COMMENT='Guestbook module: submitted details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."headlines";
    $tabledef = "hid int(11) NOT NULL auto_increment, ";
    $tabledef .= "sitename varchar(30) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "headlinesurl varchar(255) NOT NULL default '', ";
    $tabledef .= "status tinyint(1) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (hid), ";
    $tabledef .= "KEY idxheadlinesstatus (status)";
    $tablecomment = "COMMENT='News module: headline definitions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }


    $table     = $prefix . 'image_dirs';
    $tabledef  = "folder_id tinyint(4) default NULL, ";
    $tabledef .= "path varchar(255) NOT NULL default '', ";
    $tabledef .= "uri varchar(255) default NULL, ";
    $tabledef .= "PRIMARY KEY (folder_id)";
    $tablecomment = "COMMENT='Core system: pathnames for image directories'";

    if ( !mysql_query( "CREATE TABLE $table ( $tabledef ) TYPE=$table_type $tablecomment" ) )
    {
        echo $table . $dbmessage1;
    }
    else
    {
        echo $table . $dbmessage2;
    }


    $table = $prefix."lastseen";
    $tabledef = "id int(15) NOT NULL auto_increment, ";
    $tabledef .= "username varchar(25) NOT NULL default '', ";
    $tabledef .= "date int(15) NOT NULL default '0', ";
    $tabledef .= "ip varchar(20) default NULL, ";
    $tabledef .= "PRIMARY KEY  (id), ";
    $tabledef .= "UNIQUE KEY id (id), ";
    $tabledef .= "KEY idxlastseenusername (username), ";
    $tabledef .= "KEY idxlastseendatedesc (date)";
    $tablecomment = "COMMENT='Core system: details about recent online users'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_categories";
    $tabledef = "cid int(11) NOT NULL auto_increment, ";
    $tabledef .= "title varchar(50) NOT NULL default '', ";
    $tabledef .= "cdescription text NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (cid), ";
    $tabledef .= "KEY idxlinkscategoriestitle (title)";
    $tablecomment = "COMMENT='Links module: categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_editorials";
    $tabledef = "linkid int(11) NOT NULL default '0', ";
    $tabledef .= "adminid varchar(30) NOT NULL default '', ";
    $tabledef .= "editorialtimestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "editorialtext text NOT NULL, ";
    $tabledef .= "editorialtitle varchar(100) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (linkid)";
    $tablecomment = "COMMENT='Links module: editorial details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_links";
    $tabledef = "lid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "hits int(11) NOT NULL default '0', ";
    $tabledef .= "submitter varchar(25) NOT NULL default '', ";
    $tabledef .= "linkratingsummary double(6,4) NOT NULL default '0.0000', ";
    $tabledef .= "totalvotes int(11) NOT NULL default '0', ";
    $tabledef .= "totalcomments int(11) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (lid), ";
    $tabledef .= "KEY idxlinkslinkscid (cid), ";
    $tabledef .= "KEY idxlinkslinkstitle (title), ";
    $tabledef .= "KEY idxlinkslinkstitlecid (title,cid), ";
    $tabledef .= "KEY idxlinkslinkstitlesid (title,sid), ";
    $tabledef .= "KEY idxlinkslinksurl (url), ";
    $tabledef .= "KEY idxlinkslinkssid (sid), ";
    $tabledef .= "KEY idxlinkslinksdate (date), ";
    $tabledef .= "KEY idxlinkslinksdatedesccid (date,cid), ";
    $tabledef .= "KEY idxlinkslinkstitledate (title,date), ";
    $tabledef .= "KEY idxlinkslinkslinkratingsummary (linkratingsummary), ";
    $tabledef .= "KEY idxlinklinkslinkratingsummarydesclinkratingsummarytotalvotes (linkratingsummary,linkratingsummary,totalvotes), ";
    $tabledef .= "KEY idxlinkslinkshitsdesc (hits)";
    $tablecomment = "COMMENT='Links module: link details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_modrequest";
    $tabledef = "requestid int(11) NOT NULL auto_increment, ";
    $tabledef .= "lid int(11) NOT NULL default '0', ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "modifysubmitter varchar(25) NOT NULL default '', ";
    $tabledef .= "brokenlink int(3) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (requestid), ";
    $tabledef .= "UNIQUE KEY requestid (requestid), ";
    $tabledef .= "KEY idxlinksmodequestbrokenlink (brokenlink), ";
    $tabledef .= "KEY idxlinksmodrequestrequestidbrokenlink (requestid,brokenlink)";
    $tablecomment = "COMMENT='Links module: modification requests'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
         echo "".$table." $dbmessage1";
    } else {
         echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_newlink";
    $tabledef = "lid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "sid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "submitter varchar(25) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (lid)";
    $tablecomment = "COMMENT='Links module: new submitted links, need to be approved'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_subcategories";
    $tabledef = "sid int(11) NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) NOT NULL default '0', ";
    $tabledef .= "title varchar(50) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (sid), ";
    $tabledef .= "KEY idxlinkssubcategoriestitlecid (title,cid), ";
    $tabledef .= "KEY idxlinkssubcategoriescidsid (cid,sid), ";
    $tabledef .= "KEY idxlinkssubcategoriestitle (title)";
    $tablecomment = "COMMENT='Links module: subcategories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."links_votedata";
    $tabledef = "ratingdbid int(11) NOT NULL auto_increment, ";
    $tabledef .= "ratinglid int(11) NOT NULL default '0', ";
    $tabledef .= "ratinguser varchar(25) NOT NULL default '', ";
    $tabledef .= "rating int(11) NOT NULL default '0', ";
    $tabledef .= "ratinghostname varchar(60) NOT NULL default '', ";
    $tabledef .= "ratingcomments text NOT NULL, ";
    $tabledef .= "ratingtimestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "PRIMARY KEY  (ratingdbid), ";
    $tabledef .= "KEY idxlinksvotedateratinguser (ratinguser), ";
    $tabledef .= "KEY idxlinksvotedataratinglid (ratinglid)";
    $tablecomment = "COMMENT='Links module: rating details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."mymsg2";
    $tabledef = "message_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "title varchar(100) default NULL, ";
    $tabledef .= "text text, ";
    $tabledef .= "catid int(10) default NULL, ";
    $tabledef .= "topicid int(10) default NULL, ";
    $tabledef .= "time datetime default NULL, ";
    $tabledef .= "display tinyint(1) default NULL, ";
    $tabledef .= "PRIMARY KEY  (message_id)";
    $tablecomment = "COMMENT='mymsg2 module: message details'";

    @mysql_query("ALTER TABLE mymsg2 RENAME ".$table."");
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."poll_data";
    $tabledef = "pollID int(11) NOT NULL default '0', ";
    $tabledef .= "optionText char(50) NOT NULL default '', ";
    $tabledef .= "optionCount int(11) NOT NULL default '0', ";
    $tabledef .= "voteID int(11) NOT NULL default '0', ";
    $tabledef .= "KEY idxpolldatapollidvoteid (pollID,voteID), ";
    $tabledef .= "KEY idxpolldatapolliddesc (pollID)";
    $tablecomment = "COMMENT='Polls module: voting details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."poll_desc";
    $tabledef = "pollID int(11) NOT NULL auto_increment, ";
    $tabledef .= "pollTitle char(100) NOT NULL default '', ";
    $tabledef .= "timeStamp int(11) NOT NULL default '0', ";
    $tabledef .= "voters mediumint(9) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (pollID), ";
    $tabledef .= "KEY idxpolldescpolliddesc (pollID), ";
    $tabledef .= "KEY idxpolldesctimestamp (timeStamp), ";
    $tabledef .= "KEY idxpolldescpolltitle (pollTitle), ";
    $tabledef .= "KEY idxpolldescvotersdesc (voters)";
    $tablecomment = "COMMENT='Polls module: poll descriptions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."pollcomments";
    $tabledef = "tid int(11) NOT NULL auto_increment, ";
    $tabledef .= "pid int(11) default '0', ";
    $tabledef .= "pollID int(11) default '0', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "email varchar(60) default NULL, ";
    $tabledef .= "url varchar(255) default NULL, ";
    $tabledef .= "host_name varchar(60) default NULL, ";
    $tabledef .= "subject varchar(85) NOT NULL default '', ";
    $tabledef .= "comment text NOT NULL, ";
    $tabledef .= "score tinyint(4) NOT NULL default '0', ";
    $tabledef .= "reason tinyint(4) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (tid), ";
    $tabledef .= "KEY idxpollcommentsdatetidpid (date,tid,pid), ";
    $tabledef .= "KEY idxpollcommentspollidpid (pollID,pid), ";
    $tabledef .= "KEY idxpollcommentstidpollid (pollID,tid)";
    $tablecomment = "COMMENT='Polls module: submitted comments'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."popsettings";
    $tabledef = "id int(11) NOT NULL auto_increment, ";
    $tabledef .= "uid int(11) default NULL, ";
    $tabledef .= "account varchar(50) default NULL, ";
    $tabledef .= "popserver varchar(50) default NULL, ";
    $tabledef .= "port int(11) default NULL, ";
    $tabledef .= "uname varchar(25) default NULL, ";
    $tabledef .= "passwd varchar(64) default NULL, ";
    $tabledef .= "numshow int(11) default NULL, ";
    $tabledef .= "deletefromserver char(1) default NULL, ";
    $tabledef .= "refresh int(11) default NULL, ";
    $tabledef .= "timeout int(11) default NULL, ";
    $tabledef .= "PRIMARY KEY  (id)";
    $tablecomment = "COMMENT='Webmail module: POPbox settings'";

    @mysql_query("ALTER TABLE popsettings RENAME ".$table."");
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."posts";
    $tabledef = "post_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "image varchar(100) NOT NULL default '', ";
    $tabledef .= "topic_id int(10) NOT NULL default '0', ";
    $tabledef .= "forum_id int(10) NOT NULL default '0', ";
    $tabledef .= "poster_id int(10) default NULL, ";
    $tabledef .= "post_text text, ";
    $tabledef .= "post_time varchar(20) default NULL, ";
    $tabledef .= "poster_ip varchar(16) default NULL, ";
    $tabledef .= "PRIMARY KEY  (post_id), ";
    $tabledef .= "KEY forum_id (forum_id), ";
    $tabledef .= "KEY topic_id (topic_id), ";
    $tabledef .= "KEY idxtopics (topic_id,forum_id,post_id,poster_id,post_time)";
    $tablecomment = "COMMENT='Forum module: posts details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment"))
    {
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpostspostidposterid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpostspostimedesctopicid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpoststopicidposterid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpostspostidtopicid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpoststopicid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpostsposttimedescforumidposterid');
        @mysql_query('ALTER TABLE ' . $table . ' DROP INDEX idxpostsposttimedesctopicidposterid');

        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX forum_id (forum_id)' );
        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX topic_id (topic_id)' );
        @mysql_query('ALTER TABLE ' . $table . ' ADD INDEX idxtopics (topic_id,forum_id,post_id,poster_id,post_time)' );

        echo $table . $dbmessage1;
    }
    else
    {
        echo $table . $dbmessage2;
    }

    $table = $prefix."priv_msgs";
    $tabledef = "msg_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "msg_image varchar(100) default NULL, ";
    $tabledef .= "subject varchar(100) default NULL, ";
    $tabledef .= "from_userid int(10) NOT NULL default '0', ";
    $tabledef .= "to_userid int(10) NOT NULL default '0', ";
    $tabledef .= "msg_time varchar(20) default NULL, ";
    $tabledef .= "msg_text text, ";
    $tabledef .= "read_msg tinyint(10) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (msg_id), ";
    $tabledef .= "KEY msg_id (msg_id), ";
    $tabledef .= "KEY to_userid (to_userid), ";
    $tabledef .= "KEY idxprivmsgstouseridreadmsg (to_userid,read_msg), ";
    $tabledef .= "KEY idxprivmsgsmsgidfromuserid (msg_id,from_userid)";
    $tablecomment = "COMMENT='Forum module: private messages details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."queue";
    $tabledef = "qid smallint(5) unsigned NOT NULL auto_increment, ";
    $tabledef .= "uid mediumint(9) NOT NULL default '0', ";
    $tabledef .= "uname varchar(40) NOT NULL default '', ";
    $tabledef .= "subject varchar(100) NOT NULL default '', ";
    $tabledef .= "story text, ";
    $tabledef .= "timestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "topic varchar(20) NOT NULL default 'Linux', ";
    $tabledef .= "PRIMARY KEY  (qid), ";
    $tabledef .= "KEY idxqueuetimestamp (timestamp)";
    $tablecomment = "COMMENT='News module: new submitted news items, to be approved'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."quotes";
    $tabledef = "qid int(10) unsigned NOT NULL auto_increment, ";
    $tabledef .= "quote text, ";
    $tabledef .= "author varchar(150) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (qid)";
    $tablecomment = "COMMENT='Core systems: random quotes block details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."rand_banners";
    $tabledef = "banner_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "url varchar(255) NOT NULL, ";
    $tabledef .= "image varchar(150) NOT NULL, ";
    $tabledef .= "description varchar(255), ";
    $tabledef .= "PRIMARY KEY (banner_id)";
    $tablecomment = "COMMENT='Core system: random banners block details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."ranks";
    $tabledef = "rank_id int(10) NOT NULL auto_increment, ";
    $tabledef .= "rank_title varchar(50) NOT NULL default '', ";
    $tabledef .= "rank_min int(10) NOT NULL default '0', ";
    $tabledef .= "rank_max int(10) NOT NULL default '0', ";
    $tabledef .= "rank_special int(2) default '0', ";
    $tabledef .= "PRIMARY KEY  (rank_id), ";
    $tabledef .= "KEY rank_min (rank_min), ";
    $tabledef .= "KEY rank_max (rank_max), ";
    $tabledef .= "KEY idxranksrankminrankmaxranspecial (rank_min,rank_max,rank_special), ";
    $tabledef .= "KEY idxranksrankspecial (rank_special)";
    $tablecomment = "COMMENT='Forums module: user ranks'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."referer";
    $tabledef = "rid int(11) NOT NULL auto_increment, ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (rid)";
    $tablecomment = "COMMENT='Core system: referrer details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."related";
    $tabledef = "rid int(11) NOT NULL auto_increment, ";
    $tabledef .= "tid int(11) NOT NULL default '0', ";
    $tabledef .= "name varchar(30) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (rid), ";
    $tabledef .= "KEY idxrelatedtid (tid)";
    $tablecomment = "COMMENT='News module: links about related info'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."reviews";
    $tabledef = "id int(10) NOT NULL auto_increment, ";
    $tabledef .= "date date NOT NULL default '0000-00-00', ";
    $tabledef .= "title varchar(150) NOT NULL default '', ";
    $tabledef .= "text text NOT NULL, ";
    $tabledef .= "reviewer varchar(25) default NULL, ";
    $tabledef .= "email varchar(30) default NULL, ";
    $tabledef .= "score int(10) NOT NULL default '0', ";
    $tabledef .= "cover varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "url_title varchar(50) NOT NULL default '', ";
    $tabledef .= "hits int(10) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (id), ";
    $tabledef .= "KEY idxreviewshitsdesc (hits), ";
    $tabledef .= "KEY idxreviewsdatedesc (date)";
    $tablecomment = "COMMENT='Reviews module: details per review'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."reviews_add";
    $tabledef = "id int(10) NOT NULL auto_increment, ";
    $tabledef .= "date date default NULL, ";
    $tabledef .= "title varchar(150) NOT NULL default '', ";
    $tabledef .= "text text NOT NULL, ";
    $tabledef .= "reviewer varchar(25) NOT NULL default '', ";
    $tabledef .= "email varchar(30) NOT NULL default '', ";
    $tabledef .= "score int(10) NOT NULL default '0', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "url_title varchar(50) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (id)";
    $tablecomment = "COMMENT='Reviews module: new submitted reviews'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."reviews_comments";
    $tabledef = "cid int(10) NOT NULL auto_increment, ";
    $tabledef .= "rid int(10) NOT NULL default '0', ";
    $tabledef .= "userid varchar(25) NOT NULL default '', ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "comments text, ";
    $tabledef .= "score int(10) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (cid), ";
    $tabledef .= "KEY idxreviewcommentsrid (rid)";
    $tablecomment = "COMMENT='Reviews module: user comments per review'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."reviews_main";
    $tabledef = "title varchar(100) default NULL, ";
    $tabledef .= "description text";
    $tablecomment = "COMMENT='Reviews module: reviews page title and description'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."seccont";
    $tabledef = "artid int(11) NOT NULL auto_increment, ";
    $tabledef .= "secid int(11) NOT NULL default '0', ";
    $tabledef .= "title text NOT NULL, ";
    $tabledef .= "byline blob, ";
    $tabledef .= "author varchar(255) default NULL, ";
    $tabledef .= "authoremail varchar(255) default NULL, ";
    $tabledef .= "date datetime default NULL, ";
    $tabledef .= "content text NOT NULL, ";
    $tabledef .= "counter int(11) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (artid), ";
    $tabledef .= "KEY idxseccontsecid (secid), ";
    $tabledef .= "KEY idxseccontcounterdesc (counter)";
    $tablecomment = "COMMENT='Sections module: article contents'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            $result = mysql_query ("SELECT * FROM ".$table."");
            $fields = mysql_num_fields ($result);
            if ($fields == 5) {
                    @mysql_query("ALTER TABLE ".$table." ADD byline blob AFTER title, ADD author varchar(255) default NULL AFTER byline, ADD authoremail varchar(255) default NULL AFTER author, ADD date datetime default NULL AFTER authoremail");
            }
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."sections";
    $tabledef = "secid int(11) NOT NULL auto_increment, ";
    $tabledef .= "secname varchar(40) NOT NULL default '', ";
    $tabledef .= "image varchar(50) NOT NULL default '', ";
    $tabledef .= "secdesc blob, ";
    $tabledef .= "PRIMARY KEY  (secid), ";
    $tabledef .= "KEY idxsectionssecname (secname)";
    $tablecomment = "COMMENT='Sections module: sections descriptions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            @mysql_query("ALTER TABLE ".$table." ADD secdesc blob AFTER image");
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."session";
    $tabledef = "username varchar(25) NOT NULL default '', ";
    $tabledef .= "time varchar(14) NOT NULL default '', ";
    $tabledef .= "host_addr varchar(20) NOT NULL default '', ";
    $tabledef .= "guest int(1) NOT NULL default '0', ";
    $tabledef .= "forum_pass varchar(60) default NULL, ";
    $tabledef .= "KEY idxsessionusername (username), ";
    $tabledef .= "KEY idxsessionguest (guest)";
    $tablecomment = "COMMENT='Core system: active sessions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."smiles";
    $tabledef = "id int(10) NOT NULL auto_increment, ";
    $tabledef .= "code varchar(50) default NULL, ";
    $tabledef .= "smile_url varchar(100) default NULL, ";
    $tabledef .= "emotion varchar(75) default NULL, ";
    $tabledef .= "PRIMARY KEY  (id)";
    $tablecomment = "COMMENT='Forums module: smile definitions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."stories";
    $tabledef = "sid int(11) NOT NULL auto_increment, ";
    $tabledef .= "catid int(11) NOT NULL default '0', ";
    $tabledef .= "aid varchar(30) NOT NULL default '', ";
    $tabledef .= "title varchar(80) default NULL, ";
    $tabledef .= "time datetime default NULL, ";
    $tabledef .= "hometext text, ";
    $tabledef .= "bodytext text NOT NULL, ";
    $tabledef .= "comments int(11) default '0', ";
    $tabledef .= "counter mediumint(8) unsigned default NULL, ";
    $tabledef .= "topic int(3) NOT NULL default '1', ";
    $tabledef .= "informant varchar(25) NOT NULL default '', ";
    $tabledef .= "notes text NOT NULL, ";
    $tabledef .= "ihome int(1) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (sid), ";
    $tabledef .= "KEY idxstoriessiddesccatid (sid,catid), ";
    $tabledef .= "KEY idxstoriessiddesc (sid), ";
    $tabledef .= "KEY idxstoriessiddesctopic (sid,topic), ";
    $tabledef .= "KEY idxstoriessiddescihomecatid (sid,ihome,catid), ";
    $tabledef .= "KEY idxstoriestime (time), ";
    $tabledef .= "KEY idxstoriescounterdesctopic (counter,topic), ";
    $tabledef .= "KEY idxstoriescounterdesctime (counter,time), ";
    $tabledef .= "KEY idxstoriescatid (catid), ";
    $tabledef .= "KEY idxstoriesiddescinformant (sid,informant), ";
    $tabledef .= "KEY idxstoriesaid (aid), ";
    $tabledef .= "KEY idxstoriestopic (topic), ";
    $tabledef .= "KEY idxstoriescounterdesc (counter), ";
    $tabledef .= "KEY idxstoriescommentsdesc (comments)";
    $tablecomment = "COMMENT='News module: details news article'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
//enlarge the informant field to 25 char.
     $query = "ALTER TABLE $table CHANGE `informant` `informant` VARCHAR( 25 ) NOT NULL ";
    @mysql_query($query);
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."stories_cat";
    $tabledef = "catid int(11) NOT NULL auto_increment, ";
    $tabledef .= "title varchar(20) NOT NULL default '', ";
    $tabledef .= "counter int(11) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (catid), ";
    $tabledef .= "KEY idxstoriescattitle (title), ";
    $tabledef .= "KEY idxstoriescatcounterdesc (counter)";
    $tablecomment = "COMMENT='News module: category definitions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."topics";
    $tabledef = "topicid int(3) NOT NULL auto_increment, ";
    $tabledef .= "topicname varchar(20) default NULL, ";
    $tabledef .= "topicimage varchar(255) default NULL, ";
    $tabledef .= "topictext varchar(40) default NULL, ";
    $tabledef .= "counter int(11) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (topicid), ";
    $tabledef .= "KEY idxtopicstopictext (topictext), ";
    $tabledef .= "KEY idxtopicstopicname (topicname)";
    $tablecomment = "COMMENT='News module: topic descriptions'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."updatelog";
    $tabledef = "id smallint(5) unsigned NOT NULL auto_increment, ";
    $tabledef .= "name varchar(40) NOT NULL default '', ";
    $tabledef .= "email varchar(40) NOT NULL default '', ";
    $tabledef .= "date datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "files varchar(40) NOT NULL default '', ";
    $tabledef .= "updates text, ";
    $tabledef .= "bugs text, ";
    $tabledef .= "PRIMARY KEY  (id), ";
    $tabledef .= "KEY idxupdatelogiddesc (id)";
    $tablecomment = "COMMENT='Core system: system update log'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."users";
    $tabledef = "uid int(11) NOT NULL, ";
    $tabledef .= "name varchar(60) NOT NULL default '', ";
    $tabledef .= "uname varchar(25) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "femail varchar(60) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "user_avatar varchar(30) default NULL, ";
    $tabledef .= "user_regdate DATE NOT NULL default '', ";
    $tabledef .= "user_icq varchar(15) default NULL, ";
    $tabledef .= "user_occ varchar(100) default NULL, ";
    $tabledef .= "user_from varchar(100) default NULL, ";
    $tabledef .= "user_from_flag varchar(25) default NULL, ";
    $tabledef .= "user_intrest varchar(255) default NULL, ";
    $tabledef .= "user_sig varchar(255) default NULL, ";
    $tabledef .= "user_viewemail tinyint(2) default NULL, ";
    $tabledef .= "user_theme int(3) default NULL, ";
    $tabledef .= "user_aim varchar(18) default NULL, ";
    $tabledef .= "user_yim varchar(25) default NULL, ";
    $tabledef .= "user_msnm varchar(60) default NULL, ";
    $tabledef .= "pass varchar(40) NOT NULL default '', ";
    $tabledef .= "storynum tinyint(4) NOT NULL default '10', ";
    $tabledef .= "umode varchar(10) NOT NULL default '', ";
    $tabledef .= "uorder tinyint(1) NOT NULL default '0', ";
    $tabledef .= "thold tinyint(1) NOT NULL default '0', ";
    $tabledef .= "noscore tinyint(1) NOT NULL default '0', ";
    $tabledef .= "bio tinytext NOT NULL, ";
    $tabledef .= "ublockon tinyint(1) NOT NULL default '0', ";
    $tabledef .= "ublock tinytext NOT NULL, ";
    $tabledef .= "theme varchar(255) NOT NULL default '', ";
    $tabledef .= "commentmax int(11) NOT NULL default '4096', ";
    $tabledef .= "counter int(11) NOT NULL default '0', ";
    $tabledef .= "allowemail int(11) NOT NULL default '1', ";
    $tabledef .= "emailpass varchar(32) NOT NULL default '', ";
    $tabledef .= "theme_layout tinyint(1) NOT NULL default '0', ";
    $tabledef .= "theme_format tinyint(1) NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (uid), ";
    $tabledef .= "KEY idxusersuname (uname), ";
    $tabledef .= "KEY idxusersemail (email), ";
    $tabledef .= "KEY idxuserscounterdesc (counter), ";
    $tabledef .= "KEY idxusersuiddesc (uid), ";
    $tabledef .= "KEY idxusersname (name), ";
    $tabledef .= "KEY idxusersuiduname (uid,uname), ";
    $tabledef .= "KEY idxusersemailuid (email,uid), ";
    $tabledef .= "KEY idxusersfemail (femail), ";
    $tabledef .= "KEY idxusersurl (url), ";
    $tabledef .= "KEY idxusersnameuname (name,uname), ";
    $tabledef .= "KEY idxusersfemailuname (femail,uname), ";
    $tabledef .= "KEY idxusersurluname (url,uname), ";
    $tabledef .= "KEY idxusersunamepass (uname,pass), ";
    $tabledef .= "FULLTEXT KEY unamefrominterests (uname,user_from,user_intrest,bio)";
    $tablecomment = "COMMENT='Core system: users'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            $result = mysql_query ("SELECT * FROM ".$table."");
            $fields = mysql_num_fields ($result);
            if ($fields == 31) {
                    @mysql_query("ALTER TABLE ".$table." ADD user_from_flag varchar(25) NULL AFTER user_from, ADD emailpass varchar(32) NOT NULL AFTER allowemail");
                    $result = mysql_query("SELECT uid, pass FROM ".$table."");
                    while ($pass = mysql_fetch_array($result)){
                            $query = "UPDATE ".$table." SET emailpass = '$pass[1]' WHERE uid = '$pass[0]'";
                            @mysql_query($query);
                    }
            }
            if ($fields == 32) {
                    @mysql_query("ALTER TABLE ".$table." ADD emailpass varchar(32) NOT NULL AFTER allowemail");
                    $result = mysql_query("SELECT uid, pass FROM ".$table."");
                    while ($pass = mysql_fetch_array($result)){
                            $query = "UPDATE ".$table." SET emailpass = '$pass[1]' WHERE uid = '$pass[0]'";
                            @mysql_query($query);
                    }
            }

            @mysql_query('ALTER TABLE ' . $table . ' ADD theme_layout tinyint(1) NOT NULL AFTER emailpass, ADD theme_format tinyint(1) NOT NULL AFTER theme_layout');

            @mysql_query( 'ALTER TABLE ' . $table . ' ADD FULLTEXT KEY unamefrominterests (uname,user_from,user_intrest,bio)' );

            // Convert User Registration Date To Sortable Format

            $result = mysql_query( "SELECT uid, user_regdate FROM " . $table . "" );

            while ( list( $uid, $regdate ) = mysql_fetch_row( $result ) )
            {
                $regdate1 = strtotime( $regdate );
                $newdate =  date("Y-m-d",$regdate1);

                @mysql_query( "UPDATE " . $table . " SET user_regdate='$newdate' WHERE uid='$uid'" );
            }

            @mysql_query( 'ALTER TABLE ' . $table . ' CHANGE user_regdate user_regdate DATE NOT NULL' );




            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."users_status";
    $tabledef = "uid int(11) NOT NULL, ";
    $tabledef .= "posts int(10) default '0', ";
    $tabledef .= "attachsig int(2) default '0', ";
    $tabledef .= "rank int(10) default '0', ";
    $tabledef .= "level int(10) default '1', ";
    $tabledef .= "PRIMARY KEY  (uid)";
    $tablecomment = "COMMENT='Core system: status info per user'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."visits_control";
    $tabledef = "refresh int(11) NOT NULL default '1'";
    $tablecomment = "COMMENT='Core system: switch stats generation on-off'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."visits_counter";
    $tabledef = "id int(11) NOT NULL auto_increment, ";
    $tabledef .= "date varchar(10) NOT NULL default '', ";
    $tabledef .= "count int(11) NOT NULL default '0', ";
    $tabledef .= "KEY id (id)";
    $tablecomment = "COMMENT='Core system: visits counter'";
    
    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."visits_system";
    $tabledef = "id int(11) NOT NULL auto_increment, ";
    $tabledef .= "date varchar(10) NOT NULL default '', ";
    $tabledef .= "ip varchar(50) NOT NULL default '', ";
    $tabledef .= "KEY id (id)";
    $tablecomment = "COMMENT='Core system: visits per ip address'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
        echo "".$table." $dbmessage1";
    } else {
        echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_brokenlink";
    $tabledef = "reportid int(11) NOT NULL auto_increment, ";
    $tabledef .= "bid int(11) NOT NULL default '0', ";
    $tabledef .= "sender varchar(25) NOT NULL default '', ";
    $tabledef .= "ip varchar(20) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (reportid)";
    $tablecomment = "COMMENT='Yellow pages module: reported broken links'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_business";
    $tabledef = "bid int(11) unsigned NOT NULL auto_increment, ";
    $tabledef .= "cid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "phone varchar(20) NOT NULL default '', ";
    $tabledef .= "fax varchar(20) NOT NULL default '', ";
    $tabledef .= "summary varchar(255) NOT NULL default '', ";
    $tabledef .= "address varchar(100) NOT NULL default '', ";
    $tabledef .= "city varchar(50) NOT NULL default '', ";
    $tabledef .= "state varchar(25) NOT NULL default '', ";
    $tabledef .= "zipcode varchar(10) NOT NULL default '', ";
    $tabledef .= "country char(3) NOT NULL default '', ";
    $tabledef .= "logourl varchar(255) NOT NULL default '', ";
    $tabledef .= "submitter varchar(25) NOT NULL default '', ";
    $tabledef .= "status tinyint(2) unsigned NOT NULL default '0', ";
    $tabledef .= "date datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "hits int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "rating double(6,4) NOT NULL default '0.0000', ";
    $tabledef .= "votes int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "comments int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "PRIMARY KEY  (bid)";
    $tablecomment = "COMMENT='Yellow pages module: business link details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_businesstxt";
    $tabledef = "txtid int(11) unsigned NOT NULL auto_increment, ";
    $tabledef .= "bid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "PRIMARY KEY  (txtid)";
    $tablecomment = "COMMENT='Yellow pages module: extended text per business link'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_categories";
    $tabledef = "cid int(11) unsigned NOT NULL auto_increment, ";
    $tabledef .= "pid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "title varchar(50) NOT NULL default '', ";
    $tabledef .= "imgurl varchar(255) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (cid)";
    $tablecomment = "COMMENT='Yellow pages module: categories'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_modrequest";
    $tabledef = "requestid int(11) unsigned NOT NULL auto_increment, ";
    $tabledef .= "bid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "cid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "title varchar(100) NOT NULL default '', ";
    $tabledef .= "url varchar(255) NOT NULL default '', ";
    $tabledef .= "email varchar(60) NOT NULL default '', ";
    $tabledef .= "phone varchar(20) NOT NULL default '', ";
    $tabledef .= "fax varchar(20) NOT NULL default '', ";
    $tabledef .= "summary varchar(255) NOT NULL default '', ";
    $tabledef .= "address varchar(100) NOT NULL default '', ";
    $tabledef .= "city varchar(50) NOT NULL default '', ";
    $tabledef .= "state varchar(25) NOT NULL default '', ";
    $tabledef .= "zipcode varchar(10) NOT NULL default '', ";
    $tabledef .= "country char(3) NOT NULL default '', ";
    $tabledef .= "logourl varchar(255) NOT NULL default '', ";
    $tabledef .= "description text NOT NULL, ";
    $tabledef .= "modifysubmitter varchar(25) NOT NULL default '', ";
    $tabledef .= "PRIMARY KEY  (requestid)";
    $tablecomment = "COMMENT='Yellow pages module: submitted modification requests'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    $table = $prefix."yp_votedata";
    $tabledef = "ratingid int(11) unsigned NOT NULL auto_increment, ";
    $tabledef .= "bid int(11) unsigned NOT NULL default '0', ";
    $tabledef .= "ratinguser varchar(25) NOT NULL default '', ";
    $tabledef .= "rating tinyint(3) unsigned NOT NULL default '0', ";
    $tabledef .= "ratinghostname varchar(60) NOT NULL default '', ";
    $tabledef .= "ratingtimestamp datetime NOT NULL default '0000-00-00 00:00:00', ";
    $tabledef .= "PRIMARY KEY  (ratingid)";
    $tablecomment = "COMMENT='Yellow pages module: rating details'";

    if (!mysql_query("CREATE TABLE $table ($tabledef) TYPE=$table_type $tablecomment")) {
            echo "".$table." $dbmessage1";
    } else {
            echo "".$table." $dbmessage2";
    }

    echo "</div>";

    echo "<br /><hr width='80%' /><br /><p><b>Database creation is finished.</b><br />All tables have been created or updated.</b></p><br>";

    ?>
    <form action="<?php $PHP_SELF ?>" method="post">
        <center>
            <table width="50%" align=center>
            <tr>
            <td align=center>
            <input type="hidden" name="dbhost" value="<?php echo $dbhost;?>">
            <input type="hidden" name="dbuname" value="<?php echo $dbuname;?>">
            <input type="hidden" name="dbpass" value="<?php echo $dbpass;?>">
            <input type="hidden" name="dbname" value="<?php echo $dbname;?>">
            <input type="hidden" name="prefix" value="<?php echo $prefix;?>">
            <input type="submit" name="op" value="Continue">
            </td>
            </tr>
            </table>
        </center>
        </form>
    <?php
    make_footer();
}

function set_sqlprefs($dbhost, $dbuname, $dbpass, $dbname, $prefix) {
    make_header();
        ?>
    <br /><br /><p class="mpn-title">Setting Your DB Preferences</p><hr width="80%" /><p>We will now set up some of the data that is stored in the database.  You can do this now or wait until later.<br /><br />If you pass on this set up, your user/pass for the administrator will be:<br /><br /><b>God / Password</b> (case sensitive).</p><br /><em>It is highly advised that you set your own<br />user/pass combo NOW!</em><br /><br />
    <center>

    <form action="<?php $PHP_SELF ?>" method="post">

        <table width="50%" border=1>
            <tr>
                <td align="left">Admin Login</td>
                <td><input type="text" name="aid" size=30 maxlength=80 value="God"></td>
            </tr><tr>
                <td align="left">Your Name</td>
                <td><input type="text" name="name" size=30 maxlength=80 value="God"></td>
            </tr><tr>
                <td align="left">Admin Password</td>
                <td><input type="text" name="pwd" size=30 maxlength=80 value="Password"></td>
            </tr><tr>
                <td align="left">Your Email</td>
                <td><input type="text" name="email" size=30 maxlength=80 value="none@none.com"></td>
            </tr><tr>
                <td align="left">Your Url</td>
                <td>
                    <input type="text" name="url" size=30 maxlength=80 value="<?php echo _MPN_ROOT_URI ?>"></td></tr>
                    <input type="hidden" name="dbhost" value="<?php echo $dbhost;?>">
                    <input type="hidden" name="dbuname" value="<?php echo $dbuname;?>">
                    <input type="hidden" name="dbpass" value="<?php echo $dbpass;?>">
                    <input type="hidden" name="dbname" value="<?php echo $dbname;?>">
                    <input type="hidden" name="prefix" value="<?php echo $prefix; ?>">
                </td>
            </tr>
        </table>

        <br /><br />

        <input type="submit" name="op" value="Set_Login">

    </form>
</center>
    <?php
    make_footer();
    }

function input_data($dbhost, $dbuname, $dbpass, $dbname, $prefix, $aid, $name, $pwd, $email, $url) {
    global $HTTP_SERVER_VARS;

    make_header();
    $dbmessage3 = "<p class='left'><b>Updated</b> ".$prefix."";
    $dbmessage4 = "<p class='left'><b>No need to update</b> ".$prefix."";

    echo "<p class=\"mpn-title\">User Data Has Been Uploaded</p><hr width='80%' /><p>Below is your login and password.<br /><b>Make sure you write it down.</b><br /><br />If you loose your password you will not be able to recover it as it is encrypted.</p><br /><div class='info'><em>$aid / $pwd</em><br />is the supplied login information for administration.</div><br /><br /><hr width='80%' /><br /><p class='mpn-title'>Table Update Summary<br /><br /><hr width='80%' />";

    echo "<div class='dblist'>";

    mysql_connect($dbhost, $dbuname, $dbpass);
    @mysql_select_db("$dbname") or die ("<br /><br /><em>Unable to select database</em><br /><br />");
    $md5 = md5($pwd);

// UPDATE 4NSTATS_MONTHCNT //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."4nstats_monthcnt");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '1', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '2', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '3', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '4', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '5', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '6', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '7', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '8', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '9', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '10', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '11', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_monthcnt VALUES ( '12', '0')");

        echo "$dbmessage3&nbsp;4nstats_monthcnt</p>";
    } else {
        echo "$dbmessage4&nbsp;4nstats_monthcnt</p>";
    }

// UPDATE 4NSTATS_HOURCNT //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."4nstats_hourcnt");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '0', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '1', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '2', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '3', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '4', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '5', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '6', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '7', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '8', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '9', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '10', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '11', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '12', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '13', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '14', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '15', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '16', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '17', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '18', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '19', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '20', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '21', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '22', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_hourcnt VALUES ( '23', '0')");
        echo "$dbmessage3&nbsp;4nstats_hourcnt</p>";
    } else {
        echo "$dbmessage4&nbsp;4nstats_hourcnt.</p>";
    }

// UPDATE 4NSTATS_WEEKCNT //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."4nstats_weekcnt");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '0', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '1', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '2', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '3', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '4', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '5', '0')");
        mysql_query("INSERT INTO ".$prefix."4nstats_weekcnt VALUES ( '6', '0')");

        echo "$dbmessage3&nbsp;4nstats_weekcnt</p>";
    } else {
        echo "$dbmessage4&nbsp;4nstats_weekcnt.</p>";
    }

// UPDATE AUTHORS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."authors");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."authors VALUES ( '$aid', '$name', '$url', '$email', '$md5', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '-1')");
        echo "$dbmessage3&nbsp;authors</p>";
    } else {
        echo "$dbmessage4&nbsp;authors</p>";
    }

// UPDATE ACCESS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."access");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."access VALUES ( '1', 'User')");
        mysql_query("INSERT INTO ".$prefix."access VALUES ( '2', 'Moderator')");
        mysql_query("INSERT INTO ".$prefix."access VALUES ( '3', 'Super Moderator')");
        mysql_query("INSERT INTO ".$prefix."access VALUES ( '4', 'Author')");
        mysql_query("INSERT INTO ".$prefix."access VALUES ( '5', 'Webmaster')");

        echo "$dbmessage3&nbsp;access</p>";
    } else {
        echo "$dbmessage4&nbsp;access</p>";
    }

// UPDATE BLOCKS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."blocks");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '1', '0', '1', '0', '0', '1', '1', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '2', '0', '2', '2', '0', '1', '0', 'Administration', '<li><a href=\'admin.php\'>Administration</a><li><a href=\'admin.php?op=logout\'>Logout</a>', '2')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '3', '0', '3', '2', '0', '1', '12', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '4', '0', '4', '0', '0', '1', '0', 'Main Menu', '<li><a href=\'index.php\'><b>Home</b></a>
        <li><a href=\'topics.php\'>Topics</a>
        <li><a href=\'sections.php\'>Sections</a>
        <li><a href=\'reviews.php\'>Reviews</a>
        <li><a href=\'myyp.php\'>myYellow Pages</a>
        <li><a href=\'links.php\'>Web Links</a>
        <li><a href=\'download.php\'>Downloads</a>
        <li><a href=\'myegallery.php\'>eGallery</a>
        <li><a href=\'forum.php\'>Forums</a>
        <li><a href=\'submit.php\'><b>Submit News</b></a>
        <li><a href=\'eventcal.php\'>Events Calender</a>
        <li><a href=\'guestbook.php\'>Guestbook</a>
        <li><a href=\'user.php?op=logout\'>Logout</a>

        <li><a href=\'user.php\'><b>View Account</b></a>
        <li><a href=\'user.php?op=register\'>Register</a>
        <li><a href=\'friend.php\'>Recommend Us</a>
        <li><a href=\'memberslist.php\'>Members List</a>
        <li><a href=\'stats.php\'>Stats</a>
        <li><a href=\'top.php\'>Top 10</a>
        <li><a href=\'updatelog.php\'>System Updatelog</a>
        <li><a href=\'contact.php\'>Contact Us</a>
        <li><a href=\'archive.php\'>News Archive</a>
        <li><a href=\'allstories.php\'>All Stories</a>
        <li><a href=\'mailbox.php\'>Email</a>
        <li><a href=\'npp_ODP.php?enpp=odp\'>Open Directory</a>', '0')");

        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '5', '0', '5', '0', '0', '1', '2', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '6', '0', '6', '0', '0', '1', '13', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '7', '0', '7', '0', '0', '1', '0', 'First Left Block', 'You can add/remove/edit blocks for your site with myPHPNuke.
                You can also add HTML commands like <a href=\'http://www.myphpnuke.com/\'>links</a>, <b>Bold</b> text, images, etc.
                Just use you imagination.', '3')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '8', '0', '8', '0', '0', '1', '0', 'Special Sections', 'What about a <a href=\'sections.php\'>Special Sections</a> option in the myPHPNuke code? A place to publish reviews, special articles, interviews, or whatever, independent of the main news.', '3')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '9', '0', '1', '0', '0', '0', '14', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '10', '0', '2', '0', '0', '0', '16', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '11', '1', '3', '0', '0', '1', '3', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '12', '1', '4', '0', '0', '1', '4', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '13', '1', '5', '0', '0', '1', '5', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '14', '1', '6', '0', '0', '1', '6', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '15', '1', '7', '0', '0', '1', '7', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '16', '1', '8', '0', '0', '1', '8', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '17', '1', '9', '0', '0', '1', '0', 'First Right Block', 'You can add/remove/edit blocks for your site with myPHPNuke.
                You can also add HTML commands like <a href=\'http://www.myphpnuke.com/\'>links</a>, <b>Bold</b> text, images, etc.
                Just use you imagination.', '4')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '18', '1', '10', '0', '0', '0', '0', 'Information', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '19', '1', '11', '0', '0', '1', '9', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '20', '1', '12', '0', '0', '0', '10', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '21', '1', '13', '0', '0', '1', '11', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '22', '1', '14', '0', '0', '0', '15', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '23', '1', '15', '0', '0', '0', '17', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '24', '0', '0', '0', '0', '1', '19', '', '', '0')");
        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '26', '1', '2', '1', '0', '1', '0', 'Your messenger', '<li><a href=\'mailbox.php\'>Your Mailbox</a>
        <li><a href=\'contactbook.php\'>Your Addressbook</a>
        <li><a href=\'settings.php\'>Your Settings</a>
        <li><a href=\'compose.php\'>Compose</a>
        <li><a href=\'emailhelp.php\'>Help </a>

        <li><a href=\'viewpmsg.php\'>Private Messages</a>
        ', '5')");

        mysql_query("INSERT INTO ".$prefix."blocks VALUES ( '28', '1', '0', '1', '1', '1', '0', 'Your personal page', '<li><a href=\'user.php?op=edituser\'>Your Profile</a>
        <li><a href=\'user.php?op=edithome\'>Your Menu</a>
        <li><a href=\'user.php?op=editcomm\'>Your Comments </a>
        <li><a href=\'user.php?op=chgtheme\'>Your Theme </a>
        <li><a href=\'user.php?op=logout\'>Logout</a>

        <li><a href=calendar.php>Your Calender</a>', '5')");

        echo "$dbmessage3&nbsp;blocks</p>";
    } else {
        echo "$dbmessage4&nbsp;blocks</p>";
    }

// UPDATE CATEGORIES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."categories");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."categories VALUES ( '1', 'General')");

        echo "$dbmessage3&nbsp;categories</p>";
    } else {
        echo "$dbmessage4&nbsp;categories</p>";
    }

// UPDATE COMMENTS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."comments");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."comments VALUES ( '1', '0', '1', '2004-01-01 12:00:00', '', '', '', '150.10.10.10', 'Re: Welcome to myPHPNuke 1.8.8', 'FIRST COMMENT!
        <br>

        <br>
        All my life I wanted to do this ;)', '0', '0')");

        echo "$dbmessage3&nbsp;comments</p>";
    } else {
        echo "$dbmessage4&nbsp;comments</p>";
    }

// UPDATE COUNTER //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."counter");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'total', 'hits', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'WebTV', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Lynx', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'MSIE', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Opera', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Konqueror', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Netscape', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Bot', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'browser', 'Other', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'Windows', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'Linux', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'Mac', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'FreeBSD', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'SunOS', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'IRIX', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'BeOS', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'OS/2', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'AIX', '0')");
        mysql_query("INSERT INTO ".$prefix."counter VALUES ( 'os', 'Other', '0')");

        echo "$dbmessage3&nbsp;counter</p>";
    } else {
        echo "$dbmessage4&nbsp;counter</p>";
    }

// UPDATE FORUMS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."forums");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."forums VALUES ( '1', 'Test Forum', 'This is for testing', '0', '1', '1', '0', '')");

        echo "$dbmessage3&nbsp;forums</p>";
    } else {
        echo "$dbmessage4&nbsp;forums</p>";
    }

// UPDATE FORUMS CONFIG //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."forumconfig");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."forumconfig VALUES ( '0', '1', '1', '10', '10', '10')");

        echo "$dbmessage3&nbsp;forumconfig</p>";
    } else {
        echo "$dbmessage4&nbsp;forumconfig</p>";
    }

// UPDATE GALLERY CATEGORIES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."gallery_categories");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."gallery_categories VALUES ( '1', 'Art', 'gallery.gif', 'Art', 'Art Pictures', '-1', '2', '2', '2', '6', '0000-00-00')");

        echo "$dbmessage3&nbsp;gallery_categories</p>";
    } else {
        echo "$dbmessage4&nbsp;gallery_categories</p>";
    }

// UPDATE GALLERY MEDIA CLASS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."gallery_media_class");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."gallery_media_class VALUES ( '1', 'Image')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_class VALUES ( '2', 'Audio')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_class VALUES ( '3', 'Video')");

        echo "$dbmessage3&nbsp;gallery_media_class</p>";
    } else {
        echo "$dbmessage4&nbsp;gallery_media_class</p>";
    }

// UPDATE GALLERY MEDIA //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."gallery_media_types");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'gif', 'Image/GIF', '1', '<img src=\":FNAME:\" border=\"0\" width=\":WIDTH:\" height=\":HEIGHT:\" alt=\":DESCRIP:\" />', 'image_gif.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'jpg', 'Image/JPG', '1', '<img src=\":FNAME:\" border=\"0\" width=\":WIDTH:\" height=\":HEIGHT:\" alt=\":DESCRIP:\" />', 'image_jpg.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'png', 'Image/PNG', '1', '<img src=\":FNAME:\" border=\"0\" width=\":WIDTH:\" height=\":HEIGHT:\" alt=\":DESCRIP:\" />', 'image_png.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'mov', 'Video/Quicktime', '3', '<embed controller=\"true\" width=\":WIDTH:\" height=\":HEIGHT:\" src=\":FNAME:\" border=\"0\" pluginspage=\"http://www.apple.com/quicktime/download/indext.html\"></embed>', 'video_mov.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'avi', 'Video/AVI', '3', '<embed src=\":FNAME:\" border=\"0\" width=\":WIDTH:\" height=\":HEIGHT:\" type=\"application/x-mplayer2\"></embed>', 'video_avi.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'mpg', 'Video/MPEG', '3', '<embed src=\":FNAME:\" border=\"0\" width=\":WIDTH:\" height=\":HEIGHT:\" type=\"application/x-mplayer2\"></embed>', 'video_mpg.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'mp3', 'Audio/MP3', '2', '<embed controller=\"true\" width=\"200\" height=\"20\" src=\":FNAME:\" border=\"0\" pluginspage=\"http://www.apple.com/quicktime/download/indext.html\"></embed>', 'audio_mp3.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'mid', 'Audio/MIDI', '2', '<embed src=\":FNAME:\" type=\"audio/midi\" hidden=\"false\" autostart=\"true\" loop=\"true\" height=\"20\" width=\"200\"></embed>', 'audio_mid.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'swf', 'Video/Flash', '3', '<embed src=\":FNAME:\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\":WIDTH:\" height=\":HEIGHT:\" play=\"true\" loop=\"true\" quality=\"high\" scale=\"showall\" menu=\"true\"></embed>', 'video_swf.gif')");
        mysql_query("INSERT INTO ".$prefix."gallery_media_types VALUES ( 'rm', 'Video/RealMedia', '3', '<OBJECT ID=RAOCX CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" width=\":WIDTH:\" height=\":HEIGHT:\">
        <PARAM NAME=\"CONTROLS\" VALUE=\"ImageWindow\">
        <PARAM NAME=\"AUTOSTART\" Value=\"true\">
        <PARAM NAME=\"SRC\" VALUE=\":FNAME:\">
        <embed height=\":HEIGHT:\" width=\":WIDTH:\" controls=\"ImageWindow\" src=\" :FNAME:?embed\" type=\"audio/x-pn-realaudio-plugin\" autostart=\"true\" nolabels=\"0\" autogotourl=\"-1\"></OBJECT>', 'video_realmedia.gif')");

        echo "$dbmessage3&nbsp;gallery_media_types</p>";
    } else {
        // ASSUME TEMPLATES ARE PRESENT AND ARE FROM PRE 1.8.8_8-RC1 SO UPDATE THEM
        $sql  = 'UPDATE ' . $prefix . 'gallery_media_types SET ';
        $sql .= "displaytag = REPLACE(displaytag, '<:FILENAME:>', ':FNAME:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:WIDTH:>', ':WIDTH:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:HEIGHT:>', ':HEIGHT:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:DESCRIPTION:>', ':DESCRIP:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:IMAGE:>', ':IMG:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:GALLNAME:>', ':GALLNAME:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:SUBCATEGORIES:>', ':SUBCAT:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RATE:>', ':RATE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RATINGBAR:>', ':RATEBAR:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:FORMAT:>', ':FMAT:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:SIZE:>', ':SIZE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:NEW:>', ':NEW:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:HITS:>', ':HITS:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:DATE:>', ':DATE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:NAME:>', ':NAME:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:NBCOMMENTS:>', ':NBCOMM:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:SUBMITTER:>', ':SUBMITTER:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:NAMESIZE:>', ':NAMESIZE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:COMMENTS:>', ':COMM:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWIMAGE:>', ':RAWIMG:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWIMAGESIZE:>', ':RAWIMGSIZE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWIMAGEWIDTH:>', ':RAWIMGWIDTH:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWIMAGEHEIGHT:>', ':RAWIMGHEIGHT:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWDESCRIPTION:>', ':RAWDESCRIP:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWRATE:>', ':RAWRATE:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWVOTES:>', ':RAWVOTES:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWSUBMITTER:>', ':RAWSUBMITTER:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWNAME:>', ':RAWNAME:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWHITS:>', ':RAWHITS:'), ";
        $sql .= "displaytag = REPLACE(displaytag, '<:RAWDATEBRIEF:>', ':RAWDATEBRIEF:')";
        mysql_query( $sql );

        echo "$dbmessage4&nbsp;gallery_media_types</p>";
    }

// UPDATE GALLERY PICTURES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."gallery_pictures");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '1', '1', '1.jpg', '2', 'Webmaster', '2001-06-22 15:05:25', '1.jpg', '1.jpg', '0', '0', 'jpg', '413', '271')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '2', '1', '2.jpg', '2', 'Webmaster', '2001-06-22 15:05:25', '2.jpg', '', '0', '0', 'jpg', '490', '370')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '3', '1', '3.jpg', '0', 'Webmaster', '2001-06-22 15:05:25', '3.jpg', '', '0', '0', 'jpg', '216', '216')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '4', '1', '4.jpg', '0', 'Webmaster', '2001-06-22 15:05:25', '4.jpg', '', '0', '0', 'jpg', '230', '290')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '5', '1', '5.jpg', '2', 'Webmaster', '2001-06-22 15:05:25', '5.jpg', '', '0', '0', 'jpg', '232', '296')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '6', '1', '6.jpg', '3', 'Webmaster', '2001-06-22 15:05:25', '6.jpg', '', '0', '0', 'jpg', '479', '370')");
        mysql_query("INSERT INTO ".$prefix."gallery_pictures VALUES ( '7', '1', 'kodred1.swf', '2', 'Webmaster', '2001-06-22 15:05:25', 'kodred1.swf', '', '0', '0', 'swf', '320', '240')");

        echo "$dbmessage3&nbsp;gallery_pictures</p>";
    } else {
        echo "$dbmessage4&nbsp;gallery_pictures</p>";
    }


// UPDATE GALLERY TEMPLATES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."gallery_template_types");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."gallery_template_types VALUES ( '1', 'Default Main Page Template', '1', '<table align=\"center\">
        <tr>
                <td colspan=\"2\">
                        :GALLNAME:
                </td>
        </tr>
        <tr>
                <td>
                        :IMG:
                </td>
                <td valign=\"top\" align=\"left\">
                        :DESCRIP:
                </td>
        </tr>
        </table>', '2', '.common_text_black {text-color:#000000}
.common_text_white {text-color:#ffffff}')");

       
        
        mysql_query("INSERT INTO ".$prefix."gallery_template_types VALUES ( '2', 'Default', '2', '<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
        <tr>

                <td>
                        :IMG:
                </td>
                <td valign=\"top\">
                        <table>
                        <tr>
                                <td>
                                        <table>
                                        <tr>
                                                <td align=\"center\">
                                                        :DATE:
                                                </td>
                                                <td align=\"center\">
                                                        :RATE:
                                                </td>
                                                <td align=\"center\">
                                                        :HITS:
                                                </td>
                                                <td align=\"center\">
                                                        :NEW:
                                                </td>
                                        </tr>
                                        </table>
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        :DESCRIP:
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        :NBCOMM: | :FMAT: | :SIZE:
                                </td>
                        </tr>
                        </table>
                </td>
        </tr>
        </table>', '<table width=\"100%\">
        <tr>
                <td valign=\"top\" align=\"center\" width=\"30%\">
                        :NAMESIZE:
                        <br /><br />
                        <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
                        <tr>
                                <td valign=\"top\">
                                        :SUBMITTER:
                                        :DATE:
                                        :HITS:
                                        :RATE:
                                </td>
                        </tr>
                        </table><br />
                        :RATEBAR:
                </td>
                <td width=\"70%\" align=\"center\">
                        :IMG:
                </td>
        </tr>
        <tr>
                <td colspan=\"2\">:DESCRIP:</td>
        </tr>
        <tr>
                <td colspan=\"2\">
                        :COMM:
                </td>
        </tr>
        </table>', '.common_text_black {text-color:#000000}
.common_text_white {text-color:#ffffff}')");

 
        echo "$dbmessage3&nbsp;gallery_template_types</p>";
    } else {
        // ASSUME TEMPLATES ARE PRESENT AND ARE FROM PRE 1.8.8_8-RC1 SO UPDATE THEM
        $sql  = 'UPDATE ' . $prefix . 'gallery_template_types SET ';
        $sql .= "templateCategory = REPLACE(templateCategory, '<:FILENAME:>', ':FNAME:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:WIDTH:>', ':WIDTH:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:HEIGHT:>', ':HEIGHT:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:DESCRIPTION:>', ':DESCRIP:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:IMAGE:>', ':IMG:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:GALLNAME:>', ':GALLNAME:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:SUBCATEGORIES:>', ':SUBCAT:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RATE:>', ':RATE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RATINGBAR:>', ':RATEBAR:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:FORMAT:>', ':FMAT:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:SIZE:>', ':SIZE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:NEW:>', ':NEW:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:HITS:>', ':HITS:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:DATE:>', ':DATE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:NAME:>', ':NAME:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:NBCOMMENTS:>', ':NBCOMM:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:SUBMITTER:>', ':SUBMITTER:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:NAMESIZE:>', ':NAMESIZE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:COMMENTS:>', ':COMM:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWIMAGE:>', ':RAWIMG:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWIMAGESIZE:>', ':RAWIMGSIZE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWIMAGEWIDTH:>', ':RAWIMGWIDTH:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWIMAGEHEIGHT:>', ':RAWIMGHEIGHT:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWDESCRIPTION:>', ':RAWDESCRIP:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWRATE:>', ':RAWRATE:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWVOTES:>', ':RAWVOTES:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWSUBMITTER:>', ':RAWSUBMITTER:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWNAME:>', ':RAWNAME:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWHITS:>', ':RAWHITS:'), ";
        $sql .= "templateCategory = REPLACE(templateCategory, '<:RAWDATEBRIEF:>', ':RAWDATEBRIEF:'), ";

        $sql .= "templatePictures = REPLACE(templatePictures, '<:FILENAME:>', ':FNAME:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:WIDTH:>', ':WIDTH:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:HEIGHT:>', ':HEIGHT:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:DESCRIPTION:>', ':DESCRIP:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:IMAGE:>', ':IMG:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:GALLNAME:>', ':GALLNAME:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:SUBCATEGORIES:>', ':SUBCAT:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RATE:>', ':RATE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RATINGBAR:>', ':RATEBAR:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:FORMAT:>', ':FMAT:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:SIZE:>', ':SIZE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:NEW:>', ':NEW:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:HITS:>', ':HITS:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:DATE:>', ':DATE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:NAME:>', ':NAME:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:NBCOMMENTS:>', ':NBCOMM:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:SUBMITTER:>', ':SUBMITTER:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:NAMESIZE:>', ':NAMESIZE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:COMMENTS:>', ':COMM:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWIMAGE:>', ':RAWIMG:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWIMAGESIZE:>', ':RAWIMGSIZE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWIMAGEWIDTH:>', ':RAWIMGWIDTH:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWIMAGEHEIGHT:>', ':RAWIMGHEIGHT:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWDESCRIPTION:>', ':RAWDESCRIP:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWRATE:>', ':RAWRATE:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWVOTES:>', ':RAWVOTES:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWSUBMITTER:>', ':RAWSUBMITTER:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWNAME:>', ':RAWNAME:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWHITS:>', ':RAWHITS:'), ";
        $sql .= "templatePictures = REPLACE(templatePictures, '<:RAWDATEBRIEF:>', ':RAWDATEBRIEF:')";
        mysql_query( $sql );

        echo "$dbmessage4&nbsp;gallery_template_types</p>";
    }

// UPDATE HEADLINES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."headlines");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'myPHPNuke', 'http://www.myphpnuke.com', 'http://www.myphpnuke.com/backend.php', '1')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PHP-Nuke', 'http://www.phpnuke.org', 'http://www.phpnuke.org/backend.php', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Slashdot', 'http://slashdot.org', 'http://slashdot.org/slashdot.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'NewsForge', 'http://www.newsforge.com', 'http://www.newsforge.com/newsforge.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PHPBuilder', 'http://phpbuilder.com', 'http://phpbuilder.com/rss_feed.php', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Linux.com', 'http://linux.com', 'http://linux.com/mrn/front_page.rss', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Freshmeat', 'http://freshmeat.net', 'http://freshmeat.net/backend/fm.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'LinuxWeelyNews', 'http://lwn.net', 'http://lwn.net/headlines/rss', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'HappyPenguin', 'http://happypenguin.org', 'http://happypenguin.org/html/news.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'KDE', 'http://www.kde.org', 'http://www.kde.org/dotkdeorg.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Perl.com', 'http://www.perl.com', 'http://www.perl.com/pace/perlnews.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'BrunchingShuttlecocks', 'http://www.brunching.com', 'http://www.brunching.com/brunching.rdf', '0')");
//        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'NewsTrolls', 'http://newstrolls.com', 'http://newstrolls.com/newstrolls.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'AbsoluteGames', 'http://files.gameaholic.com', 'http://files.gameaholic.com/agfa.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'SciFi-News', 'http://www.technopagan.org/sf-news/', 'http://www.technopagan.org/sf-news/rdf.php', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'LinuxM68k', 'http://www.linux-m68k.org', 'http://www.linux-m68k.org/linux-m68k.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Protest.net', 'http://www.protest.net', 'http://www.protest.net/netcenter_rdf.cgi', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PBSOnline', 'http://www.pbs.org', 'http://cgi.pbs.org/cgi-registry/featuresrdf.pl', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Listology', 'http://www.listology.com', 'http://listology.com/recent.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Technocrat', 'http://www.technocrat.net', 'http://technocrat.net/rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PDABuzz', 'http://www.pdabuzz.com', 'http://www.pdabuzz.com/netscape.txt', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Gnotices', 'http://news.gnome.org/gnome-news/', 'http://news.gnome.org/gnome-news/rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'DailyDaemonNews', 'http://daily.daemonnews.org', 'http://daily.daemonnews.org/ddn.rdf.php3', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PerlMonks', 'http://www.perlmonks.org', 'http://www.perlmonks.org/headlines.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PerlNews', 'http://news.perl.org', 'http://news.perl.org/perl-news-short.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'DotKDE', 'http://dot.kde.org', 'http://dot.kde.org/rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'GeekNik', 'http://www.geeknik.net', 'http://www.geeknik.net/backend/weblog.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'HotWired', 'http://www.hotwired.com', 'http://www.hotwired.com/webmonkey/meta/headlines.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'LinuxCentral', 'http://linuxcentral.com', 'http://linuxcentral.com/backend/lcnew.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'Linux.nu', 'http://www.linux.nu', 'http://www.linux.nu/backend.php', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'MaximumBSD', 'http://www.maximumbsd.com', 'http://www.maximumbsd.com/rss/', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'SolarisCentral', 'http://www.SolarisCentral.org', 'http://www.SolarisCentral.org/news/SolarisCentral.rdf', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'DigitalTheatre', 'http://www.dtheatre.com', 'http://www.dtheatre.com/backend.php3?xml=yes', '0')");
        mysql_query("INSERT INTO ".$prefix."headlines VALUES ( NULL, 'PlanetX', 'http://www.planetx.com', 'http://www.planetx.com/xml.php', '0')");

        echo "$dbmessage3&nbsp;headlines</p>";
    } else {
        echo "$dbmessage4&nbsp;headlines</p>";
    }



// IMAGE DIRECTORIES

    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."image_dirs");
    $present = mysql_result($result, 0);

    if ($present == "0")
    {
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('1', '/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('2', 'admin/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('3', 'articles/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('4', 'banners/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('5', 'calendar/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('6', 'download/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('7', 'flags/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('8', 'forum/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('9', 'forum/avatar/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('10', 'forum/icons/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('11', 'forum/smilies/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('12', 'forum/subject/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('13', 'links/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('14', 'logos/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('15', 'members/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('16', 'menu/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('17', 'myyp/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('18', 'powered/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('19', 'reviews/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('20', 'sections/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('21', 'stats/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('22', 'topics/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('23', 'misc/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('24', 'gallery/', NULL)");
        mysql_query("INSERT INTO " . $prefix . "image_dirs VALUES ('25', 'gallery/thumbs', NULL)");

        echo $dbmessage3 . '&nbsp;image_dirs</p>';
    }
    else
    {
        echo $dbmessage4 . '&nbsp;image_dirs</p>';
    }



// UPDATE POLL_DATA //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."poll_data");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', 'Ummmm, not bad', '0', '1')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', 'Cool', '0', '2')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', 'Terrific', '0', '3')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', 'The best one!', '0', '4')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', 'what the hell is this?', '0', '0', '5')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '6')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '7')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '8')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '9')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '10')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '11')");
        mysql_query("INSERT INTO ".$prefix."poll_data VALUES ( '1', '', '0', '12')");

        echo "$dbmessage3&nbsp;poll_data</p>";
    } else {
        echo "$dbmessage4&nbsp;poll_data</p>";
    }

// UPDATE POLL DESC //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."poll_desc");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."poll_desc VALUES ( '1', 'What do you think about myPHPNuke 1.8.8?', '991366062', '1')");

        echo "$dbmessage3&nbsp;poll_desc</p>";
    } else {
        echo "$dbmessage4&nbsp;poll_desc</p>";
    }

// UPDATE RANKS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."ranks");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '1', 'Just popping in', '0', '20', '0')");
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '2', 'Not too shy to talk', '21', '40', '0')");
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '3', 'Quite a regular', '41', '70', '0')");
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '4', 'Just can\'t stay away', '71', '150', '0')");
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '5', 'Home away from home', '151', '10000', '0')");
        mysql_query("INSERT INTO ".$prefix."ranks VALUES ( '6', 'Moderators', '-1', '-1', '1')");

        echo "$dbmessage3&nbsp;ranks</p>";
    } else {
        echo "$dbmessage4&nbsp;ranks</p>";
    }

// UPDATE REVIEWS MAIN //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."reviews_main");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."reviews_main VALUES ( 'Reviews Section Title', 'Reviews Section Long Description')");

        echo "$dbmessage3&nbsp;reviews_main</p>";
    } else {
        echo "$dbmessage4&nbsp;reviews_main</p>";
    }

// UPDATE SMILES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."smiles");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '1', ':D', 'icon_biggrin.gif', 'Very Happy')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '2', ':-D', 'icon_biggrin.gif', 'Very Happy')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '3', ':grin:', 'icon_biggrin.gif', 'Very Happy')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '4', ':)', 'icon_smile.gif', 'Smile')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '5', ':-)', 'icon_smile.gif', 'Smile')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '6', ':smile:', 'icon_smile.gif', 'Smile')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '7', ':(', 'icon_frown.gif', 'Sad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '8', ':-(', 'icon_frown.gif', 'Sad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '9', ':sad:', 'icon_frown.gif', 'Sad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '10', ':O', 'icon_eek.gif', 'Surprised')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '11', ':-o', 'icon_eek.gif', 'Surprised')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '12', ':eek:', 'icon_eek.gif', 'Suprised')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '13', ':-?', 'icon_confused.gif', 'Confused')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '14', ':???:', 'icon_confused.gif', 'Confused')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '15', '8)', 'icon_cool.gif', 'Cool')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '16', '8-)', 'icon_cool.gif', 'Cool')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '17', ':cool:', 'icon_cool.gif', 'Cool')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '18', ':lol:', 'icon_lol.gif', 'Laughing')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '19', ':x', 'icon_mad.gif', 'Mad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '20', ':-x', 'icon_mad.gif', 'Mad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '21', ':mad:', 'icon_mad.gif', 'Mad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '22', ':P', 'icon_razz.gif', 'Razz')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '23', ':-P', 'icon_razz.gif', 'Razz')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '24', ':razz:', 'icon_razz.gif', 'Razz')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '25', ':oops:', 'icon_redface.gif', 'Embaressed')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '26', ':cry:', 'icon_cry.gif', 'Crying (very sad)')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '27', ':evil:', 'icon_evil.gif', 'Evil or Very Mad')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '28', ':roll:', 'icon_rolleyes.gif', 'Rolling Eyes')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '29', ':wink:', 'icon_wink.gif', 'Wink')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '30', ';)', 'icon_wink.gif', 'Wink')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '31', ';-)', 'icon_wink.gif', 'Wink')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '32', ':pint:', 'icon_drink.gif', 'Another pint of beer')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '33', ':hammer:', 'icon_hammer.gif', 'ToolTimes at work')");
        mysql_query("INSERT INTO ".$prefix."smiles VALUES ( '34', ':idea:', 'icon_idea.gif', 'I have an idea')");

        echo "$dbmessage3&nbsp;smiles</p>";
    } else {
        echo "$dbmessage4&nbsp;smiles</p>";
    }

// UPDATE STORIES //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."stories");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."stories VALUES ( '1', '0', 'god', 'Welcome to myPHPNuke!!!', '2004-01-01 12:00:00', 'This is the first article in <a href=\"http://www.myphpnuke.com/\" target=\"_blank\">myPHPNuke</a>. &nbsp;You can safely delete it.<br>Remember to set/change the nickname and/or password for the main admin user by logging in <a href=\"./admin.php\">here</a>, before the boogie man does it for you. <img src=\"./images/forum/smilies/icon_biggrin.gif\" alt=\"big grin\"><br>There aren\'t any registered/default users, so feel free to <a href=\"./user.php?op=register\">register</a> one. &nbsp;<i><small>(So it makes it look like a real website)</small></i><br>If you have some time on your hands, grab a cup of your favorite java and browse through the <a href=\"http://www.myphpnuke.com/manual188/\" target=\"_blank\">manual</a>.<br>If you want to make your site look <b><i>pretty</i></b>, run over to our <a href=\"http://themes.myphpnuke.com/\" target=\"_blank\">themes</a> site, and choose a theme from its vast collection.<br><br>Remember that this is free software. &nbsp;You can view the lock down license <a href=\"./license.php\"target=\"_blank\">here</a>.<br>If you come across any bugs, or hideous creatures, please report them at our <a href=\"http://sourceforge.net/projects/myphpnuke/\" target=\"_blank\">sourceforge</a> site.<br>Hope you enjoy this software.<p>myPHPNuke Dev Team</p>', '', '1', '1', '1', 'god', '', '0')");

        echo "$dbmessage3&nbsp;stories</p>";
    } else {
        echo "$dbmessage4&nbsp;stories</p>";
    }

// UPDATE TOPICS //

    $tmp = parse_url( $url );
    $topicname = $tmp['host'];

    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."topics");
    $present = mysql_result($result, 0);
    if ($present == "0") {
        mysql_query("INSERT INTO ".$prefix."topics VALUES ( '1', '$topicname', 'myphpnuke.gif', '$topicname', '0')");

        echo "$dbmessage3&nbsp;topics</p>";
    } else {
        echo "$dbmessage4&nbsp;topics</p>";
    }

// UPDATE USERS //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."users");
    $present = mysql_result($result, 0);

    // Global Admin SQL

    $sql = 'INSERT INTO ' . $prefix . 'users
            SET uid = -1
              , uname = "Administrator"
              , user_regdate = NOW()';

    if ($present == "0")
    {
        // Add Global Admin

        mysql_query( $sql );

        // Add Anon User

        mysql_query("INSERT INTO ".$prefix."users VALUES ( '1', '', 'Anonymous', '', '', '', '', '', '', '', '', '', '', '', '0', '0', '', '', '', '', '10', '', '0',
        '0', '0', '', '0', '', '', '0', '1', '1', '', '', '')");

        echo "$dbmessage3&nbsp;users</p>";
    }
    else if ( ! @mysql_result( mysql_query( "SELECT COUNT(*) FROM ".$prefix."users WHERE uid = -1" ), 0 ) )
    {
        // Add Global Admin If Updating

        mysql_query( $sql );

        echo "$dbmessage3&nbsp;users</p>";
    }
    else
    {
        echo "$dbmessage4&nbsp;users</p>";
    }

// UPDATE USERS STATUS

    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."users_status");
    $present = mysql_result($result, 0);

    // Global Admin SQL

    $sql = 'INSERT INTO ' . $prefix . 'users_status
            SET uid = -1
              , posts = 0
              , attachsig = 0
              , rank = 0
              , level = 3';

    if ($present == "0")
    {
        // Add Global Admin

        mysql_query( $sql );

        // Add Anon User

        mysql_query("INSERT INTO ".$prefix."users_status VALUES ( '1', '0', '0', '0', '0')");

        echo "$dbmessage3&nbsp;users_status</p>";
    }
    else if ( ! @mysql_result( mysql_query( "SELECT COUNT(*) FROM ".$prefix."users_status WHERE uid = -1" ), 0 ) )
    {
        // Insert Global Admin If Required

        mysql_query( $sql );
        echo "$dbmessage3&nbsp;users_status</p>";
    }
    else
    {
        echo "$dbmessage4&nbsp;users_status</p>";
    }

// UPDATE VISITS CONTROL //
    $result = mysql_query("SELECT COUNT(*) FROM ".$prefix."visits_control");
    $present = mysql_result($result, 0);
    if ($present == "0")
    {
        mysql_query("INSERT INTO ".$prefix."visits_control VALUES ('1')");

        echo "$dbmessage3&nbsp;visits_control</p>";
    }
    else
    {
        echo "$dbmessage4&nbsp;visits_control</p>";
    }

    echo "</div><br /><hr width='80%' /><br /><p class='mpn-title'>Configuration Files Created<br /><br /><hr width='80%' />";

// CONFIG FILE //

// Database Config

    $dbconfig_file = './admin/original/dbconfig.php';
    $dbconfig_bk = './admin/original/dbconfig_old.php';

    if (file_exists($dbconfig_file))
    {
        //include $dbconfig_file;

        if ( !copy( $dbconfig_file, $dbconfig_bk ) )
        {
            die ('<em>Unable to back up ' . $dbconfig_file . '.</em>');
        }
    }

    $db_config = array(
    '<?php',
    ' ',
    "if ( ! defined( '_MAINFILE_' ) ) { exit( '!! ACCESS DENIED !!' ); }",
    ' ',
    '// +----------------------------------------------------------------------+',
    '// | myPHPNuke Version 188_8 RC2                                          |',
    '// +----------------------------------------------------------------------+',
    '// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |',
    '// +----------------------------------------------------------------------+',
    '// | Support: http://myphpnuke.com/                                       |',
    '// +----------------------------------------------------------------------+',
    '// | Author: myPHPNuke Dev Team                                           |',
    '// +----------------------------------------------------------------------+',
    '// | Copyright:  2001-2004 myPHPNuke Dev Team                             |',
    '// +----------------------------------------------------------------------+',
    ' ',
    '//#####################################################################',
    '// Database Configuration',
    '//',
    '// dbhost:   MySQL Database Hostname',
    '// dbuname:  MySQL Username',
    '// dbpass:   MySQL Password',
    '// dbname:   MySQL Database Name',
    '// system:   deprecated',
    '//',
    '//#####################################################################',
    ' ',
    '$dbhost = "'.$dbhost.'";',
    '$dbuname = "'.$dbuname.'";',
    '$dbpass = "'.$dbpass.'";',
    '$dbname = "'.$dbname.'";',
    '$system = NULL;',
    ' ',
    '?>');

    $count = count($db_config);

    $i = 0;

    if ( $fp = @fopen( $dbconfig_file, 'w+b' ) )
    {
        foreach ( $db_config AS $line )
        {
            if ( $i == ( $count - 1 ) )
            {
                fwrite($fp, "$line");
            }
            else
            {
                fwrite($fp, "$line\n");
            }

            $i++;
        }

        fclose($fp);

        echo '<br /><p class="mpn-title"><em>Database Configuration File Created</em></p><br />';
    }


// NUKE CONFIG

    $sitename = 'myPHPNuke Powered Site';
    $nuke_url = $url = _MPN_ROOT_URI;
    $site_logo = "logo.gif";
    $slogan = "Your slogan here";
    $startdate = date('M Y');
//    $adminmail = "youradmin@mail.com";
    $adminmail = $email;
    $mailmethod = "0";
    $smtp = "127.0.0.1";
    $anonpost = 1;
    $Default_Theme = "mpn_FreshAir2";
    $foot1 = '<a href="http://www.myphpnuke.com/" title="myPHPNuke Web Portal" target="_blank"><img src="images/powered/powermpn.gif" alt="MyPHPNuke Portal System" border="0" hspace="10"></a>&nbsp;&nbsp;<a href="http://www.apache.org/" title="www.apache.org" target="_blank"><img src="images/powered/apache.gif" alt="Apache Web Server"border="0" hspace="10"></a>&nbsp;&nbsp;<a href="http://www.php.net/" title="www.php.net" target="_blank"><img src="images/powered/php2.gif" alt="PHP Scripting Language" border="0" hspace="10"></a><br /><br />';
    $foot2 = 'All logos and trademarks in this site are property of their respective owner.<br />The comments are property of their posters, all the rest &copy; 2002 by me<br /><br />';
    $foot3 = 'This web site was made with <a href="http://www.myphpnuke.com/" title="myPHPNuke Web Portal">myPHPNuke</a>, a web portal system written in PHP.<br />myPHPNuke is Free Software released under the <a href="http://www.gnu.org/" title="GNU/GPL license">GNU/GPL license</a>.<br /><br />';
    $foot4 = 'You can syndicate our news using the file<br /><a href="backend.php">backend.php</a> or <a href="ultramode.txt">ultramode.txt</a><br /><br />';
    $commentlimit = 4096;
    $anonymous = "Anonymous";
    $site_font = "Verdana,Arial,Helvetica";
    $minpass = 5;
    $pollcomm = 1;
    $top = 10;
    $storyhome = 10;
    $oldnum = 10;
    $ultramode = 1;
    $banners = 0;
    $myIP = $HTTP_SERVER_VARS['REMOTE_ADDR'];
    $backend_title = "myPHPNuke Powered Site";
    $backend_language = "en-us";
    $backend_image = $derived_url . 'images/logo.gif';
    $backend_width = 88;
    $backend_height = 31;
    $language = "english";
    $locale = "en_US";
    $serv_offset = 0;
    $perpage = 10;
    $popular = 500;
    $newlinks = 10;
    $toplinks = 10;
    $linksresults = 10;
    $links_anonaddlinklock = 1;
    $notify = 0;
    $notify_email = $email; //"me@yoursite.com";
    $notify_subject = "NEWS for my site";
    $notify_message = "Hey! You got a new submission for your site.";
    $notify_from = "webmaster";
    $moderate = 0;
    $badreasons = 4;
    $maxOptions = 12;
    $BarScale = 1;
    $setCookies = 1;
    $tipath = "images/topics/";
    $userimg = "images/menu/";
    $adminimg = "images/admin/";
    $admingraphic = 0;
    $admart = 20;
    $httpref = 1;
    $httprefmax = 1000;
    $Ephemerids = 0;
    $MaxTextLength = 0;
    $MaxTotalLength = 0;
    $CensorMode = 1;
    $CensorReplace = "*";
    $cookieadmtime = 2592000;
    $cookiePrefix = "NukePoll";
    $show_user = 20;

    $config_file = "admin/original/config.php";
    $config_bk = "admin/original/config_old.php";
    if (file_exists($config_file)) {
            include($config_file);
            if (!copy($config_file, $config_bk)) die ("<em>Unable to back up ".$config_file.".</em>");
    }

    $system = 2;
    $hardenc = 0;
    $reasons = 'array("As Is", "Offtopic", "Flamebait", "Troll", "Redundant", "Insightful", "Interesting", "Informative", "Funny", "Overrated", "Underrated")';
    $AllowableHTML = 'array()';
    $CensorList = 'array()';
    $uimages = "\$userimg\$language";
    $Version_Num = "4.4";
/*
    $foot1 = addcslashes($foot1, "\"\\\$");
    $foot2 = addcslashes($foot2, "\"\\\$");
    $foot3 = addcslashes($foot3, "\"\\\$");
    $foot4 = addcslashes($foot4, "\"\\\$");
*/
    $config = array(
    '<?php',
    ' ',
    '######################################################################',
    '# myPHPNuke: Web Portal System',
    '# ============================',
    '#',
    '# Originally based upon PHPNuke, Copyright (c) 2000 by Francisco Burzi',
    '# (fburzi@ncc.org.ve)',
    '# http://phpnuke.org',
    '#',
    '# This module is to configure the main options for your site',
    '#',
    '# This program is free software. You can redistribute it and/or modify',
    '# it under the terms of the GNU General Public License as published by',
    '# the Free Software Foundation; either version 2 of the License.',
    '######################################################################',
    ' ',
    '/*********************************************************************/',
    '/* You finished to configure the Database. Now you can change all    */',
    '/* you want in the Administration Section.   To enter just launch    */',
    '/* you web browser pointing to http://yourdomain.com/admin.php       */',
    '/*                                                                   */',
    '/* At the prompt use the following ID to login (case sensitive):     */',
    '/*                                                                   */',
    '/* AdminID: God                                                      */',
    '/* Password: Password                                                */',
    '/*                                                                   */',
    '/* Be sure to change inmediately the God login & password clicking   */',
    '/* on Edit Admin in the Admin menu. After that, click on Preferences */',
    '/* to configure your new site. In that menu you can change all you   */',
    '/* need to change.                                                   */',
    '/*                                                                   */',
    '/* Remember to chmod 666 this file in order to let the system write  */',
    '/* to it properly. If you can\'t change the permissions you can edit  */',
    '/* the rest of this file by hand.                                    */',
    '/*                                                                   */',
    '/* Congratulations! now you have an automated news portal!           */',
    '/* Thanks for choose PHP-Nuke: The Future of the Web                 */',
    '/*********************************************************************/',
    ' ',
    ' ',
    ' ',
    '######################################################################',
    '# General Site Configuration',
    '#',
    '# $sitename:      Your Site Name',
    '# $nuke_url:      Complete URL for your site (Do not put / at end)',
    '# $site_logo:     Logo for Printer Friendly Page (It\'s good to have a Black/White graphic)',
    '# $slogan:        Your site\'s slogan',
    '# $startdate:     Start Date to display in Statistic Page',
    '# $adminmail:     Site Administrator\'s Email',
    '# $smtp:          SMTP Server',
    '# $anonpost:      Allow Anonymous to Post Comments? (1=Yes 0=No)',
    '# $Default_Theme: Default Theme for your site (See /themes directory for the complete list, case sensitive!)',
    '# $foot(x):       Messages for all footer pages (Can include HTML code)',
    '# $commentlimit:  Maximum number of bytes for each comment',
    '# $anonymous:     Anonymous users Default Name',
    '# $site_font:     Font for your entire site (Comma separated for many fonts type)',
    '# $minpass:       Minimum character for users passwords',
    '# $pollcomm:      Activate comments in Polls? (1=Yes 0=No)',
    '######################################################################',
    ' ',
    '$sitename = "'.$sitename.'";',
    '$nuke_url = "'.$nuke_url.'";',
    '$site_logo = "'.$site_logo.'";',
    '$slogan = "'.$slogan.'";',
    '$startdate = "'.$startdate.'";',
    '$adminmail = "'.$adminmail.'";',
    '$mailmethod = '.$mailmethod.';',
    '$smtp = "'.$smtp.'";',
    '$anonpost = '.$anonpost.';',
    '$Default_Theme = "'.$Default_Theme.'";',
    '$foot1 = \''.$foot1.'\';',
    '$foot2 = \''.$foot2.'\';',
    '$foot3 = \''.$foot3.'\';',
    '$foot4 = \''.$foot4.'\';',
    '$commentlimit = '.$commentlimit.';',
    '$anonymous = "'.$anonymous.'";',
    '$site_font = "'.$site_font.'";',
    '$minpass = '.$minpass.';',
    '$pollcomm = '.$pollcomm.';',
    ' ',
    '######################################################################',
    '# General Stories Options',
    '#',
    '# $top:       How many items in Top Page?',
    '# $storyhome: How many stories to display in Home Page?',
    '# $oldnum:    How many stories in Old Articles Box?',
    '# $ultramode: Activate ultramode plain text file backend syndication? (1=Yes 0=No  Need to chmod 666 ultramode.txt file)',
    '######################################################################',
    ' ',
    '$top = '.$top.';',
    '$storyhome = '.$storyhome.';',
    '$oldnum = '.$oldnum.';',
    '$ultramode = '.$ultramode.';',
    ' ',
    '######################################################################',
    '# Banners/Advertising Configuration',
    '#',
    '# $banners: Activate Banners Ads for your site? (1=Yes 0=No)',
    '# $myIP:    Write your IP number to not count impressions, be fair about this!',
    '######################################################################',
    ' ',
    '$banners = '.$banners.';',
    '$myIP = "'.$myIP.'";',
    ' ',
    '######################################################################',
    '# XML/RDF Backend Configuration',
    '#',
    '# $backend_title:    Backend title, can be your site\'s name and slogan',
    '# $backend_language: Language format of your site',
    '# $backend_image:    Image logo for your site',
    '# $backend_width:    Image logo width',
    '# $backend_height:   Image logo height',
    '######################################################################',
    ' ',
    '$backend_title = "'.$backend_title.'";',
    '$backend_language = "'.$backend_language.'";',
    '$backend_image = "'.$backend_image.'";',
    '$backend_width = '.$backend_width.';',
    '$backend_height = '.$backend_height.';',
    ' ',
    '######################################################################',
    '# Site Language Preferences',
    '#',
    '# $language: Language of your site (You need to have lang-xxxxxx.php file for your selected language in the /language directory of your site)',
    '# $hardenc:  1 if language is hard encoded',
    '# $locale:   Locale configuration to correctly display date with your country format. (See /usr/share/locale)',
    '# $serv_offset:   Adjust server time to local time',
    '######################################################################',
    ' ',
    '$language = "'.$language.'";',
    '$hardenc = '.$hardenc.';',
    '$locale = "'.$locale.'";',
    '$serv_offset = '.$serv_offset.';',
    ' ',
    '######################################################################',
    '# Web Links Preferences',
    '#',
    '# $perpage:                  How many links to show on each page?',
    '# $popular:                  How many hits need a link to be listed as popular?',
    '# $newlinks:                 How many links to display in the New Links Page?',
    '# $toplinks:                 How many links to display in The Best Links Page? (Most Popular)',
    '# $linksresults:             How many links to display on each search result page?',
    '# $links_anonaddlinklock: Let Anonymous users to post new links? (1=Yes 0=No)',
    '######################################################################',
    ' ',
    '$perpage = '.$perpage.';',
    '$popular = '.$popular.';',
    '$newlinks = '.$newlinks.';',
    '$toplinks = '.$toplinks.';',
    '$linksresults = '.$linksresults.';',
    '$links_anonaddlinklock = '.$links_anonaddlinklock.';',
    ' ',
    '######################################################################',
    '# Notification of News Submissions',
    '#',
    '# $notify:         Notify you each time your site receives a news submission? (1=Yes 0=No)',
    '# $notify_email:   Email, address to send the notification',
    '# $notify_subject: Email subject',
    '# $notify_message: Email body, message',
    '# $notify_from:    account name to appear in From field of the Email',
    '######################################################################',
    ' ',
    '$notify = '.$notify.';',
    '$notify_email = "'.$notify_email.'";',
    '$notify_subject = "'.$notify_subject.'";',
    '$notify_message = "'.$notify_message.'";',
    '$notify_from = "'.$notify_from.'";',
    ' ',
    '######################################################################',
    '# Moderation Config (not 100% working)',
    '#',
    '# $moderate:   Activate moderation system? (1=Yes 0=No)',
    '# $resons:     List of reasons for the moderation (each reason under quotes and comma separated)',
    '# $badreasons: Number of bad reasons in the reasons list',
    '######################################################################',
    ' ',
    '$moderate = '.$moderate.';',
    '$reasons = '.$reasons.';',
    '$badreasons = '.$badreasons.';',
    ' ',
    '######################################################################',
    '# Surveys/Polls Config',
    '#',
    '# $maxOptions: Number of maximum options for each poll',
    '# $BarScale:   Scale for the Bar, multiple of 100, You may leave this to 1',
    '# $setCookies: Set cookies to prevent visitors vote twice in a period of 24 hours? (1=Yes 0=No)',
    '######################################################################',
    ' ',
    '$maxOptions = '.$maxOptions.';',
    '$BarScale = '.$BarScale.';',
    '$setCookies = '.$setCookies.';',
    ' ',
    '######################################################################',
    '# Some Graphics Options',
    '#',
    '# $tipath:       Topics images path (put / only at the end, not at the begining)',
    '# $userimg:      User images path (put / only at the end, not at the begining)',
    '# $adminimg:     Administration system images path (put / only at the end, not at the begining)',
    '# $admingraphic: Activate graphic menu for Administration Menu? (1=Yes 0=No)',
    '# $admart:       How many articles to show in the admin section?',
    '######################################################################',
    ' ',
    '$tipath = "'.$tipath.'";',
    '$userimg = "'.$userimg.'";',
    '$adminimg = "'.$adminimg.'";',
    '$admingraphic = '.$admingraphic.';',
    '$admart = '.$admart.';',
    ' ',
    '######################################################################',
    '# HTTP Referers Options',
    '#',
    '# $httpref:    Activate HTTP referer logs to know who is linking to our site? (1=Yes 0=No)',
    '# $httprefmax: Maximum number of HTTP referers to store in the Database', 
    '# (Try to not set this to a high number, 500 ~ 1000 is Ok)',
    '######################################################################',
    ' ',
    '$httpref = '.$httpref.';',
    '$httprefmax = '.$httprefmax.';',
    ' ',
    '######################################################################',
    '# Allowable HTML tags',
    '#',
    '# $AllowableHTML: HTML command to allow in the comments',
    '#                  =>2 means accept all qualifiers: <foo bar>',
    '#                  =>1 means accept the tag only: <foo>',
    '######################################################################',
    ' ',
    '$AllowableHTML = '.$AllowableHTML.';',
    ' ',
    '######################################################################',
    '# Miscelaneous Options',
    '#',
    '# $Ephemerids:    Activate Ephemerids (Past Events) system? (1=Yes 0=No)',
    '######################################################################',
    ' ',
    '$Ephemerids = '.$Ephemerids.';',
    ' ',
    '######################################################################',
    '# Filters Options (not working yet)',
    '######################################################################',
    ' ',
    '$MaxTextLength = '.$MaxTextLength.';',
    '$MaxTotalLength = '.$MaxTotalLength.';',
    '$CensorList = '.$CensorList.';',
    '$CensorMode = '.$CensorMode.';',
    '$CensorReplace = "'.$CensorReplace.'";',
    ' ',
    '######################################################################',
    '# Do not touch the following options!',
    '######################################################################',
    ' ',
    '$cookieadmtime = '.$cookieadmtime.';',
    '$cookiePrefix = "'.$cookiePrefix.'";',
    '$uimages = "'.$uimages.'";',
    '$Version_Num = "'.$Version_Num.'";',
    ' ',
    '######################################################################',
    '# Show a number of user ',
    '# $show_user: How many users to display in admin section?',
    '######################################################################',
    ' ',
    '$show_user = '.$show_user.';',
    ' ',
    '?>');

    if ($fp = @fopen($config_file, "wb")) {
        foreach ($config as $line) {
            fwrite($fp, "$line\n");
        }
    fclose($fp);
    echo "<br /><p class='mpn-title'>File <em>".$config_file."</em> created.</p><br />";
    }

    if ( $dbconf = file( 'dbconf.php' ) )
    {
        while ( list( $num, $row ) = each( $dbconf ) )
        {
            //if ( substr( $row, 0, 22 ) == "\ = 'mpn_';" )

            if ( (bool)FALSE !== strpos( $row, '$tableprefix =' ) )
            {
                //$dbconf[ $num ] = str_replace( 'mpn_', $prefix, $row );

                $dbconf[ $num ] = '$tableprefix = \'' . $prefix . '\';';
                $dbconf[ $num ] .= "\n";
            }
        }

        if ( $fp = @fopen( './dbconf.php', 'w+b' ) )
        {
            fwrite( $fp, join( '', $dbconf ) );
        }

        fclose($fp);
    }

// MPN CONFIG FILE //
    $mpn_activate_email = 1;
    $mpn_split_userpage = 1;
    $mpn_use_newuser_fix = 1;
    $mpn_use_gzcompress = 0;
    $mpn_use_pager = 0;
    $mpn_anonymous_id = 1;
    $mpn_poll_seperate_rows = 0;
    $mpn_use_timezone_formattimestamp = 0;
    $mpn_set_timezone = 0;
    $mpn_timezone = "";
    $mpn_host_use_safemode = 0;
    $mpn_mysql_pconnect = 0;
    $mpn_pagesize_updatelog = 10;
    $mpn_sections_only_for_users = 1;
    $mpn_display_quote = 1;
    $mpn_display_fetching_request = 0;
    $mpn_webmaster_name = $name; //"Your name";
    $mpn_conf_subject = "";
    $mpn_use_headline_applet = 0;
    $mpn_use_oldnews_applet = 0;
    $mpn_use_opendir = 0;
    $mpn_display_recenttopics = 1;
    $mpn_recenttopics_num = 5;
    $mpn_display_lastseen = 1;
    $mpn_lastseen_daysintable = 10;
    $mpn_display_whatsnews = 0;
    $mpn_display_chatboxII = 0;
    $mpn_whatsnew_entries = 5;
    $mpn_uname_test_level = 0;
    $mpn_mail_newuser_password = 1;
    $mpn_new_user_notify = 1;
    $mpn_new_comment_notify = 1;
    $mpn_new_pollcomment_notify = 1;
    $mpn_new_forumtopic_notify = 1;
    $mpn_new_guestbook_notify = 1;

    $mpn_config_file = "admin/myphpnuke/config.php";
    $mpn_config_file_bk = "admin/myphpnuke/config_old.php";
    if (file_exists($mpn_config_file)) {
            include($mpn_config_file);
            if (!@copy($mpn_config_file, $mpn_config_file_bk)) die ("<em>Unable to back up ".$mpn_config_file.".</em><br /><br />");
    }

   // $mpn_version = "1.8.8_7";
   
   // Preserve an existing value of mpn_install_date or set it to the current date time
    if ( ! isset( $mpn_install_date ) )
    {
        $mpn_install_date = time();
    }

    $mpn_config = array(
    '<?php',
    ' ',
    '###################################################################################################',
    '# myPHPNuke',
    '#',
    '# $mpn_activate_email:               Activate Email Subsystem.                         Default = 0',
    '# $mpn_split_userpage:               Split Login and New User Registration screen.     Default = 1',
    '# $mpn_use_newuser_fix:              Fix 214... error.                                 Default = 0',
    '# $mpn_use_pager:                    Enable Instant Messenger.                         Default = 0',
    '# $mpn_anonymous_id                  User Id for anonymus user.                        Default = 1',
    '# $mpn_poll_seperate_rows:           Put Poll buttons on seperate lines.               Default = 1',
    '# $mpn_use_timezone_formattimestamp: Use Timezone in formatTimestamp.                  Default = 1',
    '# $mpn_set_timezone:                 Set the timezone via putenv.                      Default = 0',
    '# $mpn_timezone:                     The timezone with is set via putenv.              Default = ',
    '# For a complete list of timezones visit: http://www.theprojects.org/dev/zone.txt',
    '# $mpn_host_use_safemode             Host uses PHP safe_mode.                          Default = 0',
    '# $mpn_mysql_pconnect                Use mysql_pconnect                                Default = 1',
    '# $mpn_pagesize_updatelog            Entries per page in the updatelog                 Default = 10',
    '# $mpn_sections_only_for_users       Only registered users can view the sections       Default = 0',
    '# $mpn_display_quote                 Activate the random quotes                        Default = 1',
    '# $mpn_display_fetching_request      Display the fetching request box                  Default = 0',
    '# $mpn_webmaster_name                Name of the webmaster for the Contact us Form     Default = ',
    '# $mpn_conf_subject                  Subject for the confirmation mail                 Default = ',
    '# $mpn_use_headline_applet           Scroll the headlines in applet                    Default = 0',
    '# $mpn_use_oldnews_applet            Scroll the old news in applet                     Default = 0',
    '# $mpn_use_opendir                   Use the opendir in weblinks                       Default = 1',
    '# $mpn_display_recenttopics          Display recent topics on first page               Default = 0',
    '# $mpn_display_lastseen              Display the last seen box                         Default = 1',
    '# $mpn_lastseen_daysintable          How many days should the entrie stay in db        Default = 10',
    '# $mpn_display_whatsnews             Display the x the what\'s new box                 Default = 1',
    '# $mpn_display_chatboxII             Display chatboxII                                 Default = 0',
    '# $mpn_whatsnew_entries              How many entries at the What\'s new Page          Default = 5',
    '# $mpn_uname_test_level              How strict are the test for the user nickname     Default = 0',
    '# $mpn_mail_newuser_password         Mail the password to the new user                 Default = 1',
    '# $mpn_new_user_notify               Send e-mail to ADMIN on New User Registration     Default = 0',
    '# $mpn_new_comment_notify            Send e-mail to ADMIN on New Comment or Reply      Default = 0',
    '# $mpn_new_pollcomment_notify        Send e-mail to ADMIN on New Poll Comment or Reply Default = 0',
    '# $mpn_new_forumtopic_notify         Send e-mail to ADMIN on New Forum Topic           Default = 0',
    '# $mpn_new_guestbook_notify          Send e-mail to ADMIN on New Guestbook entry       Default = 0',
    '###################################################################################################',
    ' ',
    '$mpn_activate_email = '.$mpn_activate_email.';',
    '$mpn_split_userpage = '.$mpn_split_userpage.';',
    '$mpn_use_newuser_fix = '.$mpn_use_newuser_fix.';',
    '$mpn_use_gzcompress = '.$mpn_use_gzcompress.';',
    '$mpn_use_pager = '.$mpn_use_pager.';',
    '$mpn_anonymous_id = '.$mpn_anonymous_id.';',
    '$mpn_poll_seperate_rows = '.$mpn_poll_seperate_rows.';',
    '$mpn_use_timezone_formattimestamp = '.$mpn_use_timezone_formattimestamp.';',
    '$mpn_set_timezone = '.$mpn_set_timezone.';',
    '$mpn_timezone = "'.$mpn_timezone.'";',
    '$mpn_host_use_safemode = '.$mpn_host_use_safemode.';',
    '$mpn_mysql_pconnect = '.$mpn_mysql_pconnect.';',
    '$mpn_pagesize_updatelog = '.$mpn_pagesize_updatelog.';',
    '$mpn_sections_only_for_users = '.$mpn_sections_only_for_users.';',
    '$mpn_display_quote = '.$mpn_display_quote.';',
    '$mpn_display_fetching_request = '.$mpn_display_fetching_request.';',
    '$mpn_webmaster_name = "'.$mpn_webmaster_name.'";',
    '$mpn_conf_subject = "'.$mpn_conf_subject.'";',
    '$mpn_use_headline_applet = '.$mpn_use_headline_applet.';',
    '$mpn_use_oldnews_applet = '.$mpn_use_oldnews_applet.';',
    '$mpn_use_opendir = '.$mpn_use_opendir.';',
    '$mpn_display_recenttopics = '.$mpn_display_recenttopics.';',
    '$mpn_recenttopics_num = '.$mpn_recenttopics_num.';',
    '$mpn_display_lastseen = '.$mpn_display_lastseen.';',
    '$mpn_lastseen_daysintable = '.$mpn_lastseen_daysintable.';',
    '$mpn_display_whatsnews = '.$mpn_display_whatsnews.';',
    '$mpn_display_chatboxII = '.$mpn_display_chatboxII.';',
    '$mpn_whatsnew_entries = '.$mpn_whatsnew_entries.';',
    '$mpn_uname_test_level = '.$mpn_uname_test_level.';',
    '$mpn_mail_newuser_password = '.$mpn_mail_newuser_password.';',
    '$mpn_new_user_notify = '.$mpn_new_user_notify.';',
    '$mpn_new_comment_notify = '.$mpn_new_comment_notify.';',
    '$mpn_new_pollcomment_notify = '.$mpn_new_pollcomment_notify.';',
    '$mpn_new_forumtopic_notify = '.$mpn_new_forumtopic_notify.';',
    '$mpn_new_guestbook_notify = '.$mpn_new_guestbook_notify.';',
    ' ',
    '$mpn_version = "'._MPN_VERSION_.'";',
    '$mpn_install_date = '.$mpn_install_date.';',
    '?>');

    if ($fp = @fopen($mpn_config_file, 'wb')) {
        foreach ($mpn_config as $line) {
            fwrite($fp, "$line\n");
        }
    fclose($fp);
    echo "<br /><p class='mpn-title'>File <em>".$mpn_config_file."</em> was created.</p><br />";
    }

       ?>
   <center>
        <form action="<?php $PHP_SELF ?>" method="post">
            <table width="50%">
                <tr>
                    <td align=center>
                        <input type="hidden" name="dbhost" value="<?php echo $dbhost;?>">
                        <input type="hidden" name="dbuname" value="<?php echo $dbuname;?>">
                        <input type="hidden" name="dbpass" value="<?php echo $dbpass;?>">
                        <input type="hidden" name="dbname" value="<?php echo $dbname;?>">
                        <input type="hidden" name="prefix" value="<?php echo $prefix; ?>">
                        <input type="hidden" name="url" value="<?php echo $url;?>">
                        <input type="submit" name="op" value="Upgrade_fields">
                    </td>
                </tr>
            </table>
        </form>
    </center>
<?php
make_footer();
}

function set_configuration($url) {
    make_header();
    ?>
    <p class="mpn-title">The Credits</p><hr width="80%" /><p>These are the scripts and people that make myPHPNuke go.  Take some time and let these people know how much you appreciate their work.<br /><br />If you would like to be listed here, contact us about being a part of the developement team.  We are always looking for some help.</p><br /><br />

    <center>

        <form action="<?php $PHP_SELF ?>" method="post">

            <textarea name="license" cols=50 rows=8 readonly><?php include("./docs/CREDITS"); ?></textarea>

        </form>

        <p>You are now done with the myPHPNuke installation.  If you run into any problems, let us know.<br /><br /><em>Make sure that you delete this script (install.php).</em>  You will not need it again.</p><br /><br /><p class='mpn-title'>Your New Links</p><hr width="80%" /><a href="./">Your Main Page</a><br /><br /><a href="./admin.php">Your Administration Page</a><br /><br />

    </center>

    <br /><br />

    <?php
    make_footer();
}

function Upgrade_fields($dbhost, $dbuname, $dbpass, $dbname, $prefix) {
    global $HTTP_SERVER_VARS;
    make_header();
    mysql_connect($dbhost, $dbuname, $dbpass);
    @mysql_select_db("$dbname") or die ("<br /><br /><em>Unable to select database</em><br /><br />");
    	@set_time_limit(600);
//		OpenTable();
		echo '<h3>Convert gallery default template</h3>';
		$sql_gallery_template="UPDATE " . $prefix.'gallery_template_types' . " SET templatePictures='<table width=\"100%\">
		    <tr>
		        <td valign=\"top\" align=\"center\" width=\"30%\">
		            :NAMESIZE:
		            <br /><br />
		            <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
		            <tr>
		                <td valign=\"top\">
		                    :SUBMITTER:
		                    :DATE:
		                    :HITS:
		                    :RATE:
		                </td>
		            </tr>
		            </table><br />
		            :RATEBAR:
		        </td>
		        <td width=\"70%\" align=\"center\">
		            :IMG:
		        </td>
		    </tr>
		    <tr>
		        <td colspan=\"2\">:DESCRIP:</td>
		    </tr>
		    <tr>
		        <td colspan=\"2\">
		            :COMM:
		        </td>
		    </tr>
		</table>
		' WHERE id=2";
		$result=mysql_query($sql_gallery_template) or die(mysql_error());
		echo 'done!<br />';
//		CloseTable();
		echo "<br />";
//		OpenTable();
		echo '<h3>Convert pagebreaks in sections articles</h3>';
		$sql_pagebreak="update " . $prefix.'seccont' . " set content =  replace(content, '[pagebreak]', '<pagebreak />')";
		//echo "<br>$sql_pagebreak<br>";
		$result = mysql_query($sql_pagebreak) or die(mysql_error());
		echo 'done!<br />';
//		CloseTable();
		echo "<br />";
		
//		OpenTable();
		Echo '<h3>Execute various sql statements that update image filenames and pathnames and update table definitions</h3>';
		/*
		* Perform database updates 
		*/
		
		$sqlarray = array();
		// Update old image links to current links
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon16.gif' WHERE guest_image = 'icon16.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon20.gif' WHERE guest_image = 'icon20.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon21.gif' WHERE guest_image = 'icon21.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon22.gif' WHERE guest_image = 'icon22.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon23.gif' WHERE guest_image = 'icon23.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon29.gif' WHERE guest_image = 'icon29.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon3.gif' WHERE guest_image = 'icon3.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon30.gif' WHERE guest_image = 'icon30.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon31.gif' WHERE guest_image = 'icon31.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon32.gif' WHERE guest_image = 'icon32.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon33.gif' WHERE guest_image = 'icon33.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon34.gif' WHERE guest_image = 'icon34.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon35.gif' WHERE guest_image = 'icon35.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon36.gif' WHERE guest_image = 'icon36.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon37.gif' WHERE guest_image = 'icon37.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon38.gif' WHERE guest_image = 'icon38.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon39.gif' WHERE guest_image = 'icon39.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'guestbook' . " SET guest_image = 'extra/icon40.gif' WHERE guest_image = 'icon40.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon16.gif' WHERE image = 'icon16.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon20.gif' WHERE image = 'icon20.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon21.gif' WHERE image = 'icon21.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon22.gif' WHERE image = 'icon22.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon23.gif' WHERE image = 'icon23.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon29.gif' WHERE image = 'icon29.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon3.gif' WHERE image = 'icon3.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon30.gif' WHERE image = 'icon30.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon31.gif' WHERE image = 'icon31.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon32.gif' WHERE image = 'icon32.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon33.gif' WHERE image = 'icon33.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon34.gif' WHERE image = 'icon34.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon35.gif' WHERE image = 'icon35.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon36.gif' WHERE image = 'icon36.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon37.gif' WHERE image = 'icon37.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon38.gif' WHERE image = 'icon38.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon39.gif' WHERE image = 'icon39.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'posts' . " SET image = 'extra/icon40.gif' WHERE image = 'icon40.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon16.gif' WHERE msg_image = 'icon16.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon20.gif' WHERE msg_image = 'icon20.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon21.gif' WHERE msg_image = 'icon21.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon22.gif' WHERE msg_image = 'icon22.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon23.gif' WHERE msg_image = 'icon23.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon29.gif' WHERE msg_image = 'icon29.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon3.gif' WHERE msg_image = 'icon3.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon30.gif' WHERE msg_image = 'icon30.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon31.gif' WHERE msg_image = 'icon31.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon32.gif' WHERE msg_image = 'icon32.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon33.gif' WHERE msg_image = 'icon33.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon34.gif' WHERE msg_image = 'icon34.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon35.gif' WHERE msg_image = 'icon35.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon36.gif' WHERE msg_image = 'icon36.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon37.gif' WHERE msg_image = 'icon37.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon38.gif' WHERE msg_image = 'icon38.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon39.gif' WHERE msg_image = 'icon39.gif' ";
		$sqlarray[]= "UPDATE " . $prefix.'priv_msgs' . " SET msg_image = 'extra/icon40.gif' WHERE msg_image = 'icon40.gif' ";
		
		// Stats improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_datecnt' . " CHANGE date date VARCHAR( 8 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_hourcnt' . " CHANGE hour hour TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_monthcnt' . " CHANGE month month TINYINT( 2 ) UNSIGNED DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_weekcnt' . " CHANGE weekday weekday TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL";
		
		// Access improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'access' . " CHANGE access_id access_id TINYINT( 2 ) NOT NULL AUTO_INCREMENT";
		
		// Article improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'autonews' . " CHANGE informant informant VARCHAR( 25 ) NOT NULL";
		
		// Banner improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'banner' . " CHANGE imageurl imageurl VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'banner' . " CHANGE clickurl clickurl VARCHAR( 255 ) NOT NULL";
		
		// Blocks improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " CHANGE side side TINYINT( 1 ) DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " CHANGE admin admin TINYINT( 1 ) DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " CHANGE position position TINYINT( 1 ) DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " CHANGE visible visible TINYINT( 1 ) DEFAULT '0' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " CHANGE category category TINYINT( 2 ) DEFAULT '0' NOT NULL";
		
		// Chatbox improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'chatboxII' . " CHANGE username username VARCHAR( 25 ) DEFAULT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'chatboxII' . " CHANGE message message VARCHAR( 75 ) DEFAULT NULL";
		
		// Comments improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'comments' . " CHANGE url url VARCHAR( 255 ) DEFAULT NULL";
		
		// Downloads improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_downloads' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_downloads' . " CHANGE version version VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_downloads' . " CHANGE submitter submitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_downloads' . " CHANGE homepage homepage VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_editorials' . " CHANGE adminid adminid VARCHAR( 30 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_modrequest' . " CHANGE modifysubmitter modifysubmitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_modrequest' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_modrequest' . " CHANGE version version VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_modrequest' . " CHANGE homepage homepage VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_newdownload' . " CHANGE submitter submitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_newdownload' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_newdownload' . " CHANGE version version VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_newdownload' . " CHANGE homepage homepage VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_votedata' . " CHANGE ratinguser ratinguser VARCHAR( 25 ) NOT NULL";
		
		// Forum improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'forums' . " CHANGE forum_access forum_access TINYINT( 1 ) DEFAULT '1'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forums' . " CHANGE forum_type forum_type TINYINT( 1 ) DEFAULT '0'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forumtopics' . " CHANGE topic_status topic_status TINYINT( 1 ) DEFAULT '0' NOT NULL";
		
		// Gallery improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_media_types' . " CHANGE filetype filetype VARCHAR( 10 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_pictures' . " CHANGE submitter submitter VARCHAR( 25 ) DEFAULT 'Webmaster' NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_pictures_newpicture' . " CHANGE submitter submitter VARCHAR( 25 ) DEFAULT 'Webmaster' NOT NULL";
		
		// Headlines improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'headlines' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'headlines' . " CHANGE headlinesurl headlinesurl VARCHAR( 255 ) NOT NULL";
		
		// Links improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'links_editorials' . " CHANGE adminid adminid VARCHAR( 30 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_links' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_links' . " CHANGE submitter submitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_modrequest' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_modrequest' . " CHANGE modifysubmitter modifysubmitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_newlink' . " CHANGE submitter submitter VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_newlink' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_votedata' . " CHANGE ratinguser ratinguser VARCHAR( 25 ) NOT NULL";
		
		// Poll improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'pollcomments' . " CHANGE url url VARCHAR( 255 ) DEFAULT NULL";
		
		// Random Banners improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'rand_banners' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'rand_banners' . " CHANGE description description VARCHAR( 255 ) DEFAULT NULL";
		
		// Referres improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'referer' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		
		// Related improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'related' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		
		// Reviews improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews' . " CHANGE reviewer reviewer VARCHAR( 25 ) DEFAULT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews_add' . " CHANGE reviewer reviewer VARCHAR( 25 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews_add' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		
		// Stories improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'stories' . " CHANGE informant informant VARCHAR( 25 ) NOT NULL";
		
		// Topics improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'topics' . " CHANGE topicimage topicimage VARCHAR( 255 ) DEFAULT NULL";
		
		// Users improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'users' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'users' . " CHANGE user_intrest user_intrest VARCHAR( 255 ) DEFAULT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'users' . " CHANGE uid uid INT( 11 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'users_status' . " CHANGE uid uid INT( 11 ) NOT NULL";
		
		// MyYP improvements
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_business' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_business' . " CHANGE logourl logourl VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_business' . " CHANGE summary summary VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_categories' . " CHANGE imgurl imgurl VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_modrequest' . " CHANGE url url VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_modrequest' . " CHANGE summary summary VARCHAR( 255 ) NOT NULL";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_modrequest' . " CHANGE logourl logourl VARCHAR( 255 ) NOT NULL";
		
/*
* We are dealing with a number of tables that are no longer part of myPHPNuke. Those tables don't belong to the tables array and as such
* they can't be created by the standard mpnTables array.
* We need to prefix them manually with the $tableprefix that lives in dbconf.php
*/
		// Delete unused tables
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'everyonenet_settings' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'flags' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'calendar' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_country' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_daynum' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_monnum' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_industry' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_occ' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'combo_yearnum' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'pager' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'chatbox' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'gallcats' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'gallery' . ";";
		$sqlarray[]="DROP TABLE IF EXISTS "  . $prefix . 'gallcomments' . ";";
		
		//Add table descriptions
		
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_datecnt' . " COMMENT = 'Statistics module: count per date'";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_hourcnt' . " COMMENT = 'Statistics module: count per hour'";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_monthcnt' . " COMMENT = 'Statistics module: count per month'";
		$sqlarray[]="ALTER TABLE " . $prefix.'4nstats_weekcnt' . " COMMENT = 'Statistics module: count per week'";
		$sqlarray[]="ALTER TABLE " . $prefix.'access' . " COMMENT = 'Forum module: access titles'";
		$sqlarray[]="ALTER TABLE " . $prefix.'authors' . " COMMENT = 'Core system: admins and authors'";
		$sqlarray[]="ALTER TABLE " . $prefix.'autonews' . " COMMENT = 'Core system: automated news items'";
		$sqlarray[]="ALTER TABLE " . $prefix.'banner' . " COMMENT = 'Banner module: banner details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'bannerclient' . " COMMENT = 'Banner module: customer details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'bannerfinish' . " COMMENT = 'Banner module: finished banners'";
		$sqlarray[]="ALTER TABLE " . $prefix.'blocks' . " COMMENT = 'Core system: side blocks definitions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'categories' . " COMMENT = 'Core system: news categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'chatboxII' . " COMMENT = 'Chat module: chat texts'";
		$sqlarray[]="ALTER TABLE " . $prefix.'click' . " COMMENT = 'Banners module: number of clicks per URL'";
		$sqlarray[]="ALTER TABLE " . $prefix.'comments' . " COMMENT = 'News module: comments on news items'";
		$sqlarray[]="ALTER TABLE " . $prefix.'contactbook' . " COMMENT = 'Webmail module: addressbook'";
		$sqlarray[]="ALTER TABLE " . $prefix.'counter' . " COMMENT = 'Statistics module: count pageviews per browser type'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_categories' . " COMMENT = 'Downloads module: categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_downloads' . " COMMENT = 'Downloads module: download details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_editorials' . " COMMENT = 'Downloads module: editorial details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_modrequest' . " COMMENT = 'Downloads module: modifcation requests'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_newdownload' . " COMMENT = 'Downloads module: new submitted, not yet approved downloads'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_subcategories' . " COMMENT = 'Downloads module: subcategories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'downloads_votedata' . " COMMENT = 'Downloads module: voting details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'ephem' . " COMMENT = 'Ephemerids module: ephemerids details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'eventcal' . " COMMENT = 'Event calendar module: calendar details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'faqanswer' . " COMMENT = 'FAQ module: questions and answers'";
		$sqlarray[]="ALTER TABLE " . $prefix.'faqcategories' . " COMMENT = 'FAQ module: categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forumconfig' . " COMMENT = 'Forum module: configuration details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forummods' . " COMMENT = 'Forum module: moderators per forum'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forums' . " COMMENT = 'Forum module: forum descriptions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'forumtopics' . " COMMENT = 'Forum module: topics (new threads)'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_categories' . " COMMENT = 'Gallery module: categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_comments' . " COMMENT = 'Gallery module: comments'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_media_class' . " COMMENT = 'Gallery module: media class definitions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_media_types' . " COMMENT = 'Gallery module: media types'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_pictures' . " COMMENT = 'Gallery module: media details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_pictures_newpicture' . " COMMENT = 'Gallery module: new submitted media, to be approved'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_rate_check' . " COMMENT = 'Gallery module: store details about a rate submitter'";
		$sqlarray[]="ALTER TABLE " . $prefix.'gallery_template_types' . " COMMENT = 'Gallery module: template types'";
		$sqlarray[]="ALTER TABLE " . $prefix.'guestbook' . " COMMENT = 'Guestbook module: submitted details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'headlines' . " COMMENT = 'News module: headline definitions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'image_dirs' . " COMMENT = 'Core system: pathnames for image directories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'lastseen' . " COMMENT = 'Core system: details about recent online users'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_categories' . " COMMENT = 'Links module: categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_editorials' . " COMMENT = 'Links module: editorial details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_links' . " COMMENT = 'Links module: link details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_modrequest' . " COMMENT = 'Links module: modification requests'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_newlink' . " COMMENT = 'Links module: new submitted links, need to be approved'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_subcategories' . " COMMENT = 'Links module: subcategories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'links_votedata' . " COMMENT = 'Links module: rating details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'mymsg2' . " COMMENT = 'mymsg2 module: message details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'poll_data' . " COMMENT = 'Polls module: voting details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'poll_desc' . " COMMENT = 'Polls module: poll descriptions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'pollcomments' . " COMMENT = 'Polls module: submitted comments'";
		$sqlarray[]="ALTER TABLE " . $prefix.'popsettings' . " COMMENT = 'Webmail module: POPbox settings'";
		$sqlarray[]="ALTER TABLE " . $prefix.'posts' . " COMMENT = 'Forum module: posts details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'priv_msgs' . " COMMENT = 'Forum module: private messages details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'queue' . " COMMENT = 'News module: new submitted news items, to be approved'";
		$sqlarray[]="ALTER TABLE " . $prefix.'quotes' . " COMMENT = 'Core systems: random quotes block details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'rand_banners' . " COMMENT = 'Core system: random banners block details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'ranks' . " COMMENT = 'Forums module: user ranks'";
		$sqlarray[]="ALTER TABLE " . $prefix.'referer' . " COMMENT = 'Core system: referer details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'related' . " COMMENT = 'News module: links about related info'";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews' . " COMMENT = 'Reviews module: details per review'";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews_add' . " COMMENT = 'Reviews module: new submitted reviews'";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews_comments' . " COMMENT = 'Reviews module: user comments per review'";
		$sqlarray[]="ALTER TABLE " . $prefix.'reviews_main' . " COMMENT = 'Reviews module: reviews page title and description'";
		$sqlarray[]="ALTER TABLE " . $prefix.'seccont' . " COMMENT = 'Sections module: article contents'";
		$sqlarray[]="ALTER TABLE " . $prefix.'sections' . " COMMENT = 'Sections module: sections descriptions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'session' . " COMMENT = 'Core system: active sessions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'smiles' . " COMMENT = 'Forums module: smile definitions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'stories' . " COMMENT = 'News module: details news article'";
		$sqlarray[]="ALTER TABLE " . $prefix.'stories_cat' . " COMMENT = 'News module: category definitions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'topics' . " COMMENT = 'News module: topic descriptions'";
		$sqlarray[]="ALTER TABLE " . $prefix.'updatelog' . " COMMENT = 'Core system: system update log'";
		$sqlarray[]="ALTER TABLE " . $prefix.'users' . " COMMENT = 'Core system: users'";
		$sqlarray[]="ALTER TABLE " . $prefix.'users_status' . " COMMENT = 'Core system: status info per user'";
		$sqlarray[]="ALTER TABLE " . $prefix.'visits_control' . " COMMENT = 'Core system: switch stats generation on-off'";
		$sqlarray[]="ALTER TABLE " . $prefix.'visits_counter' . " COMMENT = 'Core system: visits counter'";
		$sqlarray[]="ALTER TABLE " . $prefix.'visits_system' . " COMMENT = 'Core system: visits per ip address'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_brokenlink' . " COMMENT = 'Yellow pages module: reported broken links'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_business' . " COMMENT = 'Yellow pages module: business link details'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_businesstxt' . " COMMENT = 'Yellow pages module: extended text per business link'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_categories' . " COMMENT = 'Yellow pages module: categories'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_modrequest' . " COMMENT = 'Yellow pages module: submitted modification requests'";
		$sqlarray[]="ALTER TABLE " . $prefix.'yp_votedata' . " COMMENT = 'Yellow pages module: rating details'";
		
		echo "<table border='1' cellspacing='1' cellpadding='1'>";
		echo "<tr><th>Query #</th><th>SQL Statement</th><th>result</tr></tr>\n";
		foreach ($sqlarray as $key => $query)
		{
			echo "<tr>";
			echo "<td>$key</td><td>$query</td>";
			mysql_query($query) or die(mysql_error());
			echo "<td>done</td></tr>\n";
		}
		echo "</table>";
		echo "<br />";
?>
   <center>
        <form action="<?php $PHP_SELF ?>" method="post">
            <table width="50%">
                <tr>
                    <td align=center>
                        <input type="hidden" name="url" value="<?php echo $url;?>">
                        <input type="submit" name="op" value="Finish">
                    </td>
                </tr>
            </table>
        </form>
    </center>
<?php    
    make_footer();
}

if ( ! isset( $op ) ) { $op = NULL; }

switch($op)
{
    case "Next":
    get_dbinfo();
    break;

    case "Submit":
    confirm_db($dbhost, $dbuname, $dbpass, $dbname, $prefix);
    break;

    case "Upgrade":
    do_upgrade ($dbhost, $dbuname, $dbpass, $dbname, $prefix);
    break;

    case "Make_Tables":
    make_db($dbhost, $dbuname, $dbpass, $dbname, $prefix, $dbmake);
    break;

    case "Continue":
    set_sqlprefs($dbhost, $dbuname, $dbpass, $dbname, $prefix);
    break;

    case "Set_Login":
    input_data($dbhost, $dbuname, $dbpass, $dbname, $prefix, $aid, $name, $pwd, $email, $url);
    break;
    
    case "Upgrade_fields":
    Upgrade_fields($dbhost, $dbuname, $dbpass, $dbname, $prefix);
    break;

    case "Finish":
    set_configuration($url);
    break;

    default:
    show_license();
    break;
}

?>
