1 1
2 2
3 3
4 4
5 5
 
: >
>
 

0) { $query = "SELECT id,allyname FROM $allytable WHERE allyname IN ('".implode("','",$allynames)."')"; $res = mysql_query($query) or die(mysql_error()); $ally_array = array(); $alliance_ids = array(); while ($line = mysql_fetch_object($res)) { $ally_array[$line->id] = $line->allyname; array_push($alliance_ids,$line->id); } } $draw_scores = false; $draw_fleets = false; $draw_research = false; $draw_members = false; if ((count($ally_array) > 0) && !empty($allyhistory)) { if ($_GET['option'] == "month") { $query = "SELECT * FROM $allyhistory WHERE alliance_id IN ('".implode("','",$alliance_ids)."') AND year='".date("Y")."' AND month='".date("m")."' ORDER BY day"; } else { $query = "SELECT avg(points) as points, avg(fpoints) as fpoints, avg(rpoints) as rpoints, avg(members) as members, alliance_id, year, month FROM $allyhistory WHERE alliance_id IN ('".implode("','",$alliance_ids)."') GROUP BY alliance_id,year,month ORDER BY year,month"; } $res = mysql_query($query) or die(mysql_error()); $overall_entries = mysql_num_rows($res); $current_x_value = -1; // current x value $addinonal_rows = -1; $xdata = array(); $draw_scores = false; $draw_fleets = false; $draw_research = false; $draw_members = false; while ($line = mysql_fetch_object($res)) { // fill 4 graph tables points, rpoints, fpoints, members if (!isset($points_aydata[$line->alliance_id])) $points_aydata[$line->alliance_id] = array(); if (!isset($fpoints_aydata[$line->alliance_id])) $fpoints_aydata[$line->alliance_id] = array(); if (!isset($rpoints_aydata[$line->alliance_id])) $rpoints_aydata[$line->alliance_id] = array(); if (!isset($members_aydata[$line->alliance_id])) $members_aydata[$line->alliance_id] = array(); if ($_GET['option'] == "month") { if ($line->day != $current_x_value) { $addinonal_rows = -1; for ($i=$current_x_value+1;$i<=$line->day;$i++) { array_push($xdata,$i); $addinonal_rows++; } $current_x_value = $line->day; } for ($i=0; $i < $addinonal_rows; $i++) { array_push($points_aydata[$line->alliance_id],"-"); array_push($fpoints_aydata[$line->alliance_id],"-"); array_push($rpoints_aydata[$line->alliance_id],"-"); array_push($members_aydata[$line->alliance_id],"-"); } } else { $month = ($line->month < 10) ? "0".$line->month : $line->month; if ($line->year."/".$month != $current_x_value) { $current_x_value = $line->year."/".$month; array_push($xdata,$line->year."/".$month); } } if ($line->points > 0) { array_push($points_aydata[$line->alliance_id],$line->points); $draw_scores = true; } else array_push($points_aydata[$line->alliance_id],"-"); if ($line->fpoints > 0) { array_push($fpoints_aydata[$line->alliance_id],$line->fpoints); $draw_fleets = true; } else array_push($fpoints_aydata[$line->alliance_id],"-"); if ($line->rpoints > 0) { array_push($rpoints_aydata[$line->alliance_id],$line->rpoints); $draw_research = true; } else array_push($rpoints_aydata[$line->alliance_id],"-"); if ($line->members > 0) { array_push($members_aydata[$line->alliance_id],$line->members); $draw_members = true; } else array_push($members_aydata[$line->alliance_id],"-"); } } if ($draw_scores === false) unset($points_aydata); if ($draw_fleets === false) unset($fpoints_aydata); if ($draw_research === false) unset($rpoints_aydata); if ($draw_members === false) unset($members_aydata); } if (!empty($player1) || !empty($player2) || !empty($player3) || !empty($player4) || !empty($player5)) { // determine Player IDs $playernames = array(); if (trim($player1) != "") array_push($playernames,mysql_real_escape_string(trim($player1))); if (trim($player2) != "") array_push($playernames,mysql_real_escape_string(trim($player2))); if (trim($player3) != "") array_push($playernames,mysql_real_escape_string(trim($player3))); if (trim($player4) != "") array_push($playernames,mysql_real_escape_string(trim($player4))); if (trim($player5) != "") array_push($playernames,mysql_real_escape_string(trim($player5))); if (count($playernames) > 0) { $query = "SELECT id,playername FROM $playertable WHERE playername IN ('".implode("','",$playernames)."')"; $res = mysql_query($query) or die(mysql_error()); $player_array = array(); $player_ids = array(); while ($line = mysql_fetch_object($res)) { $player_array[$line->id] = $line->playername; array_push($player_ids,$line->id); } } $draw_scores = false; $draw_fleets = false; $draw_research = false; if ((count($player_array) > 0) && !empty($playerhistory)) { if ($_GET['option'] == "month") { $query = "SELECT * FROM $playerhistory WHERE player_id IN ('".implode("','",$player_ids)."') AND year='".date("Y")."' AND month='".date("m")."' ORDER BY day"; } else { $query = "SELECT avg(points) as points, avg(fpoints) as fpoints, avg(rpoints) as rpoints, player_id, year, month FROM $playerhistory WHERE player_id IN ('".implode("','",$player_ids)."') GROUP BY player_id,year,month ORDER BY year,month"; } $res = mysql_query($query) or die(mysql_error()); $overall_entries = mysql_num_rows($res); if (!isset($xdata)) $xdata = array(); $current_x_value = -1; $addinonal_rows = -1; $draw_scores = false; $draw_fleets = false; $draw_research = false; while ($line = mysql_fetch_object($res)) { // fill 3 graph tables points, rpoints, fpoints if (!isset($points_pydata[$line->player_id])) $points_pydata[$line->player_id] = array(); if (!isset($fpoints_pydata[$line->player_id])) $fpoints_pydata[$line->player_id] = array(); if (!isset($rpoints_pydata[$line->player_id])) $rpoints_pydata[$line->player_id] = array(); if ($_GET['option'] == "month") { if ($line->day != $current_x_value) { $addinonal_rows = -1; for ($i=$current_x_value+1;$i<=$line->day;$i++) { if (!in_array($i,$xdata)) { array_push($xdata,$i); } $addinonal_rows++; } $current_x_value = $line->day; } for ($i=0; $i < $addinonal_rows; $i++) { array_push($points_pydata[$line->player_id],"-"); array_push($fpoints_pydata[$line->player_id],"-"); array_push($rpoints_pydata[$line->player_id],"-"); } } else { $month = ($line->month < 10) ? "0".$line->month : $line->month; if (!in_array($line->year."/".$month,$xdata)) { array_push($xdata,$line->year."/".$month); } $current_x_value = $line->year."/".$month; } // check if there are gaps in timeline for that user while (count($points_pydata[$line->player_id]) < ($line->day)) { array_push($points_pydata[$line->player_id],"-"); } while (count($fpoints_pydata[$line->player_id]) < ($line->day)) { array_push($fpoints_pydata[$line->player_id],"-"); } while (count($rpoints_pydata[$line->player_id]) < ($line->day)) { array_push($rpoints_pydata[$line->player_id],"-"); } // for the case that not all stats were updated on that day if ($line->points > 0) { array_push($points_pydata[$line->player_id],$line->points); $draw_scores = true; } else array_push($points_pydata[$line->player_id],"-"); if ($line->fpoints > 0) { array_push($fpoints_pydata[$line->player_id],$line->fpoints); $draw_fleets = true; } else array_push($fpoints_pydata[$line->player_id],"-"); if ($line->rpoints > 0) { array_push($rpoints_pydata[$line->player_id],$line->rpoints); $draw_research = true; } else array_push($rpoints_pydata[$line->player_id],"-"); } } if ($draw_scores === false) unset($points_pydata); if ($draw_fleets === false) unset($fpoints_pydata); if ($draw_research === false) unset($rpoints_pydata); } // check if data is available which shall be printed out if (isset($xdata) && isset($overall_entries) && $overall_entries > 1) { // sort xdata (may be unsorted by adding days / year_month from alliances first and then dates from players) sort($xdata); unset($_SESSION['session_allyhistory']); $_SESSION['session_allyhistory']['xdata'] = $xdata; $_SESSION['session_allyhistory']['points_aydata'] = isset($points_aydata) ? $points_aydata : array(); $_SESSION['session_allyhistory']['fpoints_aydata'] = isset($fpoints_aydata) ? $fpoints_aydata : array(); $_SESSION['session_allyhistory']['rpoints_aydata'] = isset($rpoints_aydata) ? $rpoints_aydata : array(); $_SESSION['session_allyhistory']['members_aydata'] = isset($members_aydata) ? $members_aydata : array(); $_SESSION['session_allyhistory']['points_pydata'] = isset($points_pydata) ? $points_pydata : array(); $_SESSION['session_allyhistory']['rpoints_pydata'] = isset($rpoints_pydata) ? $rpoints_pydata : array(); $_SESSION['session_allyhistory']['fpoints_pydata'] = isset($fpoints_pydata) ? $fpoints_pydata : array(); $_SESSION['session_allyhistory']['player_array'] = isset($player_array) ? $player_array : array(); $_SESSION['session_allyhistory']['ally_array'] = isset($ally_array) ? $ally_array : array(); echo ' '; if (count($_SESSION['session_allyhistory']['points_aydata']) > 0 || count($_SESSION['session_allyhistory']['points_pydata']) > 0) { echo ''; } else { echo ''; } echo ''; if (count($_SESSION['session_allyhistory']['fpoints_aydata']) > 0 || count($_SESSION['session_allyhistory']['fpoints_pydata']) > 0) { echo ''; } else { echo ''; } echo ''; if (count($_SESSION['session_allyhistory']['rpoints_aydata']) > 0 || count($_SESSION['session_allyhistory']['fpoints_pydata']) > 0) { echo ''; } else { echo ''; } if (isset($points_aydata)) { echo ' '; } echo "
'.ALLYHISTORY_PROGESS.": ".ALLYHISTORY_SCORE.'
'.ALLYHISTORY_NOTHING.'
'.ALLYHISTORY_PROGESS.": ".ALLYHISTORY_FSCORE.'
'.ALLYHISTORY_NOTHING.'
'.ALLYHISTORY_PROGESS.": ".ALLYHISTORY_RSCORE.'
'.ALLYHISTORY_NOTHING.'
'.ALLYHISTORY_PROGESS.": ".ALLYHISTORY_MEMBER.'
\n"; } elseif (isset($overall_entries)) { // not enough entries found echo '
'.ALLYHISTORY_DETAILS.'
'.ALLYHISTORY_NOTHING.'
'; } makefooter(); function pulldowncode($name,$startval,$endval,$interval,$selected=0) { echo "\n"; } ?>