Jump to content

Archived

This topic is now archived and is closed to further replies.

bef1rst

Where write my loop in this php script ?

Recommended Posts

Hello,

I would like to use a loop in order to use different feed rss in this script but i don't know where i must put it.

[quote]<?
require('rss_fetch.inc');

include('../config.php');
require(mnminclude.'link.php');

$rss_feeds=array(
        array(
                'url'=>"http://feeds.feedburner.com/rss2.xml",
                'category'=>15,
                'author'=>15,
                'tags'=>"tags1"
        ),
);

echo "<ul>\n";
foreach ($rss_feeds as $feed ) {
$rss = fetch_rss($feed['url']);
echo "<li>Site: ", $rss->channel['title'], "<br>\n";
foreach ($rss->items as $item )
{

if ($i <= 10)
    {
        $item['author']=$feed['author'];
        $item['category']=$feed['category'];

        $title = $item[title];
        $desc= $item[description];

        echo "<ul>";
        echo "<li>Processing <a href=$url>$title</a></li>\n";
        rss_store($item);
        echo "<li>Finished Processing <a href=$url>$title</a></li><br><br/>\n\n";
        echo "</ul>";
    }
    $i++;

}
echo "</li>";
}
echo "</ul>";


function rss_store($item) {

        $linkres=new Link;

        $edit = false;
        $linkres->get(trim($item['link']));

        if(!$linkres->valid) {
                rss_error($item['link']);
                return;
        }

        if($linkres->duplicates($item['link']) > 0) {
                rss_error($item['url']);
                return;
        }
        $linkres->status='discard';
        $linkres->author=$item['author'];

        $linkres->title=$item['title'];
        $linkres->content=$item['description'];


        $linkres->id=0;
        $linkres->category=$item['category'];
        $linkres->randkey=rand(10000,10000000);
        $linkres->read();
        $linkres->status='queued';
        $linkres->store();
        return;
}

function rss_error($url){
        echo "Skipped $url <br/>\n";
}


?>[/quote]

This script works and i just would like to put different feed. I would like to create a table in my mysql database in order to write the different feed. I have already do this job.

Thanks for your answers.

Share this post


Link to post
Share on other sites
i didnt read all the script, but the following might work

$feed = "INPUT FROM FEILD"

include('inc_files/'.$feed/"'");

simply save your different feeds as seperate inc files.

you could also create an array, which could check the input, to that sent data could be simply 1, 2,3 ,4 5, 6 7 ,8 8 etc.

good luck

Share this post


Link to post
Share on other sites
Thanks for your answer. I will test as soon as possible.

I have another idea: I made a request in MYSQL who take the URL of the feed in a table of a database. It's better for the organisation of the feed because i can create an administrator acces etc.

I thnik that my request could be at the beginning of this part of the script:

[code]$query = "SELECT url FROM feed";
$result = mysql_query($query);

while ($val = mysql_fetch_array($result)) {
 
$rss_feeds=array(
        array(
                'url'=>"$url",
                'category'=>15,
                'author'=>15,
                'tags'=>"tags1"
        ),
);

} ?>[/code]



What do you think of that ? Thanks for your answers.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.