<?php

// tady můžete nastavit práva (1 - 3)
// here you can set the rights (1 - 3)
if ($rights>=3):

if ($a=="add_section") {

if ($section!="") {

include "transfer_quick.php";

$check=mysql_query("SELECT id FROM kcms_sections WHERE quick='".addslashes($quick)."'");
$check=mysql_fetch_array($check);

if ($check["id"]=="") {

$sql=mysql_query("INSERT INTO kcms_sections values ('', '".addslashes($quick)."', '".addslashes($section)."', '".addslashes($highlight)."')", $dbserver);

echo "<div class=\"popup-success\">$lang_alert_success</div>";

} else {

echo "<div class=\"popup-error\">$lang_alert_existing_section</div>";

}

} else {

echo "<div class=\"popup-error\">$lang_alert_empty_name</div>";

}

}

if ($a=="delete_section" AND $id!="") {

$sql=mysql_query("DELETE FROM kcms_sections WHERE id='".addslashes($id)."'", $dbserver);

echo "<div class=\"popup-success\">$lang_alert_success</div>";

}

if ($a=="rename" AND $id!="") {

if ($section!="") {

include "transfer_quick.php";

$old_quick=mysql_query("SELECT quick FROM kcms_sections WHERE id='".addslashes($id)."'");
$old_quick=mysql_fetch_array($old_quick);

if ($old_quick["quick"]!=$quick) {

$check=mysql_query("SELECT id FROM kcms_sections WHERE quick='".addslashes($quick)."'");
$check=mysql_fetch_array($check);

}

if ($check["id"]=="") {

$sql=mysql_query("UPDATE kcms_sections SET quick='".addslashes($quick)."', name='".addslashes($section)."', highlight='".addslashes($highlight)."' WHERE id='".addslashes($id)."'", $dbserver);

echo "<div class=\"popup-success\">$lang_alert_success</div>";

} else {

echo "<div class=\"popup-error\">$lang_alert_existing_section</div>";

}

} else {

echo "<div class=\"popup-error\">$lang_alert_empty_name</div>";

}

}

?>

<h2><?php echo($lang_sections); ?></h2>

<?php if ($f2==""): ?>

<form action="./admin.php?f=sections&amp;a=add_section" method="post">

<div><strong><?php echo($lang_form_add_section); ?>:</strong><br /><input type="text" name="section" style="width: 150px;" /> <input type="checkbox" name="highlight" value="1" /> <?php echo($lang_form_highlight); ?> <input type="submit" name="submit" value="<?php echo($lang_button_save); ?>" /></div>

</form>

<table>
<tr>
<th><?php echo($lang_form_section_name); ?></th>
<th><?php echo($lang_form_highlight); ?></th>
<th><?php echo($lang_form_options); ?></th>
</tr>
<?php

$print=mysql_query("SELECT id, name, highlight FROM kcms_sections ORDER by id");
while (list($id, $name, $highlight) = mysql_fetch_row($print)) {

echo "<tr>
<td>$name</td>
<td>";

if ($highlight==1) { echo "$lang_yes"; } else { echo "$lang_no"; }

echo "</td>
<td><input type=\"button\" value=\"$lang_button_edit\" onclick=\"parent.location='./admin.php?f=sections&amp;f2=edit_section&amp;id=$id';\" /> <input type=\"button\" value=\"$lang_button_delete\" onclick=\"if (!confirm('$lang_alert_sure')) return false; parent.location='./admin.php?f=sections&amp;a=delete_section&amp;id=$id';\" /></td>
</tr>\n";

}

?>
</table>

<?php

endif; if ($f2=="edit_section"):

$section=mysql_query("SELECT name, highlight FROM kcms_sections WHERE id='".addslashes($id)."'");
$section=mysql_fetch_array($section);

?>

<form action="./admin.php?f=sections&amp;a=rename&amp;id=<?php echo($id); ?>" method="post">

<div><strong><?php echo($lang_form_rename_section." ".$section["name"]); ?>:</strong><br /><input type="text" name="section" style="width: 150px;" value="<?php echo($section["name"]); ?>" /> <input type="checkbox" name="highlight" value="1"<?php if ($section["highlight"]==1) { echo " checked=\"checked\""; } ?> /> <?php echo($lang_form_highlight); ?> <input type="submit" name="submit" value="<?php echo($lang_button_rename); ?>" /></div>

</form>

<?php endif; else: $access_denied=1; endif; ?>