* @author Slawkens * @copyright 2019 MyAAC * @link https://my-aac.org */ use MyAAC\Models\BugTracker; defined('MYAAC') or die('Direct access not allowed!'); $title = 'Bug tracker'; if(!$logged) { echo 'You are not logged in. Log in to post on the bug tracker.

'; return; } $showed = $post = $reply = false; // type (1 = question; 2 = answer) // status (1 = open; 2 = new message; 3 = closed;) $dark = $config['darkborder']; $light = $config['lightborder']; $tags = array(1 => "[MAP]", "[WEBSITE]", "[CLIENT]", "[MONSTER]", "[NPC]", "[OTHER]"); if(admin() and isset($_REQUEST['control']) && $_REQUEST['control'] == "true") { if(empty($_REQUEST['id']) and empty($_REQUEST['acc']) or !is_numeric($_REQUEST['acc']) or !is_numeric($_REQUEST['id']) ) $bug[1] = BugTracker::where('type', 1)->orderByDesc('uid')->get()->toArray(); if(!empty($_REQUEST['id']) and is_numeric($_REQUEST['id']) and !empty($_REQUEST['acc']) and is_numeric($_REQUEST['acc'])) $bug[2] = BugTracker::where('type', 1)->where('account', $_REQUEST['acc'])->where('id', $_REQUEST['id'])->get()->toArray(); if(!empty($_REQUEST['id']) and is_numeric($_REQUEST['id']) and !empty($_REQUEST['acc']) and is_numeric($_REQUEST['acc'])) { if(!empty($_REQUEST['reply'])) $reply=true; $account = new OTS_Account(); $account->load($_REQUEST['acc']); $account->isLoaded(); $players = $account->getPlayersList(); if(!$reply) { if($bug[2]['status'] == 2) $value = '[OPEN]'; elseif($bug[2]['status'] == 3) $value = '[CLOSED]'; elseif($bug[2]['status'] == 1) $value = '[NEW ANSWER]'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Bug Tracker
Subject'.$tags[$bug[2]['tag']].' '.$bug[2]['subject'].' '.$value.'
Posted by'; foreach($players as $player) { echo ''.$player->getName().'
'; } echo '
Description
'.nl2br($bug[2]['text']).'
'; $answers = BugTracker::where('account', $_REQUEST['acc'])->where('id', $_REQUEST['id'])->where('type', 2)->orderBy('reply')->get()->toArray(); foreach($answers as $answer) { if($answer['who'] == 1) $who = '[ADMIN]'; else $who = '[PLAYER]'; echo '
'; echo ''; echo ''; echo ''; echo '
Answer #'.$answer['reply'].'
Posted by'.$who.'
Description
'.nl2br($answer['text']).'
'; } if($bug[2]['status'] != 3) echo '
[REPLY]'; } else { if($bug[2]['status'] != 3) { $reply = BugTracker::where('account', $_REQUEST['acc'])->where('id', $_REQUEST['id'])->where('type', 2)->max('reply'); $reply = $reply + 1; $iswho = BugTracker::where('account', $_REQUEST['acc'])->where('id', $_REQUEST['id'])->where('type', 2)->orderByDesc('reply')->first()->toArray(); if(isset($_POST['finish'])) { if(empty($_POST['text'])) $error[] = 'Description cannot be empty.'; if($iswho['who'] == 1) $error[] = 'You must wait for User answer.'; if(empty($_POST['status'])) $error[] = 'Status cannot be empty.'; if(!empty($error)) { foreach($error as $errors) echo ''.$errors.'
'; } else { $type = 2; $INSERT = BugTracker::create([ 'account' => $_REQUEST['aac'], 'id' => $_REQUEST['id'], 'text' => $_POST['text'], 'reply' => $reply, 'type' => $type, 'who' => 1, ]); $UPDATE = Bugtracker::where('id', $_REQUEST['id'])->where('account', $_REQUEST['acc'])->update([ 'status' => $_POST['status'] ]); header('Location: ?subtopic=bugtracker&control=true&id='.$_REQUEST['id'].'&acc='.$_REQUEST['acc'].''); } } echo '
Description
Status[OPEN]
Status[CLOSED]

'; } else { echo '
You can\'t add answer to closed bug thread.'; } } $post=true; } if(!$post) { echo ''; $i=1; foreach($bug[1] as $report) { if($report['status'] == 2) $value = '[OPEN]'; elseif($report['status'] == 3) $value = '[CLOSED]'; elseif($report['status'] == 1) $value = '[NEW ANSWER]'; echo ''; $showed=true; $i++; } echo '
Bug Tracker Admin
'.$tags[$report['tag']].' '.$report['subject'].''.$value.'
'; } } else { $acc = $account_logged->getId(); $account_players = $account_logged->getPlayersList(); foreach($account_players as $player) { $allow=true; } if(!empty($_REQUEST['id'])) $id = addslashes(htmlspecialchars(trim($_REQUEST['id']))); if(empty($_REQUEST['id'])) $bug[1] = BugTracker::where('account', $account_logged->getId())->where('type', 1)->orderBy('id')->get()->toArray(); if(!empty($_REQUEST['id']) and is_numeric($_REQUEST['id'])) $bug[2] = BugTracker::where('account', $account_logged->getId())->where('type', 1)->where('id', $id)->get()->toArray(); else $bug[2] = NULL; if(!empty($_REQUEST['id']) and $bug[2] != NULL) { if(!empty($_REQUEST['reply'])) $reply=true; if(!$reply) { if($bug[2]['status'] == 1) $value = '[OPEN]'; elseif($bug[2]['status'] == 2) $value = '[NEW ANSWER]'; elseif($bug[2]['status'] == 3) $value = '[CLOSED]'; echo ''; echo ''; echo ''; echo ''; echo '
Bug Tracker
Subject'.$tags[$bug[2]['tag']].' '.$bug[2]['subject'].' '.$value.'
Description
'.nl2br($bug[2]['text']).'
'; $answers = Bugtracker::where('account', $account_logged->getId())->where('id', $id)->where('type', 2)->orderBy('reply')->get()->toArray(); foreach($answers as $answer) { if($answer['who'] == 1) $who = '[ADMIN]'; else $who = '[YOU]'; echo '
'; echo ''; echo ''; echo ''; echo '
Answer #'.$answer['reply'].'
Posted by'.$who.'
Description
'.nl2br($answer['text']).'
'; } if($bug[2]['status'] != 3) echo '
[REPLY]'; } else { if($bug[2]['status'] != 3) { $reply = BugTracker::where('account', $aac)->where('id', $id)->where('type', 2)->max('reply'); $reply = $reply + 1; $iswho = BugTracker::where('account', $acc)->where('id', $id)->where('type', 2)->orderByDesc('reply')->first()->toArray(); if(isset($_POST['finish'])) { if(empty($_POST['text'])) $error[] = 'Description cannot be empty.'; if($iswho['who'] == 0) $error[] = 'You must wait for Administrator answer.'; if(!$allow) $error[] = 'You haven\'t any characters on account.'; if(!empty($error)) { foreach($error as $errors) echo ''.$errors.'
'; } else { $type = 2; $INSERT = BugTracker::create([ 'account' => $acc, 'id' => $id, 'text' => $_POST['text'], 'reply' => $reply, 'type' => $type ]); $UPDATE = BugTracker::where('id', $id)->where('account', $acc)->update([ 'status' => 1 ]); header('Location: ?subtopic=bugtracker&id='.$id.''); } } echo '
Description

'; } else { echo '
You can\'t add answer to closed bug thread.'; } } $post=true; } elseif(!empty($_REQUEST['id']) and $bug[2] == NULL) { echo ''; echo ''; echo '
Bug Tracker
Bug doesn\'t exist.
'; $post=true; } if(!$post) { if(!isset($_REQUEST['add']) || $_REQUEST['add'] != TRUE) { echo ''; foreach($bug[1] as $report) { if($report['status'] == 1) $value = '[OPEN]'; elseif($report['status'] == 2) $value = '[NEW ANSWER]'; elseif($report['status'] == 3) $value = '[CLOSED]'; if(is_int($report['id'] / 2)) { $bgcolor = $dark; } else { $bgcolor = $light; } echo ''; $showed=true; } if(!$showed) { echo ''; } echo '
Bug Tracker
'.$tags[$report['tag']].' '.$report['subject'].''.$value.'
You don\'t have reported any bugs.
'; echo '
[ADD REPORT]'; } elseif(isset($_REQUEST['add']) && $_REQUEST['add'] == TRUE) { $thread = BugTracker::where('account', $acc)->where('type', 1)->orderByDesc('id')->get()->toArray(); $id_next = BugTracker::where('account', $acc)->where('type', 1)->max('id'); $id_next = $id_next + 1; if(empty($thread)) $thread['status'] = 3; if(isset($_POST['submit'])) { if($thread['status'] != 3) $error[] = 'Can be only 1 open bug thread.'; if(empty($_POST['subject'])) $error[] = 'Subject cannot be empty.'; if(empty($_POST['text'])) $error[] = 'Description cannot be empty.'; if(!$allow) $error[] = 'You haven\'t any characters on account.'; if(empty($_POST['tags'])) $error[] = 'Tag cannot be empty.'; if(!empty($error)) { foreach($error as $errors) echo ''.$errors.'
'; } else { $type = 1; $status = 1; $INSERT = BugTracker::create([ 'account' => $acc, 'id' => $id_next, 'text' => $_POST['text'], 'type' => $type, 'subject' => $_POST['subject'], 'reply' => 0, 'status' => $status, 'tag' => $_POST['tags'] ]); header('Location: ?subtopic=bugtracker&id='.$id_next.''); } } echo '
Subject
Description
TAG

'; } } } if(admin() and empty($_REQUEST['control'])) { echo '

[ADMIN PANEL]'; }