bad performance $res = mysql_query($query) or die(mysql_error()); $moons = 0; $planets = 0; $coordinates = ""; $moon_coordinates = ""; $amount_metal = 0; $amount_crystal = 0; $amount_deut = 0; $draw_graph = false; $max_temp = array(123,123,120,66.7,64.5,63,41,39,36,14.5,12,11,-43,-44,-46); $moon_array = array(); $player_stats = array(); $old_coordinates = ""; $moon_ajax_array = array(); $planet_ajax_array = array(); $moon_done = false; $planet_done = false; $report_planet_array = array(); $report_moon_array = array(); $fleetsize = array("kt"=>0,"gt"=>0,"lj"=>0,"sj"=>0,"krz"=>0,"ss"=>0,"kolo"=>0,"rec"=>0,"spio"=>0,"bomb"=>0,"zerri"=>0,"ds"=>0,"skrz"=>0,"sat"=>0); $techarray = array("spiolvl"=>0,"computech"=>0,"waffentech"=>0,"schildtech"=>0,"rpz"=>0,"energytech"=>0,"hypertech"=>0,"vbt"=>0,"impulse"=>0,"hra"=>0,"lasertech"=>0,"iontech"=>0,"plasmatech"=>0,"forschungsnetz"=>0,"expedition"=>0,"gravi"=>0); $players_with_tech = 0; if (mysql_num_rows($res) > 0) { while ($line = mysql_fetch_object($res)) { // collect tech information if ($line->last_tech_update != "0000-00-00 00:00:00") { $players_with_tech++; $techarray["spiolvl"] += ($line->spiolvl == NULL) ? 0 : $line->spiolvl; $techarray["computech"] += ($line->computech == NULL) ? 0 : $line->computech; $techarray["waffentech"] += ($line->waffentech == NULL) ? 0 : $line->waffentech; $techarray["schildtech"] += ($line->schildtech == NULL) ? 0 : $line->schildtech; $techarray["rpz"] += ($line->rpz == NULL) ? 0 : $line->rpz; $techarray["energytech"] += ($line->energytech == NULL) ? 0 : $line->energytech; $techarray["hypertech"] += ($line->hypertech == NULL) ? 0 : $line->hypertech; $techarray["vbt"] += ($line->vbt == NULL) ? 0 : $line->vbt; $techarray["impulse"] += ($line->impulse == NULL) ? 0 : $line->impulse; $techarray["hra"] += ($line->hra == NULL) ? 0 : $line->hra; $techarray["lasertech"] += ($line->lasertech == NULL) ? 0 : $line->lasertech; $techarray["iontech"] += ($line->iontech == NULL) ? 0 : $line->iontech; $techarray["plasmatech"] += ($line->plasmatech == NULL) ? 0 : $line->plasmatech; $techarray["forschungsnetz"] += ($line->forschungsnetz == NULL) ? 0 : $line->forschungsnetz; $techarray["expedition"] += ($line->expedition == NULL) ? 0 : $line->expedition; $techarray["gravi"] += ($line->gravi == NULL) ? 0 : $line->gravi; } $galaxy_query = "SELECT g.planet as g_planet, g.system as g_system, g.galaxy as g_galaxy, g.moon as g_moon, r.* ". "FROM $dbtablename g LEFT JOIN $reporttable r ON (g.galaxy=r.galaxy AND g.system=r.system AND g.planet=r.planet) ". "WHERE g.player_id='$line->player_id' ". "ORDER BY g.galaxy,g.system,g.planet"; $res2 = mysql_query($galaxy_query) or die(mysql_error()); // LOOP all reports of current player $i = 0; while ($result_row = mysql_fetch_object($res2)) { $coordinates = ""; $moon_coordinates = ""; $moon_mouse_over = ""; $planet_mouse_over = ""; // collect fleet information $fleetsize["kt"] += ($result_row->kt == NULL) ? 0 : $result_row->kt; $fleetsize["gt"] += ($result_row->gt == NULL) ? 0 : $result_row->gt; $fleetsize["lj"] += ($result_row->lj == NULL) ? 0 : $result_row->lj; $fleetsize["sj"] += ($result_row->sj == NULL) ? 0 : $result_row->sj; $fleetsize["krz"] += ($result_row->krz == NULL) ? 0 : $result_row->krz; $fleetsize["ss"] += ($result_row->ss == NULL) ? 0 : $result_row->ss; $fleetsize["kolo"] += ($result_row->kolo == NULL) ? 0 : $result_row->kolo; $fleetsize["rec"] += ($result_row->rec == NULL) ? 0 : $result_row->rec; $fleetsize["spio"] += ($result_row->spio == NULL) ? 0 : $result_row->spio; $fleetsize["bomb"] += ($result_row->bomb == NULL) ? 0 : $result_row->bomb; $fleetsize["zerri"] += ($result_row->zerri == NULL) ? 0 : $result_row->zerri; $fleetsize["ds"] += ($result_row->ds == NULL) ? 0 : $result_row->ds; $fleetsize["skrz"] += ($result_row->skrz == NULL) ? 0 : $result_row->skrz; $fleetsize["sat"] += ($result_row->sat == NULL) ? 0 : $result_row->sat; if ($result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet != $old_coordinates) { // coordinates changed, so add missing planets / moons now if (!$moon_done && $i > 0) { $moons++; //if ($moons == 1) $moon_coordinates .= " - "; else $moon_coordinates .= " ; "; $moon_coordinates .= " ".$old_coordinates.""; $report_moon_array[$old_coordinates.":1"] = $moon_coordinates; $coordinates = ""; $moon_coordinates = ""; } if (!$planet_done && $i > 0) { $planets++; //if ($planets == 1) $coordinates .= " - "; else $coordinates .= " ; "; $coordinates .= " ".$old_coordinates.""; $report_planet_array[$old_coordinates.":0"] = $coordinates; $coordinates = ""; $moon_coordinates = ""; } $old_coordinates = $result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet; $old_galaxy = $result_row->g_galaxy; $old_system = $result_row->g_system; $moon_done = false; $planet_done = false; } if ($result_row->moon == "true" && $result_row->energy != NULL) { $moons++; //if ($moons == 1) $moon_coordinates .= " - "; else $moon_coordinates .= " ; "; $moon_mouse_over = ' onmouseover="ShowObject(\'report'.$moons.'_M\',\'ajax_reports.php?coordinates='."$result_row->g_galaxy:$result_row->g_system:".$result_row->g_planet.'&moon=1\',true)"'; $moon_coordinates .= " g_galaxy."&system=".$result_row->g_system."\" $moon_mouse_over>".$result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet.""; array_push($moon_ajax_array,"report".$moons."_M"); // add to moon array if ($result_row->sensor > 0) { if (!isset($moon_array[$result_row->g_galaxy])) $moon_array[$result_row->g_galaxy] = array(); $min = $result_row->g_system - (($result_row->sensor * $result_row->sensor) - 1); $max = $result_row->g_system + (($result_row->sensor * $result_row->sensor) - 1); $min = ($min < 1) ? 1 : $min; $max = ($max > 499) ? 499 : $max; array_push($moon_array[$result_row->g_galaxy],array("min"=>$min,"max"=>$max)); } $moon_done = true; } if ($result_row->moon == "false" && $result_row->energy != NULL) { $planets++; //if ($planets == 1) $coordinates .= " - "; else $coordinates .= " ; "; $planet_mouse_over = ' onmouseover="ShowObject(\'report'.$planets.'\',\'ajax_reports.php?coordinates='."$result_row->g_galaxy:$result_row->g_system:".$result_row->g_planet.'\',true)"'; $coordinates .= " g_galaxy."&system=".$result_row->g_system."\" $planet_mouse_over>".$result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet.""; array_push($planet_ajax_array,"report".$planets); if ($result_row->memi > 0) { $amount_metal += floor( 30 * $result_row->memi * pow(1.1,$result_row->memi) + 20); } if ($result_row->krimi > 0) { $amount_crystal += floor(20 * $result_row->krimi * pow(1.1,$result_row->krimi)); } if ($result_row->deutsyn > 0) { $amount_deut += floor(10 * $result_row->deutsyn * pow(1.1,$result_row->deutsyn) * (-0.002 * $max_temp[$result_row->g_planet-1] + 1.28)); } $planet_done = true; } if ($result_row->g_moon == "false") { $moon_done = true; } // add the line to array if (!empty($coordinates)) $report_planet_array[$result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet.":0"] = $coordinates; if (!empty($moon_coordinates)) $report_moon_array[$result_row->g_galaxy.":".$result_row->g_system.":".$result_row->g_planet.":1"] = $moon_coordinates; $i++; } // add last entry if (!$moon_done && $i > 0) { $moons++; //if ($moons == 1) $moon_coordinates .= " - "; else $moon_coordinates .= " ; "; $moon_coordinates .= " ".$old_coordinates.""; $report_moon_array[$old_coordinates.":1"] = $moon_coordinates; } if (!$planet_done && $i > 0) { $planets++; //if ($planets == 1) $coordinates .= " - "; else $coordinates .= " ; "; $coordinates .= " ".$old_coordinates.""; $report_planet_array[$old_coordinates.":0"] = $coordinates; } // Player specific information $score = ($line->rank > 0) ? DETAILEDINFO_RANK.": ".$line->rank." ".DETAILEDINFO_POINTS." ".number_format($line->points,0,",",".") : DETAILEDINFO_UNKNOWN; $fscore = ($line->frank > 0) ? DETAILEDINFO_RANK.": ".$line->frank." ".DETAILEDINFO_POINTS." ".number_format($line->fpoints,0,",",".") : DETAILEDINFO_UNKNOWN; $rscore = ($line->rrank > 0) ? DETAILEDINFO_RANK.": ".$line->rrank." ".DETAILEDINFO_POINTS." ".number_format($line->rpoints,0,",",".") : DETAILEDINFO_UNKNOWN; if ($line->points > 0 && !$draw_graph) { $draw_graph = true; } array_push($player_stats,array("player_id"=>$line->player_id,"name"=>$line->playername,"score"=>$line->ppoints,"fleet"=>$line->pfpoints,"research"=>$line->prpoints,"dipl_status"=>$line->diplomatic_status)); $ally_dipl_status = $line->a_dipl_status; $player_dipl_status = $line->diplomatic_status; $ally_members = $line->members; $allyname = $line->allyname; } if (count($moon_array) > 0) $phalanx_range = get_phalanx_range($moon_array); else $phalanx_range = array(); ob_start(); echo ' '; $ostat = ""; if ($_SESSION['lang'] == "german") { $ostat = 'ostat'; } elseif ($_SESSION['lang'] == "english") { $ostat = 'ostat'; } // stats link $stats_url = "allyhistory.php?a1=$allyname&option=month"; echo ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. '
'.STATS_ALLYNAME.''.$allyname.' - ('.STATS_MEMBERS.': '.$ally_members.') '.$ostat.' '; if ($_SESSION['s_diplomatic']) { echo ' close'. '
').utf8_encode(STATS_CHANGE_ALLIANCE_STATUS).htmlentities('close
').utf8_encode(STATS_CHANGE_ALLIANCE_STATUS_HINT).htmlentities('
'. '').utf8_encode(STATS_NEUTRAL).htmlentities('
'. '').utf8_encode(STATS_BOYCOTT).htmlentities('
'. '').utf8_encode(STATS_NAP).htmlentities('
'. '').utf8_encode(STATS_ALLIED).htmlentities('
'. '').utf8_encode(STATS_WAR).htmlentities('
'. '').utf8_encode(STATS_OWN).htmlentities('
'. '').utf8_encode(STATS_WING).htmlentities('
'. '').utf8_encode(STATS_NOTHING).htmlentities('
 
') .utf8_encode(STATS_DELETE).htmlentities('
' ).'\')" />'; } echo " "; // sort coordinatesarray uksort($report_planet_array,"sort_coordinates"); uksort($report_moon_array,"sort_coordinates"); echo ' '.DETAILEDINFO_SCORE.''.$score.' '.DETAILEDINFO_FLEET.''.$fscore.' '.DETAILEDINFO_RESEARCH.''.$rscore.' '.DETAILEDINFO_KNOWN_PLANETS.''.$planets."
"; $previous_galaxy = 0; foreach ($report_planet_array as $coordinates => $link) { $coordinates_array = explode(":",$coordinates); if ($coordinates_array[0] != $previous_galaxy) { $previous_galaxy = $coordinates_array[0]; echo "
"; } echo $link."; "; } echo '
  '.DETAILEDINFO_MOONS.''.$moons."
"; $previous_galaxy = 0; foreach ($report_moon_array as $coordinates => $link) { $coordinates_array = explode(":",$coordinates); if ($coordinates_array[0] != $previous_galaxy) { $previous_galaxy = $coordinates_array[0]; echo "
"; } echo $link."; "; } echo "
\n"; $i = 0; foreach ($phalanx_range as $galaxy => $text) { if ($i == 0) { echo ''.DETAILEDINFO_PHALANX_AREA.''.$text.''; } else { echo ' '.$text.''; } $i++; } if (count($phalanx_range) == 0) { echo ''.DETAILEDINFO_PHALANX_AREA.''.DETAILEDINFO_NO_PHALANX_AREA.''; } echo ''; $tab1_content = ob_get_clean(); // second tab content ob_start(); echo ''; echo '
'; // detailed information about each player (score) usort($player_stats,"sort_player_stats"); foreach ($player_stats as $data) { $ostat = ""; if ($_SESSION['lang'] == "german") { $ostat = 'ostat'; } elseif ($_SESSION['lang'] == "english") { $ostat = 'ostat'; } echo ' '."\n"; } echo "
'.STATS_PLAYERNAME.''.DETAILEDINFO_SCORE.''.DETAILEDINFO_FLEET.''.DETAILEDINFO_RESEARCH.'
'.$ostat.''.$data["name"].''.number_format($data["score"],0,",",".").''.number_format($data["fleet"],0,",",".").''.number_format($data["research"],0,",",".").'
"; $tab2_content = ob_get_clean(); // resources ob_start(); echo '
 '.DETAILEDINFO_METAL.''.DETAILEDINFO_CRYSTAL.''.DETAILEDINFO_DEUTERIUM.'
'.DETAILEDINFO_RESOURCES_PER_HOUR.''.number_format($amount_metal,0,",",".").''.number_format($amount_crystal,0,",",".").''.number_format($amount_deut,0,",",".").'
'.DETAILEDINFO_RESOURCES_PER_DAY.''.number_format($amount_metal*24,0,",",".").''.number_format($amount_crystal*24,0,",",".").''.number_format($amount_deut*24,0,",",".").'
'.DETAILEDINFO_RESOURCES_PER_WEEK.''.number_format($amount_metal*24*7,0,",",".").''.number_format($amount_crystal*24*7,0,",",".").''.number_format($amount_deut*24*7,0,",",".").'
'.DETAILEDINFO_RESOURCES_PER_MONTH.''.number_format($amount_metal*24*30,0,",",".").''.number_format($amount_crystal*24*30,0,",",".").''.number_format($amount_deut*24*30,0,",",".").'
'; $tab3_content = ob_get_clean(); // diagram ob_start(); echo ''; if ($draw_graph === true) { echo ' '; } echo "
'.DETAILEDINFO_SCORE_DISTRIBUTION.'
'; $_GET['id'] = $alliance_id; $_GET['what'] = "points"; $no_ajax = true; include "ajax_allyinfo.php"; echo '
\n"; $tab4_content = ob_get_clean(); // fleet ob_start(); echo '
'.DETAILEDINFO_FLEET_DETAIL.'
'.$flipped_probe_array[F_SMALLCARGOSHIP].''.number_format($fleetsize["kt"],0,",",".").' / ('.number_format($fleetsize["kt"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_LARGECARGOSHIP].''.number_format($fleetsize["gt"],0,",",".").' / ('.number_format($fleetsize["gt"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_LIGHFIGHTER].''.number_format($fleetsize["lj"],0,",",".").' / ('.number_format($fleetsize["lj"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_HEAVYFIGHTER].''.number_format($fleetsize["sj"],0,",",".").' / ('.number_format($fleetsize["sj"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_CRUISER].''.number_format($fleetsize["krz"],0,",",".").' / ('.number_format($fleetsize["krz"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_BATTLESHIP].''.number_format($fleetsize["ss"],0,",",".").' / ('.number_format($fleetsize["ss"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_COLONYSHIP].''.number_format($fleetsize["kolo"],0,",",".").' / ('.number_format($fleetsize["kolo"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_RECYCLER].''.number_format($fleetsize["rec"],0,",",".").' / ('.number_format($fleetsize["rec"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_ESPIONAGEPROBE].''.number_format($fleetsize["spio"],0,",",".").' / ('.number_format($fleetsize["spio"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_BOMBER].''.number_format($fleetsize["bomb"],0,",",".").' / ('.number_format($fleetsize["bomb"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_DESTROYER].''.number_format($fleetsize["zerri"],0,",",".").' / ('.number_format($fleetsize["zerri"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_DEATHSTAR].''.number_format($fleetsize["ds"],0,",",".").' / ('.number_format($fleetsize["ds"] / $ally_members,1,",",".").')
'.$flipped_probe_array[F_BATTLECRUISER].''.number_format($fleetsize["skrz"],0,",",".").' / ('.number_format($fleetsize["skrz"] / $ally_members,1,",",".").')'.$flipped_probe_array[F_SOLARSATELLITE].''.number_format($fleetsize["sat"],0,",",".").' / ('.number_format($fleetsize["sat"] / $ally_members,1,",",".").')
'; $tab5_content = ob_get_clean(); // techs ob_start(); if ($players_with_tech == 0) $players_with_tech = 1; // avoid division 0 echo '
'.DETAILEDINFO_TECH_DETAIL.'
'.$flipped_probe_array[RS_ESPIONAGE].''.number_format($techarray["spiolvl"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_COMPUTER].''.number_format($techarray["computech"] / $players_with_tech ,1,",",".").'
'.$flipped_probe_array[RS_WEAPON].''.number_format($techarray["waffentech"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_SHIELDING].''.number_format($techarray["schildtech"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_ARMOUR].''.number_format($techarray["rpz"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_ENERGY].''.number_format($techarray["energytech"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_HYPERSPACE].''.number_format($techarray["hypertech"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_COMBUSTIONENGINE].''.number_format($techarray["vbt"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_IMPULSEENGINE].''.number_format($techarray["impulse"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_HYPERSPACEENGINE].''.number_format($techarray["hra"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_LASER].''.number_format($techarray["lasertech"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_ION].''.number_format($techarray["iontech"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_PLASMA].''.number_format($techarray["plasmatech"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_IRNETWORK].''.number_format($techarray["forschungsnetz"] / $players_with_tech,1,",",".").'
'.$flipped_probe_array[RS_EXPEDITION].''.number_format($techarray["expedition"] / $players_with_tech,1,",",".").''.$flipped_probe_array[RS_GRAVITON].''.number_format($techarray["gravi"] / $players_with_tech,1,",",".").'
'; $tab6_content = ob_get_clean(); require "tab_plugin.inc.php"; $tab_plugin = new tab_plugin(); $tab_array = array( array("name"=>DETAILEDINFO_GENERAL, "content"=>$tab1_content), array("name"=>DETAILEDINFO_MEMBERS, "content"=>$tab2_content), array("name"=>DETAILEDINFO_RESOURCES, "content"=>$tab3_content), array("name"=>DETAILEDINFO_GRAPHS, "content"=>$tab4_content), array("name"=>DETAILEDINFO_FLEET_TAB, "content"=>$tab5_content), array("name"=>DETAILEDINFO_TECH, "content"=>$tab6_content) ); echo "
"; $tab_plugin->create_tabs($tab_array); echo "
"; } else { // no players within this alliance, or no alliance found } } // foreach($planet_ajax_array as $key => $value) { echo '
'."\n"; } foreach($moon_ajax_array as $key => $value) { echo '
'."\n"; } makefooter(); function sort_player_stats($a, $b) { if ($a["score"] == $b["score"]) { return 0; } return ($a["score"] > $b["score"]) ? -1 : 1; } function sort_coordinates($a, $b) { $entries_a = explode(":",$a); $entries_b = explode(":",$b); if ($entries_a[0] == $entries_b[0]) { // galaxycheck if ($entries_a[1] == $entries_b[1]) { // systemcheck if ($entries_a[2] == $entries_b[2]) { // planetcheck if ($entries_a[3] == $entries_b[3]) { // mooncheck return 0; } else { return ($entries_a[3] > $entries_b[3]) ? 1 : -1; } } else { return ($entries_a[2] > $entries_b[2]) ? 1 : -1; } } else { return ($entries_a[1] > $entries_b[1]) ? 1 : -1; } } else { return ($entries_a[0] > $entries_b[0]) ? 1 : -1; } } ?>