<?php
declare(strict_types=1);
session_start();
if (empty($_SESSION['miter'])) {
header('Location: ../../index.php');
exit;
}
$index = filter_input(INPUT_GET, 'pnl', FILTER_VALIDATE_INT);
if ($index !== false && $index >= 0) {
$panel_dir = __DIR__ . '/../../user/panels.txt';
if (file_exists($panel_dir) && is_writable($panel_dir)) {
$panel_data = array_map('trim', file($panel_dir, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
if (isset($panel_data[$index], $panel_data[$index + 1])) {
$temp = $panel_data[$index];
$panel_data[$index] = $panel_data[$index + 1];
$panel_data[$index + 1] = $temp;
$success = file_put_contents($panel_dir, implode("\n", $panel_data), LOCK_EX);
if ($success === false) {
error_log('panels_down.php: Failed to write to panels.txt');
}
}
}
}
header('Location: ../../index.php?u=panels', true, 303);
exit;