fix special char in Profile

This commit is contained in:
novgorodschi catalin
2026-08-10 19:25:19 +03:00
parent 853d4dcecb
commit ba9bb0f6f6
4 changed files with 210 additions and 44 deletions
+9 -3
View File
@@ -269,8 +269,14 @@ class Profile {
* numele se afiseaza in rapoarte de lupta, pe harta si in listele de
* sate - deci codul se executa in browserul altor jucatori.
*
* Aceleasi reguli ca la numele de cont: litere, cifre, punct, liniuta,
* underscore si spatii simple. Fara caractere cu inteles in HTML.
* Permise: litere, cifre, punct, liniuta, underscore, paranteze
* rotunde si drepte, plus spatii simple intre grupuri.
*
* Parantezele sunt sigure aici: nu au niciun inteles in HTML, iar
* numele satelor nu trec prin BBCode (acesta se aplica doar pe
* descrierile de profil si pe forum), deci un sat numit "[b]x[/b]"
* se afiseaza ca atare, nu ingrosat. Raman excluse < > & " ',
* adica exact caracterele care ar putea sparge HTML-ul.
*/
if (function_exists('mb_strlen')) {
if (mb_strlen($newName, 'UTF-8') > 25) {
@@ -280,7 +286,7 @@ class Profile {
$newName = substr($newName, 0, 25);
}
if (!preg_match('/^[\p{L}\p{N}._-]+(?: [\p{L}\p{N}._-]+)*$/u', $newName)) {
if (!preg_match('/^[\p{L}\p{N}._\-\[\]()]+(?: [\p{L}\p{N}._\-\[\]()]+)*$/u', $newName)) {
continue; // nume respins, satul isi pastreaza numele vechi
}
+107 -20
View File
@@ -204,18 +204,50 @@ if ($hour > 1759 || $hour < 500) {
?>
<div id="goldHeader">
<?php
if ($session->gold <= 1) {
echo '<font color="#B3B3B3">
<img src="' . GP_LOCATE . 'img/a/gold_g.gif" alt="' . GOLD . '" title="' . GOLD . '"/>
' . $session->gold . ' ' . GOLD . '
</font>';
} else {
echo '<img src="' . GP_LOCATE . 'img/a/gold.gif" alt="' . GOLD . '" title="' . GOLD . '"/>
' . $session->gold . ' ' . GOLD;
}
/**
* FORMAT COMPACT: iconita + valoare, fara cuvintele "Aur"/"Argint".
* Cuvintele au ramas in title/alt, deci se vad la mouseover.
*
* ICONITE SVG, nu gif-uri din graphic pack: gold.gif si gold_g.gif
* aveau alt contur si alta dimensiune decat silver.png, asa ca cele
* doua randuri nu se aliniau. Acum ambele sunt desenate la fel -
* acelasi cerc, aceeasi rama, aceeasi marime - si difera doar
* culoarea monedelor. Aceleasi clase ca iconita de argint din
* componenta Hero (css/hero_header.css), deci se potrivesc intre ele.
*/
$goldLabel = defined('GOLD') ? GOLD : 'Gold';
$goldValue = (int) $session->gold;
/**
* Argintul eroului, afisat langa aur (doar cu functiile T4 pornite).
* Un teanc de monede, desenat o singura data si refolosit.
* $tone alege paleta: aur, aur stins (fara aur) sau argint.
*/
if (!function_exists('tzCoinIcon')) {
function tzCoinIcon($tone, $title)
{
$cls = 'tzCoinStack tzCoin-' . $tone;
return '<svg viewBox="0 0 24 24" class="' . $cls . '" role="img">'
. '<title>' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</title>'
. '<circle cx="12" cy="12" r="11" class="tzCoinBg" />'
. '<ellipse cx="12" cy="16.1" rx="6.2" ry="2.3" class="tzCoinDisc" />'
. '<ellipse cx="12" cy="13.1" rx="6.2" ry="2.3" class="tzCoinDisc" />'
. '<ellipse cx="12" cy="10.1" rx="6.2" ry="2.3" class="tzCoinDisc" />'
. '<ellipse cx="12" cy="10.1" rx="2.6" ry="0.9" class="tzCoinShine" />'
. '</svg>';
}
}
// sub 2 monede aurul era deja afisat stins in interfata veche
$goldTone = ($goldValue <= 1) ? 'goldOff' : 'gold';
echo '<div id="goldHeaderRow" class="tzCoinRow tzCoinRow-' . $goldTone . '">'
. tzCoinIcon($goldTone, $goldValue . ' ' . $goldLabel)
. '<span class="tzCoinValue">' . $goldValue . '</span>'
. '</div>';
/**
* Argintul eroului, afisat sub aur (doar cu functiile T4 pornite).
* Valoarea sta pe randul eroului, in hero.silver. O tinem in
* $GLOBALS, nu intr-o variabila "static": intr-un fisier inclus,
* "static" nu persista intre includeri, deci nu ar fi un cache real.
@@ -228,10 +260,11 @@ if ($hour > 1759 || $hour < 500) {
}
$t4SilverLabel = defined('HERO_SILVER') ? HERO_SILVER : 'Silver';
$t4SilverValue = (int) $GLOBALS['t4SilverValue'];
echo '<div id="silverHeader">'
. '<img src="img/hero/silver.png" alt="' . $t4SilverLabel . '" title="' . $t4SilverLabel . '"/>'
. ' ' . (int) $GLOBALS['t4SilverValue'] . ' ' . $t4SilverLabel
echo '<div id="silverHeader" class="tzCoinRow tzCoinRow-silver">'
. tzCoinIcon('silver', $t4SilverValue . ' ' . $t4SilverLabel)
. '<span class="tzCoinValue">' . $t4SilverValue . '</span>'
. '</div>';
}
?>
@@ -325,26 +358,80 @@ if ($hour > 1759 || $hour < 500) {
/* GOLD IN DREPTUNGHIUL ALBASTRU (RELOCARE_GOLD_LOCATIE_EROU.png)
Vechea pozitie era left:370px, adica exact cercul rosu - acolo sta
acum componenta Hero (#tzHeroBox), asa ca aurul s-a mutat la dreapta,
dupa butonul Plus si iconita day/night. */
dupa butonul Plus si iconita day/night.
ANCORAT LA DREAPTA, NU LA STANGA (right, nu left):
#mtop are 570px latime, deci right:-104px pune marginea dreapta la
x=674, sub limita de 686 peste care pagina se taie pe mobil
(#header are min-width:980px si #mtop incepe la ~294px absolut).
Ancorarea la dreapta face ca valorile lungi (un jucator cu milioane
de argint) sa creasca spre STANGA, nu spre marginea paginii - cu
"left" ar fi iesit iar din ecran. */
#goldHeader {
position: absolute;
left: 630px; /* << DREPTUNGHIUL ALBASTRU - muta 620-680 daca e nevoie */
/* Centrare pe verticala in bara gri: ancoram la mijloc si compensam
inaltimea proprie. Asa ramane centrat si acum, cand sunt doua
randuri (aur + argint), nu impins spre partea de jos. */
/* ANCORAT IN INTERIORUL BARII.
#mtop are 700px latime, nu 570: lang.css face @import la
modules/new_layout_ltr.css, care se incarca DUPA compact.css si
ii suprascrie regula. Cu right negativ blocul iesea din pagina
pe mobil. right:8px il tine mereu in bara, oricat de lunga ar fi
valoarea, si lasa ~45px fata de iconita day/night. */
right: 8px;
left: auto;
white-space: nowrap;
top: 40%;
transform: translateY(-50%);
width: auto;
min-width: 100px;
height: auto;
min-height: 22px;
line-height: 16px;
text-align: center;
text-align: right;
font-size: 11px;
font-weight: bold;
z-index: 50;
}
/* Randurile de aur/argint: iconita si valoarea aliniate pe aceeasi
linie de baza, ca sa nu mai "sara" una fata de alta. */
#goldHeader .tzCoinRow {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 4px;
height: 18px;
}
#goldHeader .tzCoinStack {
display: block;
width: 16px;
height: 16px;
flex: 0 0 16px;
}
#goldHeader .tzCoinValue {
display: inline-block;
}
/* Rama comuna: acelasi cerc pentru toate cele trei variante */
#goldHeader .tzCoinBg {
fill: #f6f5f2;
stroke: #b8b6b1;
stroke-width: 1;
}
/* Aur */
#goldHeader .tzCoin-gold .tzCoinDisc { fill: #e3b427; stroke: #9a7512; stroke-width: .8; }
#goldHeader .tzCoin-gold .tzCoinShine { fill: #f7e08a; }
/* Aur epuizat: aceeasi forma, doar decolorata (inlocuieste gold_g.gif) */
#goldHeader .tzCoin-goldOff .tzCoinDisc { fill: #d3d2ce; stroke: #a3a19c; stroke-width: .8; }
#goldHeader .tzCoin-goldOff .tzCoinShine { fill: #efeeeb; }
#goldHeader .tzCoinRow-goldOff .tzCoinValue { color: #b3b3b3; }
/* Argint */
#goldHeader .tzCoin-silver .tzCoinDisc { fill: #cdd2d6; stroke: #7e858b; stroke-width: .8; }
#goldHeader .tzCoin-silver .tzCoinShine { fill: #eef1f3; }
#goldHeader img {
vertical-align: middle;
margin-right: 4px;
+77 -17
View File
@@ -273,17 +273,54 @@ if (isset($building) && is_object($building) && method_exists($building, 'getTyp
$tzHeroField = (int) $building->getTypeField(37);
}
/**
* ATENTIE la varianta "build.php?gid=37" fara nimic in spate: build.php
* rezolva gid-ul in satul CURENT, iar daca nu gaseste cladirea pune id = 1,
* adica primul camp de resurse. Cine nu avea nici erou, nici Resedinta,
* ajungea pe Padure cand apasa pe cerc. De aceea nu mai construim niciodata
* linkul "orb": daca nu stim un camp valid, componenta ramane needclickabila.
*
* $tzHeroClickable spune daca avem o tinta reala:
* - cladirea 37 exista in satul curent -> link direct
* - altfel, stim satul eroului -> newdid + gid=37
* - altfel (fara erou SI fara Resedinta nicaieri) -> fara link
*/
$tzHeroClickable = true;
if ($tzHeroField > 0) {
$tzHeroBase = 'build.php?id=' . $tzHeroField;
} elseif ($tzHeroWref > 0) {
$tzHeroBase = 'build.php?newdid=' . $tzHeroWref . '&amp;gid=37';
} else {
$tzHeroBase = 'build.php?gid=37';
$tzHeroBase = '';
$tzHeroClickable = false;
}
$tzLinkHero = $tzHeroBase;
$tzLinkAdv = $tzHeroBase . '&amp;t4tab=adventures';
$tzLinkAuc = $tzHeroBase . '&amp;t4tab=auction';
$tzLinkAdv = $tzHeroClickable ? $tzHeroBase . '&amp;t4tab=adventures' : '';
$tzLinkAuc = $tzHeroClickable ? $tzHeroBase . '&amp;t4tab=auction' : '';
/**
* Cand nu e clickabil folosim <span> in loc de <a>: fara href gol, fara
* cursor de link, fara intrare in ordinea de tabulare. Tooltip-ul ramane.
*/
$tzTag = $tzHeroClickable ? 'a' : 'span';
/**
* Deschide slotul ca <a href=...> sau ca <span>, dupa caz.
* function_exists: un template inclus de doua ori intr-un request ar da
* fatal error la redeclarare.
*/
if (!function_exists('tzHeroSlotOpen')) {
function tzHeroSlotOpen($link, $classes, $clickable)
{
if ($clickable && $link !== '') {
return '<a href="' . $link . '" class="' . $classes . '">';
}
return '<span class="' . $classes . ' tzHeroNoLink">';
}
}
/**
* ---------------------------------------------------------------------------
@@ -357,7 +394,7 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<div id="tzHeroBox" class="<?php echo $tzHeroDead ? 'tzHeroDeadState' : ''; ?>">
<!-- ============ STANGA: locatia eroului -> 37.tpl ============ -->
<a href="<?php echo $tzLinkHero; ?>" class="tzHeroSlot tzHeroHome">
<?php echo tzHeroSlotOpen($tzLinkHero, 'tzHeroSlot tzHeroHome', $tzHeroClickable); ?>
<?php if ($tzHeroState === 'dead') { ?>
@@ -373,13 +410,12 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<?php } elseif ($tzHeroState === 'adventure') { ?>
<!-- cizma de drum: eroul e plecat in aventura (ca in referinta) -->
<!-- indicator cu doua sageti: eroul e plecat in aventura -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
<circle cx="12" cy="12" r="11" class="tzHeroIcoBg" />
<path class="tzHeroBoot"
d="M8.4 4.6h3.9c.5 0 .9.4.9.9v5.2c0 1.5.7 2.4 2 3.1l2.6 1.4c.9.5 1.4 1.2 1.4 2.1v1.2c0 .5-.4.9-.9.9H8.4c-.5 0-.9-.4-.9-.9V5.5c0-.5.4-.9.9-.9z" />
<path class="tzHeroBootSole" d="M7.5 17.2h11.7v1.3c0 .5-.4.9-.9.9H8.4c-.5 0-.9-.4-.9-.9z" />
<path class="tzHeroBootCuff" d="M7.5 5.5c0-.5.4-.9.9-.9h3.9c.5 0 .9.4.9.9v1.6H7.5z" />
<rect x="11.2" y="6.2" width="1.6" height="12" rx="0.4" class="tzHeroPost" />
<path d="M5.4 7.6h10.2l2.6 2-2.6 2H5.4z" class="tzHeroSign" />
<path d="M18.6 12.6H8.4l-2.6 2 2.6 2h10.2z" class="tzHeroSign" />
</svg>
<?php } elseif ($tzHeroState === 'attack') { ?>
@@ -402,9 +438,33 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<path d="M12 5.2v14c3.5-1.2 6.1-3.7 6.1-7.3V7.5z" class="tzHeroShieldDark" />
</svg>
<?php } elseif ($tzHeroState === 'training') { ?>
<!-- clepsidra: eroul e in antrenament, inca nu e disponibil -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
<circle cx="12" cy="12" r="11" class="tzHeroIcoBg" />
<rect x="7.2" y="5.4" width="9.6" height="1.7" rx="0.6" class="tzHeroGlassFrame" />
<rect x="7.2" y="16.9" width="9.6" height="1.7" rx="0.6" class="tzHeroGlassFrame" />
<path d="M8.9 7.1h6.2L12 12z" class="tzHeroGlass" />
<path d="M8.9 16.9h6.2L12 12z" class="tzHeroGlass" />
<path d="M9.9 8.4h4.2L12 11z" class="tzHeroSand" />
<path d="M10.3 16.9h3.4L12 14.6z" class="tzHeroSand" />
</svg>
<?php } elseif ($tzHeroState === 'nohero') { ?>
<!-- silueta stinsa: jucatorul nu are inca niciun erou.
Acelasi desen ca portretul gol din centru, ca sa se citeasca
imediat ca "aici inca nu e nimeni". -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
<circle cx="12" cy="12" r="11" class="tzHeroIcoBg" />
<circle cx="12" cy="9.8" r="3.5" class="tzHeroNone" />
<path d="M5.6 19.2c0-3.7 2.9-5.8 6.4-5.8s6.4 2.1 6.4 5.8z" class="tzHeroNone" />
</svg>
<?php } else { ?>
<!-- casuta: eroul e in satul lui (sau in antrenament) -->
<!-- casuta: eroul e in satul lui -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
<circle cx="12" cy="12" r="11" class="tzHeroIcoBg" />
<path class="tzHeroRoof" d="M12 5 4.3 11.3h2.3v6.8h10.8v-6.8h2.3z" />
@@ -461,10 +521,10 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
</i>
<?php } ?>
</span>
</a>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<!-- ============ CENTRU: portret + inel Health/Experience -> 37.tpl ============ -->
<a href="<?php echo $tzLinkHero; ?>" class="tzHeroSlot tzHeroCenter">
<?php echo tzHeroSlotOpen($tzLinkHero, 'tzHeroSlot tzHeroCenter', $tzHeroClickable); ?>
<svg viewBox="0 0 64 64" class="tzHeroRing" aria-hidden="true">
@@ -510,20 +570,20 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<?php } ?>
<?php } ?>
</span>
</a>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<?php if ($tzHeroT4) { ?>
<!-- ============ DREAPTA SUS: aventuri -> 37_adventures.tpl ============ -->
<a href="<?php echo $tzLinkAdv; ?>" class="tzHeroSlot tzHeroAdv <?php echo $tzHeroAdv > 0 ? 'tzHeroAdvOn' : 'tzHeroAdvOff'; ?>">
<?php echo tzHeroSlotOpen($tzLinkAdv, 'tzHeroSlot tzHeroAdv ' . ($tzHeroAdv > 0 ? 'tzHeroAdvOn' : 'tzHeroAdvOff'), $tzHeroClickable); ?>
<span class="tzHeroAdvNum"><?php echo (int) $tzHeroAdv; ?></span>
<span class="tzHeroTip tzHeroTipAdv">
<b><?php echo $tzTxtAdventures; ?>: <?php echo (int) $tzHeroAdv; ?></b>
</span>
</a>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<!-- ============ DREAPTA JOS: argint -> 37_auction.tpl ============ -->
<a href="<?php echo $tzLinkAuc; ?>" class="tzHeroSlot tzHeroSilver">
<?php echo tzHeroSlotOpen($tzLinkAuc, 'tzHeroSlot tzHeroSilver', $tzHeroClickable); ?>
<!-- Teanc de monede desenat, in acelasi stil ca iconita de casa.
Inlocuieste img/hero/silver.png din graphic pack. -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
@@ -536,7 +596,7 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<span class="tzHeroTip tzHeroTipSilver">
<b><?php echo $tzTxtSilver; ?>: <?php echo number_format($tzHeroSilver); ?></b>
</span>
</a>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<?php } ?>
+17 -4
View File
@@ -160,10 +160,17 @@ div#mtop {
.tzHeroSkull { fill: #e9e7e2; stroke: #7d7b76; stroke-width: .8; }
.tzHeroSkullEye { fill: #3a3835; }
/* Starile "plecat": aventura (cizma), atac (sabii), intarire (scut) */
.tzHeroBoot { fill: #8a6a3f; stroke: #5f482a; stroke-width: .8; }
.tzHeroBootSole { fill: #4a3a24; }
.tzHeroBootCuff { fill: #b08a52; }
/* Aventura: indicator cu doua sageti */
.tzHeroPost { fill: #8a6a3f; }
.tzHeroSign { fill: #d8c9a6; stroke: #8a6a3f; stroke-width: .8; }
/* Antrenament: clepsidra */
.tzHeroGlassFrame { fill: #8a6a3f; }
.tzHeroGlass { fill: #dfe6ea; stroke: #8f9aa1; stroke-width: .7; }
.tzHeroSand { fill: #d8a93f; }
/* Fara erou: silueta stinsa, la fel ca portretul gol din centru */
.tzHeroNone { fill: #b9b7b2; }
.tzHeroBlade { fill: none; stroke: #9a9894; stroke-width: 2.2; stroke-linecap: round; }
.tzHeroHilt { fill: none; stroke: #8a6a3f; stroke-width: 2.2; stroke-linecap: round; }
@@ -241,6 +248,12 @@ div#mtop {
display: block;
}
/* Slot fara tinta valida (fara erou SI fara Resedinta Eroului nicaieri):
ramane vizibil si cu tooltip, dar nu mai arata a link. */
.tzHeroNoLink {
cursor: default;
}
.tzHeroTip b {
display: block;
color: #ffffff;