mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-17 00:31:02 +00:00
fix mass message and sysmessage
This commit is contained in:
@@ -47,7 +47,20 @@ $_SESSION['mass_color'] = $_SESSION['mass_color'] ?? 'black';
|
|||||||
.massmsg-form button:hover{background:#d35400}
|
.massmsg-form button:hover{background:#d35400}
|
||||||
|
|
||||||
.massmsg-success{margin-top:16px;padding:10px;background:#fef5e7;border:1px solid #e67e22;color:#a04000;border-radius:6px;text-align:center;font-weight:bold}
|
.massmsg-success{margin-top:16px;padding:10px;background:#fef5e7;border:1px solid #e67e22;color:#a04000;border-radius:6px;text-align:center;font-weight:bold}
|
||||||
.massmsg-confirm{background:#fff3cd;border:1px solid #ffeaa7;padding:15px;border-radius:8px;margin-bottom:15px}
|
.massmsg-confirm{background:#fff3cd;border:1px solid #ffeaa7;padding:12px;border-radius:8px;margin-bottom:12px;color:#6b5900}
|
||||||
|
/* Previzualizare: fundal alb si text inchis, ca mesajul sa fie lizibil
|
||||||
|
indiferent ce culoare a fost aleasa pentru titlu. */
|
||||||
|
.massmsg-preview{border:1px solid #ddd;border-radius:8px;overflow:hidden;margin-bottom:15px;background:#fff}
|
||||||
|
.massmsg-preview-head{background:#f4f4f6;border-bottom:1px solid #e2e2e6;padding:7px 12px;
|
||||||
|
font-size:11px;font-weight:bold;color:#666;text-transform:uppercase;letter-spacing:.5px}
|
||||||
|
.massmsg-preview-body{padding:16px 18px}
|
||||||
|
.massmsg-preview-text{color:#2b2b2b;font-size:13px;line-height:1.55;word-wrap:break-word}
|
||||||
|
.massmsg-preview-text a{color:#2980b9}
|
||||||
|
/* bara de formatare */
|
||||||
|
.bbbar{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:6px}
|
||||||
|
.bbbar button{background:#f2f2f4;border:1px solid #d8d8dc;color:#333;border-radius:5px;
|
||||||
|
padding:4px 10px;font-size:12px;cursor:pointer;line-height:1.2}
|
||||||
|
.bbbar button:hover{background:#e6e6ea}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="massmsg-wrap">
|
<div class="massmsg-wrap">
|
||||||
@@ -69,8 +82,56 @@ $_SESSION['mass_color'] = $_SESSION['mass_color'] ?? 'black';
|
|||||||
|
|
||||||
<?php if(isset($_GET['confirm'])):?>
|
<?php if(isset($_GET['confirm'])):?>
|
||||||
<div class="massmsg-confirm">
|
<div class="massmsg-confirm">
|
||||||
<b><?php echo ADM_CONFIRM; ?></b><?php echo ADM_ARE_YOU_SURE_YOU_WANT_TO_SEND; ?><br>
|
<b><?php echo ADM_CONFIRM; ?></b><?php echo ADM_ARE_YOU_SURE_YOU_WANT_TO_SEND; ?>
|
||||||
<b><?php echo ADM_SUBJECT; ?></b> <span style="color:<?=$_SESSION['mass_color']?>"><?=htmlspecialchars($_SESSION['mass_subject'])?></span>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Previzualizare REALA a mesajului.
|
||||||
|
*
|
||||||
|
* Inainte se vedea doar subiectul, pe fundalul galben de avertizare -
|
||||||
|
* iar daca alegeai o culoare deschisa, devenea invizibil. Corpul
|
||||||
|
* mesajului nu se afisa deloc.
|
||||||
|
*
|
||||||
|
* Randam aceleasi coduri ca la trimitere: [b] [i] [u] din BBCode.php,
|
||||||
|
* plus [url] si [img], care sunt convertite de massmessage.php.
|
||||||
|
*/
|
||||||
|
$mmText = htmlspecialchars($_SESSION['mass_message'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
$mmText = str_replace(
|
||||||
|
array('[b]','[/b]','[i]','[/i]','[u]','[/u]'),
|
||||||
|
array('<b>','</b>','<i>','</i>','<u>','</u>'),
|
||||||
|
$mmText
|
||||||
|
);
|
||||||
|
|
||||||
|
// Doar adrese http(s), ca in massmessage.php. Textul e deja escapat,
|
||||||
|
// deci ghilimelele nu pot iesi din atribut.
|
||||||
|
$mmText = preg_replace_callback('/\[img\](.*?)\[\/img\]/is', function ($m) {
|
||||||
|
$u = trim($m[1]);
|
||||||
|
return preg_match('#^https?://#i', $u)
|
||||||
|
? '<img src="' . $u . '" alt="" style="max-width:100%">'
|
||||||
|
: $u;
|
||||||
|
}, $mmText);
|
||||||
|
|
||||||
|
$mmText = preg_replace_callback('/\[url\](.*?)\[\/url\]/is', function ($m) {
|
||||||
|
$u = trim($m[1]);
|
||||||
|
return preg_match('#^https?://#i', $u)
|
||||||
|
? '<a href="' . $u . '" target="_blank" rel="noopener">' . $u . '</a>'
|
||||||
|
: $u;
|
||||||
|
}, $mmText);
|
||||||
|
|
||||||
|
$mmColor = preg_match('/^(#[0-9a-fA-F]{3,6}|[a-zA-Z]{3,20})$/', (string) ($_SESSION['mass_color'] ?? ''))
|
||||||
|
? $_SESSION['mass_color'] : '#333333';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="massmsg-preview">
|
||||||
|
<div class="massmsg-preview-head"><?php echo ADM_PREVIEW ?? 'Preview'; ?></div>
|
||||||
|
<div class="massmsg-preview-body">
|
||||||
|
<h2 style="color:<?=htmlspecialchars($mmColor)?>;margin:0 0 10px 0;font-size:16px">
|
||||||
|
<?=htmlspecialchars($_SESSION['mass_subject'], ENT_QUOTES, 'UTF-8')?>
|
||||||
|
</h2>
|
||||||
|
<div class="massmsg-preview-text"><?=nl2br($mmText)?></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form action="../GameEngine/Admin/Mods/massmessage.php" method="POST" class="massmsg-form">
|
<form action="../GameEngine/Admin/Mods/massmessage.php" method="POST" class="massmsg-form">
|
||||||
<?php echo csrf_field(); ?>
|
<?php echo csrf_field(); ?>
|
||||||
@@ -104,7 +165,39 @@ $_SESSION['mass_color'] = $_SESSION['mass_color'] ?? 'black';
|
|||||||
|
|
||||||
<div class="field full">
|
<div class="field full">
|
||||||
<label><?php echo ADM_MESSAGE_CONTENT; ?></label>
|
<label><?php echo ADM_MESSAGE_CONTENT; ?></label>
|
||||||
<textarea name="message" rows="12" placeholder="<?php echo ADM_WRITE_THE_MESSAGE_YOU_CAN_USE_URL_IMG; ?>" required></textarea>
|
<div class="bbbar">
|
||||||
|
<button type="button" onclick="bbWrap('[b]','[/b]')"><b>B</b></button>
|
||||||
|
<button type="button" onclick="bbWrap('[i]','[/i]')"><i>I</i></button>
|
||||||
|
<button type="button" onclick="bbWrap('[u]','[/u]')"><u>U</u></button>
|
||||||
|
<button type="button" onclick="bbWrap('[url]','[/url]')">URL</button>
|
||||||
|
<button type="button" onclick="bbWrap('[img]','[/img]')">IMG</button>
|
||||||
|
</div>
|
||||||
|
<textarea name="message" id="massmsg_text" rows="12" placeholder="<?php echo ADM_WRITE_THE_MESSAGE_YOU_CAN_USE_URL_IMG; ?>" required></textarea>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* Insereaza coduri BBCode in jurul selectiei.
|
||||||
|
* Fara selectie, le pune la cursor si lasa cursorul intre ele.
|
||||||
|
*
|
||||||
|
* Codurile disponibile sunt cele pe care le randeaza jocul: [b] [i] [u] din
|
||||||
|
* BBCode.php, plus [url] si [img], convertite de massmessage.php la trimitere.
|
||||||
|
* Culoarea NU apare aici - la mesajele catre jucatori ea se aplica doar
|
||||||
|
* titlului, prin campul separat de mai sus.
|
||||||
|
*/
|
||||||
|
function bbWrap(open, close) {
|
||||||
|
var t = document.getElementById('massmsg_text');
|
||||||
|
if (!t) { return; }
|
||||||
|
|
||||||
|
var a = t.selectionStart, b = t.selectionEnd;
|
||||||
|
var sel = t.value.substring(a, b);
|
||||||
|
|
||||||
|
t.value = t.value.substring(0, a) + open + sel + close + t.value.substring(b);
|
||||||
|
|
||||||
|
var pos = a + open.length + sel.length;
|
||||||
|
t.focus();
|
||||||
|
t.setSelectionRange(pos, pos);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit">
|
<button type="submit">
|
||||||
|
|||||||
@@ -43,6 +43,19 @@ $_SESSION['sys_color'] = $_SESSION['sys_color'] ?? 'black';
|
|||||||
.sysmsg-form{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:14px}
|
.sysmsg-form{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:14px}
|
||||||
.sysmsg-form .field{display:flex;flex-direction:column;gap:4px}
|
.sysmsg-form .field{display:flex;flex-direction:column;gap:4px}
|
||||||
.sysmsg-form label{font-size:11px;color:#555;font-weight:bold}
|
.sysmsg-form label{font-size:11px;color:#555;font-weight:bold}
|
||||||
|
/* Previzualizare: fundal alb si text inchis, ca mesajul sa fie lizibil
|
||||||
|
indiferent ce culoare a ales adminul pentru titlu. */
|
||||||
|
.sysmsg-preview{border:1px solid #ddd;border-radius:8px;overflow:hidden;margin-bottom:15px;background:#fff}
|
||||||
|
.sysmsg-preview-head{background:#f4f4f6;border-bottom:1px solid #e2e2e6;padding:7px 12px;
|
||||||
|
font-size:11px;font-weight:bold;color:#666;text-transform:uppercase;letter-spacing:.5px}
|
||||||
|
.sysmsg-preview-body{padding:16px 18px}
|
||||||
|
.sysmsg-preview-text{color:#2b2b2b;font-size:13px;line-height:1.55;word-wrap:break-word}
|
||||||
|
/* bara de formatare */
|
||||||
|
.bbbar{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:6px}
|
||||||
|
.bbbar button{background:#f2f2f4;border:1px solid #d8d8dc;color:#333;border-radius:5px;
|
||||||
|
padding:4px 10px;font-size:12px;cursor:pointer;line-height:1.2}
|
||||||
|
.bbbar button:hover{background:#e6e6ea}
|
||||||
|
.bbbar .sw{width:22px;height:22px;padding:0;border-radius:50%;border:1px solid rgba(0,0,0,.25)}
|
||||||
.sysmsg-form input,.sysmsg-form textarea{
|
.sysmsg-form input,.sysmsg-form textarea{
|
||||||
padding:9px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px;font-family:Verdana
|
padding:9px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px;font-family:Verdana
|
||||||
}
|
}
|
||||||
@@ -58,7 +71,7 @@ $_SESSION['sys_color'] = $_SESSION['sys_color'] ?? 'black';
|
|||||||
.sysmsg-form button:hover{background:#6c3483}
|
.sysmsg-form button:hover{background:#6c3483}
|
||||||
|
|
||||||
.sysmsg-confirm{
|
.sysmsg-confirm{
|
||||||
background:#fff3cd;border:1px solid #ffeaa7;padding:15px;border-radius:8px;margin-bottom:15px
|
background:#fff3cd;border:1px solid #ffeaa7;padding:12px;border-radius:8px;margin-bottom:12px;color:#6b5900
|
||||||
}
|
}
|
||||||
|
|
||||||
.sysmsg-success{
|
.sysmsg-success{
|
||||||
@@ -79,12 +92,46 @@ $_SESSION['sys_color'] = $_SESSION['sys_color'] ?? 'black';
|
|||||||
<?php if(isset($_GET['confirm'])): ?>
|
<?php if(isset($_GET['confirm'])): ?>
|
||||||
|
|
||||||
<div class="sysmsg-confirm">
|
<div class="sysmsg-confirm">
|
||||||
<b><?php echo ADM_CONFIRMARE_SYSTEM_MESSAGE; ?></b><br><br>
|
<b><?php echo ADM_CONFIRMARE_SYSTEM_MESSAGE; ?></b>
|
||||||
<b><?php echo ADM_COLOR; ?></b> <span style="color:<?=htmlspecialchars($_SESSION['sys_color'])?>">
|
</div>
|
||||||
<?=htmlspecialchars($_SESSION['sys_subject'])?>
|
|
||||||
</span>
|
<?php
|
||||||
<br><br>
|
/**
|
||||||
<div><?=nl2br(htmlspecialchars($_SESSION['sys_message']))?></div>
|
* Previzualizare REALA a mesajului.
|
||||||
|
*
|
||||||
|
* Inainte, textul se afisa cu htmlspecialchars pe fundal galben: BBCode-ul
|
||||||
|
* aparea brut ([b]...[/b]), iar un subiect intr-o culoare deschisa devenea
|
||||||
|
* invizibil. Acum randam aceleasi coduri ca text_format.tpl, pe fundal alb,
|
||||||
|
* deci vezi exact ce vor vedea jucatorii.
|
||||||
|
*/
|
||||||
|
$prevText = htmlspecialchars($_SESSION['sys_message'], ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
$prevText = str_replace(
|
||||||
|
array('[b]','[/b]','[i]','[/i]','[u]','[/u]'),
|
||||||
|
array('<b>','</b>','<i>','</i>','<u>','</u>'),
|
||||||
|
$prevText
|
||||||
|
);
|
||||||
|
|
||||||
|
// doar cod hexazecimal, ca in text_format.tpl
|
||||||
|
$prevText = preg_replace('/\[color=(#[0-9a-fA-F]{3,6})\]/', '<span style="color:$1">', $prevText);
|
||||||
|
// Inchidem doar atatea etichete cate s-au deschis, ca sa nu ramana
|
||||||
|
// un </span> orfan cand codul de culoare a fost invalid.
|
||||||
|
$prevOpen = substr_count($prevText, '<span style="color:');
|
||||||
|
$prevText = preg_replace('/\[\/color\]/', '</span>', $prevText, $prevOpen);
|
||||||
|
$prevText = str_replace('[/color]', '', $prevText);
|
||||||
|
|
||||||
|
$prevColor = preg_match('/^#[0-9a-fA-F]{3,6}$/', (string) $_SESSION['sys_color'])
|
||||||
|
? $_SESSION['sys_color'] : '#333333';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="sysmsg-preview">
|
||||||
|
<div class="sysmsg-preview-head"><?php echo ADM_PREVIEW ?? 'Preview'; ?></div>
|
||||||
|
<div class="sysmsg-preview-body">
|
||||||
|
<h2 style="color:<?=htmlspecialchars($prevColor)?>;margin:0 0 10px 0;font-size:16px">
|
||||||
|
<?=htmlspecialchars($_SESSION['sys_subject'], ENT_QUOTES, 'UTF-8')?>
|
||||||
|
</h2>
|
||||||
|
<div class="sysmsg-preview-text"><?=nl2br($prevText)?></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="../GameEngine/Admin/Mods/sysmessage.php" method="POST" class="sysmsg-form">
|
<form action="../GameEngine/Admin/Mods/sysmessage.php" method="POST" class="sysmsg-form">
|
||||||
@@ -121,7 +168,42 @@ $_SESSION['sys_color'] = $_SESSION['sys_color'] ?? 'black';
|
|||||||
|
|
||||||
<div class="field full">
|
<div class="field full">
|
||||||
<label><?php echo ADM_MESSAGE; ?></label>
|
<label><?php echo ADM_MESSAGE; ?></label>
|
||||||
<textarea name="message" rows="12" required></textarea>
|
<div class="bbbar">
|
||||||
|
<button type="button" onclick="bbWrap('[b]','[/b]')"><b>B</b></button>
|
||||||
|
<button type="button" onclick="bbWrap('[i]','[/i]')"><i>I</i></button>
|
||||||
|
<button type="button" onclick="bbWrap('[u]','[/u]')"><u>U</u></button>
|
||||||
|
<?php
|
||||||
|
// culori uzuale; se pot schimba fara sa atingi restul
|
||||||
|
$bbColors = array('#c0392b', '#d35400', '#27ae60', '#2980b9', '#8e44ad', '#2b2b2b');
|
||||||
|
foreach ($bbColors as $bbc) {
|
||||||
|
echo '<button type="button" class="sw" style="background:' . $bbc . '"'
|
||||||
|
. ' title="' . $bbc . '"'
|
||||||
|
. " onclick=\"bbWrap('[color=" . $bbc . "]','[/color]')\"></button>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<textarea name="message" id="sysmsg_text" rows="12" required></textarea>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* Insereaza coduri BBCode in jurul selectiei din caseta de mesaj.
|
||||||
|
* Daca nu e nimic selectat, pune codurile la pozitia cursorului si lasa
|
||||||
|
* cursorul intre ele, ca sa poti scrie direct.
|
||||||
|
*/
|
||||||
|
function bbWrap(open, close) {
|
||||||
|
var t = document.getElementById('sysmsg_text');
|
||||||
|
if (!t) { return; }
|
||||||
|
|
||||||
|
var a = t.selectionStart, b = t.selectionEnd;
|
||||||
|
var sel = t.value.substring(a, b);
|
||||||
|
|
||||||
|
t.value = t.value.substring(0, a) + open + sel + close + t.value.substring(b);
|
||||||
|
|
||||||
|
var pos = a + open.length + sel.length;
|
||||||
|
t.focus();
|
||||||
|
t.setSelectionRange(pos, pos);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit"><?php echo ADM_CONTINUE; ?></button>
|
<button type="submit"><?php echo ADM_CONTINUE; ?></button>
|
||||||
|
|||||||
@@ -4313,3 +4313,8 @@ tz_def('TZ_WS_APPLIED', 'Automatically included in this simulation:');
|
|||||||
tz_def('TZ_WS_ITEM_STRENGTH', 'Equipment strength');
|
tz_def('TZ_WS_ITEM_STRENGTH', 'Equipment strength');
|
||||||
tz_def('TZ_WS_ITEM_UNIT', 'Weapon bonus');
|
tz_def('TZ_WS_ITEM_UNIT', 'Weapon bonus');
|
||||||
tz_def('TZ_WS_VS_NATARS', 'Against Natars');
|
tz_def('TZ_WS_VS_NATARS', 'Against Natars');
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// MESAJ DE SISTEM - previzualizare
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
tz_def('ADM_PREVIEW', 'Preview');
|
||||||
|
|||||||
@@ -4256,3 +4256,8 @@ tz_def('TZ_WS_APPLIED', 'Inclus automatiquement dans cette simulation :');
|
|||||||
tz_def('TZ_WS_ITEM_STRENGTH', 'Force de l\'equipement');
|
tz_def('TZ_WS_ITEM_STRENGTH', 'Force de l\'equipement');
|
||||||
tz_def('TZ_WS_ITEM_UNIT', 'Bonus d\'arme');
|
tz_def('TZ_WS_ITEM_UNIT', 'Bonus d\'arme');
|
||||||
tz_def('TZ_WS_VS_NATARS', 'Contre les Natars');
|
tz_def('TZ_WS_VS_NATARS', 'Contre les Natars');
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// MESAJ DE SISTEM - previzualizare
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
tz_def('ADM_PREVIEW', 'Aperçu');
|
||||||
|
|||||||
@@ -4053,3 +4053,8 @@ tz_def('TZ_WS_APPLIED', 'Incluse automat in aceasta simulare:');
|
|||||||
tz_def('TZ_WS_ITEM_STRENGTH', 'Forta echipamentului');
|
tz_def('TZ_WS_ITEM_STRENGTH', 'Forta echipamentului');
|
||||||
tz_def('TZ_WS_ITEM_UNIT', 'Bonus de arma');
|
tz_def('TZ_WS_ITEM_UNIT', 'Bonus de arma');
|
||||||
tz_def('TZ_WS_VS_NATARS', 'Contra Natarilor');
|
tz_def('TZ_WS_VS_NATARS', 'Contra Natarilor');
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// MESAJ DE SISTEM - previzualizare
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
tz_def('ADM_PREVIEW', 'Previzualizare');
|
||||||
|
|||||||
@@ -43,6 +43,25 @@ $bbMap = array(
|
|||||||
*/
|
*/
|
||||||
$txt = str_replace(array_keys($bbMap), array_values($bbMap), $txt);
|
$txt = str_replace(array_keys($bbMap), array_values($bbMap), $txt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ---------------------------------------------------------
|
||||||
|
* Culoare: [color=#rrggbb]...[/color]
|
||||||
|
*
|
||||||
|
* Se accepta DOAR cod hexazecimal, verificat cu expresie regulata. Fara asta,
|
||||||
|
* un mesaj de sistem ar putea strecura CSS arbitrar in pagina fiecarui jucator.
|
||||||
|
* ---------------------------------------------------------
|
||||||
|
*/
|
||||||
|
$txt = preg_replace(
|
||||||
|
'/\[color=(#[0-9a-fA-F]{3,6})\]/',
|
||||||
|
'<span style="color:$1">',
|
||||||
|
$txt
|
||||||
|
);
|
||||||
|
// Inchidem doar atatea etichete cate s-au deschis: un cod de culoare invalid
|
||||||
|
// nu trebuie sa lase un </span> orfan in pagina jucatorului.
|
||||||
|
$colorOpen = substr_count($txt, '<span style="color:');
|
||||||
|
$txt = preg_replace('/\[\/color\]/', '</span>', $txt, $colorOpen);
|
||||||
|
$txt = str_replace('[/color]', '', $txt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
* Preserve line breaks as in original implementation
|
* Preserve line breaks as in original implementation
|
||||||
|
|||||||
Reference in New Issue
Block a user