ticket_id bintval http_request ticket_id POST 10 uid USER init session

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ticket_id = bintval(http_request('ticket_id','POST',10));
$uid = USER::init()->session_data('id');
if ($ticket_id <= 0) out_json_data(array('tickets_stat'=>false,'head'=>false,'data'=>false));
$tickets = DB::init(__LINE__,__FILE__)->query("SELECT DISTINCT t2.`noid`,t2.`created`,IFNULL(t2.aname,0) AS reply,t2.`text`,t3.`category`,t1.`status`,t1.`them`,t1.`priority` ".
"FROM tickets AS t1,tickets_message AS t2,tickets_category AS t3 ".
"WHERE t1.uid='$uid' AND t1.id='$ticket_id' AND t2.id=t1.id AND t3.id=t1.cid ");
if (DB::init()->num()){
USER::init()->session_data_put('ticket_id',$ticket_id);
$first = true;
$head['user'] = USER::init()->session_data('login');
$data = array();
while ($row = DB::init()->assoc($tickets)){
$data[] = array('noid'=>$row['noid'],'created'=>date('d.m.Y/H:i',$row['created']),'reply'=>$row['reply'],'text'=> ($row['text']));
if ($first){
$head['category'] = $row['category'];
$head['them'] = $row['them'];
$head['status'] = $row['status'];
$head['count_new'] = ($row['status'] == 3)?$this->get_count_new($uid)-1:$this->get_count_new($uid);
$first = false;
}
}
//file_put_contents(DIR.'tickets_.txt',print_r($data,1));
if ($head['status'] == 3){
DB::init(__LINE__,__FILE__)->query_unbuf("UPDATE `tickets` SET `status`='1' WHERE (`id`='$ticket_id')");
}
out_json_data(array('tickets_stat'=>true,'head'=>$head,'data'=>$data));
}else {
out_json_data(array('tickets_stat'=>false,'head'=>false,'data'=>false));
}