install.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. include 'config.php';
  3. $sql = "CREATE TABLE Images (
  4. Link TEXT NOT NULL,
  5. Unlocked TINYINT(1) NOT NULL,
  6. Uploader INT(11) NOT NULL,
  7. License TEXT NOT NULL DEFAULT 'CC BY SA 4.0',
  8. Alt TEXT NOT NULL,
  9. ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY
  10. )";
  11. if ($conn->query($sql) === TRUE) {
  12. echo "Success!";
  13. } else {
  14. echo "Error creating table: " . $conn->error;
  15. }
  16. $sql = "CREATE TABLE Log (
  17. User TEXT NOT NULL,
  18. IP TEXT NOT NULL,
  19. Input LONGTEXT NOT NULL,
  20. Date INT(11) NOT NULL,
  21. ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY
  22. )";
  23. if ($conn->query($sql) === TRUE) {
  24. echo "Success! 2";
  25. } else {
  26. echo "Error creating table: " . $conn->error;
  27. }
  28. $sql = "CREATE TABLE stor (
  29. Name TEXT NOT NULL,
  30. Text LONGTEXT NOT NULL,
  31. Options TEXT NOT NULL,
  32. Description TEXT NOT NULL,
  33. Image INT(11) NOT NULL,
  34. Owner INT(11) NOT NULL,
  35. Open INT(11) NOT NULL,
  36. RefID BIGINT NOT NULL,
  37. OpenAddLinks TINYINT(4) NOT NULL,
  38. OpenRemoveLinks TINYINT(4) NOT NULL,
  39. OpenImage TINYINT(4) NOT NULL,
  40. ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY
  41. )";
  42. if ($conn->query($sql) === TRUE) {
  43. echo "Success! 3";
  44. } else {
  45. echo "Error creating table: " . $conn->error;
  46. }
  47. $sql = "CREATE TABLE Stories (
  48. ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  49. Title TEXT NOT NULL,
  50. Opener BIGINT NOT NULL,
  51. Description TEXT NOT NULL,
  52. Owner INT(11) NOT NULL
  53. )";
  54. if ($conn->query($sql) === TRUE) {
  55. echo "Success! 4";
  56. } else {
  57. echo "Error creating table: " . $conn->error;
  58. }
  59. $sql = "CREATE TABLE Users (
  60. Name TEXT NOT NULL,
  61. Password TEXT NOT NULL,
  62. Level INT(11) NOT NULL,
  63. ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY
  64. )";
  65. if ($conn->query($sql) === TRUE) {
  66. echo "Success! 2";
  67. } else {
  68. echo "Error creating table: " . $conn->error;
  69. }
  70. $sql = "INSERT INTO Users (Name, Password, Level) VALUES (?, ?, ?)";
  71. $stmt = $conn->prepare($sql);
  72. $in1="root";
  73. $PW=bin2hex(openssl_random_pseudo_bytes(4));
  74. $in2=password_hash($PW, PASSWORD_DEFAULT);
  75. $in3='3';
  76. $stmt->bind_param("ssi", $in1, $in2, $in3);
  77. $stmt->execute();
  78. echo "<br><br> Admin account created: Name: root, PW: " . $PW;
  79. ?>