Some sample guild export code

Questions and discussions on development tools for WarcraftRealms
User avatar
Jundar
Posts: 7
Joined: Sun Feb 19, 2006 9:48 am

Post by Jundar »

I realize this is probably all old news, but here's my use of your efforts:
http://horderlies.com/index.php?id=members
The WCR link is in the middle section, i was moving the tables around to decide where I liked which parts where.. thats where it ended up, but it is there (the credit)

hehe, don't laught 8)
Also.. the "Idle" character's isn't quite right (For sure the Idle 60s), but i'll figure that out later.
Please, Don't squeeze the Shaman!
<img src='http://www.mysigspace.com/wrsig/2707488.jpg'>

User avatar
Jundar
Posts: 7
Joined: Sun Feb 19, 2006 9:48 am

Post by Jundar »

Ok, i am encountering a problem.
The "Guild at a glance" code works, the "Guild Activity" code works (as in they both reflect the correct # of guild members).
However, the Member List isn't working properly with updating new members or member levels..
http://horderlies.com/index.php?id=members

Even when the Remote and Local data match up the list doesn't properly reflect the correct data or members compared to the list on the WCR site.
http://www.warcraftrealms.com/guilddisp ... did=436705

Why is it that the otehr 2 codes reflect the correct data but not the member list?
any suggestions?
Please, Don't squeeze the Shaman!
<img src='http://www.mysigspace.com/wrsig/2707488.jpg'>

User avatar
Jundar
Posts: 7
Joined: Sun Feb 19, 2006 9:48 am

Post by Jundar »

wow, thanks for the help ;)
Anyway, Its working now. I had to point the path to the local txt file and not the csv file and since then everything seems to be updating properly now.
Yay!

Now, if only WCR profilers worked eh? i'd be in heaven
Please, Don't squeeze the Shaman!
<img src='http://www.mysigspace.com/wrsig/2707488.jpg'>

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Gonna get those profiles back in order very soon. I'm going to do all I can to allot the time to fix them this week.

Glad you got your export code working =)
phpbb:phpinfo()

User avatar
Jundar
Posts: 7
Joined: Sun Feb 19, 2006 9:48 am

Post by Jundar »

Hey Thanks a bunch!
My next goal is to try to get the report to color code each table row (or the text within, rather) based on the Class.
my php is no where near that advanced but I am sure I can figure it out from similar situations on other forums.

Ah, if it weren't for gaming, i'd just be a useless tool.
but for now, i'm a wrench being used as a hammer. ;)
Please, Don't squeeze the Shaman!
<img src='http://www.mysigspace.com/wrsig/2707488.jpg'>

dantoonina
Posts: 3
Joined: Thu Jun 01, 2006 3:08 pm

Can I get your help?

Post by dantoonina »

I can't seem to get this working, can you send me a php file that works?

$local_directory = "roster/";
$guild_id = 595244;
These are the guilds settings.
Rollie wrote:When you get it up and running, drop a link so I can check out your handywork!

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

What seems to be the problem? Where is it breaking?

It is likely your directory permissions are not set properly, or that your site host does not allow remote fopen calls.
phpbb:phpinfo()

dantoonina
Posts: 3
Joined: Thu Jun 01, 2006 3:08 pm

Re: Guild at a Glance

Post by dantoonina »

I need help, I have tried and tried to get your script to work, here is ther errors I am getting:

File Last Updated at : 12/31/69 17:00:00

Warning: fopen(): URL file-access is disabled in the server configuration in /home/content/S/O/L/SOLGuild/html/roster.php on line 44

