| 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/ |
Upload File : |
<?php
include 'protect.php';
require_once __DIR__ . '/export_helpers.php';
$mapFile = privateCategorizerDir() . '/item_map.json';
$mapDir = dirname($mapFile);
if (!is_dir($mapDir)) {
if (!mkdir($mapDir, 0775, true)) {
http_response_code(500);
echo 'Failed to create category map directory';
exit;
}
}
$itemMap = json_decode(@file_get_contents($mapFile), true);
if (!$itemMap || !is_array($itemMap)) {
$itemMap = array();
}
if (!isset($_POST['item']) || !isset($_POST['category'])) {
http_response_code(400);
echo 'Missing parameters';
exit;
}
$itemKey = strtolower(trim((string) $_POST['item']));
$category = trim((string) $_POST['category']);
if ($itemKey === '' || $category === '') {
http_response_code(400);
echo 'Invalid values';
exit;
}
$itemMap[$itemKey] = $category;
if (file_put_contents($mapFile, json_encode($itemMap, JSON_PRETTY_PRINT))) {
echo 'OK';
exit;
}
http_response_code(500);
echo 'Failed to save';