Jelajahi Sumber

add hreflang

sark 1 bulan lalu
induk
melakukan
fcc7e11ae6
4 mengubah file dengan 81 tambahan dan 23 penghapusan
  1. 0 11
      bin/migrate.php
  2. 1 1
      public/index.php
  3. 63 7
      resources/view/admin/index_new.php
  4. 17 4
      src/Pages/page.php

+ 0 - 11
bin/migrate.php

@@ -121,17 +121,6 @@ try {
         ['grupa' => 'styles', 'name' => 'burger-color2', 'value' => '#ffffff'],
 
         // SEO settings
-        ['grupa' => 'seo', 'name' => 'title', 'value' => 'Amazing Casino - Best Online Gaming Experience 2024'],
-        ['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.'],
-        ['grupa' => 'seo', 'name' => 'keywords', 'value' => 'online casino, casino games, slots, blackjack, poker, roulette, bonuses, secure gaming'],
-        ['grupa' => 'seo', 'name' => 'canonical', 'value' => 'https://amazing-casino.com'],
-        ['grupa' => 'seo', 'name' => 'og-type', 'value' => 'website'],
-        ['grupa' => 'seo', 'name' => 'og-title', 'value' => 'Amazing Casino - Win Big with Our Casino Games'],
-        ['grupa' => 'seo', 'name' => 'og-description', 'value' => 'Experience the thrill of premium casino games with Amazing Casino. Get your 200% welcome bonus today!'],
-        ['grupa' => 'seo', 'name' => 'og-locale', 'value' => 'en_US'],
-        ['grupa' => 'seo', 'name' => 'og-image', 'value' => 'media/og-image.jpg'],
-        ['grupa' => 'seo', 'name' => 'lang', 'value' => 'en'],
-        ['grupa' => 'seo', 'name' => 'lang-page', 'value' => 'en-US'],
         ['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/"}]'],
     ];
     

+ 1 - 1
public/index.php

