<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* 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: 188_8_Update.php,v 1.2.2.2 2004/04/18 12:47:20 ajvwaay Exp $


// To Use This Update Script,
// You Will Need To TEMPORARILY Move It To Your Install Root.

// FORUMS

@mysql_query('ALTER TABLE ' . $mpnTables["forums"] . ' DROP INDEX idxforumsforumidcatidforummoderator');
@mysql_query('ALTER TABLE ' . $mpnTables["forums"] . ' DROP INDEX idxforumsforumidcatid');
@mysql_query('ALTER TABLE ' . $mpnTables["forums"] . ' DROP INDEX idxforumsforumidforummoderator');

@mysql_query('ALTER TABLE ' . $mpnTables["forums"] . ' ADD INDEX idxforums (forum_id,cat_id,forum_type,forum_access)' );

// FORUMTOPICS

@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' DROP INDEX idxforumtopicsforumid');
@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' DROP INDEX idxforumtopicstopicidtopicposter');
@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' DROP INDEX idxforumtopicstopictimedescforumidtopicposter');

@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' ADD INDEX forum_id (forum_id)' );
@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' ADD INDEX idxtopics (topic_id,topic_views,topic_poster)' );
@mysql_query('ALTER TABLE ' . $mpnTables["forumtopics"] . ' ADD INDEX idxtitletime (forum_id,topic_title,topic_time)' );



// POSTS

@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpostspostidposterid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpostspostimedesctopicid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpoststopicidposterid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpostspostidtopicid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpoststopicid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpostsposttimedescforumidposterid');
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' DROP INDEX idxpostsposttimedesctopicidposterid');

@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' ADD INDEX forum_id (forum_id)' );
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' ADD INDEX topic_id (topic_id)' );
@mysql_query('ALTER TABLE ' . $mpnTables["posts"] . ' ADD INDEX idxtopics (topic_id,forum_id,post_id,poster_id,post_time)' );



// USERS

@mysql_query('ALTER TABLE ' . $mpnTables["users"] . ' ADD theme_layout tinyint(1) NOT NULL AFTER emailpass, ADD theme_format tinyint(1) NOT NULL AFTER theme_layout');

// Convert User Registration Date To Sortable Format

$result = mysql_query( "SELECT uid, user_regdate FROM " . $mpnTables['users'] . "" );

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

    @mysql_query( "UPDATE " . $mpnTables['users'] . " SET user_regdate='$newdate' WHERE uid='$uid'" );
}

@mysql_query( 'ALTER TABLE ' . $mpnTables["users"] . ' CHANGE user_regdate user_regdate DATE NOT NULL' );

@mysql_query( 'ALTER TABLE ' . $mpnTables["users"] . ' ADD INDEX FULLTEXT KEY unamefrominterests (uname,user_from,user_intrest,bio)' );


echo "Done Updating\n";

?>
