LuminaWebsite/item_info.php
Maaxxs c8c9ca2285 Item tooltips show the game data from aion2hub instead of warehouse and shop details
The info bubble in the warehouse and the Lumishop now shows only what an Aion 2 database says
about the item: name in the grade colour, grade, slot, type, binding, item level and required
level, description, base stats, item info (sockets, max stack, sell price, effect when used) and
the highest enchant. Stock, price, last movement and the gear-catalogue match are gone.

- includes/item_db.php finds the item on aion2hub by its name (/database?q=..., exact name, else
  the bound variant), reads the item page and caches both: the values in item_db, the name -> item
  id mapping in item_db_names (schema 51, also in sql/schema.sql). Data is fetched on the first
  hover only, refreshed after 30 days; names not found are searched again after 7 days.
- At most 20 aion2hub pages per minute for the whole site (rate_limits, bucket aion2hub), only
  names that exist in the warehouse or the shop, fetched via gear_source_fetch() like the gear
  planner. aion2hub allows these pages in robots.txt, only /api/ is disallowed.
- item_info.php answers the bubble (JSON: ok, missing, busy, error), assets/js/item-tooltip.js
  shows "Lade Spieldaten ..." until then and keeps the result for the page. Placeholders aion2hub
  leaves unresolved in descriptions ({abe:...}) are shown as "...".
- Shop offers linked to a warehouse item are looked up under the warehouse name.
- includes/item_tooltip.php removed; patch notes and README updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 02:03:23 +02:00

41 lines
1.7 KiB
PHP

<?php
/**
* Spieldaten eines Gegenstands fuer die Info-Blasen im Lagerhaus und Lumishop (assets/js/item-tooltip.js):
* ?name=<Name wie im Lagerhaus bzw. Lumishop>. Antwortet immer mit JSON: state ok (html), missing
* (bei aion2hub nicht gefunden), busy (Tempolimit - gleich noch einmal) oder error (message).
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/item_db.php';
require_once __DIR__ . '/includes/warehouse.php';
if (!current_user()) {
http_response_code(401);
json_response(false, 'Bitte neu anmelden.');
}
if (!user_has_permission('warehouse.view') && !user_has_permission('shop.view')) {
http_response_code(403);
json_response(false, 'Dir fehlt die Berechtigung dafür.');
}
// Ein Abruf bei aion2hub dauert - andere Seiten derselben Sitzung sollen nicht darauf warten
session_write_close();
$name = trim((string) ($_GET['name'] ?? ''));
// Nachgeschlagen wird nur, was es im Lagerhaus oder im Lumishop gibt - keine beliebigen Suchen bei aion2hub
$stmt = db()->prepare(
'SELECT w.icon FROM warehouse_items w WHERE w.name = ?
UNION ALL SELECT NULL FROM shop_items s WHERE s.name = ? LIMIT 1'
);
$stmt->execute([$name, $name]);
$known = $name !== '' && mb_strlen($name) <= 150 ? $stmt->fetch() : false;
if ($known === false) {
json_response(false, 'Unbekannter Gegenstand.');
}
$result = item_db_lookup($name);
if ($result['status'] === 'ok') {
json_response(true, '', [
'state' => 'ok',
'html' => item_db_tip_html($result['item'], warehouse_icon_html($known['icon'] ?? null, $name, 56)),
]);
}
json_response(true, (string) ($result['message'] ?? ''), ['state' => $result['status']]);