[pmwiki-users] Keeping recipes up to date

Patrick R. Michaud pmichaud at pobox.com
Thu Feb 15 10:16:45 CST 2007


On Thu, Feb 15, 2007 at 04:01:34PM -0000, marc wrote:
> Patrick R. Michaud said...
> > On Thu, Feb 15, 2007 at 03:08:20PM -0000, marc wrote:
> > > Ah well, another customised recipe for my collection :-| Thank heavens 
> > > for Subversion.
> > 
> > Well, I think we can avoid the need for customized recipes.
> > ...
> > Then a site could supply a custom setting for $UrlFopen that
> > does the equivalent of fopen with allow_url_fopen enabled.
> > Then any sites that have allow_url_fopen disabled can just
> > include_once('cookbook/urlfopen.php') to load a custom 
> > function for url-based file retrievals.
> 
> Looks okay to me.

Looking a little further at curl, it looks as though we'd
be better off having a function that returns the entire file,
as opposed to a file handle.  (In other words, I'm not sure
how to get curl to act like a filehandle.)

So, perhaps something like...?  (I've never used curl in PHP before.)

    function curl_get_contents($url) {
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      $str = curl_exec($ch);
      curl_close($ch);
      return $str;
    }
    SDV($UrlFileFunction, 'curl_get_contents');

Pm



More information about the pmwiki-users mailing list