migrate.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Database Migration Script
  4. * This file contains all database table creation scripts
  5. * Each table is checked for existence before creation
  6. */
  7. require_once __DIR__ . '/../vendor/autoload.php';
  8. try {
  9. $db = db();
  10. echo "Starting database migration...\n";
  11. // Migration: Create settings table
  12. $settingsTableSQL = "
  13. CREATE TABLE IF NOT EXISTS settings (
  14. id INTEGER PRIMARY KEY AUTOINCREMENT,
  15. grupa VARCHAR(255) NOT NULL,
  16. name VARCHAR(255) NOT NULL,
  17. value TEXT
  18. )";
  19. $db->execute($settingsTableSQL);
  20. echo " Settings table checked/created\n";
  21. // Create index for settings table
  22. $settingsIndexSQL = "CREATE INDEX IF NOT EXISTS idx_settings_grupa_name ON settings(grupa, name)";
  23. $db->execute($settingsIndexSQL);
  24. echo " Settings table index checked/created\n";
  25. // Insert default settings if they don't exist
  26. $defaultSettings = [
  27. // Content settings
  28. ['grupa' => 'content', 'name' => 'title', 'value' => 'Welcome to Amazing Casino - Your Ultimate Gaming Destination'],
  29. ['grupa' => 'content', 'name' => 'top_text', 'value' => '<h2>Best Online Casino Experience</h2><p>Discover the most exciting online casino games with amazing bonuses and instant payouts!</p>'],
  30. ['grupa' => 'content', 'name' => 'bottom_text', 'value' => '<p>Join thousands of players who trust our platform for secure gaming. Play responsibly and enjoy the thrill of winning big!</p>'],
  31. ['grupa' => 'content', 'name' => 'author-name', 'value' => 'John Smith'],
  32. ['grupa' => 'content', 'name' => 'modified-date', 'value' => '2024-01-15'],
  33. ['grupa' => 'content', 'name' => 'login', 'value' => 'Login Now'],
  34. ['grupa' => 'content', 'name' => 'password', 'value' => 'Reset Password'],
  35. ['grupa' => 'content', 'name' => 'faq-title', 'value' => 'Frequently Asked Questions'],
  36. ['grupa' => 'content', 'name' => 'footer__text', 'value' => 'Your trusted casino partner since 2020. Licensed and regulated for your safety.'],
  37. ['grupa' => 'content', 'name' => 'copyright', 'value' => '© 2024 Amazing Casino. All rights reserved.'],
  38. ['grupa' => 'content', 'name' => 'review-count', 'value' => '1250'],
  39. ['grupa' => 'content', 'name' => 'listing', 'value' => 'Top Rated Casinos'],
  40. ['grupa' => 'content', 'name' => 'content_btn', 'value' => 'Play Now'],
  41. ['grupa' => 'content', 'name' => 'hide-btns', 'value' => '0'],
  42. ['grupa' => 'content', 'name' => 'header-logo', 'value' => '{"src":"uploads/logo.png","title":"Amazing Casino Logo","alt":"Amazing Casino - Best Online Gaming"}'],
  43. ['grupa' => 'content', 'name' => 'banner-logo', 'value' => '{"src":"uploads/banner.jpg","title":"Welcome Bonus Banner","alt":"Get 200% Welcome Bonus","width":"800","height":"400"}'],
  44. ['grupa' => 'content', 'name' => 'footer-logo', 'value' => '{"src":"uploads/footer-logo.png","title":"Footer Logo","alt":"Amazing Casino Footer"}'],
  45. ['grupa' => 'content', 'name' => 'favicon', 'value' => 'uploads/favicon.ico'],
  46. ['grupa' => 'content', 'name' => 'author-img', 'value' => 'uploads/author.jpg'],
  47. ['grupa' => 'content', 'name' => 'hash', 'value' => 'ac123main'],
  48. ['grupa' => 'content', 'name' => 'hash-1', 'value' => 'ac123promo'],
  49. ['grupa' => 'content', 'name' => 'hash-2', 'value' => 'ac123bonus'],
  50. ['grupa' => 'content', 'name' => 'hash-3', 'value' => 'ac123games'],
  51. ['grupa' => 'content', 'name' => 'hash-4', 'value' => 'ac123vip'],
  52. ['grupa' => 'content', 'name' => 'hash-5', 'value' => 'ac123support'],
  53. ['grupa' => 'content', 'name' => 'casino_list', 'value' => '[{"heading":"Royal Casino","text":"200% Welcome Bonus + 50 Free Spins","button":"Claim Bonus","rating":"10"},{"heading":"Golden Palace","text":"100% Match Bonus up to $500","button":"Play Now","rating":"9.5"},{"heading":"Diamond Club","text":"$1000 Welcome Package + VIP Treatment","button":"Join VIP","rating":"9"}]'],
  54. ['grupa' => 'content', 'name' => 'faq', 'value' => '[{"question":"How do I create an account?","answer":"Click the Register button and fill in your details. Verification usually takes 5-10 minutes."},{"question":"What payment methods do you accept?","answer":"We accept credit cards, e-wallets, bank transfers, and cryptocurrencies."},{"question":"How long do withdrawals take?","answer":"Most withdrawals are processed within 24 hours."}]'],
  55. ['grupa' => 'content', 'name' => 'menu', 'value' => '[{"title":"Home","anchor":"#home"},{"title":"Games","anchor":"#games"},{"title":"Bonuses","anchor":"#bonuses"},{"title":"Reviews","anchor":"#reviews"},{"title":"Contact","anchor":"#contact"}]'],
  56. // Style settings
  57. ['grupa' => 'styles', 'name' => 'main_color', 'value' => '#1a1a2e'],
  58. ['grupa' => 'styles', 'name' => 'secondary_color', 'value' => '#16213e'],
  59. ['grupa' => 'styles', 'name' => 'accent_color', 'value' => '#e94560'],
  60. ['grupa' => 'styles', 'name' => 'font_color', 'value' => '#ffffff'],
  61. ['grupa' => 'styles', 'name' => 'hover_link_color', 'value' => '#f39c12'],
  62. ['grupa' => 'styles', 'name' => 'main-fz', 'value' => 'Arial, sans-serif'],
  63. ['grupa' => 'styles', 'name' => 'footer_color', 'value' => '#0f0f23'],
  64. ['grupa' => 'styles', 'name' => 'link_color', 'value' => '#3498db'],
  65. ['grupa' => 'styles', 'name' => 'header_color', 'value' => '#2c2c54'],
  66. ['grupa' => 'styles', 'name' => 'login_btn_color', 'value' => '#27ae60'],
  67. ['grupa' => 'styles', 'name' => 'pass_btn_color', 'value' => '#e74c3c'],
  68. ['grupa' => 'styles', 'name' => 'table', 'value' => '#ecf0f1'],
  69. ['grupa' => 'styles', 'name' => 'caption', 'value' => '#bdc3c7'],
  70. ['grupa' => 'styles', 'name' => 'faq-title-font-color', 'value' => '#2c3e50'],
  71. ['grupa' => 'styles', 'name' => 'faq-title-hover-font-color', 'value' => '#e94560'],
  72. ['grupa' => 'styles', 'name' => 'burger-color', 'value' => '#ffffff'],
  73. // SEO settings
  74. ['grupa' => 'seo', 'name' => 'title', 'value' => 'Amazing Casino - Best Online Gaming Experience 2024'],
  75. ['grupa' => 'seo', 'name' => 'description', 'value' => 'Join Amazing Casino for the ultimate online gaming experience. Enjoy 200+ games, generous bonuses, and secure payments. Licensed and trusted worldwide.'],
  76. ['grupa' => 'seo', 'name' => 'keywords', 'value' => 'online casino, casino games, slots, blackjack, poker, roulette, bonuses, secure gaming'],
  77. ['grupa' => 'seo', 'name' => 'canonical', 'value' => 'https://amazing-casino.com'],
  78. ['grupa' => 'seo', 'name' => 'og-type', 'value' => 'website'],
  79. ['grupa' => 'seo', 'name' => 'og-title', 'value' => 'Amazing Casino - Win Big with Our Casino Games'],
  80. ['grupa' => 'seo', 'name' => 'og-description', 'value' => 'Experience the thrill of premium casino games with Amazing Casino. Get your 200% welcome bonus today!'],
  81. ['grupa' => 'seo', 'name' => 'og-locale', 'value' => 'en_US'],
  82. ['grupa' => 'seo', 'name' => 'og-image', 'value' => 'uploads/og-image.jpg'],
  83. ['grupa' => 'seo', 'name' => 'lang', 'value' => 'en'],
  84. ['grupa' => 'seo', 'name' => 'lang-page', 'value' => 'en-US'],
  85. ['grupa' => 'seo', 'name' => 'hreflang', 'value' => '[{"hreflang":"en","href":"https://amazing-casino.com/en/"},{"hreflang":"es","href":"https://amazing-casino.com/es/"},{"hreflang":"fr","href":"https://amazing-casino.com/fr/"},{"hreflang":"x-default","href":"https://amazing-casino.com/"}]'],
  86. ];
  87. foreach ($defaultSettings as $setting) {
  88. $exists = $db->fetchOne(
  89. "SELECT id FROM settings WHERE grupa = ? AND name = ?",
  90. [$setting['grupa'], $setting['name']]
  91. );
  92. if (!$exists) {
  93. $db->execute(
  94. "INSERT INTO settings (grupa, name, value) VALUES (?, ?, ?)",
  95. [$setting['grupa'], $setting['name'], $setting['value']]
  96. );
  97. echo "✓ Default setting {$setting['grupa']}.{$setting['name']} created\n";
  98. }
  99. }
  100. echo "Migration completed successfully!\n";
  101. } catch (Exception $e) {
  102. echo " Migration failed: " . $e->getMessage() . "\n";
  103. exit(1);
  104. }