stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors

RSS Output






Stargeek's PHP Scripts

Please select a category:

View All Scripts
xmlsql
blogseo
statisticsmisc
 

Search Stargeek's PHP Scripts Database


Want to get this PHP script installed on your site?

Get this script installed by the author.

RSS Output RSS Output
The RSS output file that runs stargeek's feed. Cleans input to generate valid RSS. Optional category searches.

<?php
if ($HTTP_GET_VARS['limit'])
{
    
$limit = $HTTP_GET_VARS['limit'];
}
else
{
    
$limit = 20;
}

if (
$HTTP_GET_VARS['category'])
{
    
$action = "category";
    
$category = $HTTP_GET_VARS['category'];
}
elseif (
$HTTP_GET_VARS['search'])
{
    
$action = "search";
    
$search = $HTTP_GET_VARS['search'];
}
else
{
    
$action = "all";
}

//conection code $linkID!!!
switch($action)
{
    case
"category":
        
$categories = array('xml', 'code', 'design', 'news', 'standards');
        if (!
in_array($category, $categories))
        {
            
$query = "select link, headline, description from headlines order by id desc limit $limit";
        }
        else
        {
            
$query = "select link, headline, description from headlines where category = '$category' order by id desc limit $limit";
        }

        
$result = mysql_query($query, $linkID);
        while (
$line = mysql_fetch_assoc($result))
        {
            
$return[] = $line;
        }
    break;

    case
"search":
        include(
"http://zan.terrabox.com/search.php?term=$search&xml=true");
        
$file = file("this");
        foreach (
$file as $line)
        {
            
$this .= $line;
        }
        
$results2 = unserialize($this);        
        for (
$x=0; $x<$limit; $x++)
        {
             
$return[] = $results2[$x];
        }
    break;

    case
"all":
        
$query = "select link, headline, description from headlines order by id desc limit $limit";
        
$result = mysql_query($query, $linkID);

        while (
$line = mysql_fetch_assoc($result))
        {
            
$return[] = $line;
        }
    break;    
}
$now = date("D, d M Y H:i:s T");

$output = "<?xml version=\"1.0\"?>
            <rss version=\"0.92\">
                <channel>
                    <title>stargeek studios</title>
                    <link>http://www.stargeek.com/</link>
                    <description>Web Design/Development News.</description>
                    <language>en-us</language>
                    <pubDate>$now</pubDate>
                    <lastBuildDate>$now</lastBuildDate>
                    <docs>http://backend.userland.com/rss092</docs>
                    <managingEditor>zan@stargeek.com</managingEditor>
                    <webMaster>zan@stargeek.com</webMaster>
            "
;
            
foreach (
$return as $line)
{
    
$output .= "
                <item rdf:about=\"http://www.stargeek.com/link.php?link="
.htmlentities($line[link])."\">
                    <title>"
.htmlentities($line['headline'])."</title>
                    <link>http://www.stargeek.com/link.php?link="
.htmlentities($line[link])."</link>
                    <description>"
.htmlentities(strip_tags($line[description]))."</description>
                </item>"
;
}
$output .= "</channel></rss>";
echo
$output;
?>