leemason Posted September 8, 2011 Share Posted September 8, 2011 this is a little script i created to display all knowledgebase articles in an RSS2 feed. Really simple script, just upload the file to the root of your WHMCS install. (knowledgebaserss.php) you could also setup a rewrite rule so the url looks like an rss feed, add this to you .htaccess file after the RewriteEngine On line: RewriteRule ^knowledgebase.rss /knowledgebaserss.php below is the code, simply copy it into a file called knowledgebaserss.php, or download the attached zip file, unzip it and upload it. <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); function k_rss_systemurl(){ $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {return $data['value'];} }//function function k_rss_systemname(){ $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='CompanyName'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {return $data['value'];} }//function //check for seo friendly urls $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {if($data['value'] == 'on'){$seourls = true;}} echo '<title>'.k_rss_systemname().' Knowledgebase Feed</title>'; echo '<description>'.k_rss_systemname().' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.k_rss_systemurl().'</link>'; $result = mysql_query("SELECT * FROM tblknowledgebase"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; echo '<link>'.k_rss_systemurl().'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; if($seourls){ echo '<link>'.k_rss_systemurl().'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html</link>'."\n"; }else{ echo '<link>'.k_rss_systemurl().'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> knowledgebaserss.php.zip 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted September 30, 2011 Author Share Posted September 30, 2011 I have an updated version of this script know which condenses the database calls to on (for speed), cleans up the code a bit as well. see below, or download the new file attached to this post: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<title>'.$values['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$values['SystemURL'].'</link>'; $result = mysql_query("SELECT * FROM tblknowledgebase"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; if($seourls){ echo '<link>'.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> knowledgebaserss.php.zip 0 Quote Link to comment Share on other sites More sharing options...
MikeP Posted January 16, 2012 Share Posted January 16, 2012 Would this work for other parts of WHMCS? Like I want an RSS feed on the network status page so I can pull issues from that page into my forum. Thanks. 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted January 16, 2012 Author Share Posted January 16, 2012 Would this work for other parts of WHMCS? Like I want an RSS feed on the network status page so I can pull issues from that page into my forum. Thanks. the script as it stands doesnt cater for that, but i could quite easily alter it to replicate the functionality you require. pm me if you would like to discuss it. 0 Quote Link to comment Share on other sites More sharing options...
RFEHosting Posted January 19, 2012 Share Posted January 19, 2012 Is this updated and working for WHMCS v5? 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted January 19, 2012 Author Share Posted January 19, 2012 Is this updated and working for WHMCS v5? yes the script works with v5. no updates needed (im running v5 and it still works on my site.) 0 Quote Link to comment Share on other sites More sharing options...
Jbro Posted January 19, 2012 Share Posted January 19, 2012 Thanks I need the same for net work status Please 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted January 20, 2012 Author Share Posted January 20, 2012 for those of you who have asked for it for the network issues. it is already part of the whmcs install "networkissuesrss.php". i found it today when i was about to code a version for someone. 0 Quote Link to comment Share on other sites More sharing options...
bobbravo2 Posted March 16, 2012 Share Posted March 16, 2012 I've updated it to include the option of filtering by category id Just go to your this file's URL and add the catid from WHMCS: ie - knowledgebaserss.php?catid=1 <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<title>'.$values['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$values['SystemURL'].'</link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".(int)$_REQUEST['catid'];; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase"; } $result = mysql_query($query); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; if($seourls){ echo '<link>'.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> 0 Quote Link to comment Share on other sites More sharing options...
innoview Posted July 19, 2012 Share Posted July 19, 2012 Nice script but i noticed that the links are opening in new window. Any chance of disabling that? Note: I am calling the script into a joomla module. 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted July 19, 2012 Author Share Posted July 19, 2012 i think that will be a browser preference on your end. the rss output just outputs a <link> tag for the link, its how your browser has decided to open it, not the script. 0 Quote Link to comment Share on other sites More sharing options...
abysse Posted March 3, 2013 Share Posted March 3, 2013 Hello, It might an after war question, but actually i tried to check the validity of the feed and here is what I have Sorry This feed does not validate. line 10, column 0: item contains more than one link (22 occurrences) [help] <link>domain.com/knowledgebase.php?action=display ... In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations. line 11, column 0: item should contain a guid element (22 occurrences) [help] </item> line 146, column 0: Missing atom:link with rel="self" [help] </channel> Here is my genuine feed : <item> <title>My Title</title> <description> description of the KB article </description> <link> http://mydomain.com/knowledgebase.php?action=displayarticle&id=14 </link> <link> http://mydomain.com/knowledgebase.php?action=displayarticle&id=14 </link> </item> Also, it seems that the order of the feed isn't in the right order. I mean it should be the newest article first rather than the old one, am i mistaken? 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted March 3, 2013 Author Share Posted March 3, 2013 Hello, It might an after war question, but actually i tried to check the validity of the feed and here is what I have Here is my genuine feed : Also, it seems that the order of the feed isn't in the right order. I mean it should be the newest article first rather than the old one, am i mistaken? here is an updated version with the link issue fixed, improved sql query functions, and uses the global config array instead of calling the db again for domain info. it also uses a builtin function to set the right url string for titles: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); global $CONFIG; echo '<title>'.$CONFIG['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$CONFIG['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$CONFIG['SystemURL'].'</link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".(int)$_REQUEST['catid']." ORDER BY `tblknowledgebase`.`id` DESC"; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase ORDER BY `id` DESC"; } $result = full_query($query); while ($data = mysql_fetch_assoc($result)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; if($seourls){ echo '<link>'.$CONFIG['SystemURL'].'knowledgebase/'.$data['id'].'/'.getmodrewritefriendlystring($data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$CONFIG['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> 0 Quote Link to comment Share on other sites More sharing options...
abysse Posted March 13, 2013 Share Posted March 13, 2013 Wow, You actually answered the very same day I posted! How amazing it is! I apologize i didn't check the thread earlier to thank you accordingly. Well basically, it is working wonderfully well, here is the Feed Validator Output : Congratulations! This is a valid RSS feed. Recommendations This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations. line 8, column 0: item should contain a guid element (24 occurrences) [help] </item> line 134, column 0: Missing atom:link with rel="self" [help] </channel> For the use, i'll have i believe the errors aren't that critical as I intend to parse the feed here and there and use it for FB uptades. For the users that are going to use this script and happen to have the "Header already sent error", make sure you remove the extra space when copying / pasting at the end and the beginning of the script. (before opening <? and after ?>) Dealing the first error, if you really want to be perfect, here is my RSS output : <?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0"> <channel> <title>Company Name Knowledgebase Feed</title><description>Company name Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description><link>http://www.mydomain.Com</link><item> <title>My RSS TITLE</title> <description>This is the KB article ever! (written by me ofc)</description> <link>http://www.mydomain.com/whmcs/knowledgebase.php?action=displayarticle&id=24</link> </item> The </item> is my 8th line which i believe shouldn't be there. [EDIT] Best Of Luck with your upgrade of WHMCS 5.2.1 was about to take the plunge too, but not now anymore. 0 Quote Link to comment Share on other sites More sharing options...
chelioss Posted June 23, 2013 Share Posted June 23, 2013 I have an updated version of this script know which condenses the database calls to on (for speed), cleans up the code a bit as well. see below, or download the new file attached to this post: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<title>'.$values['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$values['SystemURL'].'</link>'; $result = mysql_query("SELECT * FROM tblknowledgebase"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; if($seourls){ echo '<link>'.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> If you have a solution to overcome the Turkish character and tell me how you'd love failure. 0 Quote Link to comment Share on other sites More sharing options...
aj.kerley Posted August 18, 2013 Share Posted August 18, 2013 I upgraded to the latest php code provided here and I am getting the following error: "error on line 38 at column 78: EntityRef: expecting ';'" Below is the php I am using: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); global $CONFIG; echo '<title>'.$CONFIG['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$CONFIG['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$CONFIG['SystemURL'].'</link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".(int)$_REQUEST['catid']." ORDER BY `tblknowledgebase`.`id` DESC"; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase ORDER BY `id` DESC"; } $result = full_query($query); while ($data = mysql_fetch_assoc($result)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; if($seourls){ echo '<link>'.$CONFIG['SystemURL'].'knowledgebase/'.$data['id'].'/'.getmodrewritefriendlystring($data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$CONFIG['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; ?> 0 Quote Link to comment Share on other sites More sharing options...
neo2shyalien Posted October 3, 2013 Share Posted October 3, 2013 Update of code to use Atom like announcements RSS also is bit safer avoid markup errors"error on line 38 at column 78: EntityRef: expecting ';'" longer description - I use it to sync some data UTF8 encoding to be more multi lang friendly. http://pastebin.com/78Wuc9nm 0 Quote Link to comment Share on other sites More sharing options...
JonTheWong Posted March 10, 2015 Share Posted March 10, 2015 Would it be possible to include the time the article was posted? It would help with products like hootsuite. 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted October 4, 2015 Share Posted October 4, 2015 Update of code to use Atom like announcements RSS also is bit safer avoid markup errors"error on line 38 at column 78: EntityRef: expecting ';'"longer description - I use it to sync some data UTF8 encoding to be more multi lang friendly. http://pastebin.com/78Wuc9nm hello please update this code for whmcs 6.x thanks 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted November 11, 2015 Share Posted November 11, 2015 helloplease update this code for whmcs 6.x thanks please help me 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 12, 2015 Share Posted November 12, 2015 try the following for v6.1.1 <?php header("Content-Type: application/xml; charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?'.'>'."\n"; echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("init.php"); mysql_set_charset('utf8'); $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<atom:link href="'.$values['SystemURL'].'knowledgebaserss.php" rel="self" type="application/rss+xml" />'; echo '<title><=!=[=C=D=A=T=A=['.$values['CompanyName'].' Knowledgebase Feed]=]=></title>'; echo '<description><=!=[=C=D=A=T=A=['.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.]=]=></description>'; echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].']=]=></link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".$_REQUEST['catid'];; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase"; } $result = mysql_query($query); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title><=!=[=C=D=A=T=A=['.$data['title'].']=]=></title>'."\n"; echo '<description><=!=[=C=D=A=T=A=['.$data['article'].']=]=></description>'."\n"; echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].']=]=></link>'."\n"; if($seourls){ echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html<]=]=>/link>'."\n"; }else{ echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].']=]=></link>'."\n"; }//if echo '</item>'."\n"; }//while ?> </channel> </rss> 0 Quote Link to comment Share on other sites More sharing options...
impossible Posted December 3, 2015 Share Posted December 3, 2015 try the following for v6.1.1 <?php header("Content-Type: application/xml; charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?'.'>'."\n"; echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); //define("FORCESSL",true); # Uncomment to force the page to use https:// require("init.php"); mysql_set_charset('utf8'); $result = mysql_query("SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<atom:link href="'.$values['SystemURL'].'knowledgebaserss.php" rel="self" type="application/rss+xml" />'; echo '<title><=!=[=C=D=A=T=A=['.$values['CompanyName'].' Knowledgebase Feed]=]=></title>'; echo '<description><=!=[=C=D=A=T=A=['.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.]=]=></description>'; echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].']=]=></link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".$_REQUEST['catid'];; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase"; } $result = mysql_query($query); while ($data = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<item>'."\n"; echo '<title><=!=[=C=D=A=T=A=['.$data['title'].']=]=></title>'."\n"; echo '<description><=!=[=C=D=A=T=A=['.$data['article'].']=]=></description>'."\n"; echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].']=]=></link>'."\n"; if($seourls){ echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html<]=]=>/link>'."\n"; }else{ echo '<link><=!=[=C=D=A=T=A=['.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].']=]=></link>'."\n"; }//if echo '</item>'."\n"; }//while ?> </channel> </rss> hello not working for me , please check it . thanks 0 Quote Link to comment Share on other sites More sharing options...
tuga Posted November 30, 2020 Share Posted November 30, 2020 (edited) Here's an updated version with mysqli functions and & replaced with & for sitemap validation : <?php header("Content-Type: application/xml; charset=ISO-8859-1"); echo '<?xml version="1.0" encoding="ISO-8859-1"?'.'>'."\n"; echo '<rss version="2.0">'."\n"; echo '<channel>'."\n"; define("CLIENTAREA",true); define("FORCESSL",true); # Uncomment to force the page to use https:// #require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $con = mysqli_connect("xxx","xxx","xxx","xxx"); $result = mysqli_query($con, "SELECT * FROM tblconfiguration WHERE setting='SystemURL' OR setting='CompanyName' OR setting='SEOFriendlyUrls'"); while ($data = mysqli_fetch_array($result, MYSQLI_ASSOC)) {$values[$data['setting']] = $data['value'];} echo '<title>'.$values['CompanyName'].' Knowledgebase Feed</title>'; echo '<description>'.$values['CompanyName'].' Knowledgebase Feed created by WHMCS Knowledgebase RSS addon module.</description>'; echo '<link>'.$values['SystemURL'].'</link>'; if (isset($_REQUEST['catid'])) { //Show this category $query = "SELECT * FROM `tblknowledgebase`,`tblknowledgebaselinks` WHERE `tblknowledgebaselinks`.`articleid` = `tblknowledgebase`.`id` AND `tblknowledgebaselinks`.`categoryid`=".(int)$_REQUEST['catid'];; } else { //Show all categories $query = "SELECT * FROM tblknowledgebase"; } $result = mysqli_query($con, $query); while ($data = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<item>'."\n"; echo '<title>'.$data['title'].'</title>'."\n"; echo '<description>'.strip_tags(substr($data['article'],0,140)).'</description>'."\n"; echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; $seourls = 0; if($seourls){ echo '<link>'.$values['SystemURL'].'knowledgebase/'.$data['id'].'/'.str_replace(' ','-',$data['title']).'.html</link>'."\n"; }else{ echo '<link>'.$values['SystemURL'].'knowledgebase.php?action=displayarticle&id='.$data['id'].'</link>'."\n"; }//if echo '</item>'."\n"; }//while echo '</channel>'."\n"; echo '</rss>'."\n"; mysqli_close($con); ?> Edited November 30, 2020 by tuga 0 Quote Link to comment Share on other sites More sharing options...
tuga Posted November 30, 2020 Share Posted November 30, 2020 (edited) On 12/3/2015 at 8:23 AM, impossible said: hello not working for me , please check it . thanks For Brian's version to work, you've to change =!=[=C=D=A=T=A= to ![CDATA and ]=]=> to ]]> WRONG: echo '<title><=!=[=C=D=A=T=A=['.$data['title'].']=]=></title>'."\n"; CORRECT: echo '<title><![CDATA['.$data['title'].']]></title>'."\n"; Edited November 30, 2020 by tuga 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.