<?php

include ("../inc/inc_connect.php");

if (!isset($name))
{
    print "<font face=\"arial\" size=2><b>Make sure you have made any changes you want to make to the file inc_connect.php before running this page!</b><br><br>
    <form method=\"post\" action=\"setup.php\">
    <table border=0 cellpadding=3 cellspacing=0 style=\"font-family: arial; font-size: 10pt\"><tr>

    <td align=\"center\">Your Username: </td><td align=\"center\">
    <input type=\"text\" name=\"name\"></td></tr>
    <tr><td align=\"center\">Your Password: </td><td align=\"center\"><input type=\"text\" name=\"password\"></td></tr>
    <tr><td align=\"center\">Your Email: </td><td align=\"center\"><input type=\"text\" name=\"email\"></td></tr>
    <tr><td align=\"center\">URL of Grimforum: <br>(ie. http://www.hsmx.com/forum)</td><td align=\"center\"><input type=\"text\" name=\"url\"></td></tr></table>
    <bR><br><input type=\"submit\" value=\"Setup!\"></form>";

    exit;
}


$query = "DROP TABLE $admintable, $buddytable, $calendartable, $emailtable, $forumtable, $grouptable, $passwordtable, $pmtable, $ratedtable, $searchtable, $statstable, $sweartable, $topicsreadtable, $userstable, $votetable, $votedtable, $gallerycommentstable, $spelltable, $wordtable";

mysql_query( $query, $link );



$query = "CREATE TABLE $admintable (
  strFont text NOT NULL,
  strBGColor text NOT NULL,
  strFGColor text NOT NULL,
  strAFGColor text NOT NULL,
  strFontSize text NOT NULL,
  strFontPoint text NOT NULL,
  strFontColor text NOT NULL,
  strRateColor text NOT NULL,
  strSwearColor text NOT NULL,
  strFLink text NOT NULL,
  strALink text NOT NULL,
  strVLink text NOT NULL,
  strBorderColor text NOT NULL,
  strTitle text NOT NULL,
  strPostWidth text NOT NULL,
  strSigSeperator text NOT NULL,
  strStars1 text NOT NULL,
  strStars2 text NOT NULL,
  strStars3 text NOT NULL,
  strStars4 text NOT NULL,
  strStars5 text NOT NULL,
  strShowPosts text NOT NULL,
  strShowPostId text NOT NULL,
  strShowModLevel text NOT NULL,
  strShowStars text NOT NULL,
  strShowAvatars text NOT NULL,
  strShowLocation text NOT NULL,
  strShowSeconds text NOT NULL,
  strShow24Hour text NOT NULL,
  strTimeOffset text NOT NULL,
  strShowPmIcon text NOT NULL,
  strShowWwwIcon text NOT NULL,
  strShowProfile1 text NOT NULL,
  strShowProfile2 text NOT NULL,
  strShowProfile3 text NOT NULL,
  strShowProfile4 text NOT NULL,
  strShowEditInfo text NOT NULL,
  strEditInfoColour text NOT NULL,
  strTeleporter text NOT NULL,
  strBoxedQuotes text NOT NULL,
  strQuoteBackColor text NOT NULL,
  strQuoteFontColor text NOT NULL,
  strAdLevel1 text NOT NULL,
  strAdLevel2 text NOT NULL,
  strAdLevel3 text NOT NULL,
  strAdLevel4 text NOT NULL,
  strAdLevel5 text NOT NULL,
  strAdLevel6 text NOT NULL,
  strAdLevel7 text NOT NULL,
  strShowQuotes text NOT NULL,
  strLinkRandomQuotes text NOT NULL,
  strTimerMorning text NOT NULL,
  strTimerAfternoon text NOT NULL,
  strTimerEvening text NOT NULL,
  strAllowGalleryUpload text NOT NULL,
  strGalleryRate text NOT NULL,
  strMaxImageWidth text NOT NULL,
  strUseMainForThumb text NOT NULL,
  strThumbsPerRow text NOT NULL,
  strAllowGalleryCommentFormatting text NOT NULL,
  strGalleryComments text NOT NULL,
  strSoftEdit text NOT NULL,
  strSoftDelete text NOT NULL,
  strShowLogin text NOT NULL,
  strShowTime text NOT NULL,
  strShowDate text NOT NULL,
  strShowLastPostTime text NOT NULL,
  strShowModerators text NOT NULL,
  strShowSecondIcon text NOT NULL,
  strKeyboardNavigation text NOT NULL,
  strStatisticTracking text NOT NULL,
  strAdminNewPage text NOT NULL,
  strErrorReport text NOT NULL,
  strUseOb text NOT NULL,
  strFixMagicQuotes text NOT NULL,
  strMetaDescription text NOT NULL,
  strMetaKeyWords text NOT NULL,
  strStoreProfileEmail text NOT NULL,
  strEmailFrom text NOT NULL,
  strPostIt text NOT NULL,
  strUseCalendar text NOT NULL,
  strBackImage text NOT NULL,
  strSpellCheck text NOT NULL,
  strTopicsPerPage TEXT NOT NULL,
  strPostsPerPage TEXT NOT NULL,
  strMembersPerPage TEXT NOT NULL,
  strPostsForHotTopic TEXT NOT NULL,
  strAllowAvatarUpload TEXT NOT NULL
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 1 : ".mysql_error() );


