|
|
| View previous topic :: View next topic |
| Author |
Message |
credendum
Joined: 18 Jul 2005
Posts: 5
WR Updates: 349
credendum WR Profile
|
Posted: Sat Nov 26, 2005 10:07 am Post subject: Problem !@@ |
|
|
Well... I used the code and everything for the guild export roster thing... and i get this error on the site:
| Code: |
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: | [code]<?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: 1/27/2005
//
// Author: 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 ($localstatusfile, "r");
$current_timestamp = 0;
if (!$infile)
{
echo "<p>No status file available, assuming this is the first run<br>";
}
else
{
// read our status file time
$buffer = fgets($infile, 4096);
$current_timestamp = trim( $buffer );
echo 'Local status file reads : ' . strftime("%m/%d/%y %H:%M:%S",$current_timestamp) . '<br>';
}
fclose( $infile ); // close our local status file
$filename = "http://www.warcraftrealms.com/exports/status.txt";
$infile = fopen ($filename, "r"); // open remote status file
if (!$infile)
{
echo "<p>Unable to open status file.<br>";
exit;
}
$remote_timestamp = 0;
if(!feof ($infile)) // only 1 read should be needed for the status file
{
$buffer = fgets($infile, 4096);
$remote_timestamp = trim( $buffer );
echo 'Remote status file reads : ' . strftime("%m/%d/%y %H:%M:%S",$remote_timestamp) . '<br>';
}
fclose( $infile ); // close the remote status file
if( $remote_timestamp - $current_timestamp > 86400 ) // 1 day = 60*60*24
{
//
// We can do a full get
//
// write our new status file
$outfilename = $local_directory . "status.txt";
$outfile = fopen($outfilename, "w");
if( !$outfile )
{
echo "<p>Unable to open save file => " . $outfilename . "<br>";
exit;
}
fputs($outfile, $buffer);
fclose($outfile);
//
// Now get our guild roster file
//
$filename = 'http://www.warcraftrealms.com/exports/guildexport.php?guildid=505445' . $guild_id;
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open remote file.<br>\n";
exit;
}
$outfilename = $local_directory . "guildroster.csv";
$outfile = fopen($outfilename, "w");
if( !$outfile )
{
echo "<p>Unable to open save file => " . $outfilename . "<br>\n";
exit;
}
while (!feof ($infile))
{
$buffer = fgets($infile, 4096);
fputs($outfile, $buffer);
}
fclose($outfile);
fclose($infile);
}
//
// Now let's just output our roster as it's given
//
$filename = $local_directory . "guildroster.csv";
$infile = fopen ($filename, "r");
if (!$infile)
{
echo "<p>Unable to open local roster file.<br>";
exit;
}
// do one read to get the header
$buffer = fgets($infile, 4096);
// 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 (!feof ($infile))
{
$buffer = fgets($infile, 4096);
list( $name, $race, $class, $level, $last_seen, $rank ) = explode(",",$buffer);
echo '<tr><td>' . $name . '</td><td>' . $race . '</td><td>' . $class . '</td><td>' . $level . '</td><td>' . $last_seen . '</td><td>' . $rank . '</td></tr>';
}
echo '</table>';
// don't forget our credit link =)
echo "Guild data provided by <a href='http://www.warcraftrealms.com/'>WarcraftRealms.com</a>.";
?>[/code]
help please :( |
|
|
| Back to top |
|
 |
Rollie
Site Admin

Joined: 28 Nov 2004
Posts: 5364
Location: Austin, TX
WR Updates: 480,131
Rollie WR Profile
|
Posted: Sat Nov 26, 2005 4:03 pm Post subject: |
|
|
| Looks to me like your host does not allow opening of remote files. |
|
| Back to top |
|
 |
credendum
Joined: 18 Jul 2005
Posts: 5
WR Updates: 349
credendum WR Profile
|
Posted: Sat Nov 26, 2005 6:16 pm Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
Ceto
Shady Dealer

Joined: 16 Oct 2005
Posts: 351
Location: Plymouth, NH
WR Updates: 193,167
Ceto WR Profile
|
Posted: Sat Nov 26, 2005 9:45 pm Post subject: |
|
|
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: | $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. _________________
 |
|
| Back to top |
|
 |
credendum
Joined: 18 Jul 2005
Posts: 5
WR Updates: 349
credendum WR Profile
|
Posted: Sun Nov 27, 2005 7:01 am Post subject: |
|
|
man php is so confusing.. why can't it be easy like html lol |
|
| Back to top |
|
 |
credendum
Joined: 18 Jul 2005
Posts: 5
WR Updates: 349
credendum WR Profile
|
Posted: Sun Nov 27, 2005 7:17 pm Post subject: |
|
|
| Quote: |
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? |
|
| Back to top |
|
 |
Ceto
Shady Dealer

Joined: 16 Oct 2005
Posts: 351
Location: Plymouth, NH
WR Updates: 193,167
Ceto WR Profile
|
Posted: Mon Nov 28, 2005 8:09 am Post subject: |
|
|
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: | $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.warcraftrealms.com/exports/guildexport.php?guildid=$guild_id");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$guild_export_raw = curl_exec($ch);
curl_close($ch);
$guild_array = explode("\n", $guild_export_raw); |
Here's print_r($guild_array), truncated:
| Code: | Array
(
[0] => CharName,Race,Class,Level,LastSeen,GuildRank,PVPRank
[1] => Achilees,Human,Warrior,60,11/25/05,Apprentice,
[2] => Adelphia,Night Elf,Hunter,48,11/19/05,Squire,000005
[3] => Aelias,Night Elf,Hunter,53,11/08/05,Squire,000005
[4] => Aesir,Human,Warlock,60,11/21/05,Squire,
...
[154] => Zeroflux,Human,Paladin,60,11/22/05,Squire,000006
[155] =>
) |
After that, I just foreach() the array and explode() each line.
So,
- Curl downloads files, like fopen().
- See above. PHP is a full-fledged programming language, if you've never programmed before this will probably be hard.
- See #1.
Hope this helps... _________________
 |
|
| Back to top |
|
 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|