'error', 'message' => 'OPCache configuration file not found']); exit(1); } $ini_content = file_get_contents($ini_file); if ($ini_content === false) { echo json_encode(['status' => 'error', 'message' => 'Cannot read OPCache configuration file']); exit(1); } switch ($action) { case 'enable': $new_content = preg_replace('/opcache\.enable\s*=\s*0/', 'opcache.enable = 1', $ini_content); break; case 'disable': $new_content = preg_replace('/opcache\.enable\s*=\s*1/', 'opcache.enable = 0', $ini_content); break; default: echo json_encode(['status' => 'error', 'message' => 'Invalid action']); exit(1); } if (file_put_contents($ini_file, $new_content) === false) { echo json_encode(['status' => 'error', 'message' => 'Cannot write to OPCache configuration file']); exit(1); } // Restart LiteSpeed to apply changes exec('service lsws restart', $output, $return_var); if ($return_var !== 0) { echo json_encode(['status' => 'warning', 'message' => 'OPCache ' . $action . 'd but LiteSpeed restart failed']); exit(1); } echo json_encode(['status' => 'success', 'message' => 'OPCache ' . $action . 'd successfully']);