Problem !@@

Questions and discussions on development tools for WarcraftRealms
Post Reply
credendum
Posts: 5
Joined: Mon Jul 18, 2005 1:24 pm

Problem !@@

Post by credendum »

Well... I used the code and everything for the guild export roster thing... and i get this error on the site:

Code: Select all

SecureSSI: Das Script (/usr/export/www/hosting/fireback/roster.php) hat versucht ausserhalb von ihrem Userverzeichniss auf die Datei /status.txt zuzugreifen.
Dies ist nicht erlaubt!

Warning: fopen(): Sicherheitsverletzung: in /usr/export/www/hosting/fireback/roster.php on line 32

Warning: fopen(/status.txt): failed to open stream: Operation not permitted in /usr/export/www/hosting/fireback/roster.php on line 32

No status file available, assuming this is the first run

Warning: fclose(): supplied argument is not a valid stream resource in /usr/export/www/hosting/fireback/roster.php on line 47

Warning: fopen(): URL file-access is disabled in the server configuration in /usr/export/www/hosting/fireback/roster.php on line 50

Warning: fopen(http://www.warcraftrealms.com/exports/status.txt): failed to open stream: no suitable wrapper could be found in /usr/export/www/hosting/fireback/roster.php on line 50


Unable to open status file.

 



and heres the code im using...

Code: Select all

&#91;code&#93;<?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        = 505445;   //  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=505445' . $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><tr><th>Name</th><th>Race</th><th>Class</th><th>Level</th><th>Last Seen</th><th>Rank</th></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>' . $name . '</td><td>' . $race . '</td><td>' . $class . '</td><td>' . $level . '</td><td>' . $last_seen . '</td><td>' . $rank . '</td></tr>'; 
    &#125; 
    echo '</table>'; 

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

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



help please &#58;&#40;

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

Post by Rollie »

Looks to me like your host does not allow opening of remote files.
phpbb:phpinfo()

credendum
Posts: 5
Joined: Mon Jul 18, 2005 1:24 pm

Post by credendum »

Rollie wrote:Looks to me like your host does not allow opening of remote files.
that stinks.. how i check if it does.. wat would it say on the hosting?

User avatar
Ceto
Shady Dealer
Posts: 335
Joined: Sun Oct 16, 2005 8:22 pm
Location: Plymouth, NH
Contact:

Post by Ceto »

Actually, your problem is twofold. First, you're trying to open the file /status.txt on the server, which is at the root level of the drive. Notice the comments:

Code: Select all

    $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
You may want to change $local_directory to /tmp or something in your home directory, just make sure the directory is writable by the web server.

Also, like Rollie said, it looks like your web server doesn't allow fopen() on URLs. Try using the curl library for PHP: http://php.net/curl.
Image

credendum
Posts: 5
Joined: Mon Jul 18, 2005 1:24 pm

Post by credendum »

man php is so confusing.. why can't it be easy like html :( lol

credendum
Posts: 5
Joined: Mon Jul 18, 2005 1:24 pm

Post by credendum »

Also, like Rollie said, it looks like your web server doesn't allow fopen() on URLs. Try using the curl library for PHP: http://php.net/curl.

#1 what does a curl library do
#2 i dont have a clue how to use it never mind what it does
#3 is there anyway to do this if the server doesn't allow fopen() thing?

User avatar
Ceto
Shady Dealer
Posts: 335
Joined: Sun Oct 16, 2005 8:22 pm
Location: Plymouth, NH
Contact:

Post by Ceto »

Curl is a more robust way to download files. The function page for curl_exec() gives example usage. Pay particular attention to the note about CURLOPT_RETURNTRANSFER, I've found it to be useful in my scripts.

Here's an example of how I use curl to download my guild roster:

Code: Select all

$ch = curl_init&#40;&#41;;

curl_setopt&#40;$ch, CURLOPT_URL, "http&#58;//www.warcraftrealms.com/exports/guildexport.php?guildid=$guild_id"&#41;;
curl_setopt&#40;$ch, CURLOPT_RETURNTRANSFER, true&#41;;

$guild_export_raw = curl_exec&#40;$ch&#41;;
curl_close&#40;$ch&#41;;

$guild_array = explode&#40;"\n", $guild_export_raw&#41;;
Here's print_r($guild_array), truncated:

Code: Select all

Array
&#40;
    &#91;0&#93; => CharName,Race,Class,Level,LastSeen,GuildRank,PVPRank
    &#91;1&#93; => Achilees,Human,Warrior,60,11/25/05,Apprentice,
    &#91;2&#93; => Adelphia,Night Elf,Hunter,48,11/19/05,Squire,000005
    &#91;3&#93; => Aelias,Night Elf,Hunter,53,11/08/05,Squire,000005
    &#91;4&#93; => Aesir,Human,Warlock,60,11/21/05,Squire,
    ...
    &#91;154&#93; => Zeroflux,Human,Paladin,60,11/22/05,Squire,000006
    &#91;155&#93; =>
&#41;
After that, I just foreach() the array and explode() each line.

So,
  1. Curl downloads files, like fopen().
  2. See above. PHP is a full-fledged programming language, if you've never programmed before this will probably be hard.
  3. See #1.
Hope this helps...
Image

Post Reply