@@ -4,7 +4,7 @@ require dirname(__FILE__, 2).'/vendor/autoload.php';
 //route
 $requestUri = $_GET['p'] ?? parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
 $page = match (true) {
-  ('/' === $requestUri) => 'home.php',
+  ('/' === $requestUri) => 'page.php',
   ('/admin/' === $requestUri) => 'admin/index.php',
   ('/admin/pages/' === $requestUri) => 'admin/pages.php',
   ('/admin/slots/' === $requestUri) => 'admin/slots.php',

+ 63 - 7
resources/view/admin/index_new.php

@@ -425,13 +425,69 @@ ob_start();
 
                         <!-- SEO Tab -->
                         <div x-show="activeTab === 'seo'" class="bg-white rounded-lg shadow-sm">
-                            <div class="p-6">
-                                <div class="text-center py-12">
-                                    <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
-                                    </svg>
-                                    <h3 class="mt-2 text-sm font-medium text-gray-900">SEO Coming Soon</h3>
-                                    <p class="mt-1 text-sm text-gray-500">SEO settings will be implemented in the next update.</p>
+                            <div class="p-6 space-y-8">
+
+                                <!-- Hreflang Settings -->
+                                <div x-data="{ 
+                                    hreflangs: <?= htmlspecialchars(json_encode(isset($seo['hreflang']) ? json_decode($seo['hreflang'], true) ?: [] : []), ENT_QUOTES, 'UTF-8') ?>,
+                                    addHreflang() {
+                                        this.hreflangs.push({hreflang: '', href: ''});
+                                    },
+                                    removeHreflang(index) {
+                                        this.hreflangs.splice(index, 1);
+                                    }
+                                }">
+                                    <h3 class="text-lg font-medium text-gray-900 mb-6 flex items-center">
+                                        <svg class="w-5 h-5 mr-2 text-blue-600" fill="currentColor" viewBox="0 0 20 20">
+                                            <path fill-rule="evenodd" d="M7 2a1 1 0 011 1v1h3a1 1 0 110 2H9.578a18.87 18.87 0 01-1.724 4.78c.29.354.596.696.914 1.026a1 1 0 11-1.44 1.389c-.188-.196-.373-.396-.554-.6a18.9 18.9 0 01-2.62 3.624 1 1 0 11-1.44-1.389A16.9 16.9 0 003.578 8H2a1 1 0 110-2h2.578c.15-.667.34-1.32.578-1.96A1 1 0 015.5 4c.76 0 1.5.11 2.5.342V3a1 1 0 011-1zm1.578 6H7.422c.12.456.264.903.428 1.34.164-.437.308-.884.428-1.34zM17 6a3 3 0 11-6 0 3 3 0 016 0z" clip-rule="evenodd"/>
+                                        </svg>
+                                        Hreflang Settings
+                                    </h3>
+                                    
+                                    <!-- Hidden input to store JSON data -->
+                                    <input type="hidden" name="seo[hreflang]" x-bind:value="JSON.stringify(hreflangs)">
+                                    
+                                    <div class="space-y-4">
+                                        <template x-for="(item, index) in hreflangs" :key="index">
+                                            <div class="flex gap-4 items-end">
+                                                <div class="flex-1">
+                                                    <label class="block text-sm font-medium text-gray-700 mb-2">Language Code</label>
+                                                    <input type="text" x-model="item.hreflang" placeholder="en, ru, de, x-default" 
+                                                           class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+                                                </div>
+                                                <div class="flex-2">
+                                                    <label class="block text-sm font-medium text-gray-700 mb-2">URL</label>
+                                                    <input type="url" x-model="item.href" placeholder="https://example.com/en/" 
+                                                           class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+                                                </div>
+                                                <button type="button" @click="removeHreflang(index)" 
+                                                        class="px-3 py-2 text-red-600 hover:text-red-800 border border-red-300 hover:border-red-500 rounded-md transition-colors">
+                                                    <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
+                                                        <path fill-rule="evenodd" d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z" clip-rule="evenodd"/>
+                                                        <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
+                                                    </svg>
+                                                </button>
+                                            </div>
+                                        </template>
+                                        
+                                        <button type="button" @click="addHreflang()" 
+                                                class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
+                                            <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                                                <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd"/>
+                                            </svg>
+                                            Add Hreflang
+                                        </button>
+                                    </div>
+                                </div>
+
+                                <!-- Save Button -->
+                                <div class="pt-6 border-t border-gray-200">
+                                    <button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
+                                        <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
+                                            <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
+                                        </svg>
+                                        Save Settings
+                                    </button>
                                 </div>
                             </div>
                         </div>

+ 17 - 4
src/Pages/page.php

@@ -13,8 +13,14 @@ $faqModel = new Faq();
 // Получаем slug из URL
 $slug = $slug ?? $_GET['slug'] ?? '';
 
-// Находим страницу по slug
-$currentPage = \db()->fetchOne("SELECT * FROM pages WHERE slug = ? AND is_homepage = 0", [$slug]);
+// Находим страницу по slug или главную страницу если slug пустой
+if (empty($slug)) {
+    // Главная страница
+    $currentPage = \db()->fetchOne("SELECT * FROM pages WHERE is_homepage = 1");
+} else {
+    // Обычная страница по slug
+    $currentPage = \db()->fetchOne("SELECT * FROM pages WHERE slug = ?", [$slug]);
+}
 
 // Если страница не найдена, возвращаем 404
 if (!$currentPage) {
@@ -43,7 +49,14 @@ $currentUrl = getCurrentUrl();
 
 // Определение типа пользователя
 $ip = getUserIp();
-$isSearchBot = preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'] ?? '');
+$isGoogleBot = (strpos($host, 'google') !== false)
+    ? true
+    : false;
+$isBingBot = (strpos($host, 'bing') !== false)
+    ? true
+    : false;
+
+$isSearchBot = $isGoogleBot || $isBingBot;
 
 // Определяем лейаут страницы
 $layout = \App\Enums\PageLayout::tryFrom($currentPage['layout'] ?? 'default') ?? \App\Enums\PageLayout::Default;
@@ -58,7 +71,7 @@ return ViewRender($layoutFile, [
     'topContent' => $topContent,
     'currentDomain' => $currentDomain,
     'currentUrl' => $currentUrl,
-    'isHomepage' => false,
+    'isHomepage' => !empty($currentPage['is_homepage']),
     'isSearchBot' => $isSearchBot,
     'userIp' => $ip,
 ]);