Warning: fopen(http://www.warcraftrealms.com/exports/status.txt): failed to open stream: no suitable wrapper could be found in /home/content/S/O/L/SOLGuild/html/roster.php on line 44
Unable to open status file.

How do I fix this, what did I do wrong?


Hybuir wrote:Heya everyone, I've gone ahead and made a 'condensed' version that gives critical information to the user without having to decypher the whole guild list. I've implemented the base code, with a couple of quirks. Any feedback would be greatly appreciated. Working example at http://reapers.ws/guild_at_a_glance/

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

There's your problem right there. fopen on URL is disabled on your server. YOu could try the CURL version.

http://www.warcraftrealms.com/forum/vie ... =6049#6049
phpbb:phpinfo()

villavengore
Posts: 4
Joined: Fri Feb 24, 2006 5:46 am

Post by villavengore »

Thank you guys sooooo much for all the help that there was on this thread.


http://www.sgone.info/roster2.php

http://www.sgone.info/roster1.php

needs working on for formatting etc - but it works! :wink: :wink: :wink:

Skraggy
Posts: 5
Joined: Thu Dec 22, 2005 11:05 am

Post by Skraggy »

I figure since I used Rollie's code as a base, I'd post here what I ended up with.

First, I split it out into two files, rostergrab.php which checks for new status file, and roster.php which is the main roster, and I just cron rostergrab.php. I don't really need my page hitting warcraftrealms everytime someone hits the page, so I wanted it separate.

So for rostergrab.php, I have this (which is just Rollie's code with the display part ripped out):

Code: Select all

<?php
    //
    //  Rostergrab.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&#58; 1/27/2005
    //
    //  Author&#58;  Cooper Sellers aka Rollie - Bloodscalp
    //

    $local_directory = "download/";     //  this is the directory where your local files
                                //  will be written to and read from.  Make sure
                                //  you have WRITE privileges on this directory

    $guild_id        = 18447;   //  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 &#40;$localstatusfile, "r"&#41;;
    $current_timestamp = 0;
    if &#40;!$infile&#41;
    &#123;
        echo "<p>No status file available, assuming this is the first run<br>";
    &#125;
    else
    &#123;
        //  read our status file time
        $buffer = fgets&#40;$infile, 4096&#41;;

        $current_timestamp = trim&#40; $buffer &#41;;

        echo 'Local status file reads &#58; ' . strftime&#40;"%m/%d/%y %H&#58;%M&#58;%S",$current_timestamp&#41; . '<br>';
    &#125;
    fclose&#40; $infile &#41;;         //  close our local status file

    $filename = "http&#58;//www.warcraftrealms.com/exports/status.txt";
    $infile = fopen &#40;$filename, "r"&#41;;   // open remote status file
    if &#40;!$infile&#41;
    &#123;
        echo "<p>Unable to open status file.<br>";
        exit;
    &#125;

    $remote_timestamp = 0;
    if&#40;!feof &#40;$infile&#41;&#41;   // only 1 read should be needed for the status file
    &#123;
        $buffer = fgets&#40;$infile, 4096&#41;;
        $remote_timestamp = trim&#40; $buffer &#41;;

        echo 'Remote status file reads &#58; ' . strftime&#40;"%m/%d/%y %H&#58;%M&#58;%S",$remote_timestamp&#41; . '<br>';

    &#125;
    fclose&#40; $infile &#41;;  //  close the remote status file

    if&#40; $remote_timestamp - $current_timestamp > 79200 &#41; //  1 day = 60*60*24
    &#123;
        //
        //  We can do a full get
        //

        //  write our new status file
        $outfilename = $local_directory . "status.txt";
        $outfile = fopen&#40;$outfilename, "w"&#41;;
        if&#40; !$outfile &#41;
        &#123;
            echo "<p>Unable to open save file => " . $outfilename . "<br>";
            exit;
        &#125;

        fputs&#40;$outfile, $buffer&#41;;
        fclose&#40;$outfile&#41;;

        //
        //  Now get our guild roster file
        //
        $filename = 'http&#58;//www.warcraftrealms.com/exports/guildexport.php?guildid=' . $guild_id;
        $infile = fopen &#40;$filename, "r"&#41;;
        if &#40;!$infile&#41;
        &#123;
            echo "<p>Unable to open remote file.<br>\n";
            exit;
        &#125;

        $outfilename = $local_directory . "guildroster.csv";
        $outfile = fopen&#40;$outfilename, "w"&#41;;
        if&#40; !$outfile &#41;
        &#123;
            echo "<p>Unable to open save file => " . $outfilename . "<br>\n";
            exit;
        &#125;

        while &#40;!feof &#40;$infile&#41;&#41;
        &#123;
            $buffer = fgets&#40;$infile, 4096&#41;;
            fputs&#40;$outfile, $buffer&#41;;
        &#125;

        fclose&#40;$outfile&#41;;
        fclose&#40;$infile&#41;;
    &#125;

?>
And then for my main guild list, I wanted it split out by class, and sorted by guild rank, display pvp rank and activity, so I came up with the following:

Code: Select all

<?php
    //  Author&#58;  Skraggy of Aggramar, based on Rollie's sample code

    $local_directory = "download/";     //  this is the directory where your local files
                                //  will be written to and read from.  Make sure
                                //  you have WRITE privileges on this directory

    $rankorder = array&#40;'High Champion','Chief','Chieftan','Elder','Tribal Guardian','Oathsworn','Tribesman','Brave','Officer Alt','Tribealt','Unknown'&#41;;
    $classorder = array&#40;'Druid','Hunter','Mage','Priest','Rogue','Shaman','Warlock','Warrior'&#41;;

    // Read in roster file
    $filename = $local_directory . "guildroster.csv";
    $infile = fopen &#40;$filename, "r"&#41;;
    if &#40;!$infile&#41;
    &#123;
        echo "<p>Unable to open local roster file.<br>";
        exit;
    &#125;

    // Read header
    $header = fgetcsv&#40;$infile, 4096, ","&#41;;

    // Populate Guild List array
    while &#40;&#40;$data = fgetcsv&#40;$infile, 4096, ","&#41;&#41; !== FALSE&#41; &#123;
       if &#40;isset&#40;$header&#41;&#41; &#123;
          foreach &#40;$header as $key=>$heading&#41; &#123;
             $row&#91;$heading&#93;=&#40;isset&#40;$data&#91;$key&#93;&#41;&#41; ? $data&#91;$key&#93; &#58; '';
          &#125;
          $guildlist&#91;&#93;=$row;
       &#125;
    &#125;

    fclose&#40;$infile&#41;;

    while &#40;list&#40;$key,$class&#41; = each&#40;$classorder&#41;&#41; &#123;
       printClass&#40;$class,$guildlist,$rankorder&#41;;
    &#125;

    //  don't forget our credit link =&#41;

    echo "<p> Guild data provided by <a href='http&#58;//www.warcraftrealms.com/'>WarcraftRealms.com</a>.</p>";

    function printClass&#40;$classname,$guildarray,$ranks&#41; &#123;
       while &#40;list&#40;$key,$member&#41; = each&#40;$guildarray&#41;&#41; &#123;
          if &#40;$member&#91;'Class'&#93; == $classname&#41; &#123;
             $classlist&#91;&#93; = $member;
          &#125;
       &#125;
       $num = count&#40;$classlist&#41;;
       echo "<h3><a name=\"$classname\">$classname</a>&#58; $num</h3>\n";
       echo '<table width="640" bgcolor="#5A1F0C"><tr><th>Name</th><th>Race</th><th>Level</th><th>Guild Rank</th><th>PvP Rank</th><th>Status</th></tr>';
       foreach &#40;$ranks as $key=>$rank&#41; &#123;
          $ranklist = getRankList&#40;$rank,$classlist&#41;;
          if &#40;$ranklist&#41; &#123;
             outputTable&#40;$ranklist&#41;;
          &#125;
       &#125;
       echo '</table>';
       return;
    &#125;

    function getRankList&#40;$rankname,$classarray&#41; &#123;
       $return = false;
       while &#40;list&#40;$key,$member&#41; = each&#40;$classarray&#41;&#41; &#123;
          if &#40;$member&#91;'GuildRank'&#93; == $rankname&#41; &#123;
             $return&#91;&#93; = $member;
          &#125;
       &#125;
       return $return;
    &#125;

    function outputTable&#40;$sortedclass&#41; &#123;
       while &#40;list&#40;$key,$member&#41; = each&#40;$sortedclass&#41;&#41; &#123;
          list&#40;$name,$race,$class,$level,$lastseen,$guildrank,$pvprank&#41; = array_values&#40;$member&#41;;

          //Activity threshold variables in DAYS
          $idle = 14;
          $inactive = 30;

          $interval = &#40;&#40;time&#40;&#41; - strtotime&#40;$lastseen&#41;&#41;/86400&#41;;

          $status = '<font color="red">Inactive</font>';
          if &#40;$interval <= $idle&#41;  &#123;
             $status = '<font color="#ccffcc">Active</font>';
          &#125;
          else if &#40;$interval > $idle && $interval < $inactive&#41; &#123;
             $status = '<font color="#ffcc99">Idle</font>';
          &#125;

          // Horde Ranks
          $pvpranklist = array&#40;'','','','','', 'Scout', 'Grunt', 'Sergeant', 'Senior Sergeant', 'First Sergeant', 'Stone Guard', 'Blood Guard', 'Legionnaire', 'Centurion', 'Champion', 'Lieutenant General', 'General', 'General', 'Warlord', 'High Warlord'&#41;;
          if &#40;!$pvprank&#41; $pvprank = '000004';
          $pvptitle = $pvpranklist&#91;intval&#40;$pvprank&#41;&#93;;

          echo '<tr><td>' . $name . '</td><td>' . $race . '</td><td>' . $level . '</td><td>' . $guildrank . '</td><td>' . $pvptitle . '</td><td>' . $status . '</td></tr>';

       &#125;
       return;
    &#125;
?>
Items to note if you want to use this is you'll have to change the rankorder value to list the ranks your guild has, and the order you want them displayed per class. Also, if you're alliance, you'll need to change the pvpranklist to the alliance ranks.

Anyway.... the result is you get something like this (which includes the other two activity and summary code snippets earlier in the thread): http://gamehaven.org/wow/tribe/roster.php
Last edited by Skraggy on Fri Jun 16, 2006 1:20 pm, edited 2 times in total.
Image

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Very nice!
phpbb:phpinfo()

tszeusts
Posts: 4
Joined: Tue Jul 25, 2006 10:30 pm

Post by tszeusts »

I started to create a table in a MYSQL database hosted by 1&1, but noticed the disclaimer says the database is behind a firewall. Would I be able to use the sample code you have been so generous on providing? I am wondering if I create this database and put the table on my site whether or not it will even work, since 1&1 is hosting for me.

Thanks,
~T

Skraggy
Posts: 5
Joined: Thu Dec 22, 2005 11:05 am

Post by Skraggy »

tszeusts wrote:I started to create a table in a MYSQL database hosted by 1&1, but noticed the disclaimer says the database is behind a firewall. Would I be able to use the sample code you have been so generous on providing? I am wondering if I create this database and put the table on my site whether or not it will even work, since 1&1 is hosting for me.
If your site is hosted at 1&1 as well as the database, you should have no problem using any code to put information into and access the database.

You would only have a problem if you tried to access the database directly from a web site hosted elsewhere.

None of the code in this thread requires a database however (it's all done in flat files) unless that's functionality you are planning on adding to your own.
Image

tszeusts
Posts: 4
Joined: Tue Jul 25, 2006 10:30 pm

Post by tszeusts »

If your site is hosted at 1&1 as well as the database, you should have no problem using any code to put information into and access the database.

You would only have a problem if you tried to access the database directly from a web site hosted elsewhere.

None of the code in this thread requires a database however (it's all done in flat files) unless that's functionality you are planning on adding to your own.
Oh ok I think I am getting it now. Thanks for the reply Skrag- I'm happy to admit I am venturing into web design for the first time if you can't tell. Can you clarify then, in fact, the code is on the page itself? I'll keep reading up, but appreciate any additional help you could provide. From this point forward I plan on using coffecup's free web editor. It seems to provide everything I will need to publish the site I want.

http://www.coffeecup.com/free-editor/

This site is great and the people here are very helpful !

Skraggy
Posts: 5
Joined: Thu Dec 22, 2005 11:05 am

Post by Skraggy »

There are two files written to a directory, one which is a comma delimited text file pulled from warcraftrealms, and one that simply saves the status of updating that text file.

Where it is saved in most of these scripts is defined in the beginning of the scripts:

Code: Select all

    $local_directory = "download/";     //  this is the directory where your local files
                                //  will be written to and read from.  Make sure
                                //  you have WRITE privileges on this directory 
Then, the php page simply reads this comma delimited file and makes it look pretty (sorting, calculating, doing whatever depending on which scripts you use) each time they are viewed.
Image

Hybuir
Gear Dependent Squirrel
Gear Dependent Squirrel
Posts: 1471
Joined: Tue Sep 06, 2005 6:22 am
Location: Austin, TX
Contact:

Post by Hybuir »

Don't know if there's even a demand for this anymore but... I was bored, what can I say? I expanded my 'Guild at a Glance' code to include 70's.

Step 1. Make an php file (index.php) to include this code. Make sure you update your '$guild_id' '$guild_name' '$server_id' and '$server_name' variables to reflect the correct information.
Full Code at: http://juniordimas.com/fold/index.php.txt

Step 2. Make a txt file called 'guildroster.txt' and just have it completely empty

Step 3. Make a txt file called 'status.txt' and have it just have 6 Zeros (000000)

Step 4. Upload all these files to the same folder.

Step 5. CHMOD guildroster.txt and status.txt to 666

You're done! Access your file and it should be all nice and informative
Working copy at: http://juniordimas.com/fold/index.php
Image
Last edited by Hybuir on Mon Sep 24, 2007 1:24 pm, edited 1 time in total.

rootuser
Posts: 1
Joined: Wed Feb 06, 2008 10:33 am
Location: Worcester, MA
Contact:

Thank you! Question, though..

Post by rootuser »

Hi Rollie & Co.;

Thanks for your work. The CSV file and corresponding code is very useful. The only question I've got and I didn't see it asked, yet (though I may have missed it) is has anyone addressed a purge of the data so that only current guild members are shown in the roster?

You can view my work below, though it's in need of optimization.

http://sos.fearthemike.com/roster.php

User avatar
DM.
Census Taker
Posts: 1130
Joined: Mon Oct 03, 2005 12:27 pm
Location: Toronto, Canada

Re: Thank you! Question, though..

Post by DM. »

Now if we can only see your work.. but its in a Member's only section :P
Image
Click my sig

Hybuir
Gear Dependent Squirrel
Gear Dependent Squirrel
Posts: 1471
Joined: Tue Sep 06, 2005 6:22 am
Location: Austin, TX
Contact:

Post by Hybuir »

Updated the Guild True Colors code for 70+ characters.

http://juniordimas.com/2009/02/11/warcr ... ue-colors/

Locked