Code: Select all
<style type="text/css">
a:link { font-family: "Geneva", Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; text-decoration: none; }
a:active { font-family: "Geneva", Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; text-decoration: none; }
a:visited { font-family: "Geneva", Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; text-decoration: none; }
a:hover { font-family: "Geneva", Arial, Helvetica, sans-serif; font-size: 12px; color: #FA5805; text-decoration: none; }
tr { font-family: "Geneva", Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; text-decoration: none; }
</style>
<?php
//
// members.php
//
// Guild Listing and Stats
//
// Created: 12/18/2005
//
// Author: Cooper Sellers aka Rollie - Bloodscalp
// Modified: SSSlippy
//
$local_directory = "temp/"; // this is the directory where your local files
// will be written to and read from. Make sure
// you have WRITE priveledges on this directory
$guild_id = 514799; // get this number from the link posted on the
// guilddisplay.php page
$guild_name = "Soul Killers"; // Variables to link back to your guilds full info
$server_id = "49"; // on WarcraftRealms.com
$server_name = "Stormscale";
//
// Remember to check the status file so that you are not pulling data
// more than once per day
//
$localstatusfile = $local_directory . "status.txt";
$infile = fopen ($localstatusfile, "r");
$current_timestamp = 0;
if (!$infile)
{
echo "<p>No status file available, assuming this is the first run<br>";
}
else
{
// read our status file time
$buffer = fgets($infile, 4096);
$current_timestamp = trim( $buffer );
}
fclose( $infile ); // close our local status file
$filename = "http://www.warcraftrealms.com/exports/status.txt";
$infile = fopen ($filename, "r"); // open remote status file
if (!$infile)
{
echo "<p>Unable to open status file.<br>";
exit;
}
$remote_timestamp = 0;
if(!feof ($infile)) // only 1 read should be needed for the status file
{
$buffer = fgets($infile, 4096);
$remote_timestamp = trim( $buffer );
}
fclose( $infile ); // close the remote status file
if( $remote_timestamp - $current_timestamp > 86400 ) // 1 day = 60*60*24
{
//
// We can do a full get
//
// write our new status file
$outfilename = $local_directory . "status.txt";
$outfile = fopen($outfilename, "w");
if( !$outfile )
{
echo "<p>Unable to open save file => " . $outfilename . "<br>";
exit;
}
fputs($outfile, $buffer);
fclose($outfile);
//
// Now get our guild roster file
//
$filename = 'http://www.warcraftrealms.com/exports/guildexport.php?guildid=' . $guild_id;
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open remote file.<br>\n";
exit;
}
$outfilename = $local_directory . "guildroster.csv";
$outfile = fopen($outfilename, "w");
if( !$outfile )
{
echo "<p>Unable to open save file => " . $outfilename . "<br>\n";
exit;
}
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
fputs($outfile, $buffer);
}
fclose($outfile);
fclose($infile);
}
// Guild Stats
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.csv";
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open local roster file.<br>";
exit;
}
//Do one read to get the header
$buffer = fgets($infile, 4096);
//Initiallize all counts
$total_count=0;
$sixty_count=0;
$druid_count=0;
$druid_mount=0;
$druid_sixty=0;
$hunter_count=0;
$hunter_mount=0;
$hunter_sixty=0;
$mage_count=0;
$mage_mount=0;
$mage_sixty=0;
$priest_count=0;
$priest_mount=0;
$priest_sixty=0;
$rogue_count=0;
$rogue_mount=0;
$rogue_sixty=0;
$paladin_count=0;
$paladin_mount=0;
$paladin_sixty=0;
$warlock_count=0;
$warlock_mount=0;
$warlock_sixty=0;
$warrior_count=0;
$warrior_mount=0;
$warrior_sixty=0;
$level_count=0;
// read the entries
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank ) = explode(",",$buffer);
$total_count = $total_count + 1;
$level_count = $level_count + $level;
if ($class == "Druid")
{
$druid_count = $druid_count + 1;
if ($level>="40") { $druid_mount = $druid_mount + 1; }
if ($level=="60") { $druid_sixty = $druid_sixty + 1; }
}
else if ($class == "Hunter")
{
$hunter_count = $hunter_count + 1;
if ($level>="40") { $hunter_mount = $hunter_mount + 1; }
if ($level=="60") { $hunter_sixty = $hunter_sixty + 1; }
}
else if ($class == "Mage")
{
$mage_count = $mage_count + 1;
if ($level>="40") { $mage_mount = $mage_mount + 1; }
if ($level=="60") { $mage_sixty = $mage_sixty + 1; }
}
else if ($class == "Priest")
{
$priest_count = $priest_count + 1;
if ($level>="40") { $priest_mount = $priest_mount + 1; }
if ($level=="60") { $priest_sixty = $priest_sixty + 1; }
}
else if ($class == "Rogue")
{
$rogue_count = $rogue_count + 1;
if ($level>="40") { $rogue_mount = $rogue_mount + 1; }
if ($level=="60") { $rogue_sixty = $rogue_sixty + 1; }
}
else if ($class == "Warlock")
{
$warlock_count = $warlock_count + 1;
if ($level>="40") { $warlock_mount = $warlock_mount + 1; }
if ($level=="60") { $warlock_sixty = $warlock_sixty + 1; }
}
else if ($class == "Warrior")
{
$warrior_count = $warrior_count + 1;
if ($level>="40") { $warrior_mount = $warrior_mount + 1; }
if ($level>="60") { $warrior_sixty = $warrior_sixty + 1; }
}
else if ($class == "Paladin") // Can be changed for Paladins
{
$paladin_count = $paladin_count + 1;
if ($level>="40") { $paladin_mount = $paladin_mount + 1; }
if ($level>="60") { $paladin_sixty = $paladin_sixty + 1; }
}
}
// Start of finding out the percentages of the classess
$druid_per = round(($druid_count/$total_count) * 100,1);
$hunter_per = round(($hunter_count/$total_count) * 100,1);
$mage_per = round(($mage_count/$total_count) * 100,1);
$priest_per = round(($priest_count/$total_count) * 100,1);
$rogue_per = round(($rogue_count/$total_count) * 100,1);
$paladin_per = round(($paladin_count/$total_count) * 100,1);
$warlock_per = round(($warlock_count/$total_count) * 100,1);
$warrior_per = round(($warrior_count/$total_count) * 100,1);
// Find out the percentages of players with mount capabilities
$druid_mount_per = round(($druid_mount/$druid_count)*100);
$hunter_mount_per = round(($hunter_mount/$hunter_count)*100);
$mage_mount_per = round(($mage_mount/$mage_count)*100);
$priest_mount_per = round(($priest_mount/$priest_count)*100);
$rogue_mount_per = round(($rogue_mount/$rogue_count)*100);
$paladin_mount_per = round(($paladin_mount/$paladin_count)*100);
$warlock_mount_per = round(($warlock_mount/$warlock_count)*100);
$warrior_mount_per = round(($warrior_mount/$warrior_count)*100);
// Find out the percentages of players that are 60
$druid_sixty_per = round(($druid_sixty/$druid_count)*100);
$hunter_sixty_per = round(($hunter_sixty/$hunter_count)*100);
$mage_sixty_per = round(($mage_sixty/$mage_count)*100);
$priest_sixty_per = round(($priest_sixty/$priest_count)*100);
$rogue_sixty_per = round(($rogue_sixty/$rogue_count)*100);
$paladin_sixty_per = round(($paladin_sixty/$paladin_count)*100);
$warlock_sixty_per = round(($warlock_sixty/$warlock_count)*100);
$warrior_sixty_per = round(($warrior_sixty/$warrior_count)*100);
$total_mount = $druid_mount + $hunter_mount + $mage_mount + $priest_mount + $rogue_mount + $paladin_mount + $warlock_mount + $warrior_mount;
$total_mount_per = round(($total_mount/$total_count)*100);
$total_sixty = $druid_sixty + $hunter_sixty + $mage_sixty + $priest_sixty + $rogue_sixty + $paladin_sixty + $warlock_sixty + $warrior_sixty;
$total_sixty_per = round(($total_sixty/$total_count)*100);
// Output
echo '<table bordercolor="#000000" border="1px" width="425">';
echo '<tr>';
echo '<td colspan="5"> <div align="center">Guild Stats - <a href=http://www.warcraftrealms.com/census.php?guildid=' . $guild_id . ' target=_guild>'. $guild_name . '</a> - <a href=http://www.warcraftrealms.com/census.php?serverid=' . $server_id . ' target=_server>' . $server_name .'</a> </div></td>';
echo '</tr><tr>';
echo '<th> <div align="center"><font color="#FA5805"><b>Class</b></font></div></th>';
echo '<th> <div align="center"><font color="#FA5805"><b>Count</b></font></div></th>';
echo '<th> <div align="center"><font color="#FA5805"><b>Percent</b></font></div></th>';
echo '<th> <div align="center"><font color="#FA5805"><b>Mounts</b></font></div></th>';
echo '<th> <div align="center"><font color="#FA5805"><b>Level 60</b></font></div></th>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Druid</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $druid_count . ' </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $druid_per . '% </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $druid_mount . ' (' . $druid_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $druid_sixty . ' (' . $druid_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Hunter</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $hunter_count . ' </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $hunter_per . '% </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $hunter_mount . ' (' . $hunter_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $hunter_sixty . ' (' . $hunter_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Mage</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $mage_count .'</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $mage_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $mage_mount . ' (' . $mage_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $mage_sixty . ' (' . $mage_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Paladin</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $paladin_count . '</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $paladin_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $paladin_mount . ' (' . $paladin_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $paladin_sixty . ' (' . $paladin_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Priest</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $priest_count .'</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $priest_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $priest_mount . ' (' . $priest_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $priest_sixty . ' (' . $priest_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Rogue</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $rogue_count . '</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $rogue_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $rogue_mount . ' (' . $rogue_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $rogue_sixty . ' (' . $rogue_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Warlock</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warlock_count . ' </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warlock_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warlock_mount . ' (' . $warlock_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warlock_sixty . ' (' . $warlock_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333">Warrior</td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warrior_count . ' </div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warrior_per . '%</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warrior_mount . ' (' . $warrior_mount_per . '%)</div></td>';
echo '<td bgcolor="#333333"> <div align="center">' . $warrior_sixty . ' (' . $warrior_sixty_per . '%)</div></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333"><div align="right"><strong>Total</strong></div></td>';
echo '<td bgcolor="#333333"><div align="center"><strong> ' . $total_count . ' </strong></div></td>';
echo '<td bgcolor="#333333"><div align="center"> </div></td>';
echo '<td bgcolor="#333333"><div align="center"><strong> ' . $total_mount . ' (' . $total_mount_per . '%)</strong></div></td>';
echo '<td bgcolor="#333333"><div align="center"><strong> ' . $total_sixty . ' (' . $total_sixty_per . '%)</strong></div></td>';
echo '</tr> <tr valign="bottom">';
echo '</tr>';
echo '</table>';
echo $endr;
// Guild Listing
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.csv";
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open local roster file.<br>";
exit;
}
// do one read to get the header
$buffer = fgets($infile, 4096);
// read the entries
echo '<table bordercolor="#000000" border="1px" width="425">';
echo '<tr>';
echo '<th><div align="center"><font color="#FA5805"><b>Name</b></font></div></th>';
echo '<th><div align="center"><font color="#FA5805"><b>Race</b></font></div></th>';
echo '<th><div align="center"><font color="#FA5805"><b>Class</b></font></div></th>';
echo '<th><div align="center"><font color="#FA5805"><b>Level</b></font></div></th>';
echo '<th><div align="center"><font color="#FA5805"><b>Last Seen</th>';
echo '<th width="100"><div align="center"><font color="#FA5805"><b>Rank</th>';
echo '<th><div align="center"><font color="#FA5805"><b>PvP Rank</th>';
echo '</tr>';
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank, $pvprank ) = explode(",",$buffer);
echo '<tr>';
echo '<td bgcolor="#333333"><a href="http://www.warcraftrealms.com/search.php?search=' . $name . '" target="_new">' . $name . '</a></td>';
echo '<td bgcolor="#333333">' . $race . '</td>';
echo '<td bgcolor="#333333">' . $class . '</td>';
echo '<td bgcolor="#333333">' . $level . '</td>';
echo '<td bgcolor="#333333">' . $last_seen . '</td>';
echo '<td bgcolor="#333333" width="100">' . $rank . '</td>';
echo '<td bgcolor="#333333"><div align="center">';
printf ("%01.0f", $pvprank);
echo '</div></td>';
echo '</tr>';
}
echo '</table>';
// Guild Activity
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.csv";
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open local roster file.<br>";
exit;
}
//Do one read to get the header
$buffer = fgets($infile, 4096);
//Activity threshold variables in DAYS
$idle = 14; //before $idle days you are active
$inactive = 30; //after $idle days and before $inacive day you are idle
//after $inacive days you are... uhm... inacive
$seconds_in_a_day = 24*60*60; //self explanitory.
//Initiallize all counts
$total_count=0;
$inactive_count=0;
$inactive_01_19=0;
$inactive_20_39=0;
$inactive_40_59=0;
$inactive_60=0;
$idle_count=0;
$idle_01_19=0;
$idle_20_39=0;
$idle_40_59=0;
$idle_60=0;
$active_count=0;
$active_01_19=0;
$active_20_39=0;
$active_40_59=0;
$active_60=0;
// read the entries
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank ) = explode(",",$buffer);
$interval = ((time() - strtotime($last_seen))/86400); //takes the interval in seconds and converts into days
$total_count = $total_count + 1;
if ($interval <= $idle) {
$active_count = $active_count + 1;
if ( $level < 20 ) {
$active_01_19 = $active_01_19 + 1;
}
else if ( $level <= 39 ) {
$active_20_39 = $active_20_39 + 1;
}
else if ( $level <=59 ) {
$active_40_59 = $active_40_59 + 1;
}
else if ( $level == 60 ) {
$active_60 = $active_60 + 1;
}
}
else if ( $interval > $idle && $interval < $inactive) {
$idle_count = $idle_count + 1;
if ( $level < 20 ) {
$idle_01_19 = $idle_01_19 + 1;
}
else if ( $level <= 39 ) {
$idle_20_39 = $idle_20_39 + 1;
}
else if ( $level <=59 ) {
$idle_40_59 = $idle_40_59 + 1;
}
else if ( $level == 60 ) {
$idle_60 = $idle_60 + 1;
}
}
else if ( $interval > $inactive ) {
$inactive_count = $inactive_count + 1;
if ( $level < 20 ) {
$inactive_01_19 = $inactive_01_19 + 1;
}
else if ( $level <= 39 ) {
$inactive_20_39 = $inactive_20_39 + 1;
}
else if ( $level <=59 ) {
$inactive_40_59 = $inactive_40_59 + 1;
}
else if ( $level == 60 ) {
$inactive_60 = $inactive_60 + 1;
}
}
}
// Stats Output
echo ' <table bordercolor="#000000" border="1px" width="425">';
echo ' <tr>';
echo ' <th><div align="center"><font color="#FA5805"><b>Activity</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>1-19</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>20-39</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>40-59</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>60</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>Percent</b></font></div></th>';
echo ' <th><div align="center"><font color="#FA5805"><b>#</b></font></div></th>';
echo ' </tr>';
echo ' <tr>';
echo ' <td style="BACKGROUND-COLOR: red">Inactive</td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . $inactive_01_19 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . $inactive_20_39 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . $inactive_40_59 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . $inactive_60 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . round(($inactive_count/$total_count)*100) . '%</div></td>';
echo ' <td style="BACKGROUND-COLOR: red"> <div align="center">' . $inactive_count . '</div></td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td style="BACKGROUND-COLOR: #FA5805">Idle</td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . $idle_01_19 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . $idle_20_39 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . $idle_40_59 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . $idle_60 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . round(($idle_count/$total_count)*100) . '%</div></td>';
echo ' <td style="BACKGROUND-COLOR: #FA5805"> <div align="center">' . $idle_count . '</div></td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td style="BACKGROUND-COLOR: green">Active</td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . $active_01_19 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . $active_20_39 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . $active_40_59 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . $active_60 . '</div></td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . round(($active_count/$total_count)*100) . '%</div></td>';
echo ' <td style="BACKGROUND-COLOR: green"> <div align="center">' . $active_count . '</div></td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td colspan="5"> </td><td bgcolor="#333333"><b><div align="right">Total</b></div></td>';
echo '<td bgcolor="#333333"><div align="center"><b>' . $total_count . '</b></div></td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td colspan="7"> <div align="center"><font size="1">Updated ' . strftime("%m/%d/%y %H:%M:%S",$remote_timestamp) . '. Guild data provided by <a href=http://www.warcraftrealms.com target=_new>WarcraftRealms.com</a>.</font></div></td>';
echo ' </tr>';
echo ' </table>';
echo ' <small>* Active is defined as last login within ' . $idle . ' days.</small><br>';
echo ' <small>* Idle is defined as last login between ' . $idle . ' and ' . $inactive .' days.</small><br>';
echo ' <small>* Inactive is defined as last login after ' . $inactive . ' days.</small><br>';
echo $endr;
?>
Ive modified all the echos to be easier to edit. Now this isnt suppose to be as clean as it should be and I may eliminate this later as im still setting this up.
Ok my issue is that im accessing the the csv file 3x which seems like im acessing it to much. Also I have an extra row now that ive added pvp rank.
Due to my CMS adding a access the code button doesnt work.