· 9 years ago · Jan 09, 2017, 05:36 AM
1<?PHP
2error_reporting(E_ALL ^ E_NOTICE);
3ini_set('include_path', ini_get('include_path') . ':../libs');
4$config['site'] = parse_ini_file('../config/config.ini');
5session_start();
6//save config in ini file
7function saveconfig_ini($config)
8{
9 $file = fopen('../config/config.ini', "w");
10 foreach($config as $param => $data)
11 {
12 $file_data .= $param.' = "'.str_replace('"', '', $data)."\"\n";
13 }
14 rewind($file);
15 fwrite($file, $file_data);
16 fclose($file);
17}
18
19function check_password($pass)
20{
21 $temp = strspn("$pass", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890");
22 if ($temp != strlen($pass))
23 {
24 return false;
25 }
26 else
27 {
28 $ok = "/[a-zA-Z0-9]{1,40}/";
29 return (preg_match($ok, $pass))? true: false;
30 }
31}
32
33function password_ency($password)
34{
35 $ency = $GLOBALS['config']['server']['encryptionType'];
36 if($ency != 'plain')
37 return hash($ency, $password);
38 elseif($ency == 'plain')
39 return $password;
40}
41if($_REQUEST['page'] == '' && !isset($_REQUEST['step']))
42{
43 echo '<html>
44 <head>
45 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
46 <title>Installation of account maker</title>
47 </head>
48 <frameset cols="230,*">
49 <frame name="menu" src="install.php?page=menu" />
50 <frame name="step" src="install.php?page=step&step=0" />
51 <noframes><body>Frames don\'t work. Install Firefox :P</body></noframes>
52 </frameset>
53 </html>';
54}
55if($_REQUEST['page'] == 'menu')
56{
57 echo '<h2>MENU</h2><br>
58 <b>IF NOT INSTALLED:</b><br>
59 <a href="install.php?page=step&step=start" target="step">0. Informations</a><br>
60 <a href="install.php?page=step&step=1" target="step">1. Set server path</a><br>
61 <a href="install.php?page=step&step=2" target="step">2. Check DataBase connection</a><br>
62 <a href="install.php?page=step&step=3&server_conf=yes" target="step">3. Add tables and columns to DB</a><br>
63 <a href="install.php?page=step&step=4&server_conf=yes" target="step">4. Add samples to DB</a><br>
64 <a href="install.php?page=step&step=5&server_conf=yes" target="step">5. Set Admin Account</a><br>
65 <!--<b>FOR ADMINS:</b><br>
66 <a href="index.php?subtopic=adminpanel&action=install_monsters" target="step">6. Load Monsters from OTS</a><br>
67 <a href="index.php?subtopic=adminpanel&action=install_spells" target="step">7. Load Spells from OTS</a><br>-->';
68}
69if($_REQUEST['page'] == 'step')
70{
71 if($config['site']['install'] != "no")
72 {
73 if($_REQUEST['server_conf'] == 'yes' || ($_REQUEST['step'] > 2 && $_REQUEST['step'] < 6))
74 {
75 //load server config
76 $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
77 if(isset($config['server']['sqlHost']))
78 {
79 $mysqlhost = $config['server']['sqlHost'];
80 $mysqluser = $config['server']['sqlUser'];
81 $mysqlpass = $config['server']['sqlPass'];
82 $mysqldatabase = $config['server']['sqlDatabase'];
83 }
84 $sqlitefile = $config['server']['sqliteDatabase'];
85 // loads #####POT mainfile#####
86 include('pot/OTS.php');
87 // PDO and POT connects to database
88 $ots = POT::getInstance();
89 if(strtolower($config['server']['sqlType']) == "mysql")
90 {
91 //connect to MySQL database
92 try
93 {
94 $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
95 }
96 catch(PDOException $error)
97 {
98 echo 'Database error - can\'t connect to MySQL database. Possible reasons:<br>1. MySQL server is not running on host.<br>2. MySQL user, password, database or host isn\'t configured in: <b>'.$config['site']['server_path'].'config.lua</b>.<br>3. MySQL user, password, database or host is wrong.';
99 exit;
100 }
101 }
102 elseif(strtolower($config['server']['sqlType']) == "sqlite")
103 {
104 //connect to SQLite database
105 $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
106 try
107 {
108 $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
109 }
110 catch(PDOException $error)
111 {
112 echo 'Database error - can\'t open SQLite database. Possible reasons:<br><b>'.$link_to_sqlitedatabase.'</b> - file isn\'t valid SQLite database.<br><b>'.$link_to_sqlitedatabase.'</b> - doesn\'t exist.';
113 exit;
114 }
115 }
116 else
117 {
118 echo 'Database error. Unknown database type in <b>'.$config['site']['server_path'].'config.lua</b>. Must be equal to: "<b>mysql</b>" or "<b>sqlite</b>". Now is: "<b>'.strtolower($config['server']['sqlType']).'"</b>';
119 exit;
120 }
121 $SQL = POT::getInstance()->getDBHandle();
122 }
123 $step = $_REQUEST['step'];
124 if(empty($step))
125 {
126 $step = $config['site']['install'];
127 }
128 if($step == 'start')
129 {
130 echo '<h1>STEP '.$step.'</h1>Informations<br>Welcome to Gesior Account Maker installer. <b>First do steps 1-5 one by one, later (when you will be logged on admin account) press on links to steps 6-7 to load configuration from OTS.</b><span style="color: red; font-weight:bold;">';
131 $dir = array('cache', 'config', 'images/guilds');
132 $filez = array('config/config.ini', 'config/config.php', 'cache/usercounter.dat', 'cache/serverstatus');
133 foreach ($dir as $check)
134 {
135 if(!is_writable('../'.$check))
136 echo "<br>Please set chmod 777 ".$_SERVER["DOCUMENT_ROOT"].'/'.$check;
137 }
138 foreach ($filez as $check)
139 {
140 if(!is_writable('../'.$check))
141 echo "<br>Please set chmod 777 ".$_SERVER["DOCUMENT_ROOT"].'/'.$check;
142 }
143 echo '</span>';
144 }
145 if($step == '1')
146 {
147 if(isset($_REQUEST['server_path']))
148 {
149 echo '<h1>STEP '.$step.'</h1>Check server configuration<br>';
150 $config['site']['server_path'] = $_REQUEST['server_path'];
151 $config['site']['server_path'] = trim($config['site']['server_path'])."\\";
152 $config['site']['server_path'] = str_replace("\\\\", "/", $config['site']['server_path']);
153 $config['site']['server_path'] = str_replace("\\", "/", $config['site']['server_path']);
154 $config['site']['server_path'] = str_replace("//", "/", $config['site']['server_path']);
155 if(file_exists($config['site']['server_path'].'config.lua'))
156 {
157 $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
158 if(isset($config['server']['sqlType']))
159 {
160 $config['site']['install'] = 2;
161 saveconfig_ini($config['site']);
162 echo 'File <b>config.lua</b> loaded from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> and looks like fine server config file. Now you can check database('.$config['server']['sqlType'].') connection: <a href="install.php?page=step&step=2">STEP 2 - check database connection</a>';
163 }
164 else
165 {
166 echo 'File <b>config.lua</b> loaded from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> and it\'s not valid TFS config.lua file. <a href="install.php?page=step&step=1">Go to STEP 1 - select other directory.</a> If it\'s your config.lua file from TFS contact with acc. maker author.';
167 }
168 }
169 else
170 {
171 echo 'Can\'t load file <b>config.lua</b> from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> File doesn\'t exist in selected directory. <a href="install.php?page=step&step=1">Go to STEP 1 - select other directory.</a>';
172 }
173 }
174 else
175 {
176 echo 'Please write you TFS directory below. Like: <i>C:\Documents and Settings\Gesior\Desktop\trunk.r4041\</i><form action="install.php">
177 <input type="text" name="server_path" size="90" value="'.$config['site']['server_path'].'" /><input type="hidden" name="page" value="step" /><input type="hidden" name="step" value="1" /><input type="submit" value="Set server path" />
178 </form>';
179 }
180 }
181 if($step == '2')
182 {
183 echo '<h1>STEP '.$step.'</h1>Check database connection<br>';
184 echo 'If you don\'t see any errors press <a href="install.php?page=step&step=3&server_conf=yes">link to STEP 3 - Add tables and columns to DB</a>. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.';
185 //load server config
186 $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
187 if(isset($config['server']['sqlHost']))
188 {
189 $mysqlhost = $config['server']['sqlHost'];
190 $mysqluser = $config['server']['sqlUser'];
191 $mysqlpass = $config['server']['sqlPass'];
192 $mysqldatabase = $config['server']['sqlDatabase'];
193 }
194 $sqlitefile = $config['server']['sqliteDatabase'];
195 // loads #####POT mainfile#####
196 include('pot/OTS.php');
197 // PDO and POT connects to database
198 $ots = POT::getInstance();
199 if(strtolower($config['server']['sqlType']) == "mysql")
200 {
201 //connect to MySQL database
202 try
203 {
204 $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
205 }
206 catch(PDOException $error)
207 {
208 echo 'Database error - can\'t connect to MySQL database. Possible reasons:<br>1. MySQL server is not running on host.<br>2. MySQL user, password, database or host isn\'t configured in: <b>'.$config['site']['server_path'].'config.lua</b> .<br>3. MySQL user, password, database or host is wrong.';
209 exit;
210 }
211 }
212 elseif(strtolower($config['server']['sqlType']) == "sqlite")
213 {
214 //connect to SQLite database
215 $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
216 try
217 {
218 $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
219 }
220 catch(PDOException $error)
221 {
222 echo 'Database error - can\'t open SQLite database. Possible reasons:<br><b>'.$link_to_sqlitedatabase.'</b> - file isn\'t valid SQLite database.<br><b>'.$link_to_sqlitedatabase.'</b> - doesn\'t exist.';
223 exit;
224 }
225 }
226 else
227 {
228 echo 'Database error. Unknown database type in <b>'.$config['site']['server_path'].'config.lua</b>. Must be equal to: "<b>mysql</b>" or "<b>sqlite</b>". Now is: "<b>'.strtolower($config['server']['sqlType']).'"</b>';
229 exit;
230 }
231 $SQL = POT::getInstance()->getDBHandle();
232 $config['site']['install'] = 3;
233 saveconfig_ini($config['site']);
234 }
235 if($step == '3')
236 {
237 echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
238 echo 'Installer try to add new tables and columns to database.<br>';
239 $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
240 if($config['server']['sqlType'] == "sqlite")
241 {
242 //if sqlite
243 try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
244 try { $SQL->query('ALTER TABLE accounts ADD "email_new" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
245 try { $SQL->query('ALTER TABLE accounts ADD "email_new_time" INTEGER(15) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
246 try { $SQL->query('ALTER TABLE accounts ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
247 try { $SQL->query('ALTER TABLE accounts ADD "rlname" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
248 try { $SQL->query('ALTER TABLE accounts ADD "location" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
249 try { $SQL->query('ALTER TABLE accounts ADD "page_access" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
250 try { $SQL->query('ALTER TABLE accounts ADD "email_code" VARCHAR(255) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
251 try { $SQL->query('ALTER TABLE accounts ADD "next_email" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
252 try { $SQL->query('ALTER TABLE accounts ADD "premium_points" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
253 try { $SQL->query('ALTER TABLE accounts ADD "flag" VARCHAR( 255 ) NOT NULL;'); } catch(PDOException $error) {}
254 echo "Added columns to table <b>accounts</b>.<br/>";
255 try { $SQL->query('ALTER TABLE guilds ADD "description" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
256 try { $SQL->query('ALTER TABLE guilds ADD "logo_gfx_name" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
257 echo "Added columns to table <b>guilds</b>.<br/>";
258 try { $SQL->query('ALTER TABLE players ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
259 try { $SQL->query('ALTER TABLE players ADD "nick_verify" VARCHAR(5) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
260 try { $SQL->query('ALTER TABLE players ADD "old_name" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
261 try { $SQL->query('ALTER TABLE players ADD "hide_char" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
262 try { $SQL->query('ALTER TABLE players ADD "comment" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
263 echo "Added columns to table <b>players</b>.<br/>";
264 try { $SQL->query('CREATE TABLE "z_news_big" (
265 "hide_news" INTEGER NOT NULL DEFAULT 0,
266 "date" INTEGER NOT NULL,
267 "author" VARCHAR(255) NOT NULL,
268 "author_id" INTEGER NOT NULL,
269 "image_id" INTEGER NOT NULL DEFAULT 0,
270 "topic" VARCHAR(255) NOT NULL,
271 "text" TEXT NOT NULL);'); } catch(PDOException $error) {}
272 echo "Added table <b>z_news_big</b> (news).<br/>";
273 try { $SQL->query('CREATE TABLE "z_news_tickers" (
274 "date" INTEGER NOT NULL,
275 "author" INTEGER NOT NULL,
276 "image_id" INTEGER NOT NULL DEFAULT 0,
277 "text" TEXT NOT NULL,
278 "hide_ticker" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
279 echo "Added table <b>z_news_tickers</b> (tickers).<br/>";
280 try { $SQL->query('CREATE TABLE "z_spells" (
281 "name" VARCHAR(255) NOT NULL,
282 "spell" VARCHAR(255) NOT NULL,
283 "spell_type" VARCHAR(255) NOT NULL,
284 "mana" INTEGER NOT NULL DEFAULT 0,
285 "lvl" INTEGER NOT NULL DEFAULT 0,
286 "mlvl" INTEGER NOT NULL DEFAULT 0,
287 "soul" INTEGER NOT NULL DEFAULT 0,
288 "pacc" VARCHAR(255) NOT NULL,
289 "vocations" VARCHAR(255) NOT NULL,
290 "conj_count" INTEGER NOT NULL DEFAULT 0,
291 "hide_spell" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
292 echo "Added table <b>z_spells</b> (spells list).<br/>";
293 try { $SQL->query('CREATE TABLE "z_monsters" (
294 "hide_creature" INTEGER NOT NULL DEFAULT 0,
295 "name" VARCHAR(255) NOT NULL,
296 "mana" INTEGER NOT NULL,
297 "exp" INTEGER NOT NULL,
298 "health" INTEGER NOT NULL,
299 "speed_lvl" INTEGER NOT NULL DEFAULT 1,
300 "use_haste" INTEGER NOT NULL,
301 "voices" text NOT NULL,
302 "immunities" VARCHAR(255) NOT NULL,
303 "summonable" INTEGER NOT NULL,
304 "convinceable" INTEGER NOT NULL,
305 "race" VARCHAR(255) NOT NULL,
306 "gfx_name" VARCHAR(255) NOT NULL)'); } catch(PDOException $error) {}
307 echo 'Added table <b>z_monsters</b> (monsters list).<br/><br/>';
308 try { $SQL->query('CREATE TABLE "z_ots_comunication" (
309 "id" int(11) NOT NULL auto_increment,
310 "name" varchar(255) NOT NULL,
311 "type" varchar(255) NOT NULL,
312 "action" varchar(255) NOT NULL,
313 "param1" varchar(255) NOT NULL,
314 "param2" varchar(255) NOT NULL,
315 "param3" varchar(255) NOT NULL,
316 "param4" varchar(255) NOT NULL,
317 "param5" varchar(255) NOT NULL,
318 "param6" varchar(255) NOT NULL,
319 "param7" varchar(255) NOT NULL,
320 "delete_it" int(2) NOT NULL default "1",
321 PRIMARY KEY ("id"))'); } catch(PDOException $error) {}
322 echo "Added table <b>z_ots_comunication</b> (shopsystem).<br/>";
323 try { $SQL->query('CREATE TABLE "z_shop_offer" (
324 "id" int(11) NOT NULL auto_increment,
325 "points" int(11) NOT NULL default 0,
326 "itemid1" int(11) NOT NULL default 0,
327 "count1" int(11) NOT NULL default 0,
328 "itemid2" int(11) NOT NULL default 0,
329 "count2" int(11) NOT NULL default 0,
330 "offer_type" varchar(255) default NULL,
331 "offer_description" text NOT NULL,
332 "offer_name" varchar(255) NOT NULL,
333 "pid" INT(11) NOT NULL DEFAULT 0,
334 PRIMARY KEY ("id"))'); } catch(PDOException $error) {}
335 echo "Added table <b>z_shop_offer</b> (shopsystem).<br/>";
336 try { $SQL->query('CREATE TABLE "z_shop_history_item" (
337 "id" int(11) NOT NULL auto_increment,
338 "to_name" varchar(255) NOT NULL default 0,
339 "to_account" int(11) NOT NULL default 0,
340 "from_nick" varchar(255) NOT NULL,
341 "from_account" int(11) NOT NULL default 0,
342 "price" int(11) NOT NULL default 0,
343 "offer_id" int(11) NOT NULL default 0,
344 "trans_state" varchar(255) NOT NULL,
345 "trans_start" int(11) NOT NULL default 0,
346 "trans_real" int(11) NOT NULL default 0,
347 PRIMARY KEY ("id"))'); } catch(PDOException $error) {}
348 echo "Added table <b>z_shop_history_item</b> (shopsystem).<br/>";
349 try { $SQL->query('CREATE TABLE "z_shop_history_pacc" (
350 "id" int(11) NOT NULL auto_increment,
351 "to_name" varchar(255) NOT NULL default 0,
352 "to_account" int(11) NOT NULL default 0,
353 "from_nick" varchar(255) NOT NULL,
354 "from_account" int(11) NOT NULL default 0,
355 "price" int(11) NOT NULL default 0,
356 "pacc_days" int(11) NOT NULL default 0,
357 "trans_state" varchar(255) NOT NULL,
358 "trans_start" int(11) NOT NULL default 0,
359 "trans_real" int(11) NOT NULL default 0,
360 PRIMARY KEY ("id"))'); } catch(PDOException $error) {}
361 echo "Added table <b>z_shop_history_pacc</b> (shopsystem).<br/>";
362 try { $SQL->query('CREATE TABLE "zaypay_payment" (
363 "payID" bigint(30) NOT NULL,
364 "account_id" int(20) NOT NULL,
365 "status" varchar(255) NOT NULL,
366 PRIMARY KEY ("payID"))'); } catch(PDOException $error) {}
367 echo "Added table <b>zaypay_payment</b> (shopsystem).<br/>";
368 try { $SQL->query('CREATE TABLE "z_shop_points_bought" (
369 "id" INT( 15 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
370 "amount" INT( 15 ) NOT NULL,
371 "type" VARCHAR( 255 ) NOT NULL,
372 "accountid" INT( 15 ) NOT NULL,
373 "code" VARCHAR( 255 ) NOT NULL,
374 "paypalmail" VARCHAR( 255 ) NOT NULL,
375 "date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP )'); } catch(PDOException $error) {}
376 echo "Added table <b>z_shop_points_bought</b> (shopsystem).<br/>";
377 }
378 elseif($config['server']['sqlType'] == "mysql")
379 {
380 //if mysql
381 try { $SQL->query("ALTER TABLE `accounts` ADD `lastpremdays` INT( 11 ) NOT NULL DEFAULT '0' AFTER `premdays`;"); } catch(PDOException $error) {}
382 try { $SQL->query("ALTER TABLE `accounts` ADD `premium_points` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
383 try { $SQL->query("ALTER TABLE `accounts` ADD `email_new` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
384 try { $SQL->query("ALTER TABLE `accounts` ADD `email_new_time` INT( 15 ) NOT NULL;"); } catch(PDOException $error) {}
385 try { $SQL->query("ALTER TABLE `accounts` ADD `email_code` VARCHAR( 255 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
386 try { $SQL->query("ALTER TABLE `accounts` ADD `next_email` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
387 try { $SQL->query("ALTER TABLE `accounts` ADD `created` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
388 try { $SQL->query("ALTER TABLE `accounts` ADD `page_lastday` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
389 try { $SQL->query("ALTER TABLE `accounts` ADD `page_access` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
390 try { $SQL->query("ALTER TABLE `accounts` ADD `rlname` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
391 try { $SQL->query("ALTER TABLE `accounts` ADD `location` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
392 try { $SQL->query("ALTER TABLE `accounts` ADD `flag` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
393 echo "Added columns to table <b>accounts</b><br/>";
394 try { $SQL->query('ALTER TABLE `guilds` ADD `description` TEXT NOT NULL;'); } catch(PDOException $error) {}
395 try { $SQL->query('ALTER TABLE `guilds` ADD `logo_gfx_name` VARCHAR( 255 ) NOT NULL;'); } catch(PDOException $error) {}
396 echo "Added columns to table <b>guilds</b>.<br/>";
397 try { $SQL->query("ALTER TABLE `players` ADD `created` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
398 try { $SQL->query("ALTER TABLE `players` ADD `nick_verify` VARCHAR( 5 ) NOT NULL;"); } catch(PDOException $error) {}
399 try { $SQL->query('ALTER TABLE `players` ADD `old_name` VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
400 try { $SQL->query("ALTER TABLE `players` ADD `hide_char` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
401 try { $SQL->query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"); } catch(PDOException $error) {}
402 try { $SQL->query("ALTER TABLE `players` ADD `join_date` BIGINT( 20 ) NOT NULL AFTER `guildnick`;"); } catch(PDOException $error) {}
403 echo "Added columns to table <b>players</b><br/>";
404 try { $SQL->query("CREATE TABLE `z_news_big` (
405 `hide_news` tinyint(1) NOT NULL DEFAULT '0',
406 `date` int(11) NOT NULL DEFAULT '0',
407 `author` varchar(255) NOT NULL,
408 `author_id` int(11) NOT NULL,
409 `image_id` int(3) NOT NULL DEFAULT '0',
410 `topic_df` varchar(255) NOT NULL,
411 `text_df` text NOT NULL,
412 `topic_ot` varchar(255) NOT NULL,
413 `text_ot` text NOT NULL
414 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
415 echo "Added table <b>z_news_big</b> (news).<br/>";
416 try { $SQL->query("CREATE TABLE `z_news_tickers` (
417 `date` int(11) NOT NULL default '1',
418 `author` int(11) NOT NULL,
419 `image_id` int(3) NOT NULL default '0',
420 `text` text NOT NULL,
421 `hide_ticker` tinyint(1) NOT NULL
422 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
423 echo "Added table <b>z_news_tickers</b> (news tickers).<br/>";
424 try { $SQL->query('CREATE TABLE `z_spells` (
425 `name` VARCHAR(255) NOT NULL,
426 `spell` VARCHAR(255) NOT NULL,
427 `spell_type` VARCHAR(255) NOT NULL,
428 `mana` INTEGER NOT NULL DEFAULT 0,
429 `lvl` INTEGER NOT NULL DEFAULT 0,
430 `mlvl` INTEGER NOT NULL DEFAULT 0,
431 `soul` INTEGER NOT NULL DEFAULT 0,
432 `pacc` VARCHAR(255) NOT NULL,
433 `vocations` VARCHAR(255) NOT NULL,
434 `conj_count` INTEGER NOT NULL DEFAULT 0,
435 `hide_spell` INTEGER NOT NULL DEFAULT 0
436 );'); } catch(PDOException $error) {}
437 echo 'Added table <b>z_spells</b> (libray).<br/>';
438 try { $SQL->query('CREATE TABLE `z_monsters` (
439 `hide_creature` tinyint(1) NOT NULL default \'0\',
440 `name` varchar(255) NOT NULL,
441 `mana` int(11) NOT NULL,
442 `exp` int(11) NOT NULL,
443 `health` int(11) NOT NULL,
444 `speed_lvl` int(11) NOT NULL default \'1\',
445 `use_haste` tinyint(1) NOT NULL,
446 `voices` text NOT NULL,
447 `immunities` varchar(255) NOT NULL,
448 `summonable` tinyint(1) NOT NULL,
449 `convinceable` tinyint(1) NOT NULL,
450 `race` varchar(255) NOT NULL,
451 `gfx_name` varchar(255) NOT NULL
452 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;'); } catch(PDOException $error) {}
453 echo 'Added table <b>z_monsters</b> (libray).<br/><br/>';
454 try { $SQL->query("CREATE TABLE `z_referers` (
455 `account_id` int(30) NOT NULL,
456 `ref_account_id` int(30) NOT NULL
457 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
458 echo "Added table <b>z_referers</b> (account).<br/><br/>";
459 try { $SQL->query("CREATE TABLE `z_ots_comunication` (
460 `id` int(11) NOT NULL auto_increment,
461 `name` varchar(255) NOT NULL,
462 `type` varchar(255) NOT NULL,
463 `action` varchar(255) NOT NULL,
464 `param1` varchar(255) NOT NULL,
465 `param2` varchar(255) NOT NULL,
466 `param3` varchar(255) NOT NULL,
467 `param4` varchar(255) NOT NULL,
468 `param5` varchar(255) NOT NULL,
469 `param6` varchar(255) NOT NULL,
470 `param7` varchar(255) NOT NULL,
471 `delete_it` int(2) NOT NULL default '1',
472 PRIMARY KEY (`id`)
473 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
474 echo "Added table <b>z_ots_comunication</b> (shopsystem).<br/>";
475 try { $SQL->query("CREATE TABLE `z_shop_offer` (
476 `id` int(11) NOT NULL auto_increment,
477 `points` int(11) NOT NULL default '0',
478 `itemid1` int(11) NOT NULL default '0',
479 `count1` int(11) NOT NULL default '0',
480 `itemid2` int(11) NOT NULL default '0',
481 `count2` int(11) NOT NULL default '0',
482 `offer_type` varchar(255) default NULL,
483 `offer_description` text NOT NULL,
484 `offer_name` varchar(255) NOT NULL,
485 `pid` INT(11) NOT NULL DEFAULT '0',
486 PRIMARY KEY (`id`)
487 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); } catch(PDOException $error) {}
488 echo "Added table <b>z_shop_offer</b> (shopsystem).<br/>";
489 try { $SQL->query("CREATE TABLE `z_shop_history_item` (
490 `id` int(11) NOT NULL auto_increment,
491 `to_name` varchar(255) NOT NULL default '0',
492 `to_account` int(11) NOT NULL default '0',
493 `from_nick` varchar(255) NOT NULL,
494 `from_account` int(11) NOT NULL default '0',
495 `price` int(11) NOT NULL default '0',
496 `offer_id` int(11) NOT NULL default '0',
497 `trans_state` varchar(255) NOT NULL,
498 `trans_start` int(11) NOT NULL default '0',
499 `trans_real` int(11) NOT NULL default '0',
500 PRIMARY KEY (`id`)
501 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
502 echo "Added table <b>z_shop_history_item</b> (shopsystem).<br/>";
503 try { $SQL->query("CREATE TABLE `z_shop_history_pacc` (
504 `id` int(11) NOT NULL auto_increment,
505 `to_name` varchar(255) NOT NULL default '0',
506 `to_account` int(11) NOT NULL default '0',
507 `from_nick` varchar(255) NOT NULL,
508 `from_account` int(11) NOT NULL default '0',
509 `price` int(11) NOT NULL default '0',
510 `pacc_days` int(11) NOT NULL default '0',
511 `trans_state` varchar(255) NOT NULL,
512 `trans_start` int(11) NOT NULL default '0',
513 `trans_real` int(11) NOT NULL default '0',
514 PRIMARY KEY (`id`)
515 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
516 echo "Added table <b>z_shop_history_pacc</b> (shopsystem).<br/>";
517 try { $SQL->query("CREATE TABLE `zaypay_payment` (
518 `payID` bigint(30) NOT NULL,
519 `account_id` int(20) NOT NULL,
520 `status` varchar(255) NOT NULL,
521 PRIMARY KEY (`payID`)
522 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
523 echo "Added table <b>zaypay_payment</b> (shopsystem).<br/>";
524 try { $SQL->query("CREATE TABLE `z_shop_points_bought` (
525 `id` INT( 15 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
526 `amount` INT( 15 ) NOT NULL ,
527 `type` VARCHAR( 255 ) NOT NULL ,
528 `accountid` INT( 15 ) NOT NULL ,
529 `code` VARCHAR( 255 ) NOT NULL ,
530 `paypalmail` VARCHAR( 255 ) NOT NULL ,
531 `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
532 ) ENGINE = MyISAM ;"); } catch(PDOException $error) {}
533 echo "Added table <b>z_shop_points_bought</b> (shopsystem).<br/><br/>";
534 try { $SQL->query("CREATE TABLE z_tracker (
535 `account` varchar(255) NOT NULL,
536 `type` int(11) NOT NULL,
537 `status` int(11) NOT NULL,
538 `text` text NOT NULL,
539 `id` int(11) NOT NULL,
540 `subject` varchar(255) NOT NULL,
541 `typetracker` int(11) NOT NULL,
542 `tag` int(11) NOT NULL,
543 `priority` int(11) NOT NULL,
544 `reply` int(11) NOT NULL,
545 `who` int(11) NOT NULL,
546 `uid` int(11) NOT NULL AUTO_INCREMENT,
547 PRIMARY KEY (uid)
548 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
549 echo "Added table <b>z_tracker</b> (support).<br/>";
550 try { $SQL->query("CREATE TABLE IF NOT EXISTS `z_changelog` (
551 `id` int(11) NOT NULL auto_increment,
552 `type` varchar(255) NOT NULL default '',
553 `where` varchar(255) NOT NULL default '',
554 `date` int(11) NOT NULL default '0',
555 `description` varchar(255) NOT NULL,
556 `hide` int(11) NOT NULL,
557 PRIMARY KEY (`id`)
558 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; "); } catch(PDOException $error) {}
559 echo "Added table <b>z_changelog</b> (support).<br/>";
560 }
561 $config['site']['install'] = 4;
562 saveconfig_ini($config['site']);
563 echo 'All tables and columns added to database.<br>Go to <a href="install.php?page=step&step=4&server_conf=yes">STEP 4 - Add samples</a>';
564 }
565 if($step == '4')
566 {
567 echo '<h1>STEP '.$step.'</h1>Add samples to DB:<br>';
568 $check_news_ticker = $SQL->query('SELECT * FROM z_news_tickers WHERE image_id = 1 AND author = 1 AND hide_ticker = 0 LIMIT 1 OFFSET 0;')->fetch();
569 if(!isset($check_news_ticker['author']))
570 {
571 $SQL->query('INSERT INTO z_news_tickers (date, author, image_id, text, hide_ticker) VALUES
572 ('.time().', 1, 1, "Gesior ACC - Xart prefix Edition installed!", 0)');
573 echo "Added first news ticker.<br/>";
574 }
575 else
576 echo "News ticker sample is already in database. New sample is not needed.<br/>";
577 $check_news = $SQL->query('SELECT * FROM z_news_big WHERE author = "Gesior" LIMIT 1 OFFSET 0')->fetch();
578 if(!isset($check_news['author']))
579 {
580 $SQL->query('INSERT INTO z_news_big (hide_news, date, author, author_id, image_id, topic_df, text_df) VALUES
581 (0, '.time().', "Xart", 1, 0, "Xart prefix Edition!", "Gesior ACC - Xart prefix Edition installed. All options should work fine. Report bugs on http://code.google.com/p/gesior-aac/issues/list.");');
582 echo "Added first news.<br/>";
583 }
584 else
585 echo "News sample is already in database. New sample is not needed.<br/>";
586 $check_voc_0 = $SQL->query('SELECT * FROM players WHERE name = "Rook Sample" LIMIT 1 OFFSET 0')->fetch();
587 if(!isset($check_voc_0['name']))
588 {
589 $SQL->query('INSERT INTO players (name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, save, skull, skulltime, rank_id, guildnick, lastlogout, blessings, balance, stamina, direction, loss_experience, loss_mana, loss_skills, loss_containers, loss_items, premend, online, marriage, promotion, deleted, description, comment, created, hide_char, nick_verify) VALUES
590 ("Rook Sample", 0, 1, 1, 1, 0, 150, 150, 0, 44, 44, 44, 44, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 430, 1, "", "", 1, "", "", "", "", "", "", "", 151200000, "", "", "", "", "", "", "", "", "", "", "", "", "",'.time().',1,1)');
591 echo "Added 'Rook Sample' character.<br/>";
592 }
593 else
594 echo "Character 'Rook Sample' already in database.<br/>";
595 $check_voc_1 = $SQL->query('SELECT * FROM players WHERE name = "Sorcerer Sample" LIMIT 1 OFFSET 0')->fetch();
596 if(!isset($check_voc_1['name']))
597 {
598 $SQL->query('INSERT INTO players (name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, save, skull, skulltime, rank_id, guildnick, lastlogout, blessings, balance, stamina, direction, loss_experience, loss_mana, loss_skills, loss_containers, loss_items, premend, online, marriage, promotion, deleted, description, comment, created, hide_char, nick_verify) VALUES
599 ("Sorcerer Sample", 0, 1, 1, 8, 1, 185, 185, 4200, 44, 44, 44, 44, 128, 0, 0, 35, 35, 0, 0, 0, 0, 0, 0, "", 470, 1, "", "", 1, "", "", "", "", "", "", "", 151200000, "", "", "", "", "", "", "", "", "", "", "", "", "",'.time().',1,1)');
600 echo "Added 'Sorcerer Sample' character.<br/>";
601 }
602 else
603 echo "Character 'Sorcerer Sample' already in database.<br/>";
604 $check_voc_2 = $SQL->query('SELECT * FROM players WHERE name = "Druid Sample" LIMIT 1 OFFSET 0')->fetch();
605 if(!isset($check_voc_2['name']))
606 {
607 $SQL->query('INSERT INTO players (name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, save, skull, skulltime, rank_id, guildnick, lastlogout, blessings, balance, stamina, direction, loss_experience, loss_mana, loss_skills, loss_containers, loss_items, premend, online, marriage, promotion, deleted, description, comment, created, hide_char, nick_verify) VALUES
608 ("Druid Sample", 0, 1, 1, 8, 2, 185, 185, 4200, 44, 44, 44, 44, 128, 0, 0, 35, 35, 0, 0, 0, 0, 0, 0, "", 470, 1, "", "", 1, "", "", "", "", "", "", "", 151200000, "", "", "", "", "", "", "", "", "", "", "", "", "",'.time().',1,1)');
609 echo "Added 'Druid Sample' character.<br/>";
610 }
611 else
612 echo "Character 'Druid Sample' already in database.<br/>";
613 $check_voc_3 = $SQL->query('SELECT * FROM players WHERE name = "Paladin Sample" LIMIT 1 OFFSET 0')->fetch();
614 if(!isset($check_voc_3['name']))
615 {
616 $SQL->query('INSERT INTO players (name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, save, skull, skulltime, rank_id, guildnick, lastlogout, blessings, balance, stamina, direction, loss_experience, loss_mana, loss_skills, loss_containers, loss_items, premend, online, marriage, promotion, deleted, description, comment, created, hide_char, nick_verify) VALUES
617 ("Paladin Sample", 0, 1, 1, 8, 3, 185, 185, 4200, 44, 44, 44, 44, 128, 0, 0, 35, 35, 0, 0, 0, 0, 0, 0, "", 470, 1, "", "", 1, "", "", "", "", "", "", "", 151200000, "", "", "", "", "", "", "", "", "", "", "", "", "",'.time().',1,1)');
618 echo "Added 'Paladin Sample' character.<br/>";
619 }
620 else
621 echo "Character 'Paladin Sample' already in database.<br/>";
622 $check_voc_4 = $SQL->query('SELECT * FROM players WHERE name = "Knight Sample" LIMIT 1 OFFSET 0')->fetch();
623 if(!isset($check_voc_4['name']))
624 {
625 $SQL->query('INSERT INTO players (name, world_id, group_id, account_id, level, vocation, health, healthmax, experience, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, maglevel, mana, manamax, manaspent, soul, town_id, posx, posy, posz, conditions, cap, sex, lastlogin, lastip, save, skull, skulltime, rank_id, guildnick, lastlogout, blessings, balance, stamina, direction, loss_experience, loss_mana, loss_skills, loss_containers, loss_items, premend, online, marriage, promotion, deleted, description, comment, created, hide_char, nick_verify) VALUES
626 ("Knight Sample", 0, 1, 1, 8, 4, 185, 185, 4200, 44, 44, 44, 44, 128, 0, 0, 35, 35, 0, 0, 0, 0, 0, 0, "", 470, 1, "", "", 1, "", "", "", "", "", "", "", 151200000, "", "", "", "", "", "", "", "", "", "", "", "", "",'.time().',1,1)');
627 echo "Added 'Knight Sample' character.<br/>";
628 }
629 else
630 echo "Character 'Knight Sample' already in database.<br/>";
631 $config['site']['install'] = 5;
632 saveconfig_ini($config['site']);
633 echo 'All samples added to database. Now you can go to <a href="install.php?page=step&step=5&server_conf=yes">STEP 5 - Set Admin Account</a><br/>';
634 }
635 if($step == '5')
636 {
637 echo '<h1>STEP '.$step.'</h1>Set Admin Account<br>';
638 $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
639 if(empty($_REQUEST['saveaccpassword']))
640 {
641 echo 'Admin account number is: <b>1</b><br/>Set new password to this account.<br>';
642 echo 'New password: <form action="install.php" method=POST><input type="text" name="newpass" size="35">(Don\'t give it password to anyone!)';
643 echo '<input type="hidden" name="saveaccpassword" value="yes"><input type="hidden" name="page" value="step"><input type="hidden" name="step" value="5"><input type="submit" value="SET"></form><br>If account with number 1 doesn\'t exist installator will create it and set your password.';
644 }
645 else
646 {
647 $newpass = $_POST['newpass'];
648 if(!check_password($newpass))
649 echo 'Password contains illegal characters. Please use only a-Z and 0-9. <a href="install.php?page=step&step=5&server_conf=yes">GO BACK</a> and write other password.';
650 else
651 {
652 $newpass_to_db = password_ency($newpass);
653 $account = new OTS_Account();
654 $account->load(1);
655 if($account->isLoaded())
656 {
657 $account->setPassword($newpass_to_db);
658 $account->save();
659 $account->setCustomField("page_access", 6);
660 }
661 else
662 {
663 $number = $account->create(1,1);
664 $account->setPassword($newpass_to_db);
665 $account->unblock();
666 $account->save();
667 $account->setCustomField("page_access", 6);
668 }
669 $_SESSION['account'] = 1;
670 $_SESSION['password'] = $newpass;
671 $logged = TRUE;
672 $account->setCustomField("page_lastday", time());
673 echo '<h1>Admin account number: 1<br>Admin account password: '.$_POST['newpass'].'</h1>';
674 $config['site']['install'] = 'no';
675 saveconfig_ini($config['site']);
676 }
677 }
678 }
679 }
680 else
681 {
682 echo "Account maker is already installed! To reinstall open file 'config.ini' in directory 'config' and change:<br/><b>install = \"no\"</b><br/>to:</br><b>install = \"start\"</b><br/>and enter this site again.";
683 }
684}
685?>