rss.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. James Rose <[email protected]>
  21. */
  22. return; //disable
  23. include "root.php";
  24. require_once "resources/require.php";
  25. require_once "resources/check_auth.php";
  26. require_once "config.php";
  27. if (permission_exists('content_view')) {
  28. //access granted
  29. }
  30. else {
  31. echo "access denied";
  32. exit;
  33. }
  34. //add multi-lingual support
  35. $language = new text;
  36. $text = $language->get();
  37. //include module specific information
  38. if (strlen($mod_config_path)==0) {
  39. include "config.php";
  40. }
  41. else {
  42. //$mod_config_path = "/news"; //examples
  43. //$mod_config_path = "/app/news"; //examples
  44. include $mod_config_path.'/config.php';
  45. }
  46. $rss_css_url = 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"];
  47. $rss_css_url = str_replace ("rss.php", "rss.css", $rss_css_url);
  48. $content_type = $_GET["c"];
  49. //echo "contenttype $content_type";
  50. if (strlen($_GET["rss_category"]) > 0) {
  51. $rss_category = $_GET["rss_category"];
  52. }
  53. if (strlen($content_type) == 0) {
  54. $content_type = "rss"; //define default contenttype
  55. }
  56. if ($content_type == "html") {
  57. session_start();
  58. }
  59. //echo $rss_css_url;
  60. //exit;
  61. if ($content_type == "rss") {
  62. header('Content-Type: text/xml');
  63. echo '<?xml version="1.0" ?'.'>';
  64. echo '<?xml-stylesheet type="text/css" href="'.escape($rss_css_url).'" ?'.'>';
  65. //echo '<?xml-stylesheet type="text/css" href="http://'.$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"].'" ?'.'>';
  66. //echo "\n";
  67. echo "<rss version=\"2.0\">\n";
  68. echo "<channel>\n";
  69. echo "<title>$module_title ".$text['title-rss']."</title>\n";
  70. //echo "<link>http://www.xul.fr/</link>\n";
  71. echo "<description>".$text['description-rss']."</description>\n";
  72. echo "<language>en-US</language>\n";
  73. //echo "<copyright></copyright>\n";
  74. //echo "<image>\n";
  75. //echo " <url>http://www.xul.fr/xul-icon.gif</url>\n";
  76. //echo " <link>http://www.xul.fr/index.html</link>\n";
  77. //echo "</image>";
  78. }
  79. $sql = "";
  80. $sql .= "select * from v_rss ";
  81. $sql .= "where rss_category = '$rss_category' ";
  82. $sql .= "and length(rss_del_date) = 0 ";
  83. $sql .= "or rss_category = '$rss_category' ";
  84. $sql .= "and rss_del_date is null ";
  85. $sql .= "order by rss_uuid asc ";
  86. $prep_statement = $db->prepare(check_sql($sql));
  87. $prep_statement->execute();
  88. $last_cat = "";
  89. $count = 0;
  90. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  91. foreach ($result as &$row) {
  92. $rss_uuid = $row["rss_uuid"];
  93. $rss_title = $row["rss_title"];
  94. $rss_description = $row["rss_description"];
  95. $rss_link = $row["rss_link"];
  96. //$rss_description = $row[rss_sub_description];
  97. //$rss_description = str_replace ("\r\n", "<br>", $rss_description);
  98. //$rss_description = str_replace ("\n", "<br>", $rss_description);
  99. if ($content_type == "rss") {
  100. $rss_title = htmlentities($rss_title);
  101. $rss_description = htmlentities($rss_description);
  102. echo "<item>\n";
  103. echo "<title>".escape($rss_title)."</title>\n";
  104. echo "<description>".$rss_description."</description>\n";
  105. echo "<link>".escape($rss_link)."</link>\n";
  106. //echo "<pubDate>12 Mar 2007 19:38:06 GMT</pubDate>\n";
  107. //echo "<guid isPermaLink='true'>http://www.google.com/log/123</guid>\n";
  108. //echo "<comments>http://www.google.com/log/121#comments</comments>\n";
  109. //echo "<category>Web Design</category>";
  110. echo "</item>\n";
  111. echo "\n";
  112. }
  113. else {
  114. if (strlen($rss_link) > 0) {
  115. echo "<b><a href='$rss_link'>".escape($rss_title)."</a></b><br>\n";
  116. }
  117. else {
  118. echo "<b>".escape($rss_title)."</b><br>\n";
  119. }
  120. echo "".$rss_description."\n";
  121. echo "<br><br>";
  122. if ($rss_sub_show == 1) {
  123. //--- Begin Sub List -------------------------------------------------------
  124. echo "<br><br><br>";
  125. echo "<b>$rss_sub_title</b><br>";
  126. $sql = "";
  127. $sql .= "select * from v_rss_sub ";
  128. $sql .= "where rss_uuid = '$rss_uuid' ";
  129. $sql .= "and length(rss_sub_del_date) = 0 ";
  130. $sql .= "or rss_uuid = '$rss_uuid' ";
  131. $sql .= "and rss_sub_del_date is null ";
  132. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  133. $prep_statement_2 = $db->prepare($sql);
  134. $prep_statement_2->execute();
  135. $result2 = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  136. $result_count2 = count($result2);
  137. $c2 = 0;
  138. $row_style["0"] = "background-color: #F5F5DC;";
  139. $row_style["1"] = "background-color: #FFFFFF;";
  140. echo "<div align='left'>\n";
  141. //echo " <b>Notes</b>";
  142. echo "<table width='75%' border='1' cellpadding='1' cellspacing='1'>\n";
  143. //echo "<tr><td colspan='100%'><img src='/images/spacer.gif' width='100%' height='1' style='background-color: #BBBBBB;'></td></tr>";
  144. if ($result_count == 0) { //no results
  145. echo "<tr><td>&nbsp;</td></tr>";
  146. }
  147. else {
  148. echo "<tr><td colspan='100%'><img src='/images/spacer.gif' width='100%' height='1' style='background-color: #BBBBBB;'></td></tr>\n";
  149. foreach($result2 as $row2) {
  150. echo "<tr style='".$row_style[$c]."'>\n";
  151. //echo "<td valign='top'>".$rss_uuid."</td>";
  152. //echo "<td valign='top'>&nbsp;<b>".$row2[rss_sub_title]."</b>&nbsp;</td>";
  153. //echo "<td valign='top'>&nbsp;".$row2[rss_sub_link]."&nbsp;</td>";
  154. echo "<td valign='top' width='200'>";
  155. echo " <b>".escape($row2[rss_sub_title])."</b>";
  156. echo "</td>";
  157. echo "<td valign='top'>".escape($row2[rss_sub_add_date])."</td>";
  158. //echo "<td valign='top'>".escape($row2[rss_sub_optional_1])."</td>";
  159. //echo "<td valign='top'>".escape($row2[rss_sub_optional_2])."</td>";
  160. //echo "<td valign='top'>".escape($row2[rss_sub_optional_3])."</td>";
  161. //echo "<td valign='top'>".escape($row2[rss_sub_optional_4])."</td>";
  162. //echo "<td valign='top'>".escape($row2[rss_sub_optional_5])."</td>";
  163. //echo "<td valign='top'>".escape($row2[rss_sub_add_user])."</td>";
  164. echo "<td valign='top' align='right'>";
  165. echo " &nbsp;";
  166. //echo " <input type='button' class='btn' name='' onclick=\"window.location='rsssubupdate.php?rss_uuid=".escape($rss_uuid)."&rss_sub_uuid=".escape($row2[rss_sub_uuid])."'\" value='Update'>";
  167. echo " &nbsp; \n";
  168. //echo " <a href='rsssubupdate.php?rss_uuid=".escape($rss_uuid)."&rss_sub_uuid=".escape($row2[rss_sub_uuid])."'>Update</a>&nbsp;";
  169. echo "</td>";
  170. $rss_sub_description = $row2[rss_sub_description];
  171. //$rss_sub_description = str_replace ("\r\n", "<br>", $rss_sub_description);
  172. //$rss_sub_description = str_replace ("\n", "<br>", $rss_sub_description);
  173. echo "</tr>";
  174. echo "<tr style='".$row_style[$c]."'>\n";
  175. echo "<td valign='top' width='300' colspan='3'>";
  176. echo "".$rss_sub_description."&nbsp;";
  177. echo "</td>";
  178. echo "</tr>";
  179. echo "<tr><td colspan='100%'><img src='/images/spacer.gif' width='100%' height='1' style='background-color: #BBBBBB;'></td></tr>\n";
  180. if ($c2==0) { $c2=1; } else { $c2=0; }
  181. } //end foreach
  182. unset($sql, $result, $row_count);
  183. echo "</table>\n";
  184. echo "</div>\n";
  185. echo " <br><br>";
  186. echo " </td>\n";
  187. echo "</tr>\n";
  188. } //end if results
  189. echo "</table>\n";
  190. //--- End Sub List -------------------------------------------------------
  191. }
  192. }
  193. //echo "<item>\n";
  194. //echo "<title> ".escape($row["favname"])."</title>\n";
  195. //echo "<description>".escape($row["favdesc"])."</description>\n";
  196. //echo "<link>".escape($row["favurl"])."</link>\n";
  197. //echo "</item>\n";
  198. //$last_cat = $row["favcat"];
  199. $count++;
  200. }
  201. if ($content_type == "rss") {
  202. echo "</channel>\n";
  203. echo "\n";
  204. echo "</rss>\n";
  205. }
  206. ?>