| Server IP : 188.114.96.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/admin/ |
Upload File : |
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/functions.php';
require_admin_role();
require_once dirname(__DIR__).'/includes/polana_indexnow.php';
header('Cache-Control: private, no-store');
$installed = pin77_tables_exist();
$message = ''; $isError = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
try {
if (!$installed) throw new RuntimeException('Najpierw uruchom instalator V17.7.');
$action = (string)($_POST['action'] ?? '');
if ($action === 'settings') {
$enabled = !empty($_POST['enabled']) ? '1':'0';
db()->prepare("INSERT INTO settings (setting_key,setting_value) VALUES ('polana_indexnow_enabled',?) ON DUPLICATE KEY UPDATE setting_value=VALUES(setting_value)")
->execute([$enabled]);
$message = $enabled==='1'?'IndexNow włączony.':'IndexNow wyłączony.';
} elseif ($action === 'sitemap') {
if (!pin77_enabled()) throw new RuntimeException('Najpierw włącz IndexNow i zapisz.');
$r = pin77_import_sitemap();
$message = 'Przejrzano mapę: '.$r['accepted'].' adresów prawidłowych, '.$r['rejected'].' pominiętych. Nowe adresy trafiły do kolejki.';
} elseif ($action === 'submit') {
$r=pin77_send_queue(25);
$message = 'Wysłano '.$r['count'].' adresów. HTTP '.($r['http'] ?? '—').'. '.$r['message'];
if ($r['count']>0 && !in_array($r['http'],[200,202],true)) $isError=true;
} elseif ($action === 'add') {
$lines=preg_split('/\R/u', trim((string)($_POST['urls'] ?? '')));
if (count($lines)>100) throw new RuntimeException('Maksymalnie 100 adresów na raz.');
$count=0;
foreach ($lines as $url) if (pin77_enqueue($url,true)) $count++;
$message='Dodano do kolejki: '.$count.' z '.count($lines).' adresów. Dozwolone są tylko publiczne adresy mojapolanasmakow.pl.';
} elseif ($action === 'retry') {
$stmt=db()->prepare("UPDATE polana_indexnow_queue SET status='pending',attempts=0,next_attempt=NOW(),updated_at=NOW() WHERE status='error'");
$stmt->execute(); $message='Przywrócono do kolejki błędy: '.$stmt->rowCount().'.';
} else throw new RuntimeException('Nieznana akcja.');
admin_log('indexnow_v177', $action);
} catch (Throwable $e) { $message=$e->getMessage(); $isError=true; }
}
$counts=['pending'=>0,'sent'=>0,'error'=>0]; $recent=[]; $logs=[];
if ($installed) {
try {
foreach (db()->query('SELECT status,COUNT(*) AS n FROM polana_indexnow_queue GROUP BY status')->fetchAll(PDO::FETCH_ASSOC) as $r)
$counts[$r['status']] = (int)$r['n'];
$recent=db()->query('SELECT url,status,attempts,last_http,last_error,updated_at,sent_at FROM polana_indexnow_queue ORDER BY updated_at DESC LIMIT 35')->fetchAll(PDO::FETCH_ASSOC);
$logs=db()->query('SELECT url_count,http_code,result,created_at FROM polana_indexnow_log ORDER BY id DESC LIMIT 10')->fetchAll(PDO::FETCH_ASSOC);
} catch (Throwable $e) { $message='Nie udało się odczytać kolejki: '.$e->getMessage(); $isError=true; }
}
$key=pin77_key(); $keyPath=dirname(__DIR__).'/'.$key.'.txt';
$keyLocal=$key!=='' && is_file($keyPath) && trim((string)@file_get_contents($keyPath))===$key;
$hooks=[
'Blog — publikacja/edycja'=> is_file(__DIR__.'/blog-edit.php') && str_contains((string)@file_get_contents(__DIR__.'/blog-edit.php'),'PIN77_AUTO_BLOG_SAVE'),
'Blog — usunięcie'=> is_file(__DIR__.'/blog.php') && str_contains((string)@file_get_contents(__DIR__.'/blog.php'),'PIN77_AUTO_BLOG_DELETE'),
'Menu — zmiany'=> is_file(__DIR__.'/polana-menu-centrum.php') && str_contains((string)@file_get_contents(__DIR__.'/polana-menu-centrum.php'),'PIN77_AUTO_MENU_V18') && is_file(__DIR__.'/menus.php') && str_contains((string)@file_get_contents(__DIR__.'/menus.php'),'pv18_menu_action'),
];
render_admin_header('IndexNow / Bing — Polana');
?>
<style>
.pin77-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;margin:14px 0}
.pin77-tile{border:1px solid #d8ded5;border-radius:14px;padding:18px;background:#fff}
.pin77-num{font-size:29px;font-weight:750;margin:8px 0}.pin77-ok{color:#236b43}.pin77-warn{color:#ad6a14}.pin77-bad{color:#a82929}
.pin77-inline{display:flex;gap:12px;flex-wrap:wrap;align-items:center}.pin77-inline form{display:inline-block}
.pin77-table{width:100%;border-collapse:collapse;font-size:13px}.pin77-table td,.pin77-table th{border-bottom:1px solid #e5e7e4;padding:10px;text-align:left;vertical-align:top}.pin77-table td:first-child{overflow-wrap:anywhere;max-width:550px}
.pin77-small{font-size:13px;color:#646b62}.pin77-link{color:#4b693b;text-decoration:underline}.pin77-form textarea{width:100%;min-height:100px}
</style>
<div class="admin-title-row"><div><h1>IndexNow i Bing — automatyczne SEO</h1><p>Jedna domena: <strong>mojapolanasmakow.pl</strong>. Kolejka zgłoszeń, publikacje bloga, menu i mapa witryny.</p></div><div class="actions"><a class="btn btn-light" href="/admin/polana-v177-instalator.php">Instalator / rollback</a><a class="btn btn-light" href="/admin/polana-v176-diagnostyka.php">Diagnostyka V17.6</a></div></div>
<?php if ($message!==''): ?><div class="flash <?= $isError?'flash-error':'flash-success' ?>"><?= e($message) ?></div><?php endif; ?>
<?php if (!$installed): ?><div class="flash flash-error">Moduł nie jest jeszcze zainstalowany. <a href="/admin/polana-v177-instalator.php">Uruchom instalator</a>.</div><?php endif; ?>
<div class="pin77-grid">
<div class="pin77-tile"><div class="pin77-small">Oczekujące</div><div class="pin77-num"><?= (int)$counts['pending'] ?></div></div>
<div class="pin77-tile"><div class="pin77-small">Przyjęte przez IndexNow</div><div class="pin77-num pin77-ok"><?= (int)$counts['sent'] ?></div></div>
<div class="pin77-tile"><div class="pin77-small">Błędy / do ponowienia</div><div class="pin77-num <?= $counts['error']?'pin77-bad':'pin77-ok' ?>"><?= (int)$counts['error'] ?></div></div>
<div class="pin77-tile"><div class="pin77-small">Klucz domeny</div><div class="pin77-num <?= $keyLocal?'pin77-ok':'pin77-bad' ?>" style="font-size:19px"><?= $keyLocal?'Plik jest':'Brak pliku' ?></div></div>
</div>
<section class="form-card" style="margin-top:18px"><h2>Włączenie i automatyzacja</h2>
<p>IndexNow zgłasza zmienione URL-e do wyszukiwarek obsługujących protokół (w tym Bing). HTTP 200/202 oznacza przyjęcie zgłoszenia, <strong>nie</strong> potwierdza indeksacji.</p>
<form method="post" class="pin77-inline"><?= csrf_field() ?><input type="hidden" name="action" value="settings"><label><input type="checkbox" name="enabled" value="1" <?= pin77_enabled()?'checked':'' ?>> Włącz IndexNow</label><button class="btn btn-primary" <?= !$installed?'disabled':'' ?>>Zapisz</button></form>
<p class="pin77-small">Klucz: <?= $keyLocal?'<a class="pin77-link" href="'.e(pin77_key_url()).'" target="_blank" rel="noopener">Sprawdź publiczny plik weryfikacyjny ↗</a>':'Uruchom instalator, aby utworzyć klucz' ?>. Automatyczne zdarzenia: <?php foreach($hooks as $label=>$ok): ?><span style="margin-right:12px"><?= e($label) ?>: <strong class="<?= $ok?'pin77-ok':'pin77-warn' ?>"><?= $ok?'aktywne':'nieaktywne' ?></strong></span><?php endforeach; ?></p>
</section>
<section class="form-card" style="margin-top:18px"><h2>Mapa witryny i wysyłka</h2>
<div class="pin77-inline">
<form method="post"><?= csrf_field() ?><input type="hidden" name="action" value="sitemap"><button class="btn btn-primary" <?= !$installed?'disabled':'' ?>>1. Pobierz nowe URL-e z sitemap.xml</button></form>
<form method="post"><?= csrf_field() ?><input type="hidden" name="action" value="submit"><button class="btn btn-green" <?= !$installed?'disabled':'' ?>>2. Wyślij kolejkę do IndexNow</button></form>
<form method="post"><?= csrf_field() ?><input type="hidden" name="action" value="retry"><button class="btn btn-light" <?= !$installed?'disabled':'' ?>>Ponów błędy</button></form>
</div>
<p class="pin77-small">Import mapy nie wysyła ponownie adresów już zgłoszonych. Aktualizacja wpisu blogowego lub menu zgłasza zmienione adresy automatycznie, jeśli hooki są aktywne.</p>
<div class="pin77-inline"><a class="btn btn-light" href="https://mojapolanasmakow.pl/sitemap.xml" target="_blank" rel="noopener">Sitemap XML ↗</a><a class="btn btn-light" href="https://mojapolanasmakow.pl/robots.txt" target="_blank" rel="noopener">Robots.txt ↗</a><a class="btn btn-light" href="https://www.bing.com/webmasters/" target="_blank" rel="noopener">Bing Webmaster ↗</a><a class="btn btn-light" href="https://search.google.com/search-console" target="_blank" rel="noopener">Google Search Console ↗</a></div>
</section>
<section class="form-card pin77-form" style="margin-top:18px"><h2>Dodaj konkretne adresy ręcznie</h2><p class="pin77-small">Jeden adres w linii, maksymalnie 100. Tylko publiczne strony domeny mojapolanasmakow.pl; bez parametrów, plików i zaplecza.</p>
<form method="post"><?= csrf_field() ?><input type="hidden" name="action" value="add"><textarea name="urls" placeholder="https://mojapolanasmakow.pl/menu-seo https://mojapolanasmakow.pl/blog/przykladowy-wpis"></textarea><p><button class="btn btn-primary" <?= !$installed?'disabled':'' ?>>Dodaj do kolejki</button></p></form></section>
<section class="form-card" style="margin-top:18px"><h2>Ostatnie adresy</h2><div class="table-wrap"><table class="pin77-table"><thead><tr><th>Adres</th><th>Status</th><th>HTTP</th><th>Ostatnia zmiana</th><th>Uwagi</th></tr></thead><tbody>
<?php foreach($recent as $row): ?><tr><td><?= e($row['url']) ?></td><td><?= e($row['status']) ?></td><td><?= e((string)($row['last_http']??'—')) ?></td><td><?= e((string)$row['updated_at']) ?></td><td><?= e((string)($row['last_error']??'')) ?></td></tr><?php endforeach; ?>
<?php if(!$recent): ?><tr><td colspan="5">Brak zgłoszeń. Pobierz mapę i wyślij kolejkę.</td></tr><?php endif; ?></tbody></table></div></section>
<section class="form-card" style="margin-top:18px"><h2>Ostatnie odpowiedzi API</h2><div class="table-wrap"><table class="pin77-table"><thead><tr><th>Data</th><th>URL-e</th><th>HTTP</th><th>Wynik</th></tr></thead><tbody><?php foreach($logs as $row): ?><tr><td><?= e($row['created_at']) ?></td><td><?= (int)$row['url_count'] ?></td><td><?= e((string)($row['http_code']??'—')) ?></td><td><?= e($row['result']) ?></td></tr><?php endforeach; ?><?php if(!$logs): ?><tr><td colspan="4">Brak wysyłek.</td></tr><?php endif; ?></tbody></table></div></section>
<section class="form-card" style="margin-top:18px"><h2>Co jeszcze warto skonfigurować</h2>
<p><strong>Google:</strong> dodaj sitemap.xml w Search Console; Google nie obsługuje IndexNow. <strong>Bing:</strong> zweryfikuj domenę w Bing Webmaster Tools (można importować z GSC) i dodaj tę samą mapę. <strong>Wizytówka Google:</strong> utrzymuj aktualne godziny, zdjęcia, menu i link do rezerwacji.</p>
<p class="pin77-small">IndexNow jest bezpłatny. Nie wymaga Bing API key. Publiczny plik z kluczem jest częścią weryfikacji domeny.</p></section>
<?php render_admin_footer(); ?>