Guest User

Auto installer

a guest
May 16th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. <?php
  2. echo 'The config setup is for Kitsune AS2 only!';
  3.  
  4. //config starts.
  5. $answers = array(
  6. 'yes'
  7. );
  8. $no = array(
  9. 'no'
  10. );
  11. echo "Enter Database Host: ";
  12. $dbhost = ' ';
  13. echo "Enter Database Username: ";
  14. $dbUser = ' ';
  15. echo "Enter Database Password: ";
  16. $dbPass = ' ';
  17. echo "Enter Database Name: ";
  18. $dbName = ' ';
  19.  
  20. if ($dbPass == "") {
  21. echo "Without db pass? Omg, please setup a password for your db.";
  22. }
  23.  
  24. if ($dbName == "") {
  25. echo "Um, please provide a database for the script.";
  26. }
  27.  
  28. if (strlen($dbPass) < 5) {
  29. echo "Um, please use a strong password.";
  30. }
  31.  
  32. $con = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName);
  33. $conan = ' ';
  34.  
  35. if (!con) {
  36. echo "Oops! We couldn't connect to the database..\n";
  37. } else {
  38. $xml = new DOMDocument('1.0', 'utf-8');
  39. $xml->formatOutput = true;
  40. $xml->preserveWhiteSpace = false;
  41. $xml->load('Database.xml');
  42.  
  43. $element = $xml->getElementsByTagName('Database');
  44.  
  45. $address = $element->getElementsByTagName('address');
  46. $username = $element->getElementsByTagName('username');
  47. $password = $element->getElementsByTagName('password');
  48. $name = $element->getElementsByTagName('name');
  49.  
  50. $element->replaceChild($address, $dbhost);
  51. $element->replaceChild($username, $dbUser);
  52. $element->replaceChild($password, $dbPass);
  53. $element->replaceChild($name, $dbName);
  54. }
  55.  
  56. if (in_array($conan, $answers)) {
  57. $xml = new DOMDocument('1.0', 'utf-8');
  58. $xml->formatOutput = true;
  59. $xml->preserveWhiteSpace = false;
  60. $xml->load('Database.xml');
  61.  
  62. $element = $xml->getElementsByTagName('Database');
  63.  
  64. $address = $element->getElementsByTagName('address');
  65. $username = $element->getElementsByTagName('username');
  66. $password = $element->getElementsByTagName('password');
  67. $name = $element->getElementsByTagName('name');
  68.  
  69. $element->replaceChild($address, $dbhost);
  70. $element->replaceChild($username, $dbUser);
  71. $element->replaceChild($password, $dbPass);
  72. $element->replaceChild($name, $dbName);
  73. }
  74.  
  75. if (in_array($conan, $no)) {
  76. die("Shutting down configuration...");
  77. }
  78.  
  79. if ($con) {
  80. echo "Almost done!\n";
  81. echo "Would you like us to setup the database?";
  82. $answer = ' ';
  83. mysqli_query('CREATE DATABASE IF NOT EXISTS ' . $dbName . '') or die(mysqli_error());
  84. mysqli_query('USE ' . $dbName . '');
  85. mysqli_query("CREATE TABLE IF NOT EXISTS `bans` (
  86. `ID` int(11) NOT NULL AUTO_INCREMENT,
  87. `Moderator` char(12) NOT NULL,
  88. `Player` int(11) unsigned NOT NULL,
  89. `Comment` text NOT NULL,
  90. `Expiration` int(8) NOT NULL,
  91. `Time` int(8) NOT NULL,
  92. `Type` smallint(3) unsigned NOT NULL
  93. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;") or die(mysqli_error());
  94.  
  95. mysqli_query("CREATE TABLE IF NOT EXISTS `igloos` (
  96. `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  97. `Owner` int(10) unsigned NOT NULL,
  98. `Type` tinyint(3) unsigned NOT NULL DEFAULT '1',
  99. `Floor` tinyint(3) unsigned NOT NULL DEFAULT '0',
  100. `Music` smallint(6) NOT NULL DEFAULT '0',
  101. `Furniture` text NOT NULL,
  102. `Locked` tinyint(1) NOT NULL DEFAULT '1'
  103. ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1") or die(mysqli_error());
  104.  
  105. mysqli_query("CREATE TABLE IF NOT EXISTS `penguins` (
  106. `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  107. `Username` char(12) NOT NULL,
  108. `Nickname` char(16) NOT NULL,
  109. `Password` char(32) NOT NULL,
  110. `LoginKey` char(32) NOT NULL,
  111. `Email` char(254) NOT NULL,
  112. `RegistrationDate` int(8) NOT NULL,
  113. `Moderator` tinyint(1) NOT NULL DEFAULT '0',
  114. `Inventory` text NOT NULL,
  115. `Coins` mediumint(7) unsigned NOT NULL DEFAULT '500',
  116. `Igloo` int(10) unsigned NOT NULL COMMENT 'Current active igloo',
  117. `Igloos` text NOT NULL COMMENT 'Owned igloo types',
  118. `Furniture` text NOT NULL COMMENT 'Furniture inventory',
  119. `Color` tinyint(3) unsigned NOT NULL DEFAULT '1',
  120. `Head` smallint(5) unsigned NOT NULL DEFAULT '0',
  121. `Face` smallint(5) unsigned NOT NULL DEFAULT '0',
  122. `Neck` smallint(5) unsigned NOT NULL DEFAULT '0',
  123. `Body` smallint(5) unsigned NOT NULL DEFAULT '0',
  124. `Hand` smallint(5) unsigned NOT NULL DEFAULT '0',
  125. `Feet` smallint(5) unsigned NOT NULL DEFAULT '0',
  126. `Photo` smallint(5) unsigned NOT NULL DEFAULT '0',
  127. `Flag` smallint(5) unsigned NOT NULL DEFAULT '0',
  128. `Walking` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Puffle ID',
  129. `Banned` varchar(20) NOT NULL DEFAULT '0' COMMENT 'Timestamp of ban',
  130. `Stamps` text NOT NULL,
  131. `StampBook` varchar(150) NOT NULL DEFAULT '1%1%-1%1',
  132. `EPF` varchar(9) NOT NULL DEFAULT '0,0,0',
  133. `Buddies` text NOT NULL,
  134. `Ignores` text NOT NULL,
  135. `MinutesPlayed` int(11) NOT NULL
  136. ) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;") or die(mysqli_error());
  137.  
  138. mysqli_query("CREATE TABLE IF NOT EXISTS `postcards` (
  139. `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  140. `Recipient` int(10) unsigned NOT NULL,
  141. `SenderName` char(12) NOT NULL,
  142. `SenderID` int(10) unsigned NOT NULL,
  143. `Details` varchar(12) NOT NULL,
  144. `Date` int(8) NOT NULL,
  145. `Type` smallint(5) unsigned NOT NULL,
  146. `HasRead` tinyint(1) NOT NULL DEFAULT '0'
  147. ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;") or die(mysqli_error());
  148.  
  149. mysqli_query("CREATE TABLE IF NOT EXISTS `puffles` (
  150. `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  151. `Owner` int(10) unsigned NOT NULL,
  152. `Name` char(12) NOT NULL,
  153. `AdoptionDate` int(8) NOT NULL,
  154. `Type` tinyint(3) unsigned NOT NULL,
  155. `Food` tinyint(3) unsigned NOT NULL DEFAULT '100',
  156. `Play` tinyint(3) unsigned NOT NULL DEFAULT '100',
  157. `Rest` tinyint(3) unsigned NOT NULL DEFAULT '100',
  158. `Walking` int(11) NOT NULL
  159. ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;") or die(mysqli_error());
  160.  
  161. mysqli_query("INSERT INTO `puffles` (`ID`, `Owner`, `Name`, `AdoptionDate`, `Type`, `Food`, `Play`, `Rest`, `Walking`) VALUES
  162. (3, 101, 'Blue', 1453750614, 0, 100, 100, 100, 0),
  163. (4, 101, 'Blue', 1453752421, 0, 100, 100, 100, 0),
  164. (5, 101, 'Red', 1453753127, 5, 100, 100, 100, 1),
  165. (6, 101, 'Yellow', 1453753887, 6, 100, 100, 100, 0),
  166. (7, 101, 'Pink', 1453829330, 1, 100, 100, 100, 0),
  167. (8, 101, 'Purple', 1454159945, 4, 100, 100, 100, 0);") or die(mysqli_error());
  168.  
  169. echo "The database is now setup!";
  170. } else {
  171. die("The configuration file has been written, but we were not able to give you\n the option of setting up your database because the connection failed!");
  172. }
  173. ?>
Add Comment
Please, Sign In to add comment