function umc_error_log() { global $UMC_DOMAIN; $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); if (isset($s_post['delete'])) { $del_id = $s_post['delete']; $sql_find = "SELECT * FROM minecraft_log.`error_log` WHERE error_id={$del_id};"; $rst_find = umc_mysql_query($sql_find); $f_row = umc_mysql_fetch_array($rst_find); $file = umc_mysql_real_escape_string($f_row['file']); $sql_del = "DELETE FROM minecraft_log.`error_log`\r\n WHERE `type`='{$f_row['type']}'\r\n\t\tAND `message`='{$f_row['message']}'\r\n\t\tAND `line`='{$f_row['line']}'\r\n\t\tAND `file`={$file};"; $rst_del = umc_mysql_query($sql_del); umc_mysql_free_result($rst_del); umc_mysql_free_result($rst_find); } $sql = "SELECT min(error_id) AS sample, count(error_id) AS freq, `type`,`message`,`line`,`file`,`referer`,max(`datetime`) AS latest\r\n FROM minecraft_log.`error_log`\r\n\tGROUP BY type, file, line, message\r\n\tORDER BY freq DESC "; $rst = umc_mysql_query($sql); $out = "<form class=\"shoptables\" action=\"{$UMC_DOMAIN}/error-log/\" method=\"POST\" style=\"font-size:80%\">\n" . "<table>\n<tr><th>Freq</th><th>Type</th><th>Message</th><th>Line</th><th>File</th><th>Date</th><th><input type=\"submit\" name=\"submit\" value=\"Solved\"></th></tr>\n"; while ($row = umc_mysql_fetch_array($rst)) { $path = substr($row['file'], 15); $out .= "<tr><td>{$row['freq']}</td><td>{$row['type']}</td><td>{$row['message']}</td><td>{$row['line']}</td><td>{$path}</td><td>{$row['latest']}</td>" . "<td><input type=\"radio\" name=\"delete\" value=\"{$row['sample']}\"></tr>\n"; } $out .= "</table>\n</form>\n"; umc_mysql_free_result($rst); return $out; }
function umc_get_worldguard_id($type, $name, $add = false) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); $valid_terms = array('world', 'user'); if (!in_array($type, $valid_terms)) { XMPP_ERROR_trigger("Error trying to get a type ID of unknown type: {$type}"); return false; } $name_str = 'name'; if ($type == 'user') { $name = umc_uuid_getone($name, 'uuid'); $name_str = 'uuid'; } $sql = "SELECT id FROM minecraft_worldguard.{$type} WHERE {$name_str} LIKE '{$name}';"; $D = umc_mysql_fetch_all($sql); if (count($D) > 0) { $row = $D[0]; return $row['id']; } else { if ($type == 'user' && $add) { $uuid = umc_uuid_getone($name, 'uuid'); $sql = "INSERT INTO minecraft_worldguard.user (uuid) VALUES ('{$uuid}');"; $rst = umc_mysql_query($sql); $user_id = umc_mysql_insert_id(); umc_mysql_free_result($rst); if (!$user_id) { XMPP_ERROR_trigger("Error with username '{$name}/{$uuid}'. User does not exist and could not create! (umc_get_worldguard_id)"); return false; } return $user_id; // No such world or player. } else { if ($type == 'user' && !$add) { return false; } else { if ($type == 'world') { XMPP_ERROR_trigger("Error with {$type} '{$name}'. {$type} does not exist! (umc_get_worldguard_id)"); return false; } } } } }
function umc_donation_calc_average() { $sql_count = "SELECT count(UUID) AS count FROM minecraft_srvr.donations;"; $rst_count = umc_mysql_query($sql_count); $row_count = umc_mysql_fetch_array($rst_count); umc_mysql_free_result($rst_count); $donator_count = $row_count['count']; $sql_sum = "SELECT sum(amount) as sum from minecraft_srvr.donations;"; $row_sum = umc_mysql_fetch_all($sql_sum); $donation_sum = $row_sum[0]['sum']; $donation_avg = round($donation_sum / $donator_count, 2); return $donation_avg; }
function umc_user_countlots($user) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); // worldguard stores everything in lower case. $uuid = umc_uuid_getone($user, 'uuid'); $sql = "SELECT COUNT(region_id) AS counter\r\n FROM minecraft_worldguard.`region_players`\r\n LEFT JOIN minecraft_worldguard.user ON user_id=user.id\r\n WHERE owner=1 AND user.uuid='{$uuid}';"; $rst = umc_mysql_query($sql); $row = umc_mysql_fetch_array($rst); umc_mysql_free_result($rst); $out = $row['counter']; return $out; }