The Geek Forum

  • May 16, 2024, 11:07:34 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Due to the prolific nature of these forums, poster aggression is advised.

*

Recent Forum Posts

Shout Box

Members
Stats
  • Total Posts: 129632
  • Total Topics: 7188
  • Online Today: 168
  • Online Ever: 1013
  • (January 12, 2023, 01:18:11 AM)

Author Topic: PHP & Remote Files  (Read 1784 times)

Nosferatu

  • Troll
  • *
  • Coolio Points: +25/-3
  • Offline Offline
  • Gender: Male
  • Posts: 293
  • Fire doesn't clense, it blackens
    • View Profile
    • MySpace (I don't even know why...)
PHP & Remote Files
« on: March 22, 2007, 09:22:28 PM »

Having problems with my localhost crashing every time PHP tries to access a remote file.

Stuff like using copy() with a remote URL.  If it comes up against anything like that, I get a "memory could not be read" error and Apache crashes.

allow_url_fopen is active.  Turning it off stops the crashing, but then I get the PHP "you can't do that" message.

I'm feeling this probably has more to do with Apache than PHP, any thoughts?
Logged

"My God, it's full of stars!"

milifist

  • Troll
  • *
  • Coolio Points: +36/-1
  • Offline Offline
  • Posts: 233
  • Beam me up!
    • View Profile
    • HaXor Central
Re: PHP & Remote Files
« Reply #1 on: March 22, 2007, 10:10:42 PM »

Not really enough information.

Does fopen work at all? What wrapper are you using?

open_basedir?
safe_mode?

And most importantly, are you sure the file you're trying to open exists at the url specified?
Logged

Nosferatu

  • Troll
  • *
  • Coolio Points: +25/-3
  • Offline Offline
  • Gender: Male
  • Posts: 293
  • Fire doesn't clense, it blackens
    • View Profile
    • MySpace (I don't even know why...)
Re: PHP & Remote Files
« Reply #2 on: March 23, 2007, 12:51:56 AM »

fopen() works fine with local files, safe_mode is off, open_basedir is undefined.

For testing purposes, I usually use files I know exist =P
(Though I suspect that if this were the problem, it would produce an error, and not crash the server?)

No wrapper, it's just the bare code for testing at the moment, wanted to try to isolate the problem with nothing getting in the way.

Code: [Select]
<?
$url=$_POST["URL"];

print "<FORM METHOD=POST><INPUT TYPE=TEXT NAME=URL><INPUT TYPE=SUBMIT></FORM>";

if($url != FALSE){
$dest=getcwd()."\\".basename($url);
print "<B>Origin:</B> ".$url."<BR>";
print "<B>Destination:</B> ".$dest."<BR>";
if(copy($url, $dest)){
print "Copy complete";
}else{
print "Copy failed";
}
}
?>

This script works fine when the final If statement is removed.
Logged

"My God, it's full of stars!"

milifist

  • Troll
  • *
  • Coolio Points: +36/-1
  • Offline Offline
  • Posts: 233
  • Beam me up!
    • View Profile
    • HaXor Central
Re: PHP & Remote Files
« Reply #3 on: March 23, 2007, 08:38:45 AM »

Try changing:

$dest=getcwd()."\\".basename($url);


To:

$dest=getcwd()."/".basename($url);
Logged

Nosferatu

  • Troll
  • *
  • Coolio Points: +25/-3
  • Offline Offline
  • Gender: Male
  • Posts: 293
  • Fire doesn't clense, it blackens
    • View Profile
    • MySpace (I don't even know why...)
Re: PHP & Remote Files
« Reply #4 on: March 24, 2007, 05:41:14 PM »

That's what I had before, it pumped out something like "C:\www\test/file.ext"

As far as I'm aware, it isn't a syntax error though, it's just that either the server, or PHP is throwing a fit every time a remote file is accessed, it does it with any command using a remote file.

Anyway, since I've had to reinstall XP and the server is dead for the moment, it's not gonna bother me, I'll get back to it later, who knows, the reinstall might give it a kick up the arse. =P

Thanks for the help though, 'preciated.
Logged

"My God, it's full of stars!"