* re-written august 2004 by Shaira * */ /* [START] konfiguration */ if ($orgid == '') {$orgid = '2416';} if ($stats == '') {$stats = 1;} $source = "http://people.anarchy-online.com/org/stats/d/5/name/$orgid/basicstats.xml"; $html_site_title = "BDDoRK - Members"; $html_path = "./"; $html_files[header] = "header.tpl"; $html_files[table] = "table.tpl"; $html_files[footer] = "footer.tpl"; $html_files[stats] = "stats.tpl"; $html_gfx_bar = "bar.jpg"; /* [END] konfiguration */ /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* */ /* at this point, you shouldn´t modify anything! */ /* */ /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ foreach ($html_files as $k => $v) { $html_files[$k] = $html_path.$v; } function xml_parse_source($parser, $source) { if (!($fp = @fopen($source, "r"))) { echo( "can't find source \"".$source."\"!
\n" ); return false; } while ($data = fread($fp, 4096)) { if (!xml_parse( $parser, $data, feof($fp))) { echo "error while parse data!
\n"; return false; } } @fclose($fp); return true; } function xml_element_start($parser, $data, $attrs) { global $char_data; $char_data = ""; } function xml_element_end($parser, $data) { global $char_data, $org, $org_data, $member; switch(strtolower($data)) { case 'id': $org_data[org_id] = $char_data; break; case 'name': $org_data[org_name] = $char_data; break; case 'side': $org_data[org_side] = $char_data; break; case 'last_updated': $org_data[last_updated] = $char_data; break; case 'firstname': $member[firstname] = $char_data; break; case 'nickname': $member[nickname] = $char_data; break; case 'lastname': $member[lastname] = $char_data; break; case 'rank': $member[rank] = $char_data; break; case 'rank_name': $member[rank_name] = $char_data; break; case 'level': $member[level] = $char_data; break; case 'profession': $member[profession] = $char_data; break; case 'gender': $member[gender] = $char_data; break; case 'breed': $member[breed] = $char_data; break; case 'photo_url': $member[photo_url] = str_replace( "http://www.anarchy-online.com/character/photos/", "http://cdn.funcom.com/billing_files/AO_shop/face/", $char_data); break; case 'smallphoto_url': $member[smallphoto_url] = str_replace( "http://www.anarchy-online.com/character/smallphotos/", "http://cdn.funcom.com/billing_files/AO_shop/face/", $char_data); break; case 'member': $org["$member[nickname]"] = array( firstname => $member[firstname], nickname => $member[nickname], lastname => $member[lastname], rank => $member[rank], rank_name => $member[rank_name], level => $member[level], profession => $member[profession], gender => $member[gender], breed => $member[breed], photo_url => $member[photo_url], smallphoto_url => $member[smallphoto_url] ); break; } } function xml_char_data($parser, $data) { global $char_data; $char_data .= $data; } /* parse xml source file */ function gen_member_data() { global $org, $source, $member; $parser = xml_parser_create(); xml_set_element_handler($parser, "xml_element_start", "xml_element_end"); xml_set_character_data_handler($parser, "xml_char_data"); xml_parse_source($parser, $source); } /* required by stats() */ function calculate_percent() { global $org, $org_data; foreach ($org_data as $k => $v) { /* calculate profession */ if (ereg("^prof.*count",$k)) { $percent_name = str_replace("count","percent",$k); $barl_name = str_replace("count","barl",$k); if (!empty($v)) { $org_data[$percent_name] = number_format(round(($org_data[$k] * 100) / $org_data[members_count],3),1); } else { $org_data[$percent_name] = "0.0"; } $org_data[$barl_name] = round($org_data[$percent_name]*1.67,0); } /* calculate breed */ if (ereg("^bre.*count",$k)) { $percent_name = str_replace("count","percent",$k); $barl_name = str_replace("count","barl",$k); if (!empty($v)) { $org_data[$percent_name] = number_format(round(($org_data[$k] * 100) / $org_data[members_count],3),1); } else { $org_data[$percent_name] = "0.0"; } $org_data[$barl_name] = round($org_data[$percent_name]*1.67,0); } /* calculate gender */ if (ereg("^gen.*count",$k)) { $percent_name = str_replace("count","percent",$k); $barl_name = str_replace("count","barl",$k); if (!empty($v)) { $org_data[$percent_name] = number_format(round(($org_data[$k] * 100) / $org_data[members_count],3),1); } else { $org_data[$percent_name] = "0.0"; } $org_data[$barl_name] = round($org_data[$percent_name]*1.67,0); } } } /* make statistics (requires calculate_percent() function) */ function stats() { global $org, $org_data; $org_data[members_count] = 0; $org_data[level_sum] = 0; /* reset profession count */ $org_data[prof_soldier_count] = 0; $org_data[prof_martial_artist_count] = 0; $org_data[prof_engineer_count] = 0; $org_data[prof_fixer_count] = 0; $org_data[prof_agent_count] = 0; $org_data[prof_adventurer_count] = 0; $org_data[prof_trader_count] = 0; $org_data[prof_bureaucrat_count] = 0; $org_data[prof_enforcer_count] = 0; $org_data[prof_nano_technician_count] = 0; $org_data[prof_meta_physicist_count] = 0; $org_data[prof_doctor_count] = 0; $org_data[prof_shade_count] = 0; $org_data[prof_keeper_count] = 0; /* reset breed count */ $org_data[bre_solitus_count] = 0; $org_data[bre_opifex_count] = 0; $org_data[bre_nano_count] = 0; $org_data[bre_atrox_count] = 0; /* reset gender count */ $org_data[gen_male_count] = 0; $org_data[gen_female_count] = 0; $org_data[gen_neuter_count] = 0; foreach ($org as $nick => $data) { foreach ($data as $k => $v) { /* profession stats */ if ($k == "profession") { switch ($v) { case 'Soldier': $org_data[prof_soldier_count] += 1; break; case 'Martial Artist': $org_data[prof_martial_artist_count] += 1; break; case 'Engineer': $org_data[prof_engineer_count] += 1; break; case 'Fixer': $org_data[prof_fixer_count] += 1; break; case 'Agent': $org_data[prof_agent_count] += 1; break; case 'Adventurer': $org_data[prof_adventurer_count] += 1; break; case 'Trader': $org_data[prof_trader_count] += 1; break; case 'Bureaucrat': $org_data[prof_bureaucrat_count] += 1; break; case 'Enforcer': $org_data[prof_enforcer_count] += 1; break; case 'Nano-Technician': $org_data[prof_nano_technician_count] += 1; break; case 'Meta-Physicist': $org_data[prof_meta_physicist_count] += 1; break; case 'Doctor': $org_data[prof_doctor_count] += 1; break; case 'Shade': $org_data[prof_shade_count] += 1; break; case 'Keeper': $org_data[prof_keeper_count] += 1; break; } } /* breed stats */ if ($k == "breed") { switch ($v) { case 'Solitus': $org_data[bre_solitus_count] += 1; break; case 'Opifex': $org_data[bre_opifex_count] += 1; break; case 'Nano': $org_data[bre_nano_count] += 1; break; case 'Atrox': $org_data[bre_atrox_count] += 1; break; } } /* gender stats */ if ($k == "gender") { switch ($v) { case 'Male': $org_data[gen_male_count] += 1; break; case 'Female': $org_data[gen_female_count] += 1; break; case 'Neuter': $org_data[gen_neuter_count] += 1; break; } } /* level stats */ if ($k == "level") { /* highest level */ if ($v > $org_data[highest_level]) { $org_data[highest_level] = $v; } /* lowest level */ if (!isset($org_data[lowest_level])) { $org_data[lowest_level] = $v; } elseif ($v < $org_data[lowest_level]) { $org_data[lowest_level] = $v; } $org_data[level_sum] += $v; } } $org_data[members_count]++; } /* average level */ $org_data[average_level] = round($org_data[level_sum] / $org_data[members_count]); } function make_all() { global $org, $org_data, $html_files, $html_site_title, $html_gfx_bar, $members_count, $stats; foreach ($html_files as $tpl_name => $tpl_file) { if (!file_exists($tpl_file)) { echo "html_file \"".$tpl_file."\" not found!
\n"; exit; } } /* read html templates */ $html_header = @implode("",file("$html_files[header]")); $html_table = @implode("",file("$html_files[table]")); $html_footer = @implode("",file("$html_files[footer]")); $html_stats = @implode("",file("$html_files[stats]")); /* parse body */ $members_count = 0; /* row counter */ $i = 0; $rn = ""; $to = 0; $org_type ='Unknown'; foreach ($org as $nick => $data) { $modify_html = 1; foreach ($data as $key => $value) { if ($modify_html == 1) { $modify_html = $html_table; } $search = "{_".strtoupper($key)."_}"; $modify_html = str_replace("$search", $value, $modify_html); } if ($rn != $data[rank_name]) { if ($to == 1) { $output_table .= ''; $to = 0; $i = 0; } $rn = $data[rank_name]; $rni = $rn.'s'; if ($rn == 'President') {$rni = $rn;} if ($rn == 'Director') {$rni = $rn;} if ($rn == 'Lord') {$rni = $rn;} if ($rn == 'Monarch') {$rni = $rn;} if ($rn == 'Anarchist') {$org_type ='Anarchy';} if ($rn == 'General') {$org_type ='Departement';} if ($rn == 'Director') {$org_type ='Faction';} if ($rn == 'Lord') {$org_type ='Feudalism';} if ($rn == 'Monarch') {$org_type ='Monarchy';} if ($rn == 'Advisor') {$org_type ='Republic';} $output_table .= '
'.$rni.':

'; } /* split to 3 rows */ $i++; if ($i == 1) { $output_table .= '
'; $to = 1; } if ($i == 2) { $output_table .= ''; } if ($i == 3) { $output_table .= ''; } /* end */ $output_table .= $modify_html; /* close split - table */ if (($i == 3) and ($to == 1)) { $output_table .= '
'; $to = 0; $i = 0; } /* end */ $members_count++; } if (($i == 1) or ($i == 2)) {$output_table .= '';} $output = $html_header.$output_table; if ($stats == 1) {$output .=$html_stats;} $output .= $html_footer; unset($html_header, $html_table, $html_footer, $ouput_table); /* parse org_data */ foreach ($org_data as $key => $value) { $search = "{_".strtoupper($key)."_}"; $output = str_replace("$search", $value, $output); } /* parse members_count */ $output = str_replace("{_MEMBERS_COUNT_}",$members_count, $output); $output = str_replace("{_ORG_TYPE_}", $org_type, $output); /* parse site_title */ // $output = str_replace("{_SITE_TITLE_}", $html_site_title, $output); // original $output = str_replace("{_SITE_TITLE_}", "Members: ".$org_data[org_name], $output); /* parse html_gfx_bar */ $output = str_replace("{_GFX_BAR_}", $html_gfx_bar, $output); return $output; } /* parse xml source file */ gen_member_data(); /* make statistics */ stats(); /* calculate percentuage from profession/breed/gender */ calculate_percent(); /* parse html templates */ echo make_all(); ?>