Code: Select all
<?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 = ""; // 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 = 153595; // 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 "<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 );
echo 'Local status file reads : ' . 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 "<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 );
echo 'Remote status file reads : ' . 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 "<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.txt";
$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);
}
//
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.txt";
$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 style="margin-left: auto; margin-right: auto; text-align: left; width: 80%; height: 60px;" border="1" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-weight: bold; font-family: Verdana;"><small>Name</small></td><td style="font-weight: bold; font-family: Verdana;"><small>Rasse</small></td><td style="font-weight: bold; font-family: Verdana;"><small>Klasse</small></td><td style="font-weight: bold; font-family: Verdana;"><small>Level</small></td><td style="font-weight: bold; font-family: Verdana;"><small>Zuletzt gesehen</small></td><td style="font-weight: bold; font-family: Verdana;"><small>Rang</small></td></tr><tr>';
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank ) = explode(",",$buffer);
$member_count++;
echo '<tr><td style="font-family: Verdana;"><small>' . $name . '</small></td><td style="font-family: Verdana;"><small>' . $race . '</small></td><td style="font-family: Verdana;"><small>' . $class . '</small></td><td style="font-family: Verdana;"><small>' . $level . '</small></td><td style="font-family: Verdana;"><small>' . $last_seen . '</small></td><td style="font-family: Verdana;"><small>' . $rank . '</small></td></tr>';
}
echo '</table>';
echo '<table class="content"><tr><td class="topcontent"><center>Statistics</center><tr><td class="content">';
echo 'Total Members: ';
echo "$member_count";
echo '</center>';
echo "Guild data provided by <a href='http://www.warcraftrealms.com/'>WarcraftRealms.com</a>.";
echo '</td></tr></table>';
?>
Notice: Undefined variable: member_count in /usr/home/bts/www/BtsWeb/census/test4.php on line 134
Notice: Undefined offset: 5 in /usr/home/bts/www/BtsWeb/census/test4.php on line 132
Notice: Undefined offset: 4 in /usr/home/bts/www/BtsWeb/census/test4.php on line 132
Notice: Undefined offset: 3 in /usr/home/bts/www/BtsWeb/census/test4.php on line 132
Notice: Undefined offset: 2 in /usr/home/bts/www/BtsWeb/census/test4.php on line 132
Notice: Undefined offset: 1 in /usr/home/bts/www/BtsWeb/census/test4.php on line 132
you can test it on http://83.97.51.86/BtsWeb/census/test4.php