<?php
require_once('../wu_init.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }
include('wu_checkadmin.php');

if(isset($_POST['id'])){
if(!empty($_POST['id'])){
$id = intval($_POST['id']);

$ticket = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT id,new_a,closed FROM `".DB_PREFIX."_tickets_main` WHERE id='$id' LIMIT 1"));
if (empty($ticket['id'])) { exit('wu-error'); }

if ($ticket['new_a'] == 1) { exit('0'); }

if ($ticket['closed'] == 1) { exit('2'); }

mysqli_query($connect_db, "UPDATE `".DB_PREFIX."_tickets_main` SET `closed` = '1' WHERE id = '$id' LIMIT 1");

exit('1');
} else { exit('wu-error'); }
} else { exit('wu-error'); }
?>