Gear planner: sets can be shared by link or build code and imported as your own
Asked for: share a build with a link or build code, and an import tool that takes such a code. - "Teilen" on an own set creates a link (gear.php?build=CODE) and the same code as build code: 10 characters without 0/O and 1/I/L, shown as K7QX2-M9FRT, stored in gear_sets.share_code (schema version 59, unique; also in sql/schema.sql). Whoever opens it sees the set even if it is not on the profile, always in its current state; the session remembers the code so tabs, slots and compare work, and a renewed or withdrawn code ends that access. "Neuen Code erzeugen" and "Nicht mehr teilen" invalidate the old one. The dialog reopens after creating (#teilen) with copy buttons. - "Build importieren" on "Meine Sets" takes the code (with or without dash, any case) or the whole link; viewing someone else's set (shared or on the profile) offers "In meine Sets übernehmen". Both copy the set with gear, skills, macros and all planner pages via gear_set_copy() (also used by "Kopieren" now); the copy is neither shared nor on the profile. Errors reopen the dialog (#import). - Members only (gear.view). Opening any page without being logged in now brings you back to it after the login (auth_login_return_target) - only for page views in the browser, not for background requests like live updates or autosave. - Privacy policy (shared sets), patch notes and README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6f2f44d960
commit
525bd0d4b5
13 changed files with 358 additions and 35 deletions
13
README.md
13
README.md
|
|
@ -819,6 +819,19 @@ vergleichen. Jedes Set hat neun Unterseiten (Reiter, Reihenfolge wie im Build-Pl
|
||||||
Seiten), bis zu vier nebeneinander vergleichen (Werte, Ausrüstung, Werte der Planer-Seiten,
|
Seiten), bis zu vier nebeneinander vergleichen (Werte, Ausrüstung, Werte der Planer-Seiten,
|
||||||
Skillstufen) und auf der eigenen Profilseite zeigen.
|
Skillstufen) und auf der eigenen Profilseite zeigen.
|
||||||
|
|
||||||
|
- **Teilen und importieren:** „Teilen“ beim eigenen Set erzeugt einen Link (`gear.php?build=CODE`) und
|
||||||
|
denselben Code als **Buildcode** zum Kopieren – 10 Zeichen ohne die verwechselbaren 0/O und 1/I/L,
|
||||||
|
angezeigt als `K7QX2-M9FRT` (`gear_sets.share_code`, Helfer `gear_share_*` in `includes/gear.php`). Wer ihn
|
||||||
|
öffnet, sieht das Set auch ohne Freigabe fürs Profil – die Sitzung merkt sich den Code, damit Reiter, Slots
|
||||||
|
und Vergleich gehen – und zwar immer den aktuellen Stand. „Neuen Code erzeugen“ macht den alten ungültig,
|
||||||
|
„Nicht mehr teilen“ beide. „Build importieren“ unter „Meine Sets“ nimmt den Code (mit oder ohne Strich,
|
||||||
|
klein oder groß) oder den ganzen Link; beim Ansehen eines fremden Sets (geteilt oder auf dem Profil)
|
||||||
|
macht „In meine Sets übernehmen“ dasselbe. Übernommen wird eine Kopie mit Ausrüstung, Skills, Makros und
|
||||||
|
allen Planer-Seiten (`gear_set_copy`, auch für „Kopieren“), nicht geteilt und nicht auf dem Profil.
|
||||||
|
Das alles nur mit Konto (`gear.view`); wer nicht angemeldet einen Link öffnet, landet nach dem Login
|
||||||
|
wieder dort (`auth_login_return_target()` in `includes/auth.php` – gilt für jede Seite, die man ohne
|
||||||
|
Anmeldung im Browser aufruft).
|
||||||
|
|
||||||
- **Gegenstände** kommen von [aion2hub.com](https://aion2hub.com/database) (aus dem
|
- **Gegenstände** kommen von [aion2hub.com](https://aion2hub.com/database) (aus dem
|
||||||
Global-Client ausgelesen). Admins mit `gear.manage` übernehmen sie unter **Gegenstände &
|
Global-Client ausgelesen). Admins mit `gear.manage` übernehmen sie unter **Gegenstände &
|
||||||
Skills verwalten** (`admin/gear_items.php`) einzeln oder als ganze Liste und gleichen sie
|
Skills verwalten** (`admin/gear_items.php`) einzeln oder als ganze Liste und gleichen sie
|
||||||
|
|
|
||||||
|
|
@ -6236,6 +6236,12 @@ strong.grade-common, strong.grade-rare, strong.grade-epic, strong.grade-unique,
|
||||||
.gear-save-status.is-busy { color: var(--text-muted); font-style: italic; }
|
.gear-save-status.is-busy { color: var(--text-muted); font-style: italic; }
|
||||||
.gear-save-status.is-error { color: #f08a86; }
|
.gear-save-status.is-error { color: #f08a86; }
|
||||||
.gear-delete-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
|
.gear-delete-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
|
||||||
|
/* Teilen per Link und Buildcode, Build importieren (gear.php) */
|
||||||
|
.gear-share-field { margin-top: 0.9rem; }
|
||||||
|
.gear-share-field label { display: block; margin-bottom: 0.35rem; }
|
||||||
|
.gear-share-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.08em; }
|
||||||
|
.gear-share-actions { flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
|
||||||
|
.gear-share-actions form { margin: 0; }
|
||||||
.gear-detail-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; }
|
.gear-detail-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; }
|
||||||
.gear-detail-list div { display: flex; gap: 0.5rem; }
|
.gear-detail-list div { display: flex; gap: 0.5rem; }
|
||||||
.gear-detail-list dt { color: var(--text-muted); min-width: 110px; }
|
.gear-detail-list dt { color: var(--text-muted); min-width: 110px; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Gear-Planer (gear.php): Dialog "Set bearbeiten", Auswahl zum Vergleichen (2-4 Sets),
|
* Gear-Planer (gear.php): Dialoge "Set bearbeiten", "Teilen" und "Build importieren", Auswahl zum Vergleichen (2-4 Sets),
|
||||||
* Hinweise zur Spanne der Seelenpraegung (Platzhalter + Pruefung beim Tippen) und das
|
* Hinweise zur Spanne der Seelenpraegung (Platzhalter + Pruefung beim Tippen) und das
|
||||||
* automatische Speichern von Slots und Skillstufen.
|
* automatische Speichern von Slots und Skillstufen.
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,17 +16,35 @@
|
||||||
if (first) first.focus();
|
if (first) first.focus();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// Beim Schliessen auch den Anker aus der Adresse nehmen, der den Dialog geoeffnet hat - sonst ginge er beim
|
||||||
|
// Neuladen wieder auf
|
||||||
|
var closeModal = function (modal) {
|
||||||
|
modal.hidden = true;
|
||||||
|
if (modal.dataset.hash && location.hash === '#' + modal.dataset.hash && window.history.replaceState) {
|
||||||
|
window.history.replaceState(null, '', location.pathname + location.search);
|
||||||
|
}
|
||||||
|
};
|
||||||
document.querySelectorAll('.modal-overlay').forEach(function (modal) {
|
document.querySelectorAll('.modal-overlay').forEach(function (modal) {
|
||||||
var close = modal.querySelector('.modal-close');
|
var close = modal.querySelector('.modal-close');
|
||||||
if (close) close.addEventListener('click', function () { modal.hidden = true; });
|
if (close) close.addEventListener('click', function () { closeModal(modal); });
|
||||||
modal.addEventListener('click', function (event) {
|
modal.addEventListener('click', function (event) {
|
||||||
if (event.target === modal) modal.hidden = true;
|
if (event.target === modal) closeModal(modal);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
document.addEventListener('keydown', function (event) {
|
document.addEventListener('keydown', function (event) {
|
||||||
if (event.key !== 'Escape') return;
|
if (event.key !== 'Escape') return;
|
||||||
document.querySelectorAll('.modal-overlay:not([hidden])').forEach(function (modal) { modal.hidden = true; });
|
document.querySelectorAll('.modal-overlay:not([hidden])').forEach(closeModal);
|
||||||
});
|
});
|
||||||
|
// Dialog direkt oeffnen, wenn die Adresse auf ihn zeigt: #teilen nach dem Erzeugen des Buildcodes, #import nach
|
||||||
|
// einem Fehler beim Importieren
|
||||||
|
if (location.hash.length > 1) {
|
||||||
|
document.querySelectorAll('.modal-overlay[data-hash]').forEach(function (modal) {
|
||||||
|
if ('#' + modal.dataset.hash !== location.hash) return;
|
||||||
|
modal.hidden = false;
|
||||||
|
var field = modal.querySelector('input[type="text"]');
|
||||||
|
if (field) field.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Info-Blasen beim Drueberfahren: Skills (Beschreibung aus .gear-tip-src der Karte) und Felder der
|
// ---- Info-Blasen beim Drueberfahren: Skills (Beschreibung aus .gear-tip-src der Karte) und Felder der
|
||||||
// Daevanion-Bretter (data-tip: was das Feld gibt, data-tip-meta, data-state: ob es sich aktivieren laesst) ----
|
// Daevanion-Bretter (data-tip: was das Feld gibt, data-tip-meta, data-state: ob es sich aktivieren laesst) ----
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?= $heading('mitgliederbereich') ?>
|
<?= $heading('mitgliederbereich') ?>
|
||||||
<p>Im Mitgliederbereich verarbeiten wir, was du selbst einträgst oder was bei der Nutzung entsteht - je nach Funktion:</p>
|
<p>Im Mitgliederbereich verarbeiten wir, was du selbst einträgst oder was bei der Nutzung entsteht - je nach Funktion:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Profil:</strong> Anzeigename, Klassen und Main-Klasse, Profiltext und -hintergrund, Profilbild, deine Charaktere (Name, Klasse, Stufe, Notiz, Bilder, Berufe mit Stufe und Hauptberuf, Sammel-Spezialisierung – die Berufe stehen auch in der Übersicht „Berufe“), Galeriebilder mit Beschreibung (und ob eins davon auf der Startseite gezeigt wird), Kommentare und Reaktionen sowie Gear-Sets, die du auf deinem Profil zeigst.</li>
|
<li><strong>Profil:</strong> Anzeigename, Klassen und Main-Klasse, Profiltext und -hintergrund, Profilbild, deine Charaktere (Name, Klasse, Stufe, Notiz, Bilder, Berufe mit Stufe und Hauptberuf, Sammel-Spezialisierung – die Berufe stehen auch in der Übersicht „Berufe“), Galeriebilder mit Beschreibung (und ob eins davon auf der Startseite gezeigt wird), Kommentare und Reaktionen sowie Gear-Sets, die du auf deinem Profil zeigst oder per Link bzw. Buildcode teilst – wer den Link oder Code hat, sieht das Set mit deinem Namen und kann es als eigenes übernehmen, solange du es teilst.</li>
|
||||||
<li><strong>Aktivität:</strong> wann du dich zuletzt angemeldet hast und zuletzt aktiv warst (in der Mitgliederliste sichtbar), deine tägliche Lumipunkte-Belohnung, die Einführungstour, gelesene Patchnotes, wann du zuletzt in die Galerie und auf die Raid-Seite geschaut hast (für die Anzeige neuer Bilder und Raids) und die Reihenfolge deiner Menüpunkte.</li>
|
<li><strong>Aktivität:</strong> wann du dich zuletzt angemeldet hast und zuletzt aktiv warst (in der Mitgliederliste sichtbar), deine tägliche Lumipunkte-Belohnung, die Einführungstour, gelesene Patchnotes, wann du zuletzt in die Galerie und auf die Raid-Seite geschaut hast (für die Anzeige neuer Bilder und Raids) und die Reihenfolge deiner Menüpunkte.</li>
|
||||||
<li><strong>Raids und Premades:</strong> deine Anmeldungen mit Klasse und Gruppe, deine Anwesenheit (anwesend, abwesend, entschuldigt) und die dafür vergebenen Lumipunkte; bei Raids, die du selbst anlegst, dass du ihr Raid-Lead bist (für alle sichtbar). Leitest du eine Premade, das Banner, das du für sie wählst oder hochlädst - eigene Bilder mit dem Vermerk, wer sie hochgeladen hat, und mit derselben Freigabe wie Galeriebilder.</li>
|
<li><strong>Raids und Premades:</strong> deine Anmeldungen mit Klasse und Gruppe, deine Anwesenheit (anwesend, abwesend, entschuldigt) und die dafür vergebenen Lumipunkte; bei Raids, die du selbst anlegst, dass du ihr Raid-Lead bist (für alle sichtbar). Leitest du eine Premade, das Banner, das du für sie wählst oder hochlädst - eigene Bilder mit dem Vermerk, wer sie hochgeladen hat, und mit derselben Freigabe wie Galeriebilder.</li>
|
||||||
<li><strong>Lumipunkte und Lumishop:</strong> Punktevergaben und -abzüge, deine Shop-Anträge mit Bemerkung (z. B. Charaktername) und deren Bearbeitung.</li>
|
<li><strong>Lumipunkte und Lumishop:</strong> Punktevergaben und -abzüge, deine Shop-Anträge mit Bemerkung (z. B. Charaktername) und deren Bearbeitung.</li>
|
||||||
|
|
|
||||||
|
|
@ -72,4 +72,4 @@ discord_store_tokens($account['id'], $tokens);
|
||||||
discord_apply_member($account['id'], $member);
|
discord_apply_member($account['id'], $member);
|
||||||
auth_login_session($account['id'], 'discord');
|
auth_login_session($account['id'], 'discord');
|
||||||
|
|
||||||
redirect($account['status'] === 'pending' ? '/pending.php' : '/dashboard.php');
|
redirect($account['status'] === 'pending' ? '/pending.php' : auth_login_return_target());
|
||||||
|
|
|
||||||
99
gear.php
99
gear.php
|
|
@ -8,6 +8,7 @@
|
||||||
* /gear.php?set=ID&tab=arcana|pets|daevanion|pantheon|closet die Seiten nach dem aion2hub-Planer
|
* /gear.php?set=ID&tab=arcana|pets|daevanion|pantheon|closet die Seiten nach dem aion2hub-Planer
|
||||||
* (includes/gear_planner_view.php)
|
* (includes/gear_planner_view.php)
|
||||||
* /gear.php?compare[]=ID&… 2-4 Sets nebeneinander
|
* /gear.php?compare[]=ID&… 2-4 Sets nebeneinander
|
||||||
|
* /gear.php?build=CODE ein per Link/Buildcode geteiltes Set (weiter zu ?set=ID, includes/gear.php)
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/gear.php';
|
require_once __DIR__ . '/includes/gear.php';
|
||||||
|
|
@ -25,6 +26,18 @@ $mySets = gear_sets_for_user($userId);
|
||||||
$mySlots = gear_slots_for_sets(array_column($mySets, 'id'));
|
$mySlots = gear_slots_for_sets(array_column($mySets, 'id'));
|
||||||
$mySkills = gear_set_skills_for_sets($mySets);
|
$mySkills = gear_set_skills_for_sets($mySets);
|
||||||
|
|
||||||
|
// Geteilter Link: Code fuer diese Sitzung merken, dann weiter zum Set (so gehen auch Reiter, Slots und Vergleich)
|
||||||
|
if (isset($_GET['build'])) {
|
||||||
|
$code = gear_share_code_input((string) $_GET['build']);
|
||||||
|
$shared = $code !== null ? gear_set_by_share_code($code) : null;
|
||||||
|
if (!$shared) {
|
||||||
|
set_flash('error', 'Diesen Build gibt es nicht (mehr) – vielleicht wird das Set nicht mehr geteilt.');
|
||||||
|
redirect('/gear.php');
|
||||||
|
}
|
||||||
|
gear_share_remember($shared);
|
||||||
|
redirect('/gear.php?set=' . (int) $shared['id']);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Welche Ansicht? ----
|
// ---- Welche Ansicht? ----
|
||||||
$set = null;
|
$set = null;
|
||||||
$compare = [];
|
$compare = [];
|
||||||
|
|
@ -307,6 +320,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?= count(array_filter($slots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots belegt
|
<?= count(array_filter($slots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots belegt
|
||||||
<?php if ($itemLevel !== null): ?> · Ø Gegenstandsstufe <?= e(number_format($itemLevel, 1, ',', '.')) ?><?php endif; ?>
|
<?php if ($itemLevel !== null): ?> · Ø Gegenstandsstufe <?= e(number_format($itemLevel, 1, ',', '.')) ?><?php endif; ?>
|
||||||
<?php if ($isOwn && $set['show_on_profile']): ?> · <span class="badge">auf dem Profil sichtbar</span><?php endif; ?>
|
<?php if ($isOwn && $set['show_on_profile']): ?> · <span class="badge">auf dem Profil sichtbar</span><?php endif; ?>
|
||||||
|
<?php if ($isOwn && !empty($set['share_code'])): ?> · <span class="badge">per Link geteilt</span><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if (!empty($set['note'])): ?><p><?= e($set['note']) ?></p><?php endif; ?>
|
<?php if (!empty($set['note'])): ?><p><?= e($set['note']) ?></p><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -317,12 +331,21 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($isOwn): ?>
|
<?php if ($isOwn): ?>
|
||||||
<button type="button" class="button button-secondary" data-modal-open="gear-set-edit"><?= icon('edit') ?> Bearbeiten</button>
|
<button type="button" class="button button-secondary" data-modal-open="gear-set-edit"><?= icon('edit') ?> Bearbeiten</button>
|
||||||
|
<button type="button" class="button button-secondary" data-modal-open="gear-set-share"><?= icon('link') ?> Teilen</button>
|
||||||
<form method="post" action="/gear_action.php">
|
<form method="post" action="/gear_action.php">
|
||||||
<?= csrf_field() ?>
|
<?= csrf_field() ?>
|
||||||
<input type="hidden" name="action" value="duplicate">
|
<input type="hidden" name="action" value="duplicate">
|
||||||
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
||||||
<button type="submit" class="button button-secondary">Kopieren</button>
|
<button type="submit" class="button button-secondary">Kopieren</button>
|
||||||
</form>
|
</form>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php // Fremdes Set (geteilt oder auf dem Profil): als eigenes uebernehmen und dann anpassen ?>
|
||||||
|
<form method="post" action="/gear_action.php">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="import">
|
||||||
|
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
||||||
|
<button type="submit" class="button" title="Kopie mit Ausrüstung, Skills, Makros und allen Planer-Seiten in deine Sets – das Original bleibt, wie es ist">In meine Sets übernehmen</button>
|
||||||
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php $compareWith = array_values(array_filter($mySets, static fn (array $s): bool => (int) $s['id'] !== (int) $set['id'])); ?>
|
<?php $compareWith = array_values(array_filter($mySets, static fn (array $s): bool => (int) $s['id'] !== (int) $set['id'])); ?>
|
||||||
<?php if ($compareWith): ?>
|
<?php if ($compareWith): ?>
|
||||||
|
|
@ -645,6 +668,59 @@ include __DIR__ . '/includes/header.php';
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php // Teilen per Link und Buildcode - nach dem Erzeugen geht der Dialog wieder auf (#teilen, assets/js/gear.js) ?>
|
||||||
|
<div class="modal-overlay" id="gear-set-share" data-hash="teilen" hidden>
|
||||||
|
<div class="modal">
|
||||||
|
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
|
||||||
|
<h2>Set teilen</h2>
|
||||||
|
<p class="text-muted">
|
||||||
|
Wer den Link oder den Buildcode hat, sieht dieses Set – auch wenn es nicht auf deinem Profil steht – und kann
|
||||||
|
es mit einem Klick in seine eigenen Sets übernehmen: mit Ausrüstung, Skills, Makros und allen Planer-Seiten.
|
||||||
|
Das geht mit einem Konto hier auf der Website. Geteilt wird immer der aktuelle Stand des Sets.
|
||||||
|
</p>
|
||||||
|
<?php if (!empty($set['share_code'])): ?>
|
||||||
|
<div class="gear-share-field">
|
||||||
|
<label for="gear-share-link">Link</label>
|
||||||
|
<div class="data-link-copy">
|
||||||
|
<input type="text" id="gear-share-link" value="<?= e(gear_share_url((string) $set['share_code'])) ?>" readonly>
|
||||||
|
<button type="button" class="button-secondary" data-copy-target="gear-share-link">Kopieren</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="gear-share-field">
|
||||||
|
<label for="gear-share-code">Buildcode <span class="text-muted">(zum Einfügen unter „Meine Sets“ → „Build importieren“)</span></label>
|
||||||
|
<div class="data-link-copy">
|
||||||
|
<input type="text" id="gear-share-code" class="gear-share-code" value="<?= e(gear_share_code_label((string) $set['share_code'])) ?>" readonly>
|
||||||
|
<button type="button" class="button-secondary" data-copy-target="gear-share-code">Kopieren</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="actions gear-share-actions">
|
||||||
|
<form method="post" action="/gear_action.php" data-confirm="Neuen Link und Buildcode erzeugen? Die bisherigen gelten dann nicht mehr." data-confirm-title="Neuer Buildcode" data-confirm-ok="Neu erzeugen">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="share">
|
||||||
|
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
||||||
|
<input type="hidden" name="renew" value="1">
|
||||||
|
<button type="submit" class="button button-secondary button-small">Neuen Code erzeugen</button>
|
||||||
|
</form>
|
||||||
|
<form method="post" action="/gear_action.php" data-confirm="Nicht mehr teilen? Link und Buildcode gelten dann nicht mehr – schon übernommene Kopien bleiben." data-confirm-title="Nicht mehr teilen" data-confirm-ok="Nicht mehr teilen">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="unshare">
|
||||||
|
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
||||||
|
<button type="submit" class="button button-secondary button-small">Nicht mehr teilen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<form method="post" action="/gear_action.php">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="share">
|
||||||
|
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit" class="button"><?= icon('link') ?> Link und Buildcode erzeugen</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
@ -664,6 +740,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" class="button">Neues Set</button>
|
<button type="submit" class="button">Neues Set</button>
|
||||||
</form>
|
</form>
|
||||||
|
<button type="button" class="button button-secondary" data-modal-open="gear-import"><?= icon('link') ?> Build importieren</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (!$mySets): ?>
|
<?php if (!$mySets): ?>
|
||||||
|
|
@ -701,9 +778,31 @@ include __DIR__ . '/includes/header.php';
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php // Build importieren: Buildcode oder Link eines geteilten Sets - nach einem Fehler geht der Dialog wieder auf (#import) ?>
|
||||||
|
<div class="modal-overlay" id="gear-import" data-hash="import" hidden>
|
||||||
|
<div class="modal">
|
||||||
|
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
|
||||||
|
<h2>Build importieren</h2>
|
||||||
|
<p class="text-muted">
|
||||||
|
Hat dir jemand einen Buildcode oder Link geschickt? Füg ihn hier ein – das Set kommt als dein eigenes in deine
|
||||||
|
Sets, mit Ausrüstung, Skills, Makros und allen Planer-Seiten. Das Original bleibt, wie es ist.
|
||||||
|
</p>
|
||||||
|
<form method="post" action="/gear_action.php">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="import">
|
||||||
|
<label for="gear-import-code">Buildcode oder Link</label>
|
||||||
|
<input type="text" id="gear-import-code" class="gear-share-code" name="code" required maxlength="300" autocomplete="off" spellcheck="false" placeholder="z.B. K7QX2-M9FRT">
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit" class="button">Importieren</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
||||||
|
<script src="<?= e(asset_url('/assets/js/copy-button.js')) ?>"></script>
|
||||||
<script src="<?= e(asset_url('/assets/js/gear.js')) ?>"></script>
|
<script src="<?= e(asset_url('/assets/js/gear.js')) ?>"></script>
|
||||||
<?php if ($set && isset(GEAR_PLAN_SECTIONS[$tab])): ?><script src="<?= e(asset_url('/assets/js/gear-plans.js')) ?>"></script><?php endif; ?>
|
<?php if ($set && isset(GEAR_PLAN_SECTIONS[$tab])): ?><script src="<?= e(asset_url('/assets/js/gear-plans.js')) ?>"></script><?php endif; ?>
|
||||||
<?php if ($set && $tab === 'macro'): ?><script src="<?= e(asset_url('/assets/js/gear-macro.js')) ?>"></script><?php endif; ?>
|
<?php if ($set && $tab === 'macro'): ?><script src="<?= e(asset_url('/assets/js/gear-macro.js')) ?>"></script><?php endif; ?>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Gear-Planer: Sets anlegen, bearbeiten, kopieren, loeschen, Slots belegen, Skillstufen samt
|
* Gear-Planer: Sets anlegen, bearbeiten, kopieren, loeschen, Slots belegen, Skillstufen samt
|
||||||
* Spezialisierungen planen, die Makros und die Seiten Arcana, Pets, Daevanion, Pantheon und Closet speichern.
|
* Spezialisierungen planen, die Makros und die Seiten Arcana, Pets, Daevanion, Pantheon und Closet speichern,
|
||||||
* Jedes Mitglied bearbeitet nur seine eigenen Sets.
|
* Sets per Link/Buildcode teilen und geteilte Sets uebernehmen. Jedes Mitglied bearbeitet nur seine eigenen Sets.
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/gear.php';
|
require_once __DIR__ . '/includes/gear.php';
|
||||||
|
|
@ -51,6 +51,11 @@ $cleanClass = static fn (string $value): ?string => in_array($value, AION_CLASSE
|
||||||
$touch = static function (int $setId) use ($pdo): void {
|
$touch = static function (int $setId) use ($pdo): void {
|
||||||
$pdo->prepare('UPDATE gear_sets SET updated_at = NOW() WHERE id = ?')->execute([$setId]);
|
$pdo->prepare('UPDATE gear_sets SET updated_at = NOW() WHERE id = ?')->execute([$setId]);
|
||||||
};
|
};
|
||||||
|
$setCount = static function () use ($pdo, $userId): int {
|
||||||
|
$count = $pdo->prepare('SELECT COUNT(*) FROM gear_sets WHERE user_id = ?');
|
||||||
|
$count->execute([$userId]);
|
||||||
|
return (int) $count->fetchColumn();
|
||||||
|
};
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'create':
|
case 'create':
|
||||||
|
|
@ -59,9 +64,7 @@ switch ($action) {
|
||||||
set_flash('error', 'Bitte gib dem Set einen Namen.');
|
set_flash('error', 'Bitte gib dem Set einen Namen.');
|
||||||
redirect('/gear.php');
|
redirect('/gear.php');
|
||||||
}
|
}
|
||||||
$count = $pdo->prepare('SELECT COUNT(*) FROM gear_sets WHERE user_id = ?');
|
if ($setCount() >= GEAR_MAX_SETS) {
|
||||||
$count->execute([$userId]);
|
|
||||||
if ((int) $count->fetchColumn() >= GEAR_MAX_SETS) {
|
|
||||||
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
|
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
|
||||||
redirect('/gear.php');
|
redirect('/gear.php');
|
||||||
}
|
}
|
||||||
|
|
@ -116,30 +119,69 @@ switch ($action) {
|
||||||
|
|
||||||
case 'duplicate':
|
case 'duplicate':
|
||||||
$set = $ownSet();
|
$set = $ownSet();
|
||||||
$count = $pdo->prepare('SELECT COUNT(*) FROM gear_sets WHERE user_id = ?');
|
if ($setCount() >= GEAR_MAX_SETS) {
|
||||||
$count->execute([$userId]);
|
|
||||||
if ((int) $count->fetchColumn() >= GEAR_MAX_SETS) {
|
|
||||||
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
|
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
|
||||||
redirect('/gear.php?set=' . (int) $set['id']);
|
redirect('/gear.php?set=' . (int) $set['id']);
|
||||||
}
|
}
|
||||||
$pdo->beginTransaction();
|
$newId = gear_set_copy($set, $userId, mb_substr($set['name'] . ' (Kopie)', 0, 80), (int) $set['sort_order'] + 1);
|
||||||
$pdo->prepare(
|
|
||||||
'INSERT INTO gear_sets (user_id, name, class_name, note, build_url, show_on_profile, sort_order, updated_at)
|
|
||||||
SELECT user_id, ?, class_name, note, build_url, 0, sort_order + 1, NOW() FROM gear_sets WHERE id = ?'
|
|
||||||
)->execute([mb_substr($set['name'] . ' (Kopie)', 0, 80), $set['id']]);
|
|
||||||
$newId = (int) $pdo->lastInsertId();
|
|
||||||
$pdo->prepare(
|
|
||||||
'INSERT INTO gear_set_slots (set_id, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone)
|
|
||||||
SELECT ?, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone FROM gear_set_slots WHERE set_id = ?'
|
|
||||||
)->execute([$newId, $set['id']]);
|
|
||||||
$pdo->prepare('INSERT INTO gear_set_skills (set_id, skill_id, level, specs) SELECT ?, skill_id, level, specs FROM gear_set_skills WHERE set_id = ?')
|
|
||||||
->execute([$newId, $set['id']]);
|
|
||||||
$pdo->prepare('INSERT INTO gear_set_plans (set_id, section, data, updated_at) SELECT ?, section, data, NOW() FROM gear_set_plans WHERE set_id = ?')
|
|
||||||
->execute([$newId, $set['id']]);
|
|
||||||
$pdo->commit();
|
|
||||||
set_flash('success', 'Set kopiert - jetzt kannst du Varianten ausprobieren.');
|
set_flash('success', 'Set kopiert - jetzt kannst du Varianten ausprobieren.');
|
||||||
redirect('/gear.php?set=' . $newId);
|
redirect('/gear.php?set=' . $newId);
|
||||||
|
|
||||||
|
case 'share':
|
||||||
|
// Link und Buildcode erzeugen - mit renew einen neuen, der alte gilt dann nicht mehr. Der Dialog "Teilen" geht
|
||||||
|
// nach dem Neuladen wieder auf (#teilen) und zeigt beides zum Kopieren.
|
||||||
|
$set = $ownSet();
|
||||||
|
if (empty($set['share_code']) || !empty($_POST['renew'])) {
|
||||||
|
$store = $pdo->prepare('UPDATE gear_sets SET share_code = ? WHERE id = ?');
|
||||||
|
for ($attempt = 1; ; $attempt++) {
|
||||||
|
try {
|
||||||
|
$store->execute([gear_share_code_new(), $set['id']]);
|
||||||
|
break;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
if ($attempt >= 5) { // derselbe Code wie bei einem anderen Set - neu wuerfeln
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
redirect('/gear.php?set=' . (int) $set['id'] . '#teilen');
|
||||||
|
|
||||||
|
case 'unshare':
|
||||||
|
$set = $ownSet();
|
||||||
|
$pdo->prepare('UPDATE gear_sets SET share_code = NULL WHERE id = ?')->execute([$set['id']]);
|
||||||
|
set_flash('success', 'Das Set wird nicht mehr geteilt – Link und Buildcode gelten nicht mehr.');
|
||||||
|
redirect('/gear.php?set=' . (int) $set['id']);
|
||||||
|
|
||||||
|
case 'import':
|
||||||
|
// Ein geteiltes Set (Buildcode oder Link aus "Build importieren") bzw. ein fremdes, das man gerade ansieht
|
||||||
|
// (Knopf beim Set: geteilt oder aufs Profil gestellt), als eigenes uebernehmen
|
||||||
|
if (isset($_POST['code'])) {
|
||||||
|
$code = gear_share_code_input((string) $_POST['code']);
|
||||||
|
$source = $code !== null ? gear_set_by_share_code($code) : null;
|
||||||
|
if (!$source) {
|
||||||
|
set_flash('error', $code === null
|
||||||
|
? 'Das ist kein Buildcode – er hat 10 Zeichen wie K7QX2-M9FRT. Du kannst auch den ganzen Link einfügen.'
|
||||||
|
: 'Diesen Buildcode gibt es nicht (mehr) – vielleicht wird das Set nicht mehr geteilt.');
|
||||||
|
redirect('/gear.php#import');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$source = gear_set((int) ($_POST['set_id'] ?? 0));
|
||||||
|
if (!$source || !gear_can_view_set($source)) {
|
||||||
|
set_flash('error', 'Dieses Set gibt es nicht (mehr).');
|
||||||
|
redirect('/gear.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($setCount() >= GEAR_MAX_SETS) {
|
||||||
|
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
|
||||||
|
redirect(isset($_POST['code']) ? '/gear.php#import' : '/gear.php?set=' . (int) $source['id']);
|
||||||
|
}
|
||||||
|
$isOwnSource = (int) $source['user_id'] === $userId;
|
||||||
|
$newId = gear_set_copy($source, $userId, mb_substr($source['name'] . ($isOwnSource ? ' (Kopie)' : ' (' . $source['owner_name'] . ')'), 0, 80));
|
||||||
|
set_flash('success', $isOwnSource
|
||||||
|
? 'Das war dein eigenes Set – hier ist eine Kopie davon.'
|
||||||
|
: '„' . $source['name'] . '“ von ' . $source['owner_name'] . ' übernommen – das ist jetzt dein eigenes Set, Änderungen betreffen nur dich.');
|
||||||
|
redirect('/gear.php?set=' . $newId);
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$set = $ownSet();
|
$set = $ownSet();
|
||||||
$pdo->prepare('DELETE FROM gear_sets WHERE id = ?')->execute([$set['id']]);
|
$pdo->prepare('DELETE FROM gear_sets WHERE id = ?')->execute([$set['id']]);
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,17 @@ function auth_force_logout(string $message): void
|
||||||
set_flash('error', $message);
|
set_flash('error', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wohin nach dem Login: zur Seite, die vorher ohne Anmeldung aufgerufen wurde (require_login), sonst ins Dashboard.
|
||||||
|
* Nur Pfade dieser Website - keine fremden Adressen.
|
||||||
|
*/
|
||||||
|
function auth_login_return_target(): string
|
||||||
|
{
|
||||||
|
$target = (string) ($_SESSION['login_return'] ?? '');
|
||||||
|
unset($_SESSION['login_return']);
|
||||||
|
return preg_match('~^/(?![/\\\\])~', $target) && !preg_match('/[\x00-\x1f]/', $target) ? $target : '/dashboard.php';
|
||||||
|
}
|
||||||
|
|
||||||
/** Meldet einen Nutzer an (nach Passwort- oder Discord-Login). */
|
/** Meldet einen Nutzer an (nach Passwort- oder Discord-Login). */
|
||||||
function auth_login_session(int $userId, string $method): void
|
function auth_login_session(int $userId, string $method): void
|
||||||
{
|
{
|
||||||
|
|
@ -94,6 +105,14 @@ function require_login(): void
|
||||||
{
|
{
|
||||||
$user = current_user();
|
$user = current_user();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
|
// Aufgerufene Seite fuer nach dem Login merken (z.B. ein geteilter Build-Link aus Discord) - nur beim Aufruf im
|
||||||
|
// Browser, nicht bei Abrufen im Hintergrund (Live-Aktualisierung, Autosave), die sonst dort landen wuerden
|
||||||
|
$mode = (string) ($_SERVER['HTTP_SEC_FETCH_MODE'] ?? '');
|
||||||
|
$isPageView = ($_SERVER['REQUEST_METHOD'] ?? '') === 'GET' && empty($_SERVER['HTTP_X_REQUESTED_WITH'])
|
||||||
|
&& ($mode !== '' ? $mode === 'navigate' : str_contains((string) ($_SERVER['HTTP_ACCEPT'] ?? ''), 'text/html'));
|
||||||
|
if ($isPageView) {
|
||||||
|
$_SESSION['login_return'] = (string) ($_SERVER['REQUEST_URI'] ?? '');
|
||||||
|
}
|
||||||
redirect('/login.php');
|
redirect('/login.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -579,11 +579,116 @@ function gear_sets_for_user(int $userId, bool $profileOnly = false): array
|
||||||
return $stmt->fetchAll();
|
return $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Darf der aktuelle Nutzer das Set ansehen? Eigene immer, fremde nur, wenn aufs Profil freigegeben. */
|
/**
|
||||||
|
* Darf der aktuelle Nutzer das Set ansehen? Eigene immer, fremde, wenn aufs Profil freigegeben oder per Link/Buildcode
|
||||||
|
* geteilt und der Code in dieser Sitzung geoeffnet wurde - solange der Besitzer ihn nicht zurueckgezogen oder erneuert hat.
|
||||||
|
*/
|
||||||
function gear_can_view_set(array $set): bool
|
function gear_can_view_set(array $set): bool
|
||||||
{
|
{
|
||||||
$me = current_user();
|
$me = current_user();
|
||||||
return $me && ((int) $me['id'] === (int) $set['user_id'] || !empty($set['show_on_profile']));
|
if (!$me) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((int) $me['id'] === (int) $set['user_id'] || !empty($set['show_on_profile'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$opened = $_SESSION['gear_shared'][(int) $set['id']] ?? null;
|
||||||
|
return is_string($opened) && !empty($set['share_code']) && hash_equals((string) $set['share_code'], $opened);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Teilen per Link und Buildcode ----
|
||||||
|
// Der Code ist zugleich der Link (/gear.php?build=CODE): wer ihn hat, sieht das Set - auch wenn es nicht auf dem Profil
|
||||||
|
// steht - und kann es in seine eigenen Sets uebernehmen. Er zeigt immer den aktuellen Stand des Sets. Zeichen ohne die
|
||||||
|
// leicht verwechselbaren 0/O, 1/I/L; angezeigt in zwei Fuenfergruppen (K7QX2-M9FRT), gespeichert ohne Strich.
|
||||||
|
const GEAR_SHARE_ALPHABET = '23456789ABCDEFGHJKMNPQRSTUVWXYZ';
|
||||||
|
const GEAR_SHARE_LENGTH = 10;
|
||||||
|
|
||||||
|
function gear_share_code_new(): string
|
||||||
|
{
|
||||||
|
$code = '';
|
||||||
|
for ($i = 0; $i < GEAR_SHARE_LENGTH; $i++) {
|
||||||
|
$code .= GEAR_SHARE_ALPHABET[random_int(0, strlen(GEAR_SHARE_ALPHABET) - 1)];
|
||||||
|
}
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Code zum Anzeigen: "K7QX2-M9FRT" */
|
||||||
|
function gear_share_code_label(string $code): string
|
||||||
|
{
|
||||||
|
return substr($code, 0, 5) . '-' . substr($code, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Link zum geteilten Set */
|
||||||
|
function gear_share_url(string $code): string
|
||||||
|
{
|
||||||
|
return site_url('/gear.php?build=' . rawurlencode($code));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eingabe beim Importieren: der Buildcode (mit oder ohne Strich und Leerzeichen, egal ob gross oder klein) oder der
|
||||||
|
* ganze Link. Gibt den Code zurueck oder null, wenn es keiner sein kann.
|
||||||
|
*/
|
||||||
|
function gear_share_code_input(string $raw): ?string
|
||||||
|
{
|
||||||
|
$raw = trim($raw);
|
||||||
|
if (preg_match('~[?&]build=([^&#\s]+)~i', $raw, $match)) {
|
||||||
|
$raw = rawurldecode($match[1]);
|
||||||
|
}
|
||||||
|
$code = strtoupper((string) preg_replace('/[\s\-]+/u', '', $raw));
|
||||||
|
return preg_match('/^[' . GEAR_SHARE_ALPHABET . ']{' . GEAR_SHARE_LENGTH . '}$/', $code) ? $code : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function gear_set_by_share_code(string $code): ?array
|
||||||
|
{
|
||||||
|
$stmt = db()->prepare('SELECT id FROM gear_sets WHERE share_code = ?');
|
||||||
|
$stmt->execute([$code]);
|
||||||
|
$id = $stmt->fetchColumn();
|
||||||
|
return $id !== false ? gear_set((int) $id) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kopie eines Sets anlegen - beim Kopieren eines eigenen Sets und beim Uebernehmen eines geteilten oder aufs Profil
|
||||||
|
* gestellten: Ausruestung, Skills und alle Planer-Seiten samt Makro. Die Kopie ist weder geteilt noch auf dem Profil.
|
||||||
|
* Ohne $sortOrder kommt sie ans Ende der Sets. Gibt die ID der Kopie zurueck.
|
||||||
|
*/
|
||||||
|
function gear_set_copy(array $source, int $userId, string $name, ?int $sortOrder = null): int
|
||||||
|
{
|
||||||
|
$pdo = db();
|
||||||
|
if ($sortOrder === null) {
|
||||||
|
$last = $pdo->prepare('SELECT COALESCE(MAX(sort_order), 0) + 10 FROM gear_sets WHERE user_id = ?');
|
||||||
|
$last->execute([$userId]);
|
||||||
|
$sortOrder = (int) $last->fetchColumn();
|
||||||
|
}
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
try {
|
||||||
|
$pdo->prepare(
|
||||||
|
'INSERT INTO gear_sets (user_id, name, class_name, note, build_url, show_on_profile, sort_order, updated_at)
|
||||||
|
SELECT ?, ?, class_name, note, build_url, 0, ?, NOW() FROM gear_sets WHERE id = ?'
|
||||||
|
)->execute([$userId, $name, $sortOrder, (int) $source['id']]);
|
||||||
|
$newId = (int) $pdo->lastInsertId();
|
||||||
|
$pdo->prepare(
|
||||||
|
'INSERT INTO gear_set_slots (set_id, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone)
|
||||||
|
SELECT ?, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone FROM gear_set_slots WHERE set_id = ?'
|
||||||
|
)->execute([$newId, (int) $source['id']]);
|
||||||
|
$pdo->prepare('INSERT INTO gear_set_skills (set_id, skill_id, level, specs) SELECT ?, skill_id, level, specs FROM gear_set_skills WHERE set_id = ?')
|
||||||
|
->execute([$newId, (int) $source['id']]);
|
||||||
|
$pdo->prepare('INSERT INTO gear_set_plans (set_id, section, data, updated_at) SELECT ?, section, data, NOW() FROM gear_set_plans WHERE set_id = ?')
|
||||||
|
->execute([$newId, (int) $source['id']]);
|
||||||
|
$pdo->commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
return $newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Geoeffneten Buildcode fuer diese Sitzung merken - dann gehen auch die Reiter, Slots und der Vergleich des Sets. */
|
||||||
|
function gear_share_remember(array $set): void
|
||||||
|
{
|
||||||
|
$opened = is_array($_SESSION['gear_shared'] ?? null) ? $_SESSION['gear_shared'] : [];
|
||||||
|
unset($opened[(int) $set['id']]);
|
||||||
|
$opened[(int) $set['id']] = (string) $set['share_code'];
|
||||||
|
$_SESSION['gear_shared'] = array_slice($opened, -50, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function gear_is_own_set(array $set): bool
|
function gear_is_own_set(array $set): bool
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,17 @@ const PATCHNOTE_TYPES = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const PATCHNOTES = [
|
const PATCHNOTES = [
|
||||||
|
[
|
||||||
|
'id' => '2026-09-26-e',
|
||||||
|
'date' => '2026-09-26',
|
||||||
|
'title' => 'Builds teilen und importieren',
|
||||||
|
'summary' => 'Teile deine Gear-Sets per Link oder Buildcode – und übernimm Builds von anderen mit einem Klick.',
|
||||||
|
'changes' => [
|
||||||
|
['type' => 'neu', 'area' => 'Gear-Planer', 'text' => '„Teilen“ bei deinem Set erzeugt einen Link und einen kurzen Buildcode (z.B. K7QX2-M9FRT) zum Kopieren. Wer ihn hat, sieht dein Set – auch wenn es nicht auf deinem Profil steht – immer im aktuellen Stand. Mit „Neuen Code erzeugen“ oder „Nicht mehr teilen“ machst du den alten ungültig.'],
|
||||||
|
['type' => 'neu', 'area' => 'Gear-Planer', 'text' => '„Build importieren“ unter „Meine Sets“: Buildcode oder Link einfügen, und das Set kommt als dein eigenes zu deinen Sets – mit Ausrüstung, Skills, Makros und allen Planer-Seiten. Beim Ansehen eines fremden Sets geht das auch direkt mit „In meine Sets übernehmen“.'],
|
||||||
|
['type' => 'verbessert', 'area' => 'Login', 'text' => 'Öffnest du einen Link zur Website, ohne angemeldet zu sein, landest du nach dem Login direkt auf dieser Seite statt im Dashboard.'],
|
||||||
|
],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'id' => '2026-09-26-d',
|
'id' => '2026-09-26-d',
|
||||||
'date' => '2026-09-26',
|
'date' => '2026-09-26',
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||||
const SCHEMA_VERSION = 58;
|
const SCHEMA_VERSION = 59;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||||
|
|
@ -112,11 +112,15 @@ CREATE TABLE IF NOT EXISTS gear_sets (
|
||||||
build_url VARCHAR(300) NULL,
|
build_url VARCHAR(300) NULL,
|
||||||
-- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen)
|
-- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen)
|
||||||
show_on_profile TINYINT(1) NOT NULL DEFAULT 0,
|
show_on_profile TINYINT(1) NOT NULL DEFAULT 0,
|
||||||
|
-- Per Link/Buildcode geteilt (includes/gear.php, gear_share_*): wer den Code hat, sieht das Set und kann es
|
||||||
|
-- uebernehmen - NULL = nicht geteilt
|
||||||
|
share_code VARCHAR(12) NULL,
|
||||||
sort_order INT NOT NULL DEFAULT 0,
|
sort_order INT NOT NULL DEFAULT 0,
|
||||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at DATETIME NULL,
|
updated_at DATETIME NULL,
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
INDEX idx_gear_sets_user (user_id, sort_order)
|
INDEX idx_gear_sets_user (user_id, sort_order),
|
||||||
|
UNIQUE KEY uq_gear_sets_share (share_code)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
SQL,
|
SQL,
|
||||||
'gear_set_slots' => <<<'SQL'
|
'gear_set_slots' => <<<'SQL'
|
||||||
|
|
@ -857,6 +861,8 @@ function schema_column_upgrades(): array
|
||||||
// Link zum Skill-/Daevanion-Plan eines Gear-Sets (gear.php, "Set bearbeiten")
|
// Link zum Skill-/Daevanion-Plan eines Gear-Sets (gear.php, "Set bearbeiten")
|
||||||
'gear_sets' => [
|
'gear_sets' => [
|
||||||
'build_url' => "ALTER TABLE gear_sets ADD COLUMN build_url VARCHAR(300) NULL AFTER note",
|
'build_url' => "ALTER TABLE gear_sets ADD COLUMN build_url VARCHAR(300) NULL AFTER note",
|
||||||
|
// Per Link/Buildcode geteilt (gear.php, "Teilen") - NULL = nicht geteilt
|
||||||
|
'share_code' => "ALTER TABLE gear_sets ADD COLUMN share_code VARCHAR(12) NULL AFTER show_on_profile, ADD UNIQUE KEY uq_gear_sets_share (share_code)",
|
||||||
],
|
],
|
||||||
// Skillplaner: deutsche Namen und Spezialisierungen (includes/gear_skills.php)
|
// Skillplaner: deutsche Namen und Spezialisierungen (includes/gear_skills.php)
|
||||||
'gear_skills' => [
|
'gear_skills' => [
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
} else {
|
} else {
|
||||||
$error = attempt_login($username, $password);
|
$error = attempt_login($username, $password);
|
||||||
if ($error === '') {
|
if ($error === '') {
|
||||||
redirect('/dashboard.php');
|
redirect(auth_login_return_target());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -746,11 +746,15 @@ CREATE TABLE IF NOT EXISTS gear_sets (
|
||||||
build_url VARCHAR(300) NULL,
|
build_url VARCHAR(300) NULL,
|
||||||
-- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen)
|
-- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen)
|
||||||
show_on_profile TINYINT(1) NOT NULL DEFAULT 0,
|
show_on_profile TINYINT(1) NOT NULL DEFAULT 0,
|
||||||
|
-- Per Link/Buildcode geteilt (includes/gear.php, gear_share_*): wer den Code hat, sieht das Set und kann es
|
||||||
|
-- uebernehmen - NULL = nicht geteilt
|
||||||
|
share_code VARCHAR(12) NULL,
|
||||||
sort_order INT NOT NULL DEFAULT 0,
|
sort_order INT NOT NULL DEFAULT 0,
|
||||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at DATETIME NULL,
|
updated_at DATETIME NULL,
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
INDEX idx_gear_sets_user (user_id, sort_order)
|
INDEX idx_gear_sets_user (user_id, sort_order),
|
||||||
|
UNIQUE KEY uq_gear_sets_share (share_code)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS gear_set_slots (
|
CREATE TABLE IF NOT EXISTS gear_set_slots (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue