<?php
declare(strict_types=1);
session_start();
if (empty($_SESSION['miter'])) {
header('Location: index.php');
exit;
}
?>
<div class='tenon_header'>
<div class='tenon_header_td'>
<span class='title'>Panels</span>
</div>
</div>
<div class='tenon_panel_table'>
<div class='tenon_td'>
<?php
$panel_txt_path = 'user/panels.txt';
if (file_exists($panel_txt_path)) {
$panel_file = file($panel_txt_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$count_panels = count($panel_file);
$count_panels = $count_panels - 1;
$i = 1;
foreach($panel_file as $panel_item) {
$panel_item_notitle = substr($panel_item, 0, 1);
$panel_item_get = substr($panel_item, 1);
$panel_item_title = preg_replace('/\s+/', '', $panel_item_get);
$panel_item_line = $panel_item_notitle . "" . $panel_item_title;
$panel_adj_title = str_replace("_", " ", $panel_item_title);
$array_pos = $i - 1;
$safe_item_line = htmlspecialchars($panel_item_line, ENT_QUOTES, 'UTF-8');
$safe_adj_title = htmlspecialchars(substr($panel_adj_title, 0, 30), ENT_QUOTES, 'UTF-8');
echo "<div class='list_doc'><div class='list_doc_left'><span class='text'>" . $i++ . ". </span><a href='index.php?u=panels&pnl={$safe_item_line}'>{$safe_adj_title}</a></div>";
echo "<span class='span_right'>";
if ($array_pos == '0') {
echo "<a href=''><img src='images/icons/up.png' class='tenon_list_button_end' alt='up'></a>";
} else {
echo "<a href='back/panels/panels_up.php?pnl={$array_pos}'><img src='images/icons/up.png' class='tenon_list_button_end' alt='up'></a>";
}
if ($array_pos == $count_panels) {
echo "<a href='' class='grey'><img src='images/icons/down.png' class='tenon_list_button_end' alt='down'></a>";
} else {
echo "<a href='back/panels/panels_down.php?pnl={$array_pos}'><img src='images/icons/down.png' class='tenon_list_button_end' alt='down'></a>";
}
echo "<a href='back/panels/panels_delete.php?pnl={$safe_item_line}' onclick='return confirm_delete()'><img src='images/icons/delete_line.png' class='tenon_list_button_end' alt='delete'></a>";
echo "</span></div>";
}
}
?>
</div>
</div>
<?php
$panel_huh_notitle = '';
$panel_fill_title = '';
$panel_write_edit = '';
$panel_addy = '';
if (isset($_GET['pnl'])) {
$panel_huh = $_GET['pnl'];
$panel_huh_notitle = substr($panel_huh, 0, 1);
$panel_huh_get = preg_replace('/[^a-zA-Z0-9_-]/', '', substr($panel_huh, 1));
$panel_addy = "panels/" . $panel_huh_get . ".txt";
$panel_fill_title = str_replace("_", " ", $panel_huh_get);
$panel_write_edit = $_GET['pnl'];
}
?>
<div class='tenon_header_middle'>
<div class='tenon_header_td'>
<?php
if (isset($_GET['pnl'])) {
echo "<span class='title'>Edit " . htmlspecialchars($panel_fill_title, ENT_QUOTES, 'UTF-8') . "</span>";
} else {
echo "<span class='title'>New Panel</span>";
}
?>
</div>
</div>
<div class='full_tenon_table'>
<form name='panelform' id='panelform' action='back/panels/<?php
if (isset($_GET['pnl'])) {
echo 'panels_edit.php';
} else {
echo 'panels_new.php';
}
?>' method='POST' enctype='multipart/form-data'>
<div class='title_field_table'>
<div class='title_field_left'>
<input id='title' name='title' class='title_field_panel' placeholder='Title' value='<?php
if (isset($_GET['pnl'])) {
echo htmlspecialchars($panel_fill_title, ENT_QUOTES, 'UTF-8');
} ?>' maxlength='35' required>
</div>
<div class='title_field_right'>
<?php
if ($panel_huh_notitle == '2') {
echo "<input type='checkbox' class='checkbox_title' id='hidetitle' name='hidetitle' value='yes' checked>";
} else {
echo "<input type='checkbox' class='checkbox_title' id='hidetitle' name='hidetitle' value='yes'>";
}
?><span class='grey'>Hide Title</span>
</div>
</div>
<textarea id='panel' name='panel' class='full_textarea' placeholder='Content' required><?php
if (isset($_GET['pnl']) && file_exists($panel_addy)) {
echo htmlspecialchars(file_get_contents($panel_addy), ENT_QUOTES, 'UTF-8');
}
?></textarea>
<?php
if (isset($_GET['pnl'])) {
echo "<input type='hidden' id='panel_edit_name' name='panel_edit_name' value='" . htmlspecialchars($panel_write_edit, ENT_QUOTES, 'UTF-8') . "'>";
}
?>
<input type='submit' name='submit' value='Update' class='full_submit_button_middle'>
</form>
</div>
<div class='full_button_table'>
<div class='full_button_td'>
<?php $more_buttons = 'back/tenon/tenon_inserts_form.php'; ?>
<?php include $more_buttons; ?>
</div>
</div>
<div class='bump'></div>
<script src='back/js/autosize.js'></script>
<script> autosize(document.querySelectorAll('textarea')); </script>
<script src='back/js/panels_lower.js'></script>