Page 1 of 1

My sites guild list

Posted: Sun Dec 11, 2005 8:46 pm
by SSSlippy
http://www.ssslippy.com/soulkillers/ind ... egoryid=15

will eventually be on www.soulkillers.org in about 2 days
<?php
//
// Rostertest.php
//
// Sample guild export downloader and display
// You may use this script as you wish. This is only some sample code
// provided to help get a jumpstart!
//
// Created: 1/27/2005
//
// Author: Cooper Sellers aka Rollie - Bloodscalp
//

$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

//
// 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 "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 );

echo '<div align="center">File Last Updated at : ' . strftime("%m/%d/%y %H:%M:%S",$current_timestamp) . '<br>';
}
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 "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 );

echo '<div align="center">Servers Last Update : ' . strftime("%m/%d/%y %H:%M:%S",$remote_timestamp) . '<br>';

}
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 "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/g ... p?guildid=' . $guild_id;
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "Unable to open remote file.<br>\n";
exit;
}

$outfilename = $local_directory . "guildroster.csv";
$outfile = fopen($outfilename, "w");
if( !$outfile )
{
echo "Unable to open save file => " . $outfilename . "<br>\n";
exit;
}

while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
fputs($outfile, $buffer);
}

fclose($outfile);
fclose($infile);
}



//
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.csv";
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "Unable to open local roster file.<br>";
exit;
}

// do one read to get the header
$buffer = fgets($infile, 4096);

// read the entries
echo '<table DATAPAGESIZE="6" RULES="rows" BORDER="1" WIDTH="400"><tr><th><FONT COLOR="FFA34F">Name</FONT></th><th><FONT COLOR="FFA34F">Race</FONT></th><th><FONT COLOR="FFA34F">Class</FONT></th><th><FONT COLOR="FFA34F">Level</FONT></th><th><FONT COLOR="FFA34F">Last Seen</FONT></th><th><FONT COLOR="FFA34F">Rank</FONT></th></tr></td>';
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank ) = explode(",",$buffer);

echo '<tr><TBODY BGCOLOR="#333333"><td><a href="http://www.warcraftrealms.com/search.php?search=' . $name . '" TARGET="_new">' . $name . '</a></td><td>' . $race . '</td><td>' . $class . '</td><td>' . $level . '</td><td>' . $last_seen . '</td><td>' . $rank . '</td></tr></td>';
}
echo '</table>';

?>

Posted: Mon Dec 12, 2005 9:25 am
by Hybuir
Dont forget your "Guild data provided by WarcraftRealms.com" link. Nicely done :-)

Posted: Mon Dec 12, 2005 7:42 pm
by SSSlippy
Web page isnt official done. I will be adding a link when I figure out where I want to put links. O does warcraftrealms have a cool picture link?