Exemple #1
0
function ShowStep2()
{
    require "Config/Main.php";
    $_SESSION['SiteFolder'] = $MainSiteFolder;
    require "System/MuDatabase.class.php";
    $db = new MuDatabase(true);
    if (isset($_POST['submit'])) {
        if ($_POST['dbCreate'] == 1) {
            $drops = "\n\t\t\tUSE [MuOnline]\n\t\t\tIF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[PK_HEROI]'))\n\t\t\tDROP TRIGGER [dbo].[PK_HEROI]\n\t\t\tIF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[Z_PK_HERO]'))\n\t\t\tDROP TRIGGER [dbo].[Z_PK_HERO]\n\t\t\tIF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[XW_PK_HERO]'))\n\t\t\tDROP TRIGGER [dbo].[XW_PK_HERO]\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_BlockedUsers]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_BlockedUsers;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_CastleSiegeWins]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_CastleSiegeWins;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_ChangeKeyLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_ChangeKeyLog;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_ChangePassLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_ChangePassLog;  \n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Credits]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Credits;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_CreditShopItens]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_CreditShopItens;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_CreditShopLogs]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_CreditShopLogs;\n\t\t\tIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_CreditShopPacks]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_CreditShopPacks;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Currencies]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Currencies;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_DepositBanks]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_DepositBanks;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_DepositWayData]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_DepositWayData;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_DepositWays]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_DepositWays;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskAttach]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_HelpDeskAttach;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskBlock]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_HelpDeskBlock;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskButtons]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_HelpDeskButtons;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskMessages]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_HelpDeskMessages;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskTickets]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_HelpDeskTickets;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Income]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Income;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_LostPasswordLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_LostPasswordLog;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_MailListMessages]') AND type in (N'U'))\n\t\t\tDROP TABLE [dbo].[Z_MailListMessages]\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_MailListSending]') AND type in (N'U'))\n\t\t\tDROP TABLE [dbo].[Z_MailListSending]\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_MailValidation]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_MailValidation;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Messages]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Messages;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_News]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_News;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Users]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Users;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Rename]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Rename;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Resellers]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Resellers;   \n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopCategories]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopCategories;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopDiscCodes]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopDiscCodes;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopItems]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopItems;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopLog;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopPackItems]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopPackItems;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebShopPacks]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebShopPacks;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebTradeDirectSale]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebTradeDirectSale;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebTradeDirectSaleItems]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebTradeDirectSaleItems;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_WebVault]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_WebVault;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_PollAnswers]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_PollAnswers;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Polls]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Polls;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_PollVotes]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_PollVotes;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_GuideDBCategories]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_GuideDBCategories;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Guides]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Guides;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_Events]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_Events;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_EventsSchedule]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_EventsSchedule;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_ResetTransferLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_ResetTransferLog;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_VipItemData]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_VipItemData;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_VipItemUsers]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_VipItemUsers;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_GameCurrencies]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_GameCurrencies;\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_ChangeClassLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_ChangeClassLog;\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_MasterResetLog]') AND type in (N'U'))\n\t\t\tDROP TABLE Z_MasterResetLog;\t\t\n\t\t\t\t\t\t\n\t\t\t";
            //Drop All Tables
            $db->Query($drops);
            $query[0] = "\n\t\t\tSET ANSI_NULLS ON\n\t\t\tSET QUOTED_IDENTIFIER ON\n\t\t\tIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DT_GenHash]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))\n\t\t\tBEGIN\n\t\t\texecute dbo.sp_executesql @statement = N'CREATE  FUNCTION [dbo].[DT_GenHash] (@data VARCHAR(10), @data2 VARCHAR(10)) \n\t\t\tRETURNS BINARY(16) AS\n\t\t\tBEGIN\n\t\t\tDECLARE @hash BINARY(16)\n\t\t\tEXEC master.dbo.XP_MD5_EncodeKeyVal @data2, @data, @hash OUT\n\t\t\tRETURN @hash\n\t\t\tEND' \n\t\t\tEND\n\t\t\t";
            //MD5 hash
            $query[1] = "\n\t\t\tALTER PROCEDURE [dbo].[WZ_CS_ModifyCastleOwnerInfo]\n\t\t\t@iMapSvrGroup  SMALLINT,\n\t\t\t@iCastleOccupied INT,\n\t\t\t@szOwnGuildName VARCHAR(8)\n\t\t\tAs\n\t\t\tBegin\n\t\t\tBEGIN TRANSACTION\n\t\t\tSET NOCOUNT ON\n\t\t\tIF EXISTS ( SELECT MAP_SVR_GROUP FROM MuCastle_DATA  WITH (READUNCOMMITTED) WHERE MAP_SVR_GROUP = @iMapSvrGroup)\n\t\t\tBEGIN\n\t\t\tUPDATE MuCastle_DATA \n\t\t\tSET CASTLE_OCCUPY = @iCastleOccupied, OWNER_GUILD = @szOwnGuildName\n\t\t\tWHERE MAP_SVR_GROUP = @iMapSvrGroup\n\t\t\t\n\t\t\tDECLARE @exist varchar(10)\n\t\t\tset @exist = 'NOT'\n\t\t\t\n\t\t\tSELECT @exist = Guild FROM Z_CastleSiegeWins WHERE Guild = @szOwnGuildName\n\t\t\tif( @exist <> 'NOT' )\n\t\t\tbegin \n\t\t\tUPDATE Z_CastleSiegeWins SET Points = Points+1 WHERE Guild = @szOwnGuildName\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\tINSERT INTO Z_CastleSiegeWins (Guild,Points)\n\t\t\tVALUES (@szOwnGuildName,1)\n\t\t\tend\n\t\t\t\n\t\t\tSELECT 1 As QueryResult\n\t\t\tEND\n\t\t\tELSE\n\t\t\tBEGIN\n\t\t\tSELECT 0 As QueryResult\n\t\t\tEND\n\t\t\tIF(@@Error <> 0 )\n\t\t\tROLLBACK TRANSACTION\n\t\t\tELSE \n\t\t\tCOMMIT TRANSACTION\n\t\t\tSET NOCOUNT OFF \n\t\t\tEnd  \n\t\t\t";
            //Procedure CS
            $query[2] = "\n\t\t\tCREATE TABLE [dbo].[Z_BlockedUsers](\n\t\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t\t[cause] [nvarchar](255) NULL,\n\t\t\t\t[blockdate] [datetime] NOT NULL,\n\t\t\t\t[unblockdate] [datetime] NULL,\n\t\t\t\t[image] [nvarchar](255) NULL,\n\t\t\t\t[admin] [tinyint] NOT NULL,\n\t\t\t\t[status] [tinyint] NOT NULL,\n\t\t\t CONSTRAINT [PK_Z_BlockedUsers] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tIF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Z_BlockedUsers]') AND name = N'IX_Z_BlockedUsers')\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_BlockedUsers] ON [dbo].[Z_BlockedUsers]\n\t\t\t(\n\t\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t\n\t\t\tIF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_Z_BlockedUsers_bloc_date]') AND type = 'D')\n\t\t\tBEGIN\n\t\t\tALTER TABLE [dbo].[Z_BlockedUsers] ADD  CONSTRAINT [DF_Z_BlockedUsers_bloc_date]  DEFAULT (getdate()) FOR [blockdate]\n\t\t\tEND\t\t\t\n\t\t\n\t\t\tIF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_Z_BlockedUsers_status]') AND type = 'D')\n\t\t\tBEGIN\n\t\t\tALTER TABLE [dbo].[Z_BlockedUsers] ADD  CONSTRAINT [DF_Z_BlockedUsers_status]  DEFAULT ((1)) FOR [status]\n\t\t\tEND\n\t\t\t";
            //Z_BlockedUsers
            $query[3] = "\n\t\t\tCREATE TABLE [dbo].[Z_CastleSiegeWins](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[Guild] [varchar](10) NOT NULL,\n\t\t\t[Points] [int] NOT NULL\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            //Z_CastleSiegeWins
            $query[4] = "\n\t\t\tCREATE TABLE [dbo].[Z_ChangeKeyLog](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[old___key] [nvarchar](7) NOT NULL,\n\t\t\t[new___key] [nvarchar](7) NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_ChangeKeyLog_date]  DEFAULT (getdate()),\n\t\t\tCONSTRAINT [PK_Z_ChangeKeyLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_ChangeKeyLog] ON [dbo].[Z_ChangeKeyLog] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_ChangeKeyLog
            $query[5] = "\n\t\t\tCREATE TABLE [dbo].[Z_ChangePassLog](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[old___pwd] [nvarchar](10) NOT NULL,\n\t\t\t[new___pwd] [nvarchar](10) NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_ChangePassLog_date]  DEFAULT (getdate()),\n\t\t\tCONSTRAINT [PK_Z_ChangePassLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tIF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Z_ChangePassLog]') AND name = N'IX_Z_ChangePassLog')\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_ChangePassLog] ON [dbo].[Z_ChangePassLog] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_ChangePassLog
            $query[6] = "\n\t\t\tCREATE TABLE [dbo].[Z_Credits](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[value] [int] NOT NULL CONSTRAINT [DF_Z_Credits_value]  DEFAULT ((0)),\n\t\t\t[type] [tinyint] NOT NULL CONSTRAINT [DF_Z_Credits_type]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_Credits] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_Credits] ON [dbo].[Z_Credits] \n\t\t\t(\n\t\t\t[memb___id] ASC,\n\t\t\t[type] DESC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_Credits
            $query[7] = "\n\t\t\tCREATE TABLE [dbo].[Z_CreditShopItens](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[pack_idx] [int] NOT NULL,\n\t\t\t[item] [nvarchar](10) NOT NULL,\n\t\t\t[value] [int] NOT NULL CONSTRAINT [DF_Z_CreditShopItens_value]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_CreditShopItens] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_CreditShopItens] ON [dbo].[Z_CreditShopItens] \n\t\t\t(\n\t\t\t[pack_idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_CreditShopItens
            $query[8] = "\n\t\t\tCREATE TABLE [dbo].[Z_CreditShopLogs](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nchar](10) NULL,\n\t\t\t[date] [datetime] NULL CONSTRAINT [DF_Z_CreditShopLogs_date]  DEFAULT (getdate()),\n\t\t\t[package] [int] NULL,\n\t\t\t[paidvalue] [int] NULL,\n\t\t\tCONSTRAINT [PK_Z_CreditShopLogs] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_CreditShopLogs] ON [dbo].[Z_CreditShopLogs] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_CreditShopLogs
            $query[9] = "\n\t\t\tCREATE TABLE [dbo].[Z_CreditShopPacks](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[name] [nvarchar](50) NOT NULL,\n\t\t\t[description] [nvarchar](255) NULL,\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_CreditShopPacks_status]  DEFAULT ((0)),\n\t\t\t[price] [smallint] NOT NULL CONSTRAINT [DF_Z_CreditShopPacks_price]  DEFAULT ((0)),\n\t\t\t[order] [smallint] NOT NULL CONSTRAINT [DF_Z_CreditShopPacks_order]  DEFAULT ((0)),\n\t\t\t[multiply] [nvarchar](50) NOT NULL CONSTRAINT [DF_Z_CreditShopPacks_multiply]  DEFAULT ((1)),\n\t\t\tCONSTRAINT [PK_Z_CreditShopPacks] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_CreditShopPacks] ON [dbo].[Z_CreditShopPacks] \n\t\t\t(\n\t\t\t[status] ASC,\n\t\t\t[order] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_CreditShopPacks
            $query[10] = "\n\t\t\tCREATE TABLE [dbo].[Z_Currencies](\n\t\t\t[idx] [int] NOT NULL,\n\t\t\t[name] [nvarchar](50) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_Currencies] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            //Z_Currencies
            $query[11] = "\n\t\t\tCREATE TABLE [dbo].[Z_DepositBanks](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[bank_name] [nvarchar](50) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_DepositBanks] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            //Z_DepositBanks
            $query[12] = "\n\t\t\tCREATE TABLE [dbo].[Z_DepositWayData](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[data] [nvarchar](255) NOT NULL,\n\t\t\t[format] [nvarchar](255) NOT NULL,\n\t\t\t[way] [int] NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_DepositWayData] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_DepositWayData] ON [dbo].[Z_DepositWayData] \n\t\t\t(\n\t\t\t[way] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_DepositWayData
            $query[13] = "\n\t\t\tCREATE TABLE [dbo].[Z_DepositWays](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[way_name] [nvarchar](20) NOT NULL,\n\t\t\t[bank] [int] NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_DepositWays] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_DepositWays] ON [dbo].[Z_DepositWays] \n\t\t\t(\n\t\t\t[bank] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_DepositWays
            $query[14] = "\n\t\t\tCREATE TABLE [dbo].[Z_HelpDeskAttach](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[msg_idx] [bigint] NOT NULL,\n\t\t\t[file] [nvarchar](37) NOT NULL,\n\t\t\t[orig_name] [nvarchar](50) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_HelpDeskAttach] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_HelpDeskAttach] ON [dbo].[Z_HelpDeskAttach] \n\t\t\t(\n\t\t\t[msg_idx] DESC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_HelpDeskAttach
            $query[15] = "\n\t\t\tCREATE TABLE [dbo].[Z_HelpDeskBlock](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](50) NOT NULL,\n\t\t\t[admin] [tinyint] NOT NULL CONSTRAINT [DF_Z_HelpDeskBlock_admin]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_HelpDeskBlock] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_HelpDeskBlock] ON [dbo].[Z_HelpDeskBlock] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_HelpDeskBlock
            $query[16] = "\n\t\t\tCREATE TABLE [dbo].[Z_HelpDeskButtons](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[title] [nvarchar](32) NULL,\n\t\t\t[text] [text] NULL,\n\t\t\t[user] [tinyint] NULL CONSTRAINT [DF_Z_HelpDeskButtons_user]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_HelpDeskButtons] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tIF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Z_HelpDeskButtons]') AND name = N'IX_Z_HelpDeskButtons')\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_HelpDeskButtons] ON [dbo].[Z_HelpDeskButtons] \n\t\t\t(\n\t\t\t[user] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_HelpDeskButtons
            $query[17] = "\n\t\t\tCREATE TABLE [dbo].[Z_HelpDeskMessages](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[ticket_idx] [bigint] NOT NULL,\n\t\t\t[message] [text] NULL,\n\t\t\t[by] [nvarchar](50) NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_HelpDeskMessages_date]  DEFAULT (getdate()),\n\t\t\t[ip] [nvarchar](15) NULL,\n\t\t\tCONSTRAINT [PK_HelpDeskMessages] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_HelpDeskMessages] ON [dbo].[Z_HelpDeskMessages] \n\t\t\t(\n\t\t\t[ticket_idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_HelpDeskMessages
            $query[18] = "\n\t\t\tCREATE TABLE [dbo].[Z_HelpDeskTickets](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[created] [datetime] NOT NULL CONSTRAINT [DF_Z_HelpDeskTickets_created]  DEFAULT (getdate()),\n\t\t\t[last_update] [datetime] NOT NULL CONSTRAINT [DF_Z_HelpDeskTickets_last_update]  DEFAULT (getdate()),\n\t\t\t[admin] [tinyint] NULL,\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_HelpDeskTickets_status]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_HelpDeskTickets] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_HelpDeskTickets] ON [dbo].[Z_HelpDeskTickets] \n\t\t\t(\n\t\t\t[memb___id] ASC,\n\t\t\t[status] DESC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_HelpDeskTickets
            $query[19] = "\n\t\t\tCREATE TABLE [dbo].[Z_Income](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](50) NOT NULL,\n\t\t\t[amount] [smallint] NOT NULL,\n\t\t\t[bank] [nvarchar](50) NOT NULL,\n\t\t\t[way] [nvarchar](50) NOT NULL,\n\t\t\t[date_pay] [datetime] NULL CONSTRAINT [DF_Z_Income_date_pay]  DEFAULT (getdate()),\n\t\t\t[date_confirm] [datetime] NULL,\n\t\t\t[data] [text] NOT NULL,\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_Income_status]  DEFAULT ((0)),\n\t\t\t[extra_info] [text] NULL,\n\t\t\tCONSTRAINT [PK_Z_Income] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_Income] ON [dbo].[Z_Income] \n\t\t\t(\n\t\t\t[status] ASC,\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_Income
            $query[20] = "\n\t\t\tCREATE TABLE [dbo].[Z_LostPasswordLog](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_LostPasswordLog_date]  DEFAULT (getdate()),\n\t\t\tCONSTRAINT [PK_Z_LostPasswordLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_LostPasswordLog] ON [dbo].[Z_LostPasswordLog] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_LostPasswordLog
            $query[21] = "\n\t\t\tCREATE TABLE [dbo].[Z_MailValidation](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[code] [nvarchar](32) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_MailValidation] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            //Z_MailValidation
            $query[22] = "\n\t\t\tCREATE TABLE [dbo].[Z_Messages](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[subject] [nvarchar](50) NOT NULL,\n\t\t\t[message] [text] NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_Messages_date]  DEFAULT (getdate()),\n\t\t\t[status] [smallint] NOT NULL CONSTRAINT [DF_Z_Messages_status]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_Messages] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_Messages] ON [dbo].[Z_Messages] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_Messages
            $query[23] = "\n\t\t\tCREATE TABLE [dbo].[Z_News](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[title] [nvarchar](255) NOT NULL,\n\t\t\t[text] [text] NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_News_date]  DEFAULT (getdate()),\n\t\t\t[admin] [nvarchar](20) NOT NULL,\n\t\t\t[stick] [tinyint] NOT NULL CONSTRAINT [DF_Z_News_stick]  DEFAULT ((0)),\n\t\t\t[views] [int] NOT NULL CONSTRAINT [DF_Z_News_views]  DEFAULT ((0)),\n\t\t\t[order] [smallint] NOT NULL CONSTRAINT [DF_Z_News_order]  DEFAULT ((0)),\n\t\t\t[archive] [tinyint] NOT NULL CONSTRAINT [DF_Z_News_archive]  DEFAULT ((0)),\n\t\t\t[link] [nvarchar](255) NULL,\n\t\t\tCONSTRAINT [PK_Z_News] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_News] ON [dbo].[Z_News] \n\t\t\t(\n\t\t\t[archive] DESC,\n\t\t\t[order] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]  \n\t\t\t";
            //Z_News
            $query[24] = "\n\t\t\tCREATE TABLE [dbo].[Z_Users](\n\t\t\t[id] [smallint] IDENTITY(1,1) NOT NULL,\n\t\t\t[username] [nvarchar](20) NOT NULL,\n\t\t\t[password] [nvarchar](20) NOT NULL,\n\t\t\t[realname] [nvarchar](50) NOT NULL,\n\t\t\t[userlevel] [tinyint] NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_Users] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            //Z_Users
            $query[25] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopCategories](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[name] [nvarchar](30) NOT NULL,\n\t\t\t[orderN] [smallint] NOT NULL,\n\t\t\t[pack] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopCategories_pack]  DEFAULT ((0)),\n\t\t\t[main_cat] [int] NOT NULL CONSTRAINT [DF_Z_WebShopCategories_main_cat] DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_WebShopCategories] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopCategories] ON [dbo].[Z_WebShopCategories] \n\t\t\t(\n\t\t\t[pack] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebShopCategories
            $query[26] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopItems](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[category_idx] [int] NOT NULL,\n\t\t\t[type] [smallint] NOT NULL,\n\t\t\t[id] [smallint] NOT NULL,\n\t\t\t[max_exc_opts] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_max_exc_opts]  DEFAULT ((6)),\n\t\t\t[currency] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_currency]  DEFAULT ((1)),\n\t\t\t[base_price] [int] NOT NULL CONSTRAINT [DF_Z_WebShopItens_base_price]  DEFAULT ((0)),\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_status]  DEFAULT ((0)),\n\t\t\t[min_level] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_min_level]  DEFAULT ((0)),\n\t\t\t[max_level] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_max_level]  DEFAULT ((15)),\n\t\t\t[addopt] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_addopt]  DEFAULT ((0)),\n\t\t\t[skill] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_skill]  DEFAULT ((0)),\n\t\t\t[luck] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_luck]  DEFAULT ((0)),\n\t\t\t[ancient] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_ancient]  DEFAULT ((0)),\n\t\t\t[harmony] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_harmony]  DEFAULT ((0)),\n\t\t\t[opt380] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_opt380]  DEFAULT ((0)),\n\t\t\t[socket_empty] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_socket_empty]  DEFAULT ((0)),\n\t\t\t[max_socket] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItens_max_socket]  DEFAULT ((0)),\n\t\t\t[socket_level] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_socket_level]  DEFAULT ((5)),\n\t\t\t[max_amount] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_max_amount]  DEFAULT ((1)),\n\t\t\t[sold] [int] NOT NULL CONSTRAINT [DF_Z_WebShopItens_sold]  DEFAULT ((0)),\n\t\t\t[limit] [int] NOT NULL CONSTRAINT [DF_Z_WebShopItens_limit]  DEFAULT ((0)),\n\t\t\t[insurance] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_insurance]  DEFAULT ((0)),\n\t\t\t[cancellable] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_cancellable]  DEFAULT ((0)),\n\t\t\t[vip_item] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopItems_vip_item] DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_WebShopItens] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopItems] ON [dbo].[Z_WebShopItems] \n\t\t\t(\n\t\t\t[category_idx] ASC,\n\t\t\t[status] DESC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebShopItems
            $query[27] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopLog](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[serial] [nchar](8) NOT NULL,\n\t\t\t[item] [nchar](32) NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_WebShopLog_date]  DEFAULT (getdate()),\n\t\t\t[price] [int] NOT NULL CONSTRAINT [DF_Z_WebShopLog_price]  DEFAULT ((0)),\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_status]  DEFAULT ((1)),\n\t\t\t[insurance] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_insurance]  DEFAULT ((0)),\n\t\t\t[amount] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_amount]  DEFAULT ((1)),\n\t\t\t[pack] [smallint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_pack]  DEFAULT ((0)),\n\t\t\t[currency] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_currency]  DEFAULT ((1)),\n\t\t\t[discCode] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,\n\t\t\t[cancellable] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopLog_cancellable]  DEFAULT ((0)), \n\t\t\tCONSTRAINT [PK_Z_WebShopLogs] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopLog] ON [dbo].[Z_WebShopLog] \n\t\t\t(\n\t\t\t[memb___id] ASC,\n\t\t\t[item] ASC,\n\t\t\t[status] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebShopLog
            $query[28] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopPackItems](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[pack_idx] [int] NOT NULL,\n\t\t\t[type] [tinyint] NOT NULL,\n\t\t\t[id] [tinyint] NOT NULL,\n\t\t\t[exc_opts] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_max_exc_opts]  DEFAULT ((63)),\n\t\t\t[level] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_min_level]  DEFAULT ((15)),\n\t\t\t[addopt] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_addopt]  DEFAULT ((7)),\n\t\t\t[skill] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_skill]  DEFAULT ((0)),\n\t\t\t[luck] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_luck]  DEFAULT ((1)),\n\t\t\t[ancient] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_ancient]  DEFAULT ((0)),\n\t\t\t[harmony_opt] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_harmony_opt1]  DEFAULT ((0)),\n\t\t\t[harmony_lvl] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_harmony]  DEFAULT ((0)),\n\t\t\t[opt380] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_opt380]  DEFAULT ((0)),\n\t\t\t[socket1] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_max_socket]  DEFAULT ((0)),\n\t\t\t[socket2] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_socket2]  DEFAULT ((0)),\n\t\t\t[socket3] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_socket3]  DEFAULT ((0)),\n\t\t\t[socket4] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_socket4]  DEFAULT ((0)),\n\t\t\t[socket5] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPackItems_socket5]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_WebShopPackItems] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopPackItems] ON [dbo].[Z_WebShopPackItems] \n\t\t\t(\n\t\t\t[pack_idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebShopPackItems
            $query[29] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopPacks](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[category_idx] [int] NOT NULL,\n\t\t\t[pack_name] [nvarchar](50) NOT NULL,\n\t\t\t[currency] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_currency]  DEFAULT ((1)),\n\t\t\t[base_price] [int] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_base_price]  DEFAULT ((0)),\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_status]  DEFAULT ((1)),\n\t\t\t[sold] [int] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_sold]  DEFAULT ((0)),\n\t\t\t[limit] [int] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_limit]  DEFAULT ((0)),\n\t\t\t[insurance] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_insurance]  DEFAULT ((1)),\n\t\t\t[cancellable] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_cancellable]  DEFAULT ((0)),\n\t\t\t[vip_item] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebShopPacks_vip_item] DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_WebShopPacks] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopPacks] ON [dbo].[Z_WebShopPacks] \n\t\t\t(\n\t\t\t[category_idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebShopPacks
            $query[30] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebTradeDirectSale](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[source] [nvarchar](10) NOT NULL,\n\t\t\t[destinationChar] [nvarchar](10) NOT NULL,\n\t\t\t[destination] [nvarchar](10) NOT NULL,\n\t\t\t[status] [tinyint] NOT NULL CONSTRAINT [DF_Z_WebTradeDirectSell_status]  DEFAULT ((0)),\n\t\t\t[dateSent] [datetime] NOT NULL CONSTRAINT [DF_Z_WebTradeDirectSell_dateSent]  DEFAULT (getdate()),\n\t\t\t[dateUpdate] [datetime] NOT NULL CONSTRAINT [DF_Z_WebTradeDirectSell_dateUpdate]  DEFAULT (getdate()),\n\t\t\tCONSTRAINT [PK_Z_WebTradeDirectSell] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebTradeDirectSale] ON [dbo].[Z_WebTradeDirectSale] \n\t\t\t(\n\t\t\t[destination] ASC,\n\t\t\t[source] ASC,\n\t\t\t[status] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebTradeDirectSale
            $query[31] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebTradeDirectSaleItems](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[sale_idx] [bigint] NOT NULL,\n\t\t\t[via] [tinyint] NOT NULL,\n\t\t\t[item] [nchar](32) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_WebTradeDirectSellItems] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebTradeDirectSaleItems] ON [dbo].[Z_WebTradeDirectSaleItems] \n\t\t\t(\n\t\t\t[sale_idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebTradeDirectSaleItems_1] ON dbo.Z_WebTradeDirectSaleItems\n\t\t\t(\n\t\t\t[item] ASC\n\t\t\t) WITH(PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t\n\t\t\t";
            //Z_WebTradeDirectSaleItems
            $query[32] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebVault](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[item] [nchar](32) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_WebVault] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebVault] ON [dbo].[Z_WebVault] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebVault_1] ON [dbo].[Z_WebVault]\n\t\t\t(\n\t\t\t[item]\n\t\t\t) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t";
            //Z_WebVault
            $query[33] = "INSERT INTO [Z_Users] ([username],[password],[realname],[userlevel]) VALUES ('admin','admin','Admin','9')";
            //INSERT USER
            $query[34] = "\n\t\t\tCREATE TABLE [dbo].[Z_MailListMessages](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[title] [nvarchar](255) NOT NULL,\n\t\t\t[message] [text] NULL,\n\t\t\tCONSTRAINT [PK_Z_MailListMessages] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE TABLE [dbo].[Z_MailListSending](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[msg_idx] [int] NOT NULL,\n\t\t\t[mail_addr] [nvarchar](255) NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_MailListSending] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            // Mail List
            $query[35] = "\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects where name = 'DF_Character_Z_RankPK' and type = 'D')\n\t\t\tBEGIN\n\t\t\t\tALTER TABLE dbo.Character DROP CONSTRAINT DF_Character_Z_RankPK\n\t\t\tEND\n\t\t\t\n\t\t\tIF  EXISTS (SELECT * FROM sys.objects where name = 'DF_Character_Z_RankHR' and type = 'D')\n\t\t\tBEGIN\n\t\t\t\tALTER TABLE dbo.Character DROP CONSTRAINT DF_Character_Z_RankHR\n\t\t\tEND\n\t\t\t\n\t\t\tIF EXISTS (select * from sys.columns where Name = N'Z_RankPK' and Object_ID = Object_ID(N'Character'))\n\t\t\tBEGIN\n\t\t\t\tALTER TABLE dbo.Character DROP COLUMN Z_RankPK, Z_RankHR\n\t\t\tEND\n\t\t\t\n\t\t\tIF NOT EXISTS (select * from sys.columns where Name = N'Z_RankPK' and Object_ID = Object_ID(N'Character'))\n\t\t\tBEGIN\n\t\t\t\tALTER TABLE dbo.Character ADD\n\t\t\t\tZ_RankPK int NOT NULL CONSTRAINT DF_Character_Z_RankPK DEFAULT 0,\n\t\t\t\tZ_RankHR int NOT NULL CONSTRAINT DF_Character_Z_RankHR DEFAULT 0\n\t\t\tEND\t\t\t\n\t\t\t";
            // Ranking PK/HERO
            $query[36] = "\n\t\t\tCREATE TRIGGER [dbo].[Z_PK_HERO] ON [dbo].[Character]\n\t\t\tAFTER UPDATE\n\t\t\tAS\n\t\t\t\n\t\t\tDECLARE @rank int\n\t\t\tDECLARE @valor int\n\t\t\tDECLARE @char varchar(10)\n\t\t\t\n\t\t\tSELECT @valor = PkCount FROM DELETED\n\t\t\tSELECT @rank = PkCount, @char = Name FROM INSERTED\n\t\t\t\n\t\t\tIF (@rank > 0) and (@rank > @valor)\n\t\t\tUPDATE [dbo].[Character]\n\t\t\tSET Z_RankPK = Z_RankPK + (@rank-@valor)\n\t\t\tWHERE Name = @char\n\t\t\tELSE\n\t\t\tIF (@rank < 0) and (@rank < @valor)\n\t\t\tUPDATE [dbo].[Character]\n\t\t\tSET Z_RankHR = Z_RankHR + (@valor-@rank)\n\t\t\tWHERE Name = @char\n\t\t\t";
            // TRIGGER PK/HERO
            $query[37] = "\n\t\t\tCREATE TABLE [dbo].[Z_Rename](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[oldName] [nvarchar](10) NOT NULL,\n\t\t\t[newName] [nvarchar](10) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_Rename_date]  DEFAULT (getdate()),\n\t\t\t[ip] [nvarchar](15) NULL,\n\t\t\tCONSTRAINT [PK_Z_Rename] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY];\n\t\t\t";
            // Z_Rename
            $query[38] = "\n\t\t\tCREATE TABLE [dbo].[Z_WebShopDiscCodes](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[code] [nvarchar](50) NOT NULL,\n\t\t\t[type] [tinyint] NOT NULL CONSTRAINT [DF_Z_DiscountCodes_type]  DEFAULT ((1)),\n\t\t\t[value] [int] NOT NULL CONSTRAINT [DF_Z_DiscountCodes_value]  DEFAULT ((0)),\n\t\t\t[expireDate] [smalldatetime] NULL CONSTRAINT [DF_Z_DiscountCodes_expireDate]  DEFAULT (getdate()),\n\t\t\t[count] [int] NOT NULL CONSTRAINT [DF_Z_DiscountCodes_count]  DEFAULT ((1)),\n\t\t\tCONSTRAINT [PK_Z_DiscountCodes] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[code] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_WebShopDiscCodes] ON [dbo].[Z_WebShopDiscCodes] \n\t\t\t(\n\t\t\t[idx] ASC,\n\t\t\t[expireDate] ASC,\n\t\t\t[count] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]";
            // Z_WebShopDiscCodes
            $query[39] = "\n\t\t\tCREATE TABLE [dbo].[Z_Resellers](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t[name] [nvarchar](50) NULL,\n\t\t\t[description] [nvarchar](255) NULL,\n\t\t\t[commission] [tinyint] NULL,\n\t\t\tCONSTRAINT [PK_Z_Resellers] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX [IX_Z_Resellers] ON [dbo].[Z_Resellers] \n\t\t\t(\n\t\t\t[memb___id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t";
            // Z_Resellers
            $query[40] = "\n\t\t\tCREATE TABLE [dbo].[Z_PollAnswers](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[poll_id] [bigint] NOT NULL,\n\t\t\t[answer] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL,\n\t\t\tCONSTRAINT [PK_Z_PoolAnswers] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE TABLE [dbo].[Z_Polls](\n\t\t\t[id] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[question] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL,\n\t\t\t[creation_date] [datetime] NOT NULL CONSTRAINT [DF_Z_Pools_creation_date]  DEFAULT (getdate()),\n\t\t\t[expiration_date] [datetime] NOT NULL,\n\t\t\t[minAL] [tinyint] NOT NULL CONSTRAINT [DF_Z_Pools_minAL]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_Pools] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[id] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE TABLE [dbo].[Z_PollVotes](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[poll_id] [bigint] NOT NULL,\n\t\t\t[answer_id] [bigint] NOT NULL,\n\t\t\t[memb___id] [nvarchar](10) COLLATE Latin1_General_CI_AS NOT NULL,\n\t\t\t[ip] [nvarchar](15) COLLATE Latin1_General_CI_AS NULL,\n\t\t\tCONSTRAINT [PK_Z_PoolVotes] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]";
            //Poll system
            $query[41] = "\n\t\t\tCREATE TABLE [dbo].[Z_GuideDBCategories](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[name] [nvarchar](30) COLLATE Latin1_General_CI_AS NOT NULL,\n\t\t\t[orderN] [smallint] NOT NULL,\n\t\t\t[main_cat] [int] NOT NULL CONSTRAINT [DF_Z_GuideDBCategories_main_cat]  DEFAULT ((0)),\n\t\t\tCONSTRAINT [PK_Z_GuideDBCategories] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE TABLE [dbo].[Z_Guides](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[category] [bigint] NOT NULL,\n\t\t\t[title] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,\n\t\t\t[text] [text] COLLATE Latin1_General_CI_AS NULL,\n\t\t\tCONSTRAINT [PK_Z_Guides] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\n\t\t\t";
            //GuideDB system
            $query[42] = "\n\t\t\tCREATE TABLE [dbo].[Z_Events](\n\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t[title] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL,\n\t\t\t[description] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,\n\t\t\t[by] [tinyint] NOT NULL,\n\t\t\t[type] [tinyint] NOT NULL CONSTRAINT [DF_Z_Events_type]  DEFAULT ((0)),\n\t\t\t[currency1] [int] NOT NULL CONSTRAINT [DF_Z_Events_currency1]  DEFAULT ((0)),\n\t\t\t[currency2] [int] NOT NULL CONSTRAINT [DF_Z_Events_currency2]  DEFAULT ((0)),\n\t\t\t[currency3] [int] NOT NULL CONSTRAINT [DF_Z_Events_currency3]  DEFAULT ((0)),\n\t\t\t[currency4] [int] NOT NULL CONSTRAINT [DF_Z_Events_currency4]  DEFAULT ((0)),\n\t\t\t[currency5] [int] NOT NULL CONSTRAINT [DF_Z_Events_currency5]  DEFAULT ((0)),\n\t\t\t[playerLimit] [smallint] NOT NULL CONSTRAINT [DF_Z_Events_limit]  DEFAULT ((0)),\n\t\t\t[AccountLevel] [tinyint] NOT NULL CONSTRAINT [DF_Z_Events_AccountLevel]  DEFAULT ((0)),\n\t\t\t[winQuantity] [tinyint] NOT NULL CONSTRAINT [DF_Z_Events_winAmount]  DEFAULT ((1)),\n\t\t\tCONSTRAINT [PK_Z_Events] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE TABLE [dbo].[Z_EventsSchedule](\n\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t[event] [int] NOT NULL,\n\t\t\t[type] [tinyint] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_type]  DEFAULT ((0)),\n\t\t\t[date_start] [datetime] NULL,\n\t\t\t[date_end] [datetime] NULL,\n\t\t\t[date] [datetime] NOT NULL,\n\t\t\t[winner] [nvarchar](10) COLLATE Latin1_General_CI_AS NULL,\n\t\t\t[by] [tinyint] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_by]  DEFAULT ((0)),\n\t\t\t[currency1] [int] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_currency1] DEFAULT ((0)),\n\t\t\t[currency2] [int] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_currency2] DEFAULT ((0)),\n\t\t\t[currency3] [int] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_currency3] DEFAULT ((0)),\n\t\t\t[currency4] [int] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_currency4] DEFAULT ((0)),\n\t\t\t[currency5] [int] NOT NULL CONSTRAINT [DF_Z_EventsSchedule_currency5] DEFAULT ((0)),\n\t\t\t[place] [nvarchar](50) NULL,\n\t\t\tCONSTRAINT [PK_Z_EventsSchedule] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]";
            // Events
            $query[43] = "\n\t\t\tCREATE TABLE [dbo].[Z_ResetTransferLog](\n\t\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[source] [varchar](10) NOT NULL,\n\t\t\t\t[destination] [varchar](10) NOT NULL,\n\t\t\t\t[resets] [int] NOT NULL,\n\t\t\t\t[totalTax] [int] NOT NULL,\n\t\t\t\t[date] [datetime] NOT NULL CONSTRAINT [DF_Z_ResetTransferLog_date] DEFAULT (getdate()),\n\t\t\t\t[ip] [varchar](15) NULL,\n\t\t\t CONSTRAINT [PK_Z_ResetTransferLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t";
            // Reset Tranfer Log
            $query[44] = "\n\t\t\tCREATE TABLE [dbo].[Z_VipItemData](\n\t\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t\t[serial] [nchar](8) NOT NULL,\n\t\t\t\t[item] [nchar](32) NOT NULL,\n\t\t\t\t[date] [datetime] NOT NULL,\n\t\t\t\t[deleted] [tinyint] NOT NULL,\n\t\t\t CONSTRAINT [PK_Z_VipItemData] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tALTER TABLE [dbo].[Z_VipItemData] ADD  CONSTRAINT [DF_Z_VipItemData_serial]  DEFAULT ((0)) FOR [serial]\n\t\t\tALTER TABLE [dbo].[Z_VipItemData] ADD  CONSTRAINT [DF_Z_VipItemData_date]  DEFAULT (getdate()) FOR [date]\n\t\t\tALTER TABLE [dbo].[Z_VipItemData] ADD  CONSTRAINT [DF_Z_VipItemData_deleted]  DEFAULT ((0)) FOR [deleted]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX IX_Z_VipItemData ON dbo.Z_VipItemData\n\t\t\t(\n\t\t\tdeleted\n\t\t\t) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX IX_Z_VipItemData_1 ON dbo.Z_VipItemData\n\t\t\t(\n\t\t\tmemb___id\n\t\t\t) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t";
            $query[45] = "\n\t\t\tCREATE TABLE [dbo].[Z_VipItemUsers](\n\t\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[status] [tinyint] NOT NULL,\n\t\t\t\t[due_date] [datetime] NULL,\n\t\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t CONSTRAINT [PK_Z_VipItemUsers] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tALTER TABLE [dbo].[Z_VipItemUsers] ADD  CONSTRAINT [DF_Z_VipItemUsers_status]  DEFAULT ((0)) FOR [status]\n\t\t\tALTER TABLE [dbo].[Z_VipItemUsers] ADD  CONSTRAINT [DF_Z_VipItemUsers_due_date]  DEFAULT (getdate()) FOR [due_date]\n\t\t\t\n\t\t\tCREATE NONCLUSTERED INDEX IX_Z_VipItemUsers ON dbo.Z_VipItemUsers\n\t\t\t(\n\t\t\tstatus\n\t\t\t) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t";
            $query[46] = "\n\t\t\tCREATE TABLE [dbo].[Z_GameCurrencies](\n\t\t\t\t[idx] [tinyint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[name] [nvarchar](50) NOT NULL,\n\t\t\t\t[database] [nvarchar](50) NOT NULL,\n\t\t\t\t[table] [nvarchar](50) NOT NULL,\n\t\t\t\t[column] [nvarchar](50) NOT NULL,\n\t\t\t\t[accountColumn] [nvarchar](12) NOT NULL,\n\t\t\t\t[onlyoff] [tinyint] NOT NULL,\n\t\t\t CONSTRAINT [PK_Z_GameCurrencies] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tALTER TABLE [dbo].[Z_GameCurrencies] ADD  CONSTRAINT [DF_Z_GameCurrencies_database]  DEFAULT (N'MuOnline') FOR [database]\n\t\t\tALTER TABLE [dbo].[Z_GameCurrencies] ADD  CONSTRAINT [DF_Z_GameCurrencies_accountColumn]  DEFAULT (N'memb___id') FOR [accountColumn]\n\t\t\tALTER TABLE [dbo].[Z_GameCurrencies] ADD  CONSTRAINT [DF_Z_GameCurrencies_status]  DEFAULT ((0)) FOR [onlyoff]\n\t\t\t";
            $query[47] = "\n\t\t\tCREATE TABLE [dbo].[Z_ChangeClassLog](\n\t\t\t\t[idx] [bigint] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t\t[char] [nvarchar](10) NOT NULL,\n\t\t\t\t[fromClass] [tinyint] NOT NULL,\n\t\t\t\t[toClass] [tinyint] NOT NULL,\n\t\t\t\t[date] [datetime] NOT NULL,\n\t\t\t CONSTRAINT [PK_Z_ChangeClassLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tALTER TABLE [dbo].[Z_ChangeClassLog] ADD  CONSTRAINT [DF_Z_ChangeClassLog_date]  DEFAULT (getdate()) FOR [date]\n\t\t\t";
            $query[48] = "\n\t\t\tCREATE TABLE [dbo].[Z_MasterResetLog](\n\t\t\t\t[idx] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[Name] [nvarchar](10) NOT NULL,\n\t\t\t\t[memb___id] [nvarchar](10) NOT NULL,\n\t\t\t\t[date] [datetime] NOT NULL,\n\t\t\t\t[ResetCount] [int] NOT NULL,\n\t\t\t\t[bonus] [int] NOT NULL,\n\t\t\t CONSTRAINT [PK_XW_MasterResetLog] PRIMARY KEY CLUSTERED \n\t\t\t(\n\t\t\t\t[idx] ASC\n\t\t\t)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n\t\t\t) ON [PRIMARY]\n\t\t\t\n\t\t\tALTER TABLE [dbo].[Z_MasterResetLog] ADD  CONSTRAINT [DF_XW_MasterResetLog_date]  DEFAULT (getdate()) FOR [date]\n";
            foreach ($query as $key => $theQuery) {
                if (!empty($theQuery)) {
                    if (!$db->Query($theQuery)) {
                        echo "<h3 align=\"center\" style=\"color:#FF0000\">Oh, master, I have got an error in the query #" . ($key + 1) . ".<br />\n\t\t\t\t\t\tPlease contact Ferrarezi support and report this error with the query number!</h3>";
                        echo $db->GetError();
                        return;
                    }
                }
            }
        }
        echo "<h1>YES!</h1>";
        echo "<h3>I've managed to install the Ferrarezi Web successfully!</h3>";
        echo "<h3>You can now configure and use your site fully!</h3>";
        echo "<h3>Thanks for your attention, master! See you next time! ;)</h3>";
        echo "<hr />";
        echo "<h2>You should configure now your Manager users.</h2>";
        echo "<h3>Your default credentials:<br />\n\t\t<span style=\"float:left; width:100px; text-align: right; color: #990000; margin-right: 5px;\">Login: </span> <span>admin</span><br />\n\t\t<span style=\"float:left; width:100px; text-align: right; color: #990000; margin-right: 5px;\">Password: </span> <span>admin</span></h3>";
        echo "<h3>To do your first login right now, <a href=\"Manager/\">click here!</a></h3>";
        @unlink("install.php");
        @unlink("installer.php");
        return;
    }
    ?>
	<br />
	<?php 
    if ($db->Query("SELECT 1")) {
        ?>
		<form action="?step=2" name="" method="post">
			<h2>Everything went well until now, master! It is just Great! \o/</h2>
			<h3>Now I'm about to start your Database configurarion.</h3>
			<?php 
        if ($db->Query("SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Z_BlockedUsers]') AND type in (N'U')")) {
            if ($db->NumRows() > 0) {
                ?>
				
				<h3 style="background-color:#FF0">Should I (re)create all the site database?</h3>
				<p>
					<input type="radio" name="dbCreate" value="1" />
					YES, (re)create all tables. (<strong style="color:#FF0000">You'll lose all the site data!</strong>)<br />
					<input name="dbCreate" type="radio" value="0" checked="checked" />
					NO, leave as it is. </p>
				<h3 style="color:#FF0000">Please, be careful! <u>This will empty your WHOLE site Database</u>, if it already exists!</h3><p>&nbsp;</p>
                <?php 
            } else {
                ?>
					<input type="hidden" name="dbCreate" value="1" />
					<?php 
            }
        }
        ?>
			<h3>Are you ready for that?</h3>
			<p align="center">
				<input name="submit" type="submit" id="submit" value="Rush!" />
			</p>
		</form>
		<?php 
    } else {
        ?>
		<h3>I'm sorry, but I could not connect to your database with the provided data.</h3>
		<h3>So, please, <a href="?step=1">go back</a> and try again, Master!</h3>
		<?php 
    }
}