Need help,error in script

Questions and discussions on development tools for WarcraftRealms
Post Reply
Prinz
Posts: 2
Joined: Sun Sep 11, 2005 8:49 am
Location: Germany, Paderborn

Need help,error in script

Post by Prinz »

Hello,maybe somebody can help me. This is my 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;; 

        $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;
    echo '</table>'; 
    


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>'; 

    

?>
and this is the error:
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

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

Post by Rollie »

Easiest thing to do would be to disable the Notice msgs.

At the top of your script, add:

Code: Select all

error_reporting&#40;E_ALL ^ E_NOTICE&#41;;
And see if that removes the notice msgs.
phpbb:phpinfo()

User avatar
Stimme
Posts: 10
Joined: Sat Sep 10, 2005 8:52 am

Post by Stimme »

Looks like you managed to have it work?

Btw: If you are not happy with the English names for races and classes, you can also adapt some parts of the script I wrote for translatiion into German:
http://www.warcraftrealms.com/forum/viewtopic.php?t=869
Image

PrinzGuest

Post by PrinzGuest »

Thanks a lot Rollie! It works great :)
Last question :D Have anybody an idea how I could sort the members by rank?


Achja,und danke Stimme f?r den Tipp,ich denke das werd ich auch machen!

Energetic

Post by Energetic »

Write the Data once a day into a database

1. Faster Access
2. Sort/Group functions
3. Many other Queries (How Many Human/Night Elfs..., Everage Level, etc.)

Post Reply