SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please assist - need small script converted from fopen to cURL

    My host just switched off fopen and my php skills are lousy at best.

    PLEASE help!

    PHP Code:
    $file WEATHER_FILE '.' $zip '.xml'
      if(!
    file_exists($file) || filemtime($file) < time() - 3600) { 
          
    $this->data = @file_get_contents('http://xml.mydomain.com/rss?p=' $zip '&u=' $units['temp']); 
          
    $fp = @fopen($file'w'); 
          @
    fwrite($fp$this->data); 
          @
    fclose($fd); 
      } 
      else 
    $this->data = @file_get_contents($file); 
      if(
    strlen($this->data) <= 0) return; 

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $file WEATHER_FILE '.' $zip '.xml'
        if(!
    file_exists($file) || filemtime($file) < time() - 3600) { 
            
    $ch curl_init('http://xml.mydomain.com/rss?p=' $zip '&u=' $units['temp']); 
            
    $fp = @fopen($file'w');
            
    curl_setopt($chCURLOPT_FILE$fp);
            
    curl_setopt($chCURLOPT_HEADER0);

            
    curl_exec($ch);
            
    curl_close($ch);

          
            @
    fwrite($fp$this->data);
            
    curl_close($ch);
            @
    fclose($fd); 
        } else {
            
    $this->data = @file_get_contents($file); 
            if(
    strlen($this->data) <= 0) return; 
    Your provider has turned off a wrapper of some sort, I do not have the curl library installed, but form the documentation this should work.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    Tacoma, WA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some hosts turn off fopen() because of security reasons. I have DreamHost, and that feature's turned off. can be a bit annoying sometimes but cURL replacement works fine.
    TheNewsFeeds.com - Feed your RSS Needs
    IPThing.com - Make longggggg URLs short!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •