'Reported', 1 => 'To-Do List', 2 => 'Confirmed bug', 3 => 'Invalid', 4 => 'Rejected', 5 => 'Fixed' ); // Which status IDs should give option to add to changelog? $statusChangeLog = array(0,5); // Autohide rows that have these status IDs: $hideStatus = array(3, 4, 5); // Fetch data from SQL $reportsData = mysql_select_multi('SELECT id, name, posx, posy, posz, report_description, date, status FROM znote_player_reports ORDER BY id DESC;'); // If SQL data is not empty if ($reportsData !== false) { // Order reports array by ID for easy reference later on. $reports = array(); for ($i = 0; $i < count($reportsData); $i++) foreach ($statusTypes as $key => $value) if ($key == $reportsData[$i]['status']) $reports[$key][$reportsData[$i]['id']] = $reportsData[$i]; } // POST logic (Update report and give player points) if (!empty($_POST)) { // Fetch POST data $playerName = getValue($_POST['playerName']); $status = getValue($_POST['status']); $price = getValue($_POST['price']); $customPoints = getValue($_POST['customPoints']); $reportId = getValue($_POST['id']); $changelogReportId = (int)$_POST['changelogReportId']; $changelogValue = &$_POST['changelogValue']; $changelogText = getValue($_POST['changelogText']); $changelogStatus = ($changelogReportId !== false && $changelogValue === '2' && $changelogText !== false) ? true : false; if ($customPoints !== false) $price = (int)($price + $customPoints); // Update SQL mysql_update("UPDATE `znote_player_reports` SET `status`='$status' WHERE `id`='$reportId' LIMIT 1;"); echo "

Report status updated to ".$statusTypes[(int)$status] ."!

"; // Update local array representation foreach ($reports as $sid => $sa) foreach ($sa as $rid => $ra) if ($reportId == $rid) { $reports[$status][$reportId] = $reports[$sid][$rid]; $reports[$status][$reportId]['status'] = $status; unset($reports[$sid][$rid]); } // If we should do anything with changelog: if ($changelogStatus) { $time = time(); // Check if changelog exist (`id`, `text`, `time`, `report_id`, `status`) $changelog = mysql_select_single("SELECT * FROM `znote_changelog` WHERE `report_id`='$changelogReportId' LIMIT 1;"); // If changelog exist $updatechangelog = false; if ($changelog !== false) { // Update it mysql_update("UPDATE `znote_changelog` SET `text`='$changelogText', `time`='$time' WHERE `id`='".$changelog['id']."' LIMIT 1;"); echo "

Changelog message updated!

"; $updatechangelog = true; } else { // Create it mysql_insert("INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) VALUES ('$changelogText', '$time', '$changelogReportId', '$status');"); echo "

Changelog message created!

"; $updatechangelog = true; } if ($updatechangelog) { // Cache changelog $cache = new Cache('engine/cache/changelog'); $cache->setContent(mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;")); $cache->save(); } } // If we should give user price if ($price > 0) { $account = mysql_select_single("SELECT `a`.`id`, `a`.`email` FROM `accounts` AS `a` INNER JOIN `players` AS `p` ON `p`.`account_id` = `a`.`id` WHERE `p`.`name` = '$playerName' LIMIT 1;"); if ($account !== false) { // transaction log mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$reportId', 'report@admin.".$user_data['name']." to ".$account['email']."', '".$account['id']."', '0', '".$price."')"); // Process payment $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='".$account['id']."';"); // Give points to user $new_points = $data['old_points'] + $price; mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='".$account['id']."'"); // Remind GM that he sent points to character echo "".$playerName." has been granted ".$price." points for his reports."; } } // GET logic (Edit report data and specify how many [if any] points to give to user) } elseif (!empty($_GET)) { // Fetch GET data $action = getValue($_GET['action']); $playerName = getValue($_GET['name']); $reportId = getValue($_GET['id']); // Fetch the report we intend to modify foreach ($reports as $sid => $sa) foreach ($sa as $rid => $ra) if ($rid == $reportId) $report = $reports[$sid][$reportId]; // Create HTML form ?>
Player:
Set status:
Give user points: +

Add / update changelog message?

$statusArray) { ?>

(Visible)

$report) { ?>
Info Description
Report ID: #
Name:
Position:
Reported:
Status: . Edit
No reports submitted."; ?>