Entrar

$erro

"; ?>
$imgName, 'texto' => trim($_POST['texto'] ?? ''), 'cor' => $_POST['cor'] ?? '', 'direcao' => $_POST['direcao'] ?? '', 'link' => trim($_POST['link'] ?? ''), ]; if (file_put_contents($jsonPath, json_encode($slides, JSON_PRETTY_PRINT)) === false) { die("Erro ao gravar no slides.json"); } atualizarHTML($slides, $htmlPath); header("Location: " . basename(__FILE__)); exit; } // SALVAR ALTERAÇÕES (editar e reordenar) if (isset($_POST['save'])) { $novos_slides = []; $ids = array_keys($slides); $ordem = $_POST['ordem'] ?? []; foreach ($ids as $i) { $texto = trim($_POST['texto'][$i] ?? ''); $cor = $_POST['cor'][$i] ?? ''; $link = trim($_POST['link'][$i] ?? ''); $direcao = $_POST['direcao'][$i] ?? ''; $ord = intval($ordem[$i] ?? 0); $novos_slides[$i] = [ 'imagem' => $slides[$i]['imagem'], 'texto' => $texto, 'cor' => $cor, 'link' => $link, 'direcao' => $direcao, 'ordem' => $ord, ]; } usort($novos_slides, function($a, $b) { return ($a['ordem'] ?? 0) <=> ($b['ordem'] ?? 0); }); foreach ($novos_slides as &$slide) { unset($slide['ordem']); } $slides = $novos_slides; if (file_put_contents($jsonPath, json_encode($slides, JSON_PRETTY_PRINT)) === false) { die("Erro ao gravar no slides.json"); } atualizarHTML($slides, $htmlPath); header("Location: " . basename(__FILE__)); exit; } // EXCLUIR SLIDE if (isset($_GET['delete'])) { $index = (int) $_GET['delete']; if (isset($slides[$index])) { $imgDel = $slides[$index]['imagem']; @unlink("$imagensDir/$imgDel"); array_splice($slides, $index, 1); file_put_contents($jsonPath, json_encode($slides, JSON_PRETTY_PRINT)); atualizarHTML($slides, $htmlPath); } header("Location: " . basename(__FILE__)); exit; } function atualizarHTML($slides, $htmlPath) { $novoConteudo = '
' . PHP_EOL; foreach ($slides as $slide) { $botao = ''; if (!empty(trim($slide['texto'] ?? ''))) { $cor = $slide['cor'] ?? '#000'; $dir = $slide['direcao'] ?? 'up'; $txt = htmlspecialchars($slide['texto']); $link = htmlspecialchars($slide['link'] ?? '#') ?: '#'; $botao = "$txt"; } $novoConteudo .= << $botao
HTML; } $novoConteudo .= <<❮
HTML; foreach ($slides as $i => $_) { $n = $i + 1; $novoConteudo .= " "; } $novoConteudo .= '
'; $html = file_get_contents($htmlPath); $novoHtml = preg_replace( '#
.*?
\s*#s', $novoConteudo, $html ); file_put_contents($htmlPath, $novoHtml); } ?> Editar Slides

Gerenciar Slides

Use imagens com a proporção 81/46. As dimensões de exibição são 405px de largura por 230px de altura.


Editar slides existentes

$s): ?>
Ordem Imagem Texto do botão Link do botão Cor do botão Direção Ações
Excluir