This commit modifies the `fxAdminIsDevPreprod` function to improve environment validation for text editing tools, ensuring access is restricted to the appropriate development and pre-production environments. Additionally, it introduces a 403 Forbidden response in `traduction.php` for unauthorized access attempts, enhancing security and user feedback.
313 lines
10 KiB
PHP
313 lines
10 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Éditeur traduction info (pop-up bib v4) — info_texte + info_aide FR/EN.
|
|
*/
|
|
|
|
require_once('inc_start_time.php');
|
|
require_once('inc_fonctions.php');
|
|
require_once('inc_fx_messages.php');
|
|
|
|
if (!fxAdminCanUseTextEditTools()) {
|
|
header('HTTP/1.1 403 Forbidden');
|
|
echo 'Accès refusé.';
|
|
exit;
|
|
}
|
|
|
|
function tradEsc($str) {
|
|
return htmlspecialchars((string)$str, ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
function tradFieldAttrs($strChamp, $intRow) {
|
|
return 'id="info[' . (int)$intRow . '][' . tradEsc($strChamp) . ']" name="info[' . (int)$intRow . '][' . tradEsc($strChamp) . ']"';
|
|
}
|
|
|
|
function tradFieldVal($strChamp, $strType, $tabRow, $strDefault = '') {
|
|
if ($strType === 'mod' && is_array($tabRow) && array_key_exists($strChamp, $tabRow)) {
|
|
return $tabRow[$strChamp];
|
|
}
|
|
return $strDefault;
|
|
}
|
|
|
|
function tradRowByLang($tabResults) {
|
|
$tabOut = array('fr' => null, 'en' => null);
|
|
if (!is_array($tabResults)) {
|
|
return $tabOut;
|
|
}
|
|
foreach ($tabResults as $row) {
|
|
if (!empty($row['info_langue'])) {
|
|
$tabOut[$row['info_langue']] = $row;
|
|
}
|
|
}
|
|
return $tabOut;
|
|
}
|
|
|
|
$clef = trim($_GET['clef'] ?? $_POST['clef'] ?? '');
|
|
$bd = trim(strtolower($_GET['bd'] ?? $_POST['bd'] ?? 'client'));
|
|
$page = trim(strtolower($_GET['page'] ?? $_POST['page'] ?? ''));
|
|
$pk_prg = trim($_GET['pk_prg'] ?? $_POST['pk_prg'] ?? '');
|
|
$blnSaved = false;
|
|
|
|
if (isset($_POST['btn_mod']) && !empty($_POST['info']) && is_array($_POST['info'])) {
|
|
foreach ($_POST['info'] as $tabPosted) {
|
|
if (empty($tabPosted['info_clef']) || empty($tabPosted['info_langue'])) {
|
|
continue;
|
|
}
|
|
if (!empty($tabPosted['pk_info'])) {
|
|
fxSetInfo('mod', $tabPosted, '', $tabPosted['pk_info']);
|
|
} else {
|
|
$memId = 0;
|
|
fxSetInfo('add', $tabPosted, '', $memId);
|
|
}
|
|
$clef = trim($tabPosted['info_clef']);
|
|
$bd = trim(strtolower($tabPosted['bd'] ?? $bd));
|
|
$page = trim(strtolower($tabPosted['page'] ?? $page));
|
|
$pk_prg = trim(strtolower($tabPosted['info_prg'] ?? $pk_prg));
|
|
}
|
|
$blnSaved = true;
|
|
}
|
|
|
|
$sqlValide = "SELECT * FROM info
|
|
WHERE info_clef = '" . $objDatabase->fxEscape($clef) . "'
|
|
AND info_prg = '" . $objDatabase->fxEscape($pk_prg) . "'
|
|
ORDER BY info_langue DESC";
|
|
$recValide = $objDatabase->fxGetResults($sqlValide);
|
|
$tabLang = tradRowByLang($recValide);
|
|
$type = ($recValide != null) ? 'mod' : 'add';
|
|
|
|
$tabLangMeta = array(
|
|
'fr' => array('label' => 'Français', 'row' => 1),
|
|
'en' => array('label' => 'English', 'row' => 2),
|
|
);
|
|
|
|
?><!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Traduction — <?php echo tradEsc($clef); ?></title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
|
|
font-size: 14px;
|
|
line-height: 1.45;
|
|
color: #212529;
|
|
background: #f1f3f5;
|
|
}
|
|
.trad-page {
|
|
max-width: 920px;
|
|
margin: 0 auto;
|
|
padding: 20px 16px 28px;
|
|
}
|
|
.trad-card {
|
|
background: #fff;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 8px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,.06);
|
|
overflow: hidden;
|
|
}
|
|
.trad-card-header {
|
|
padding: 14px 18px;
|
|
background: #2f5fd0;
|
|
color: #fff;
|
|
}
|
|
.trad-card-header h1 {
|
|
margin: 0 0 4px;
|
|
font-size: 17px;
|
|
font-weight: 700;
|
|
}
|
|
.trad-card-header .trad-key {
|
|
font-size: 12px;
|
|
opacity: .9;
|
|
word-break: break-all;
|
|
}
|
|
.trad-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 10px;
|
|
padding: 12px 18px;
|
|
background: #f8f9fa;
|
|
border-bottom: 1px solid #e9ecef;
|
|
}
|
|
.trad-meta dt {
|
|
margin: 0;
|
|
font-size: 11px;
|
|
text-transform: uppercase;
|
|
letter-spacing: .04em;
|
|
color: #6c757d;
|
|
}
|
|
.trad-meta dd {
|
|
margin: 2px 0 0;
|
|
font-weight: 600;
|
|
word-break: break-all;
|
|
}
|
|
.trad-alert {
|
|
margin: 14px 18px 0;
|
|
padding: 10px 12px;
|
|
border-radius: 6px;
|
|
background: #d1e7dd;
|
|
color: #0f5132;
|
|
border: 1px solid #badbcc;
|
|
}
|
|
.trad-lang-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 16px;
|
|
padding: 18px;
|
|
}
|
|
@media (max-width: 720px) {
|
|
.trad-lang-grid { grid-template-columns: 1fr; }
|
|
.trad-meta { grid-template-columns: 1fr; }
|
|
}
|
|
.trad-lang-panel {
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 6px;
|
|
padding: 14px;
|
|
background: #fff;
|
|
}
|
|
.trad-lang-panel h2 {
|
|
margin: 0 0 12px;
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
color: #2f5fd0;
|
|
}
|
|
.trad-field {
|
|
margin-bottom: 12px;
|
|
}
|
|
.trad-field:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
.trad-field label {
|
|
display: block;
|
|
margin-bottom: 4px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
}
|
|
.trad-field .trad-hint {
|
|
font-weight: 400;
|
|
color: #868e96;
|
|
}
|
|
.trad-field input[type="text"],
|
|
.trad-field textarea {
|
|
width: 100%;
|
|
padding: 8px 10px;
|
|
border: 1px solid #ced4da;
|
|
border-radius: 4px;
|
|
font: inherit;
|
|
color: #212529;
|
|
background: #fff;
|
|
}
|
|
.trad-field textarea {
|
|
min-height: 120px;
|
|
resize: vertical;
|
|
}
|
|
.trad-field input:focus,
|
|
.trad-field textarea:focus {
|
|
outline: none;
|
|
border-color: #2f5fd0;
|
|
box-shadow: 0 0 0 2px rgba(47,95,208,.15);
|
|
}
|
|
.trad-actions {
|
|
padding: 0 18px 18px;
|
|
}
|
|
.trad-btn-save {
|
|
padding: 9px 22px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
background: #28a745;
|
|
color: #fff;
|
|
font: inherit;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
}
|
|
.trad-btn-save:hover {
|
|
background: #218838;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="trad-page">
|
|
<form action="<?php echo tradEsc($vDomaine); ?>/php/traduction.php" method="post" id="frm_traduction">
|
|
<input type="hidden" name="clef" value="<?php echo tradEsc($clef); ?>">
|
|
|
|
<div class="trad-card">
|
|
<div class="trad-card-header">
|
|
<h1>Traduction</h1>
|
|
<div class="trad-key"><?php echo tradEsc($clef); ?></div>
|
|
</div>
|
|
|
|
<dl class="trad-meta">
|
|
<div>
|
|
<dt>Programme</dt>
|
|
<dd><?php echo tradEsc($pk_prg); ?></dd>
|
|
</div>
|
|
<div>
|
|
<dt>Base</dt>
|
|
<dd><?php echo tradEsc($bd); ?></dd>
|
|
</div>
|
|
<div>
|
|
<dt>Page</dt>
|
|
<dd><?php echo tradEsc($page); ?></dd>
|
|
</div>
|
|
</dl>
|
|
|
|
<?php if ($blnSaved) { ?>
|
|
<div class="trad-alert">Enregistré.</div>
|
|
<?php } ?>
|
|
|
|
<div class="trad-lang-grid">
|
|
<?php foreach ($tabLangMeta as $strLang => $meta) {
|
|
$tabRow = $tabLang[$strLang];
|
|
$intRow = $meta['row'];
|
|
$strRowType = ($tabRow !== null) ? 'mod' : 'add';
|
|
?>
|
|
<section class="trad-lang-panel">
|
|
<h2><?php echo tradEsc($meta['label']); ?></h2>
|
|
|
|
<input type="hidden" <?php echo tradFieldAttrs('pk_info', $intRow); ?>
|
|
value="<?php echo tradEsc(tradFieldVal('pk_info', $strRowType, $tabRow)); ?>">
|
|
<input type="hidden" <?php echo tradFieldAttrs('info_clef', $intRow); ?>
|
|
value="<?php echo tradEsc($clef); ?>">
|
|
<input type="hidden" <?php echo tradFieldAttrs('info_prg', $intRow); ?>
|
|
value="<?php echo tradEsc($pk_prg); ?>">
|
|
<input type="hidden" <?php echo tradFieldAttrs('info_langue', $intRow); ?>
|
|
value="<?php echo tradEsc($strLang); ?>">
|
|
<input type="hidden" <?php echo tradFieldAttrs('bd', $intRow); ?>
|
|
value="<?php echo tradEsc($bd); ?>">
|
|
<input type="hidden" <?php echo tradFieldAttrs('page', $intRow); ?>
|
|
value="<?php echo tradEsc($page); ?>">
|
|
|
|
<div class="trad-field">
|
|
<label for="info[<?php echo $intRow; ?>][info_texte]">
|
|
Libellé <span class="trad-hint">(info_texte — vide autorisé)</span>
|
|
</label>
|
|
<input type="text"
|
|
<?php echo tradFieldAttrs('info_texte', $intRow); ?>
|
|
maxlength="50"
|
|
value="<?php echo tradEsc(tradFieldVal('info_texte', $strRowType, $tabRow)); ?>">
|
|
</div>
|
|
|
|
<div class="trad-field">
|
|
<label for="info[<?php echo $intRow; ?>][info_aide]">
|
|
Aide longue <span class="trad-hint">(info_aide — pop-up ?)</span>
|
|
</label>
|
|
<textarea <?php echo tradFieldAttrs('info_aide', $intRow); ?>><?php
|
|
echo tradEsc(tradFieldVal('info_aide', $strRowType, $tabRow));
|
|
?></textarea>
|
|
</div>
|
|
</section>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<div class="trad-actions">
|
|
<button type="submit" name="btn_mod" value="save" class="trad-btn-save">Enregistrer</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|