<?php
- include ('mysql.php');
+include ('mysql.php');
-$query = "CREATE Table `players` (`name` text, `level` int NOT NULL default 1, `exp` bigint NOT NULL default 0, `gold` bigint NOT NULL default 0, `bank` bigint NOT NULL default 0, `hp` int NOT NULL default 0, `maxhp` int NOT NULL default 0, `strength` int NOT NULL default 0, `defense` int NOT NULL default 0, `forestfights` int NOT NULL default 0, `playerfights` int NOT NULL default 0, `lastlogin` text, `weapon` text NOT NULL, `armor` text NOT NULL, PRIMARY KEY (`name`(255))) ENGINE=InnoDB DEFAULT CHARSET=latin1";
+$query = "CREATE Table `$itemtablename` (`id` bigint NOT NULL auto_increment, `name` text NOT NULL, `price` bigint NOT NULL default 0, `uses` int NOT NULL, `strengthmod` int NOT NULL default 0, `defensemod` int NOT NULL default 0, `maxhpmod` int NOT NULL default 0, `hpmod` int NOT NULL default 0, `forestfightsmod` int NOT NULL default 0, `playerfightsmod` int NOT NULL default 0, `goldmod` bigint NOT NULL default 0, `bankbalmod` bigint NOT NULL default 0, PRIMARY KEY (`id`)) ENGINE=InnoDB";
+
+mysql_query($query) or die("Couldn't create table $itemtablename: " . mysql_error());
+
+echo "Item table created.<br>";
+
+$query = "CREATE Table `$playertablename` (`name` text, `level` int NOT NULL default 1, `exp` bigint NOT NULL default 0, `gold` bigint NOT NULL default 0, `bank` bigint NOT NULL default 0, `hp` int NOT NULL default 0, `maxhp` int NOT NULL default 0, `strength` int NOT NULL default 0, `defense` int NOT NULL default 0, `forestfights` int NOT NULL default 0, `playerfights` int NOT NULL default 0, `lastlogin` text, `weaponID` bigint NOT NULL default 0, `armorID` bigint NOT NULL default 0, PRIMARY KEY (`name`(255)), KEY `weaponID` (`weaponID`), KEY `armorID` (`armorID`), CONSTRAINT `" . $playertablename . "_ibfk_1` FOREIGN KEY (`weaponID`) REFERENCES $itemtablename(`id`), CONSTRAINT `" . $playertablename . "_ibfk_2` FOREIGN KEY (`armorID`) REFERENCES $itemtablename(`id`)) ENGINE=InnoDB";
+
+echo "\n $query \n";
+mysql_query($query) or die("Couldn't create table $playertablename: " . mysql_error());
+
+echo "Player table created.<br>";
+
+echo '<a href="readdata.php">Click here to import the data into mysql</a>';
?>
\ No newline at end of file
<?php
include ('config.php');
- $link = mysql_connect("$mysqlhost", "$mysqluser", "$mysqlpassword") or die ('Couldn't connect: ' . mysql_error());
+ $link = mysql_connect("$mysqlhost", "$mysqluser", "$mysqlpassword") or die ("Couldn't connect: " . mysql_error());
mysql_select_db("$mysqldatabase") or die ('Could not select database: ' . mysql_error());
?>
\ No newline at end of file
--- /dev/null
+<?php
+include('readitems.php');
+include('readplayers.php');
+?>
\ No newline at end of file
--- /dev/null
+<?php
+$include ('mysql.php');
+// type~ID~name~price~uses~strengthmod~defensemod~maxhpmod~hpmod~forestfightsmod~playerfightsmod~goldmod~bankbalmod
+
+$handle = @fopen("$itemdata", "r");
+if ($handle) {
+ while (!feof($handle)) {
+ $buffer = fgets($handle, 4096);
+ $item = explode(" ", $buffer, 13);
+ $id = $item[1];
+ $name = $item[2];
+ $price = $item[3];
+ $uses = $item[4];
+ $strengthmod = $item[5];
+ $defensemod = $item[6];
+ $maxhpmod = $item[7];
+ $hpmod = $item[8];
+ $forestfightsmod = $item[9];
+ $playerfightsmod = $item[10];
+ $goldmod = $item[11];
+ $bankbalmod = $item[12];
+ $query = "insert into $itemtablename values ('$id', '$name', '$price', '$uses', '$strengthmod', '$defensemod', '$maxhpmod', '$hpmod', '$forestfightsmod', '$playerfightsmod', '$goldmod', '$bankbalmod')";
+ mysql_query($query);
+ }
+ mysql_close($link);
+ fclose($handle);
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+$handle = @fopen("$playerdata", "r");
+if ($handle) {
+ while (!feof($handle)) {
+ $buffer = fgets($handle, 4096);
+ $player = explode(" ", $buffer, 16);
+ $player_name = $player[0];
+ $player_level = $player[1];
+ $player_exp = $player[2];
+ $player_gold = $player[3];
+ $player_bank = $player[4];
+ $player_hp = $player[5];
+ $player_maxhp = $player[6];
+ $player_strength = $player[7];
+ $player_defense = $player[8];
+ $player_forestfights = $player[9];
+ $player_playerfights = $player[10];
+ $player_lastlogin = $player[13];
+ $player_weaponnum = $player[14];
+ $player_armornum = $player[15];
+ }
+ fclose($handle);
+ mysql_close($link);
+}
+?>