Ejemplo n.º 1
0
function getBattleGrounds($day, $month, $year, $level_cond, $type_cond, $limit)
{
    global $db, $date_format, $time_format, $ALLIANCE, $HORDE, $alliance_color, $horde_color, $none_color;
    if ($year != "") {
        $year_cond = sprintf("YEAR(date) = '%s'", $year);
    } else {
        die("Function getBattleGrounds() called passing year = null");
    }
    if ($month != "" && $month != 0) {
        $month_cond = sprintf("AND MONTH(date) = '%s'", $month);
    } else {
        $month_cond = "";
    }
    if ($day != "") {
        $day_cond = sprintf("AND DAY(date) = '%s'", $day);
    } else {
        $day_cond = "";
    }
    if ($level_cond != "") {
        $level_cond = "AND " . $level_cond;
    } else {
        $level_cond = "";
    }
    if ($type_cond != "") {
        $type_cond = "AND " . $type_cond;
    } else {
        $type_cond = "";
    }
    $query = sprintf("SELECT * FROM pvpstats_battlegrounds WHERE %s %s %s %s %s ORDER BY date DESC LIMIT 0, %d;", $year_cond, $month_cond, $day_cond, $level_cond, $type_cond, $limit);
    $result = $db->query($query);
    if (!$result) {
        die("Error querying: " . $query);
    }
    while (($row = $result->fetch_array()) != null) {
        $datetime = new DateTime($row['date']);
        $date = $datetime->format($date_format);
        $time = $datetime->format($time_format);
        if ($row['winner_faction'] == $ALLIANCE) {
            $color = $alliance_color;
        } else {
            if ($row['winner_faction'] == $HORDE) {
                $color = $horde_color;
            } else {
                $color = $none_color;
            }
        }
        printf("<tr style=\"color: %s; font-weight: bold;\" class=\"hover-pointer\" onClick=\"location.href='battleground.php?id=%s'\"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr></a>", $color, $row['id'], $row['id'], getBattleGroundTypeName($row['type']), getLevelRangeByBracketId($row['bracket_id']), $date, $time);
    }
}
Ejemplo n.º 2
0
require_once "functions.php";
require_once "factionScores.php";
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $query = sprintf("SELECT * FROM pvpstats_battlegrounds WHERE id = %d", $id);
    $result = $db->query($query);
    if (!$result) {
        die("Error querying: " . $query);
    } else {
        if ($result->num_rows > 0) {
            $row = $result->fetch_array();
            $type = $row['type'];
            $winner_faction = $row['winner_faction'];
            $bracket_id = $row['bracket_id'];
            $datetime = new DateTime($row['date']);
            $bracket_level_range = getLevelRangeByBracketId($bracket_id);
            $type_name = getBattleGroundTypeName($type);
            $date = $datetime->format($date_format);
            $time = $datetime->format($time_format);
            $month = $datetime->format('M');
            $year = $datetime->format('Y');
            $month_and_year = $month . " " . $year;
            $this_day_condition = "DATE(date) = DATE('" . $row['date'] . "')";
            $this_month_condition = "MONTH(date) = MONTH('" . $row['date'] . "') AND YEAR(date) = YEAR('" . $row['date'] . "')";
            $this_level_condition = "bracket_id = " . $bracket_id;
            $score_this_day = getFactionScores($this_day_condition, $this_level_condition, "");
            $score_this_month = getFactionScores($this_month_condition, $this_level_condition, "");
            $alliance_today = $score_today[0];
            $horde_today = $score_today[1];
            $alliance_this_day = $score_this_day[0];
            $horde_this_day = $score_this_day[1];