$query = "CREATE TABLE $buddytable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strBuddyName text NOT NULL,
  strDateAdded text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 2 : ".mysql_error() );

$query = "CREATE TABLE $calendartable( intId int( 11 ) NOT NULL auto_increment, intDay int( 11 ) NOT NULL default '0', intMonth int( 11 ) NOT NULL default '0', intYear int( 11 ) NOT NULL default '0', strName text NOT NULL , intTime time NOT NULL default '00:00:00', strAuthor text NOT NULL , strTitle text NOT NULL , memMessage longtext NOT NULL , ynMainRow text NOT NULL , intEventId int( 11 ) NOT NULL default '0', intTopicId int( 11 ) NOT NULL default '0', ynSport text NOT NULL , strLeague text NOT NULL , strHomeTeam text NOT NULL , strAwayTeam text NOT NULL , intHomeScore int( 11 ) NOT NULL default '0', intAwayScore int( 11 ) NOT NULL default '0', memReview longtext NOT NULL , strReviewer text NOT NULL , strResult text NOT NULL , KEY intId( intId ) ) TYPE = MYISAM";

mysql_query( $query, $link ) or die ( "Error! 3 : ".mysql_error() );



$query = "CREATE TABLE $emailtable (
  intId int( 11 ) NOT NULL auto_increment,
  strFrom text NOT NULL,
  strTo text NOT NULL,
  strSubject text NOT NULL,
  memMessage longtext NOT NULL,
  strDate text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 3 : ".mysql_error() );


