Some sample guild export code

Questions and discussions on development tools for WarcraftRealms
Guest

Post by Guest »

I'm in Gideon's boat here. I'll try to describe my situation and maybe it will help more than the two of us.

I have purchased hosting at globat.com and have access to their tools. They run PHP, MySQL, and a host of other eCommerce things (that part I really don't care about). I have access to tools like phpMyAdmin (even though I have zilch experience in using it).

I've done my best to understand what exactly I need to do with the code listed in this forum and turn it into a viable guild roster page as it's displayed here on your site.

I do believe I have access to all the tools I need.

But like Gideon, I have zippo experience in programming (minus HTML), I haven't used PHP in the past and no experience with MySQL. I can write fairly efficient HTML code and understand it.

I guess I'd just like to be able to grasp how I take this CSV file and turn it into what you display on your site.

What I do have is energy and enthusiasm to learn what I need to do so I can present my guild's roster in a professional manner.

Thank you very much for any help and assistance you can provide.

Raffi
Officer of "The Unnamed"
Cenarius

Raffi
Posts: 2
Joined: Mon May 16, 2005 5:53 pm

Post by Raffi »

Gah, thought I was logged in.

Raffi

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

Post by Rollie »

Well, you are probably closer than you realize to being able to do it then. Do you have much/any database experience? I guess it wouldn't hurt to throw together an SQL script that would create the necessary database tables and such. Might make it a little easier to get up and running.
phpbb:phpinfo()

Raffi
Posts: 2
Joined: Mon May 16, 2005 5:53 pm

Post by Raffi »

I would say that I'm a beginning database user at best.

Thanks again for your help and assitance.

Raffi

Crippler

Getting csv with ASP

Post by Crippler »

Hi all

Has anyone got this working with ASP ???

I know it should be very easy, i just have no idea how to download the csv file with ASP, the rest i can do myself, like import that csv into a database and setup a page to view it etc, but i have no idea how to pull the csv file itself.

Any help would be much appreciated,


Thanks in advance

Raducanu
Posts: 1
Joined: Thu Jul 28, 2005 6:20 am

Post by Raducanu »

Hello,

i'm still a PHP newbee but i like to filter the results.

Is there a way to do this.

For example:
Just show all priest >50 or members online <30 days and so on.

Can someone write me an example for this?

Im using this script (see in action http://www.marcelmertens.de/temp/guilde.php)

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&#58; 1/27/2005   
    //
    //  Author&#58;  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        = 102065;   //  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 > 86400 &#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;



    //
    //  Now let's just output our roster as it's given
    //
    $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;

    //  do one read to get the header
    $buffer = fgets&#40;$infile, 4096&#41;;

    //  read the entries
    echo '<table style="margin-left&#58; auto; margin-right&#58; auto; text-align&#58; left; width&#58; 80%; height&#58; 60px;" border="1" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Name</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Rasse</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Klasse</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Level</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Rank</small></td></tr><tr>';
    while &#40;!feof &#40;$infile&#41;&#41;
    &#123;
        $buffer = fgets&#40;$infile, 4096&#41;;
        list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",",$buffer&#41;;

        echo '<tr><td style="font-family&#58; Verdana;"><small>' . $name . '</small></td><td style="font-family&#58; Verdana;"><small>' . $race . '</small></td><td style="font-family&#58; Verdana;"><small>' . $class . '</small></td><td style="font-family&#58; Verdana;"><small>' . $level . '</small></td><td style="font-family&#58; Verdana;"><small>' . $rank . '</small></td></tr>';
    &#125;
    echo '</table>';
   
//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>'; 

    

?>

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

Post by Rollie »

All you would need to do is customize your output based on the results from this statement:

Code: Select all

    list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",", $d_file&#91;$i&#93;&#41;; 
Which is located near the bottom in the Printing Out The Member Data section.
phpbb:phpinfo()

Guest

Post by Guest »

I have experience with php.

Can someone give me a example how to (f.e.) show all priest higher than 40?

Guest

Post by Guest »

Sorry, forgot to login, no edit function.

I have NO Experience with PHP

Dagobert

Post by Dagobert »

Could maybe somebody help me? i don?t get.

http://berentirsidh.fbhosting.com/census.php

It should be work, but it don?t. I also don?t get an error but the Datas are missing :(

What did I wrong? What could be the reason?



Another question: Does somebody know a free webspace provider where the script is running? Maybe I don?t have all permissions that i need, but on the other hand that cant be the reason because I dont get a permission error.

Dagobert

Post by Dagobert »

sorry,now it works.
I had to rename the csv files on my server to txt files and change it in the script,too because of the permissions of my provider

Dagobert

Post by Dagobert »

I use the same script like "Raducanu" with the difference that i had to rename the csv files to txt. But why dont the member counter works and the "Last Seen" Output?

Could somebody hlp me please?

TANKS!!

http://berentirsidh.fbhosting.com/test3.php

Guest

Dagobert

Post by Guest »

sorry,I am a gump :D
Forget the "Last Seen" Problem,but the counter still dont works.I am too stupid

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

Post by Rollie »

Without seeing the actual php code, there is no way to determine why the counter is not working correctly.
phpbb:phpinfo()

Dagobert

Post by Dagobert »

Sorry,this is my actual code:

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&#58; 1/27/2005    
    // 
    //  Author&#58;  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 &#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 > 86400 &#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.txt"; 
        $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; 



    // 
    //  Now let's just output our roster as it's given 
    // 
    $filename = $local_directory . "guildroster.txt"; 
    $infile = fopen &#40;$filename, "r"&#41;; 
    if &#40;!$infile&#41; 
    &#123; 
        echo "<p>Unable to open local roster file.<br>"; 
        exit; 
    &#125; 

    //  do one read to get the header 
    $buffer = fgets&#40;$infile, 4096&#41;; 

    //  read the entries 
    echo '<table style="margin-left&#58; auto; margin-right&#58; auto; text-align&#58; left; width&#58; 80%; height&#58; 60px;" border="1" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Name</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Rasse</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Klasse</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Level</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Zuletzt gesehen</small></td><td style="font-weight&#58; bold; font-family&#58; Verdana;"><small>Rang</small></td></tr><tr>'; 
    while &#40;!feof &#40;$infile&#41;&#41; 
    &#123; 
        $buffer = fgets&#40;$infile, 4096&#41;; 
        list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",",$buffer&#41;; 

        echo '<tr><td style="font-family&#58; Verdana;"><small>' . $name . '</small></td><td style="font-family&#58; Verdana;"><small>' . $race . '</small></td><td style="font-family&#58; Verdana;"><small>' . $class . '</small></td><td style="font-family&#58; Verdana;"><small>' . $level . '</small></td><td style="font-family&#58; Verdana;"><small>' . $last_seen . '</small></td><td style="font-family&#58; Verdana;"><small>' . $rank . '</small></td></tr>'; 
    &#125; 
    echo '</table>'; 
    
//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><td>' . $name . '</td><td>' . $race . '</td><td>' . $class . '</td><td>' . $level . '</td><td>' . $last_seen . '</td><td>' . $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>'; 

    

?>

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

Post by Rollie »

Remove all of this

Code: Select all

//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><td>' . $name . '</td><td>' . $race . '</td><td>' . $class . '</td><td>' . $level . '</td><td>' . $last_seen . '</td><td>' . $rank . '</td></tr>';
&#125;

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

Code: Select all

    while &#40;!feof &#40;$infile&#41;&#41;
    &#123;
        $buffer = fgets&#40;$infile, 4096&#41;;
        list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",",$buffer&#41;;

        echo '<tr><td style="font-family&#58; Verdana;"><small>' . $name . '</small></td><td style="font-family&#58; Verdana;"><small>' . $race . '</small></td><td style="font-family&#58; Verdana;"><small>' . $class . '</small></td><td style="font-family&#58; Verdana;"><small>' . $level . '</small></td><td style="font-family&#58; Verdana;"><small>' . $last_seen . '</small></td><td style="font-family&#58; Verdana;"><small>' . $rank . '</small></td></tr>';
    &#125; 
to this:

Code: Select all

    while &#40;!feof &#40;$infile&#41;&#41;
    &#123;
        $buffer = fgets&#40;$infile, 4096&#41;;
        list&#40; $name, $race, $class, $level, $last_seen, $rank &#41; = explode&#40;",",$buffer&#41;;

        $member_count++;

        echo '<tr><td style="font-family&#58; Verdana;"><small>' . $name . '</small></td><td style="font-family&#58; Verdana;"><small>' . $race . '</small></td><td style="font-family&#58; Verdana;"><small>' . $class . '</small></td><td style="font-family&#58; Verdana;"><small>' . $level . '</small></td><td style="font-family&#58; Verdana;"><small>' . $last_seen . '</small></td><td style="font-family&#58; Verdana;"><small>' . $rank . '</small></td></tr>';
    &#125; 
phpbb:phpinfo()

Dagobert

Post by Dagobert »

cool,thx ! It works great ! :)

I?ve got another question, do you know how I can test if the guildroster-updating-function really works?

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

Post by Rollie »

I'm not quite sure I understand.
phpbb:phpinfo()

Dagobert

Post by Dagobert »

Sorry, my english is not the best ;)

Okay, i will try to explain what I mean. When I execute the script (by surfing to http://berentirsidh.fbhosting.com/test3.php) the script is looking in the database of warcraftrealms for a newer guildrost,right?
I don?t need to hold it up to date manually,right?

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

Post by Rollie »

Yes, it is automatic!
phpbb:phpinfo()

Locked