Add favicon; fix two server bugs found deploying to socoban.08h.ru

- Favicon: 🚀 emoji via inline SVG data URI, both sokoban.html and php/index.php
- api.php: mb_substr() -> substr() (mbstring not enabled on the server)
- api.php: MariaDB rejects LIMIT directly inside NOT IN(...) (error 1235) —
  wrap the top-5 subquery in an extra derived-table SELECT
Verified live against the deployed MySQL/MariaDB DB: whoami, set_name,
submit (insert + dedup + trim-to-5), top all round-trip correctly.
This commit is contained in:
Alex Cube
2026-08-10 15:29:14 +03:00
parent 6006ad0690
commit 4ac392a9ab
3 changed files with 9 additions and 3 deletions
+6 -2
View File
@@ -45,7 +45,7 @@ switch ($action) {
case 'set_name': {
$body = read_json_body();
$name = trim(mb_substr((string)($body['name'] ?? ''), 0, 40));
$name = trim(substr((string)($body['name'] ?? ''), 0, 40));
if ($name === '') { http_response_code(400); echo json_encode(['error' => 'empty name']); break; }
$u = current_user($pdo);
if ($u) {
@@ -102,10 +102,14 @@ switch ($action) {
// UNIQUE(level_name, move_key) — та же последовательность уже есть, не ошибка
}
// держим только топ-5 по числу ходов на уровень
// держим только топ-5 по числу ходов на уровень. MariaDB не даёт
// LIMIT прямо внутри NOT IN(...) (ошибка 1235) — оборачиваем
// подзапрос ещё одним SELECT (derived table), это разрешено.
$pdo->prepare('
DELETE FROM solutions WHERE level_name = ? AND id NOT IN (
SELECT id FROM (
SELECT id FROM solutions WHERE level_name = ? ORDER BY move_count ASC LIMIT 5
) AS keep_ids
)
')->execute([$level, $level]);
+1
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sokoban 60 Levels</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🚀</text></svg>">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }
+1
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sokoban — 60 Levels</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🚀</text></svg>">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #0f0f1a; display: flex; justify-content: center; align-items: center; min-height: 100vh; font-family: 'Courier New', monospace; }