Page 1 of 1

How to display rss images with magpierss

Posted: Tue May 12, 2009 8:53 am
by lauthiamkok
How can I display the RSS images with magpierss? I have looked around online but cant find any resources about displaying RSS images... does magpierss has this function to display images? If it does not, any other solutions?

Here is my code, but the $image obviously doesnt work.

Code: Select all

<?php
        require_once 'magpierss/rss_fetch.inc';
        
        $url = 'http://globaltolerance.com/?feed=rss2';
        $rss = fetch_rss($url);
        $items = array_slice($rss->items, $startRow, 3);
 
        foreach ($items as $item) {
            $title = $item['title'];
            $url   = $item['link'];
            $image   = $item['image'];
            $date = $item['date_timestamp'];
            $desc = $item['description'];
            
            if (strlen($title) >= 25)
                {
                $title = substr($title,0,24)."...";
                }
            
            if (strlen($desc) >= 25)
                {
                $desc = substr($desc,0,24)."...";
                }
        ?> 
            <!--item-->
            <div class="item">
                
                <!--item_left-->
                <div class="item_left">
                    <a href="#"><?php echo $image;?></a>                
                </div>
                <!--item_left-->
                
                <!--item_right-->
                <div class="item_right">
                    <div class="title"><a href="<?php echo $url;?>"><?php echo $title;?></a></div>
                    <div class="desicription"><?php echo $desc;?></div>
                    <div class="date"><?php echo date("l, F jS, Y", $date);?></div>
                </div>
                <!--item_right-->
            </div>
            <!--item-->
            
            <?php
            }
            ?>
Many thanks,
Lau

Re: How to display rss images with magpierss

Posted: Tue May 12, 2009 3:20 pm
by kaisellgren
The question you are asking is not related to security. Since this is a security forum, I will tell you that your script is vulnerable to XSS.

Re: How to display rss images with magpierss

Posted: Tue May 12, 2009 5:16 pm
by lauthiamkok
kaisellgren wrote:The question you are asking is not related to security. Since this is a security forum, I will tell you that your script is vulnerable to XSS.
sorry to post it on the wrong area but it worth knowing XSS. thanks.

Re: How to display rss images with magpierss

Posted: Tue May 12, 2009 5:31 pm
by Benjamin
:arrow: Moved to PHP - Code

Re: How to display rss images with magpierss

Posted: Tue May 12, 2009 9:43 pm
by divito
image and textinput
$rss->image and $rss-textinput are associative arrays including name-value pairs for anything found between the respective parent tags.
As found on the Magpie website.