Some sample guild export code

Questions and discussions on development tools for WarcraftRealms
User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

I get the guild info from a guild info request. I need to do further testing on this to be sure as it might not get characters if you do not have the 'Show offline characters' box checked on the guild tab.

If there are some members missing then this might be the case, or it might be due to a still troublesome bug I am trying to track down that causes not all guild members to always update correctly.

I had thought I had put this one behind me, but it may still be around =/
phpbb:phpinfo()

Oyjord

help running cron job?

Post by Oyjord »

Hi all,

Great, great thread, I'm looking forward to testing these php files out on my guild's site.

I've never learned how CRONtas/jobs work, however.

Any tips on what command to enter in my CRONtab field? I'm not sure what command to enter to grab the guild data file once a day.

Thanks for any tips,
Oy.

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

Post by Rollie »

It depends on your host and how they have it set up. I would suggest asking on the support forums for your host if available. Or, if you just build it into the main page, it can do the status checks for you and download the file when necessary (as the php script in the first post does).
phpbb:phpinfo()

Oyjord

Post by Oyjord »

Rollie wrote:It depends on your host and how they have it set up. I would suggest asking on the support forums for your host if available. Or, if you just build it into the main page, it can do the status checks for you and download the file when necessary (as the php script in the first post does).
Thanks, Rollie.

I just cut and paste your script from the first post and edited the top two config entries, and it appears to be working great. Thanks a ton. The "Rank" field shows "Unknown" all the way down, but I'm sure I goofed that up somehow :). It's been less than 24 hrs since I installed and first called the .php file, so I'm not sure if it'll update correctly, which is why I was asking about the crontabs function. My ISP has a really nice online crontabs interface, with pull down menus for all kinds of options (times, etc), and the only field I really don't get is the most important one, the "command" field heh.

Regardless, is there a way of my checking (maybe the local status.txt files?) to ensure the data will update come 24 hrs? I'm still not sure how the status.txt files work. Sorry for being such a newb.

Cheers,
Oy.

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

Post by Rollie »

First off, the reason the rank field would show unknown would be due to nobody in your guild having submitted guild data using the Census+ mod. It's real easy to do and I encourage you to do so.

As for the status.txt file, it is just a timestamp of the last time certain files were generated on the server. It is a tiny file so checking the timestamp file is cheap (bandwidth wise) compared to downloading the guild info file every time to access the data. So in an effort to decrease bandwidth usage, I request that info files only be downloaded once per day.

You can either set up a cron job to download once per day, or you can check the last time you downloaded the file with the current status.txt file to see how much time has passed since the files were last generated. If enough time has lapsed (24 hours), then the files can be downloaded again!

That answer your questions?
phpbb:phpinfo()

Oyjord

Post by Oyjord »

Rollie wrote:First off, the reason the rank field would show unknown would be due to nobody in your guild having submitted guild data using the Census+ mod. It's real easy to do and I encourage you to do so.

As for the status.txt file, it is just a timestamp of the last time certain files were generated on the server. It is a tiny file so checking the timestamp file is cheap (bandwidth wise) compared to downloading the guild info file every time to access the data. So in an effort to decrease bandwidth usage, I request that info files only be downloaded once per day.

You can either set up a cron job to download once per day, or you can check the last time you downloaded the file with the current status.txt file to see how much time has passed since the files were last generated. If enough time has lapsed (24 hours), then the files can be downloaded again!

That answer your questions?
Aye, Rollie, thanks the help. Now I just need to find what command to enter to set up a cron job to download once per day. My ISP has a really nice GUI Crontabs for morons like me, but I still need to somehow tell it to grab the .csv file and put it somewhere heh. I'll work on that.

Thanks again, great having this guild info on our site now,
Oyjord.

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

Post by Rollie »

Just drop the saving part into a php file, say saveinfo.php:

Code: Select all

        $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; 
        &#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;; 
Now, depending on your ISP's setup, you should be able to do something like

lynx -dump /dev/null http://www.yourdomain.com/saveinfo.php > /dev/null

This would invoke the text based browser, Lynx, to process the php script. There may be some issues with having the correct path that you might have to qualify the lynx call, or the location of the saveinfo.php file, but that should do it when you get the paths correct.
phpbb:phpinfo()

Shade
Posts: 2
Joined: Mon Feb 07, 2005 3:17 pm

Post by Shade »

Yo, Rollie can you help me wit sumfin? I'm trying to sort the guild member list by classes into separate tables, yet after the first table is shown all the output is showing is just the table with the header (Username, Level, etc..)
and the other users arent showing.