$query = "CREATE TABLE $forumtable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strTopicName text NOT NULL,
  memPost longtext NOT NULL,
  strGalleryThumb text NOT NULL,
  strGalleryImage text NOT NULL,
  strForumComment text NOT NULL,
  ynTopicRow text NOT NULL,
  ynGalleryRow text NOT NULL,
  strDate text NOT NULL,
  intTopicId int( 11 ) NOT NULL default '0',
  intPostId int( 11 ) NOT NULL default '0',
  strTime time NOT NULL default '00:00:00',
  strAvatar text NOT NULL,
  memSig longtext NOT NULL,
  strEmail text NOT NULL,
  intPosts int( 11 ) NOT NULL default '0',
  strHomepage text NOT NULL,
  strIp text NOT NULL,
  ynShowEmail text NOT NULL,
  strIcqNumber text NOT NULL,
  strMsnName text NOT NULL,
  strYahooId text NOT NULL,
  strLocation text NOT NULL,
  intLastPost int( 11 ) NOT NULL default '0',
  intReplies int( 11 ) NOT NULL default '0',
  intViews int( 11 ) NOT NULL default '0',
  strSmilieUrl text NOT NULL,
  strLastPostName text NOT NULL,
  strLastPostTime time NOT NULL default '00:00:00',
  strLastPostDate text NOT NULL,
  strEpochTime int( 11 ) NOT NULL default '0',
  ynLocked text NOT NULL,
  strLockedBy text NOT NULL,
  ynPriority int( 11 ) NOT NULL default '0',
  intForumId int( 11 ) NOT NULL default '0',
  intForumGroup int( 11 ) NOT NULL default '0',
  intVoteId int( 11 ) NOT NULL default '0',
  strEdit text NOT NULL,
  intHbhForum int( 11 ) NOT NULL default '0',
  intOpenForum int( 11 ) NOT NULL default '0',
  intPostHidden int( 11 ) NOT NULL default '0',
  strHider text NOT NULL,
  intEdited int( 11 ) NOT NULL default '0',
  strEditor text NOT NULL,
  intNewId int( 11 ) NOT NULL default '0',
  intFromEdit int( 11 ) NOT NULL default '0',
  intEditId int( 11 ) NOT NULL default '0',
  strEditDate text NOT NULL,
  strEditTime time NOT NULL default '00:00:00',
  intRateTopic int( 11 ) NOT NULL default '0',
  intRating int( 11 ) NOT NULL default '0',
  strRateThis text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 4 : ".mysql_error() );


$query = "CREATE TABLE $grouptable (
  intId int( 11 ) NOT NULL auto_increment,
  intGroupId int( 11 ) NOT NULL default '0',
  intGroupOrder int( 11 ) NOT NULL default '0',
  strName text NOT NULL,
  strDateCreated text NOT NULL,
  ynGroupMaster int( 11 ) NOT NULL default '0',
  strGrimforumName text NOT NULL,
  strComments text NOT NULL,
  strPassword text NOT NULL,
  intAllowVote int( 11 ) NOT NULL default '0',
  intAllowRate int( 11 ) NOT NULL default '0',
  intHbhForum int( 11 ) NOT NULL default '0',
  intOpenForum int( 11 ) NOT NULL default '0',
  intGallery int( 11 ) NOT NULL default '0',
  intAllowCalendar int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 5 : ".mysql_error() );

$query = "CREATE TABLE $gallerycommentstable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  memComment longtext NOT NULL,
  strTime time NOT NULL default '00:00:00',
  strDate text NOT NULL,
  intTieTo int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 6 : ".mysql_error() );



$query = "CREATE TABLE $passwordtable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strPassword text NOT NULL,
  intTopicId int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 6 : ".mysql_error() );


$query = "CREATE TABLE $pmtable (
  intId int( 11 ) NOT NULL auto_increment,
  strFrom text NOT NULL,
  strTo text NOT NULL,
  strSubject text NOT NULL,
  memMessage longtext NOT NULL,
  intRead int( 11 ) NOT NULL default '0',
  intNotified int( 11 ) NOT NULL default '0',
  intReplied int( 11 ) NOT NULL default '0',
  strDateRecieved text NOT NULL,
  strDateRead text NOT NULL,
  strDateReplied text NOT NULL,
  strTimeRecieved time NOT NULL default '00:00:00',
  strTimeRead time NOT NULL default '00:00:00',
  strTimeReplied time NOT NULL default '00:00:00',
  strEpochTime int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! : 7 ".mysql_error() );


$query = "CREATE TABLE $ratedtable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  intRateId int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 8 : ".mysql_error() );


$query = "CREATE TABLE $searchtable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strSearch text NOT NULL,
  strWhat text NOT NULL,
  intSuccess int( 11 ) NOT NULL default '0',
  strTime text NOT NULL,
  strDate text NOT NULL,
  what text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 9 : ".mysql_error() );

$query = "CREATE TABLE $spelltable (
  strName text NOT NULL,
  memPost longtext NOT NULL,
  memOrigPost longtext NOT NULL,
  intTopicId int( 11 ) NOT NULL default '0'
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 9 : ".mysql_error() );




