Title: Hesk RSS Feed
Version: 1.0
Author: Aaron Lee by write up from www.seopher.com
Demo: NA
Download: NA
Website: NA
Short description: After following an easy write up
I was able to establish RSS feeds for Hesk.
Original Source of write up:
http://www.seopher.com/how-to-write-rss-generator.php
*************************************/
Code: Select all
<?php
// Insert here the the title of your feed
$rss_title= "Hesk RSS Feed";
// Insert your site, in the format site.com
$rss_site= "site.com/hesk" ;
// Insert the description of your website
$rss_description= "Hesk Help Desk RSS Feed";
// Applicable language of the feed. For spanish, change to "es"
$rss_language="en";
// Address of the logo file. It can be called whatever you want it to be!
$rss_logo="http://".$rss_site."/img/feed-icon32x32.png";
// the feed's author email
$emailadmin="me@here.gov";
// set the file's content type and character set
// this must be called before any output
header("Content-Type: text/xml;charset=iso-8859-1");
// Open the database
mysql_connect("localhost","hesk","password");
@mysql_select_db("databasename") or die("Unable to select DB");
// Select all the records from the Articles/Blog table - whatever you're using it for
$query = "select * from hesk_tickets ORDER BY ID DESC" ;
$result = mysql_query($query) or die("Query failed") ;
echo
'<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<title>'.$rss_title.'</title>
<link>http://'.$rss_site.'</link>
<description>'.$rss_description.'</description>
<language>en-en</language>
<image>
<url>'.$rss_logo.'</url>
<title>'.$rss_site.'</title>
<link>http://'.$rss_site.'</link>
</image>';
for($i=0;$i<20; $i++) //will loop through 20 times to generate 20 RSS items
{
$photo_name = 'http://site.com/img/feed-icon32x32.png'; //where-ever a photo for this article could be found
$subject = mysql_result($result,$i,'subject'); //subject line for the RSS item
// Pass the record URL_product to the variable $url_product. It also
// has to include the relative path, like in: "path/product1.htm"
$ticketid = mysql_result($result,$i,'trackid');
$url_product = '/ticket.php?track='; //define the URL of where people could read this blog/article entry
// Define a description of the item
$description = mysql_result($result,$i,'message'); //easiest way is by grabbing the content
// Clean the description
$description = str_replace ("&","",htmlspecialchars(strip_tags($description)));
//This is a teaser of your article, basically what RSS readers will show the user in their inbox.
//This is how you entice users to come over and read the full article
//the easiest way is to just take the first few hundred characters of the content (description)
$short_description = substr($description,0,500) . "...";
//so you can define when it was published
$timestamp = mysql_result($result,$i,'dt');
//cleans the timestamp into an RSS friendly format
$pubdate = date("r", strtotime($timestamp));
//outputs the RSS item
echo
'
<item>
<title>'.$subject.'</title>
<link>http://'.$rss_site.$url_product.$ticketid.'</link>
<guid isPermaLink="true">http://'.$rss_site.$url_product.$ticketid.'</guid>
<description>'.$short_description.'</description>
<pubDate>'.$pubdate.'</pubDate>
</item>
';
} //end of the for-loop
mysql_close(); //close the DB
echo //close the XML file
' </channel>
</rss>';
?>