How to display rss images with magpierss

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

How to display rss images with magpierss

Post 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
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: How to display rss images with magpierss

Post 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.
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

Re: How to display rss images with magpierss

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to display rss images with magpierss

Post by Benjamin »

:arrow: Moved to PHP - Code
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: How to display rss images with magpierss

Post 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.
Post Reply