$query = "CREATE TABLE $statstable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strIp text NOT NULL,
  strBrowser text NOT NULL,
  strRefer text NOT NULL,
  strPage text NOT NULL,
  strPageLink text NOT NULL,
  strTime time NOT NULL default '00:00:00',
  strDate text NOT NULL,
  intEpochTime int(15) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 10 : ".mysql_error() );


$query = "CREATE TABLE $sweartable (
  intId int( 11 ) NOT NULL auto_increment,
  strSwear text NOT NULL,
  strReplace1 text NOT NULL,
  strReplace2 text NOT NULL,
  strReplace3 text NOT NULL,
  strReplace4 text NOT NULL,
  strReplace5 text NOT NULL,
  intReplace int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 11 : ".mysql_error() );


$query = "CREATE TABLE $topicsreadtable (
  IntId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  intTopicId int( 11 ) NOT NULL default '0',
  datLastTime int( 11 ) NOT NULL default '0',
  PRIMARY KEY (IntId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 12 : ".mysql_error() );


$query = "CREATE TABLE $userstable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  strPassword text NOT NULL,
  strEmail text NOT NULL,
  intAdminLevel int( 11 ) NOT NULL default '0',
  strForumsModerated text NOT NULL,
  strAvatar text NOT NULL,
  memSig longtext NOT NULL,
  strPhoto text NOT NULL,
  strConnection text NOT NULL,
  strForumComment text NOT NULL,
  intPosts int( 11 ) NOT NULL default '0',
  intTopics int( 11 ) NOT NULL default '0',
  strHomepage text NOT NULL,
  strIp text NOT NULL,
  strUrl text NOT NULL,
  strForename text NOT NULL,
  strSurname text NOT NULL,
  ynShowOnline text NOT NULL,
  ynShowEmail text NOT NULL,
  strIcqNumber text NOT NULL,
  strMsnName text NOT NULL,
  strYahooId text NOT NULL,
  memBiography text NOT NULL,
  strLocation text NOT NULL,
  strOccupation text NOT NULL,
  strHardware text NOT NULL,
  strProfile1 text NOT NULL,
  strProfile1Answer text NOT NULL,
  strProfile2 text NOT NULL,
  strProfile2Answer text NOT NULL,
  strProfile3 text NOT NULL,
  strProfile3Answer text NOT NULL,
  strProfile4 text NOT NULL,
  strProfile4Answer text NOT NULL,
  strTimeOffset text NOT NULL,
  intBirthDay int( 11 ) NOT NULL default '0',
  intBirthMonth int( 11 ) NOT NULL default '0',
  datRegistrationDate text NOT NULL,
  intEpochRegistration int( 11 ) NOT NULL default '0',
  ynBanIp text NOT NULL,
  strLastPostTitle text NOT NULL,
  strLastPostDate text NOT NULL,
  strLastPostGroupId text NOT NULL,
  strLastPostTopicId text NOT NULL,
  strLastPostId text NOT NULL,
  strLastOnline text NOT NULL,
  intThreadsReported int( 11 ) NOT NULL default '0',
  strLastSeen text NOT NULL,
  strLastSeenUrl text NOT NULL,
  intKeyNav int( 11 ) NOT NULL default '0',
  intShowTime int( 11 ) NOT NULL default '0',
  intTimePlus int( 11 ) NOT NULL default '0',
  intLanguageFile int( 11 ) NOT NULL default '0',
  memPostIt longtext NOT NULL,
  here longtext NOT NULL,
  strSubscribedForums text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 13 : ".mysql_error() );


$query = "CREATE TABLE $votetable (
  intId int( 11 ) NOT NULL auto_increment,
  intTieToTopic int( 11 ) NOT NULL default '0',
  strStarter text NOT NULL,
  intTotalVotes int( 11 ) NOT NULL default '0',
  strTitle text NOT NULL,
  memInfo longtext NOT NULL,
  strOption1 text NOT NULL,
  strOption2 text NOT NULL,
  strOption3 text NOT NULL,
  strOption4 text NOT NULL,
  strOption5 text NOT NULL,
  strOption6 text NOT NULL,
  strOption7 text NOT NULL,
  strOption8 text NOT NULL,
  strOption9 text NOT NULL,
  strOption10 text NOT NULL,
  intVotes1 int( 11 ) NOT NULL default '0',
  intVotes2 int( 11 ) NOT NULL default '0',
  intVotes3 int( 11 ) NOT NULL default '0',
  intVotes4 int( 11 ) NOT NULL default '0',
  intVotes5 int( 11 ) NOT NULL default '0',
  intVotes6 int( 11 ) NOT NULL default '0',
  intVotes7 int( 11 ) NOT NULL default '0',
  intVotes8 int( 11 ) NOT NULL default '0',
  intVotes9 int( 11 ) NOT NULL default '0',
  intVotes10 int( 11 ) NOT NULL default '0',
  intVotes11 int( 11 ) NOT NULL default '0',
  strVoteFor1 longtext NOT NULL,
  strVoteFor2 longtext NOT NULL,
  strVoteFor3 longtext NOT NULL,
  strVoteFor4 longtext NOT NULL,
  strVoteFor5 longtext NOT NULL,
  strVoteFor6 longtext NOT NULL,
  strVoteFor7 longtext NOT NULL,
  strVoteFor8 longtext NOT NULL,
  strVoteFor9 longtext NOT NULL,
  strVoteFor10 longtext NOT NULL,
  strVoteFor11 longtext NOT NULL,
  intLocked int( 11 ) NOT NULL default '0',
  strLocker text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 14 : ".mysql_error() );

//mail("gfinfo@hsmx.com", "GrimForum In Use!", "GF5 is being used by $name at $url.");

$query = "CREATE TABLE $votedtable (
  intId int( 11 ) NOT NULL auto_increment,
  strName text NOT NULL,
  intVoteId int( 11 ) NOT NULL default '0',
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 15 : ".mysql_error() );


$query = "CREATE TABLE $wordtable (
  intId int( 11 ) NOT NULL auto_increment,
  strWord text NOT NULL,
  KEY intId(intId)
) TYPE=MyISAM";