im trying to just use an if statement like:

Code: Select all

if &#40;$class == 'Rogue'&#41; &#123;
echo &#40;" table info with the $name, $level, blah blah "&#41;;
&#125;
if &#40;$class == 'Warrior'&#41;&#123;
echo &#40;" more table info "&#41;;
&#125;
except with your guild roster code it's just doing what i said up top.
Basically i want it to look like:
http://www.freepgs.com/warng/rostertemplate.htm

thanks,
Frozenshade

[/code]

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

Post by Rollie »

To do what you are trying to do, you would have to be sure to first sort the list by class, then do a check in your output loop to catch when the class changes and output the proper html as needed.

That or build up separate table information as you process the list and then do a string replace on some key value in your template file to insert the proper html as needed.

If I have a chance this weekend, I'll try to give you an example of what to do.
phpbb:phpinfo()

Nukes

Nice Posts guys

Post by Nukes »

I'm experience in PHP and I understand what this code is doing. I have one problem. My web hosting company requires the directory to be CHMOD 755. Therefor I cannot write to the directory. Any ideas?

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

Post by Rollie »

You could always use a database. Read the status file, write the value to the database. Compare that before reading the guild export. When you do read the export, write the contents to database instead of a file. Then pull from the database for display.
phpbb:phpinfo()

Nukes

Post by Nukes »

Duh..... I should of thought of that. Thanks bro.

Nukes

Post by Nukes »

Rollie, started a new thread for development of a php script for PHP/Database information. Maybe if you have time you can help me out. I have a good chunk of code written.

Xhooght79

Cencus Borders

Post by Xhooght79 »

First of all this is great stuff. I love it!

Forgive my ignorance, but I love how the cencus looks. May i use the borders and general layout of the cencus as long as i give cridit on the website?

here is the link to my census

[url=mailto:mharmon827@gmail.com]Here[/url] is my email address

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

Post by Rollie »

You are welcome to use the graphics/layout of the guild display. Also, you don't currently have your Guild Data provided by WarcraftRealms.com link so please add that to your page as well =)
phpbb:phpinfo()

Xhooght
Posts: 2
Joined: Thu Mar 17, 2005 1:50 pm

was having troubles

Post by Xhooght »

Ya, i know next to nothing about PHP but i do some programming on the side so i generally know what is happening. I was playing with echo and where to end my table and kept loosing the link on the bottom. Its there now though. Thanks for letting me use the layout.

Here is a sample of my output code, look formilure? I want to have a border of 1px under each cell. How do go about doing this? I have been playing and tinkering, can't seem to get it. (sorry for the messy code)

Code: Select all

 <?php
require &#40;"test.php"&#41;;

//Printing out the member data
    
	for&#40;$i = 1;$i < count&#40;$d_file&#41;;$i++&#41;
&#123; 
    list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",", $d_file&#91;$i&#93;&#41;;

    echo '<tr class="content"><td class="content">' . $name . '</td><td class="content">' . $race . '</td><td class="content">' . $class . '</td><td class="content">' . $level . '</td><td class="content">' . $last_seen . '</td><td class="content">' . $rank . '</td></tr>'; 
&#125; 

echo '</table>';
//The first line contains no member data
$member_count = count&#40;$d_file&#41; - 1;

echo '<table class="content"><tr><td class="topcontent"><center>Statistics</center><tr><td class="content">';
echo 'Total Members&#58; ';
echo "$member_count";
echo '</center>';
echo "Guild data provided by <a href='http&#58;//www.warcraftrealms.com/'>WarcraftRealms.com</a>.";
echo '</td></tr></table>';

?>
[/code]

P.S. do you maintain this website yourself?

Xhooght
Posts: 2
Joined: Thu Mar 17, 2005 1:50 pm

Sorting Data

Post by Xhooght »

I am haveing some troubles being able to sort my data. I want to make it so you can click on the header and it sorts that field.. for example click on level and it sorts it by level.. I noticed you have it on your site and wonder how you do it.

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

Post by Rollie »

How are you storing your data? Are you storing everything in a database or just using the export file?
phpbb:phpinfo()

gideon

im a dummie

Post by gideon »

oke im a dummie i tried this 2 get on my website but my programming skill nill 2 zero i just dont quite get it
could some one plz explain step by step how 2 do this or maybe send me a email about this

my email paulbloom1980 @ yahoo.com

i would very much apreciate this and i know many others will 2
thnx

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

Post by Rollie »

Gideon, tell me a little more about your background and what you have available as far as your web host goes and perhaps I can help a little more.
phpbb:phpinfo()

Locked