Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
71 righe
2.9 KiB
71 righe
2.9 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
if (!empty($_POST) && !empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice,$_POST["codice"]) && tokenVerify()) { |
|
if (!empty($_SESSION["ente"])) { $_POST["codice_ente"] = $_SESSION["ente"]->codice; } |
|
$coerenza = ""; |
|
if ($_POST["tipologia"]=="HTML" && empty($_POST["testo"])) { $coerenza = __('testo') . " " . __('obbligatorio'); } |
|
if ($_POST["tipologia"]=="Link" && empty($_POST["link"])) { $coerenza = __('Link') . " " . __('obbligatorio'); } |
|
if (empty($_POST["codice"])) { |
|
$sql = "SELECT max(ordinamento) as ordinamento FROM b_pagina "; |
|
$ris = $pdo->go($sql); |
|
$_POST["ordinamento"] = 0; |
|
if ($ris->rowCount() > 0) { |
|
$_POST["ordinamento"] = $ris->fetch(PDO::FETCH_ASSOC)["ordinamento"] ?? 0; |
|
$_POST["ordinamento"]++; |
|
} |
|
} |
|
if (empty($coerenza)) { |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_pagina"; |
|
$salva->operazione = empty($_POST["codice"]) ? "INSERT" : "UPDATE"; |
|
$salva->oggetto = $_POST; |
|
$codice = $salva->save(); |
|
if ($codice !== false) { |
|
$error = false; |
|
if (isset($_POST["allegato"])) { |
|
$errori_upload = array(); |
|
foreach($_POST["allegato"] as $allegato) { |
|
if (filesManager::saveFile($allegato["filename"],$codice,"pagine",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? "") === false) { |
|
$errori_upload[] = $allegato["filename"]; |
|
} |
|
} |
|
} |
|
if (isset($_POST["allegato-multimedia"])) { |
|
$errori_upload = array(); |
|
foreach($_POST["allegato-multimedia"] as $allegato) { |
|
if (filesManager::saveFile($allegato["filename"],$codice,"pagine",$allegato["nome"] ?? "","M",$allegato["classificazione"] ?? "") === false) { |
|
$errori_upload[] = $allegato["filename"]; |
|
} |
|
} |
|
} |
|
if (!empty($errori_upload)) { |
|
$errori = implode("<br><strong>" . __("errore") . " upload:</strong> ", $errori_upload); |
|
?> |
|
swal({title:js_dict["success-msg"],html:"<div style='text-align:left'><strong><?= __("errore") ?> upload:</strong> <?= $errori ?></div>",type:"warning"}).then(function(){ window.location.href="/backend/pagine/edit.php?codice=<?= $codice ?>"; }); |
|
<? |
|
} else { |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ window.location.href="/backend/pagine/edit.php?codice=<?= $codice ?>"; }); |
|
<? |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:js_dict["error-generic"],type:"error"}); |
|
<? |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:'<?= $coerenza ?>',type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|
|
|