mysql_query( $query, $link ) or die ( "Error! 15 : ".mysql_error() );

print "Tables set!<br><br>";


//$query = "INSERT INTO $admintable VALUES ('Arial', '#EFF3F7', '#BCCDDE', '#DCEDFE', '2', '10', 'BLACK', 'RED', 'RED', '#111111', '#111111', '#111111', '#111111', '1', '90%', '------------------------------------', '50', '100', '250', '500', '1000', '', '', '1', '1', '1', '1', '', '', '0', '1', '1', '', '', '', '1', '1', 'GREEN', '1', '', '#8080FF', 'WHITE', 'Moderator', 'High Moderator', 'Master Moderator', 'Administrator', 'High Administrator', 'Master Administrator', 'Forum Owner', '1', '', 'Morning', 'Noon', 'Night', '1', '1', '975', '1', '5', '', '1', '1', '', '1', '1', '1', '1', '1', '1', '1', '1', '1', '2', '', '', '', '', '1', 'grimforum@yourdomain.com', '1', '1', '', '', '50', '0', '100', '1')";
//mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

$query = "INSERT INTO $admintable ( strFont, strBGColor, strFGColor, strAFGColor, strFontSize, strFontPoint, strFontColor, strUseOb) values( 'Arial', '#EFF3F7', '#BCCDE', '#DCEDFE', '2', '10', 'BLACK', '1')";
mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );


$query = "INSERT INTO $userstable ( strName, strPassword, strEmail, intAdminLevel) values( '$name', '$password', '$email', '8' )";
mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

print "Data added!<bR><br>";


print "<a href=\"setup_old_users.php\">Click here to move GF4 user details to GF5</a> (Note - GrimForum4.1 must have tables in the same database as GF5!)<br><br>";

print "<a href=\"words.php\">Click here to add spell-checking words to your database</a><br><br>";

print "<a href=\"../login.php\">Login now!</a> (Note - Don't forget to delete these setup pages!)";

















