[dokuwiki] Re: How to embed an external picture

Hi


> The plugin works fine so far - when doing the preview, I see the cartoon
> where it should be. As soon as I press "Save", the page is rendered anew
> and contains PHP source code instead of the text (and cartoon) I entered.

This is very strange and from looking at your code I have no idea why
that should happen.

> ///////////////////////////////////////////////////////////////////////////////////////////////////
> // GIF Util - (C) 2003 Yamasoft (S/C)
> // http://www.yamasoft.com
> // All Rights Reserved
> // This file can be frelly copied, distributed, modified, updated by
> anyone under the only
> // condition to leave the original address (Yamasoft,
> http://www.yamasoft.com) and this header.
> ///////////////////////////////////////////////////////////////////////////////////////////////////

Does this tell you anything? Do you recognize this header? Is there a
file on your server that contains that code?
You should try to figure this out first... there seems to be something
fishy going on.

When you resolved that mystery, here are some comments on your code.

1. Using regular expressions should make it much easier to grep the
wanted string from the HTML instead of using substr/strpos
2. don't rely on file, file_get_contents or similar functions to fetch
data via HTTP. URL opening is disabled on many hosters. Use the
HTTPClient library of DokuWiki instead. If you use SimplePie (see
below) it will do the downloading for you.
3. site scraping is a bad idea (and might be illegal). Userfriendly
provides an RSS feed that includes the image. Parsing that is much
easier and will not break when the site's layout changes. Hint: use
the SimplePie library shipped with DokuWiki to parse the feed.
4. you might need to disable caching for the page lower the cachetime
of your wiki to have a daily fresh image
5. pull the image through lib/exe/fetch.php to get image caching (use
the ml() function to construct the src)


Andi

-- 
splitbrain.org
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: