ravi_030 Posted August 17, 2013 Share Posted August 17, 2013 Dear talents i am try to generate xml page with rss feed here is code sample but it cannot generate show default page include "init.php"; if(!isset($feed)){ $title = "Generate RSS Feed Code - Rss Generator"; $desc = ""; $sscript = ""; include "header.php"; check_site_onoff(); $r = query("SELECT * FROM {$prefix}category"); $arr = Array(); while($cat = fetch($r)) { $arr []= "<option value=$cat[cat_id]>$cat[cat_name]</option>"; } $arr = implode("\n",$arr); $rss_temp = " <form name=rfx id=rfx style='margin:0'> <table width=92% align=center> <tr valign=top> <td> <b>What are RSS Feeds?</b><br><br> RSS is a format for syndicating news feeds using XML. By using our RSS Feeds, you can display our articles and content directly on you site, our content will be published on your website. Our articles / content is updated daily, you can keep your content up tp date by usign our RSS feeds. <br><br><b>Select Feed options</b><br>please select different combination of options to get your rss feed code.<br><br> <b>Articles' Category</b> : <select name=cat_id id=cat_id style='font-size:10;'>$arr</select><br> <b>Number of articles to fetch</b> : <input type=text class=txt name=n id=n value=all size=4> <i>type <u>all</u> to fetch all articles, otherwise enter number</i><br> <b>Number of characters per article</b> : <input type=text class=txt name=nc id=nc value=all size=4> <i>type <u>all</u> to fetch full articles, otherwise enter number</i><br> <br><input type=button class=btn value='Get RSS-Feed URL' onclick=\"javascript: rfx.url.value='$root_path/rss.php?feed&c='+rfx.cat_id.value+'&n='+rfx.n.value+'&nc='+rfx.nc.value; jscode.value='<script language="JavaScript1.2" type="text/javascript" src="$root_path/rss2html.php?url='+escape(url.value)+'&js"></script>'; phpcode.value='<?\\n\\treadfile( "$root_path/rss2html.php?url='+escape(url.value)+'");\\n?>'; \" ><br><br> <b>RSS-Feed URL</b> :<br> <input type=text size=60 name=url id=url><br><br> <b>Embedable JavaScript</b> : <br>You can embed this code directly into your webpage, it will use your css styles while publishing.<br><br> <textarea cols=51 rows=5 name=jscode id=jscode></textarea><br> <INPUT class=btn onclick=javascript:jscode.focus();jscode.select(); type=button value='Select code'>   Use <b>Ctrl+C</b> to copy select text and <b>Ctrl+V</b> to paste. <br><br><b>Equvilant PHP Code to fetch read</b> : <br> Create a new file with notepad, and paste the following code into it, it will display the updated content, you can use your custom css styles.<br><br> <textarea cols=51 rows=6 name=phpcode></textarea><br> <INPUT class=btn onclick=javascript:phpcode.focus();phpcode.select(); type=button value='Select code'>    Use <b>Ctrl+C</b> to copy select text and <b>Ctrl+V</b> to paste. <br><br> If you are having any problems, please <a href=./contact.php>contact us</a>. <br><br> </td> </tr> </table> </form> "; /* ------------------------------------------------------ | Intializing all left templates | | | ------------------------------------------------------ */ $left_main_categories = get_cats(); $temp = template("./templates/left_more_options"); eval("\$left_more_options = \"$temp\";"); $temp = template("./templates/left_newsletter"); eval("\$left_newsletter = \"$temp\";"); /* ------------------------------------------------------ | Intializing all right templates | | | ------------------------------------------------------ */ $right_random_article = get_random_art(); $right_statistics = get_stats(); /* ------------------------------------------------------ | Intializing all center templates | | | ------------------------------------------------------ */ $temp = template("./templates/top_site_search"); eval("\$top_site_search = \"$temp\";"); $left="$left_main_categories<br>$left_more_options<br>$left_newsletter<br>"; $center = "$top_site_search $rss_temp"; $right = "$right_random_article<br>$right_statistics<br>"; $temp = template("./templates/center_main"); eval("\$center_main = \"$temp\";"); echo $center_main; $temp = template("./templates/footer"); eval("\$footer = \"$temp\";"); echo $footer; @mysql_close(); } else { if(isset($_GET['feed'])) { $r = query("SELECT * FROM {$prefix}category WHERE cat_id=$_GET[c]"); $cat = fetch($r); header("Content-type:application/xml"); echo "<?xml version=\"1.0\">\n"; echo "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"> <channel> <title>$root_path</title> <link>$root_path</link> <language>en</language> <description>"._html($cat['cat_name'])."</description> "; $limit = $_GET['n']=='all' ? '' : " LIMIT $_GET[n] "; $r = query("SELECT * FROM {$prefix}articles WHERE art_cat_id=$_GET[c] ORDER BY art_date DESC $limit") or die("Invalid RSS URL"); while($art = fetch($r)) { $ac_name = _html($art['art_title']); $art['art_title'] = _html($art['art_title']); $art['art_short_desc'] = $_GET['nc']=='all' ? $art['art_short_desc'] : substr($art['art_short_desc'],0,intval("$_GET[nc]")); $art['art_short_desc'] = _html($art['art_short_desc']); $date = date("F d, Y",intval($art['art_date'])); echo " <item> <title>$art[art_title]</title> <guid>".($settings['set_seo_onoff']=='on' ? _html("$root_path/article/".plaintext($ac_name)."-$art[art_id]-1.html") : _html("$root_path/articles.php?art_id=$art[art_id]&start=1") )."</guid> <link>".($settings['set_seo_onoff']=='on' ? _html("$root_path/article/".plaintext($ac_name)."-$art[art_id]-1.html") : _html("$root_path/articles.php?art_id=$art[art_id]&start=1") )."</link> <description>$art[art_short_desc]</description> <pubDate>$date</pubDate> </item> "; } echo "</channel>\n</rss>\n</xml>"; die(); } } @mysql_close(); ?> functions.phpinit.php Here i attach function & init php file regards & thanks ra Quote Link to comment https://forums.phpfreaks.com/topic/281273-rss-generate-self-page/ 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.