function prData_Domy($spojeni) { $id = $_POST["iddata"]; $iddum = $_SESSION["iddum"]; $idmenu = $_SESSION["iddomy_Menu"]; if (!$idmenu) { return 0; } $datum = date('Y-m-d-H-i-s'); $nazevdomu = $_SESSION["nazevdomu"]; $typ = $_GET["typ"]; $typmenu = $_POST["typm"]; $novy = $_POST["novy_x"] || $_POST["novy"]; $nahoru = $_POST["nahoru_x"]; $dolu = $_POST["dolu_x"]; $smazat = $_POST["smazat_x"]; $text = $_POST["text"]; $prejmenovat = $_POST["prejmenovat_x"] || $_POST["prejmenovat"]; if ($novy) { switch ($typ) { case "O": $poradi = $_POST["poradinove"]; $nazevobr = "{$iddum}-{$idmenu}-{$nazevdomu}-{$datum}"; $cesta = CESTA_OBRAZKY; $nazevs = UlozObrazek($cesta, $nazevobr, $typmenu); $nazevs = $cesta . $nazevs; $nazevnahl = str_replace("obr-", "nahled-", $nazevs); $sql = "INSERT INTO domy_Data (id_domy_Menu,id_dum,soubor,nahled,typ,poradi) VALUES ({$idmenu},{$iddum},'{$nazevs}','{$nazevnahl}','O',{$poradi})"; $res = PrSql($spojeni, $sql); break; case "S": $poradi = $_POST["poradinove"]; $text = $_POST["textn"]; $nazevs = "soub-{$iddum}-{$idmenu}-{$nazevdomu}-{$datum}"; $cesta = CESTA_SOUBORY; $nazevs = UlozSoubor($cesta); $nazevs = $cesta . $nazevs; $sql = "INSERT INTO domy_Data (id_domy_Menu,id_dum,soubor,text,typ,poradi) VALUES ({$idmenu},{$iddum},'{$nazevs}','{$text}','S',{$poradi})"; $res = PrSql($spojeni, $sql); break; case "T": $text = $_POST["text"]; $sql = "INSERT INTO domy_Data (id_domy_Menu,id_dum,text,typ) VALUES ({$idmenu},{$iddum},'{$text}','T')"; $res = PrSql($spojeni, $sql); break; } } if ($prejmenovat) { $sql = "UPDATE domy_Data SET text='{$text}' where id_domy_Data={$id}"; $res = PrSql($spojeni, $sql); } if ($smazat) { $sql = "SELECT * from domy_Data where id_domy_Data={$id}"; $res = PrSql($spojeni, $sql); $zaznam = mysqli_fetch_array($res); $soubor = $zaznam["soubor"]; // if ($soubor) unlink($soubor); $sql = "DELETE from domy_Data where id_domy_Data={$id}"; $res = PrSql($spojeni, $sql); } if ($nahoru || $dolu) { $poradi = $_POST["poradi"]; if ($nahoru) { $sql = "SELECT * from domy_Data where poradi<{$poradi} and id_dum={$iddum} order by poradi DESC LIMIT 1"; } else { $sql = "SELECT * from domy_Data where poradi>{$poradi} and id_dum={$iddum} order by poradi ASC LIMIT 1"; } $res = PrSQL($spojeni, $sql); $pocet = mysqli_num_rows($res); if ($pocet > 0) { $zaznam = mysqli_fetch_array($res); $idvrchni = $zaznam["id_domy_Data"]; $porvrchni = $zaznam["poradi"]; $sql = "UPDATE domy_Data SET poradi={$porvrchni} where id_domy_Data={$id}"; $res = PrSql($spojeni, $sql); $sql = "UPDATE domy_Data SET poradi={$poradi} where id_domy_Data={$idvrchni}"; $res = PrSql($spojeni, $sql); } } editData_Domy($spojeni); }
function editMenu_soubory($spojeni, $idmenu, $nazevmenu) { if ($_POST) { $novy = $_POST["novy_x"] || $_POST["novy"]; $nahoru = $_POST["nahoru_x"]; $dolu = $_POST["dolu_x"]; $smazat = $_POST["smazat_x"]; $id = $_POST["iddata"]; if ($smazat) { $sql = "DELETE from soubory_menu where id={$id}"; $res = PrSql($spojeni, $sql); } else { $poradi = $_POST["poradinove"]; $text = $_POST["textn"]; $nazevmenu = friendly_url($nazevmenu); $nazevs = "{$nazevmenu}-soub-{$iddum}-{$idmenu}-{$nazevdomu}-{$datum}"; $cesta = 'soubory/'; $nazevs = UlozSoubor($cesta); $nazevs = $cesta . $nazevs; $sql = "INSERT INTO soubory_menu (id_content_Menu,nazev,cesta,poradi) VALUES ({$idmenu},'{$text}','{$nazevs}',{$poradi})"; $res = PrSql($spojeni, $sql); } } ?> <script language="JavaScript"> function KontrolaNazvu(id) { var nazevform = "dataMenu" + id; var nazevpole = "text" + id; var text_jmena = document.forms[nazevform][nazevpole].value; var je_ok = text_jmena != ""; if (je_ok == false) alert('Nebyl zadán název souboru!'); return je_ok; } </script> <table> <?php $sql = "SELECT * FROM soubory_menu where id_content_Menu={$idmenu} order by poradi"; $res = PrSql($spojeni, $sql); $pocet = mysqli_num_rows($res); $poradi = 0; if ($pocet > 0) { ?> <tr><td colspan="3">Nahrané soubory</td></tr><tr> <?php $i = 0; $j = 1; while ($zaznam = mysqli_fetch_array($res)) { ?> <form name="dataMenu<?php echo $zaznam["id"]; ?> " ENCTYPE="multipart/form-data" method="post" action="" onsubmit="return KontrolaNazvu(<?php echo $zaznam["id_domy_Data"]; ?> );"> <td><input size="30" type="text" name="text" value="<?php echo $zaznam["nazev"]; ?> "><br> <a href="<?php echo $zaznam["cesta"]; ?> "><?php echo $zaznam["nazev"]; ?> </a><br> <input name="prejmenovat" type ="image" src="img/b_edit.png" value="1" > <?php if ($i > 0) { ?> <input name="nahoru" type ="image" src="img/j_arrow_left.png" value="1"><?php } if ($i < $pocet - 1) { ?> <input name="dolu" type ="image" src="img/j_arrow_right.png" value="1"><?php } ?> <input name="smazat" type ="image" src="img/b_drop.png" onclick="return confirm('Opravdu smazat?')" value="1"><input name="poradi" type="hidden" value="<?php echo $zaznam["poradi"]; ?> "><input name="iddata" type="hidden" value="<?php echo $zaznam["id"]; ?> "></td> </form> <?php $poradi = $zaznam["poradi"]; $i = $i + 1; $j = $j + 1; if ($j > 3) { echo "</tr><tr>"; $j = 1; } } ?> </tr> <?php } ?> <form name="dataMenun" ENCTYPE="multipart/form-data" method="post" action="" onsubmit="return KontrolaNazvu('n');"> <tr> <td><input name="novy" type ="image" src="img/icon-16-new.png" value="1"></td><td>Název souboru : <input type="text" value="" name="textn" value=""></td><td>Soubor : <input type="file" size="30" name="userfile" ><input name="poradinove" type="hidden" value="<?php echo $poradi + 1; ?> "></td> </tr> </form> </table> <?php }