| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcfs/tabs/categorize/ |
Upload File : |
<?php
/* autosave.php
Handles AJAX saving of item ? category mappings
*/
$map_file = __DIR__ . "/item_map.json";
/* Load existing map or create blank */
$item_map = json_decode(@file_get_contents($map_file), true);
if (!$item_map || !is_array($item_map)) {
$item_map = [];
}
/* Validate request */
if (!isset($_POST['item']) || !isset($_POST['category'])) {
http_response_code(400);
echo "Missing parameters";
exit;
}
$item = strtolower(trim($_POST['item']));
$category = trim($_POST['category']);
if ($item === "" || $category === "") {
http_response_code(400);
echo "Invalid values";
exit;
}
/* Update mapping */
$item_map[$item] = $category;
/* Save JSON safely */
if (file_put_contents($map_file, json_encode($item_map, JSON_PRETTY_PRINT))) {
echo "OK";
} else {
http_response_code(500);
echo "Failed to save";
}
?>