PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/PO/custom_rss.php

https://github.com/tlezotte/ePOS
PHP | 122 lines | 69 code | 17 blank | 36 comment | 6 complexity | aec777b95100965bace9b3a2c94ec43e MD5 | raw file
  1. <?php
  2. /**
  3. * Company.com
  4. *
  5. * rss.php generates RSS feed.
  6. *
  7. * @version 1.5
  8. * @link http://www.Company.com
  9. * @author Thomas LeZotte (tom@lezotte.net)
  10. *
  11. * @package PO
  12. * @filesource
  13. *
  14. * PHP Debug
  15. * @link http://phpdebug.sourceforge.net/
  16. */
  17. /**
  18. * - Set debug mode
  19. */
  20. $debug_page = false;
  21. include_once('debug/header.php');
  22. /* ------------------ START DATABASE CONNECTIONS ----------------------- */
  23. require_once('../Connections/connDB.php');
  24. //http://www.yourdomain.com/go/Request/PO/custom_rss.php?e=MDEzNTI%3D
  25. /* --- Custom RSS feed by employee --- */
  26. if (array_key_exists('a', $_GET) AND array_key_exists('e', $_GET)) {
  27. $search_query = "p." . $_GET['a'] . "='" . base64_decode(urldecode($_GET['e'])) . "'";
  28. } else if (array_key_exists('e', $_GET)) {
  29. $search_query = "p.req='" . base64_decode(urldecode($_GET['e'])) . "'";
  30. }
  31. /* --- Custom RSS feed by plant --- */
  32. if (array_key_exists('p', $_GET)) {
  33. $search_query = "p.plant='" . $_GET['p'] . "'";
  34. }
  35. /* --- Custom RSS feed by department --- */
  36. if (array_key_exists('d', $_GET)) {
  37. $search_query = "p.department='" . $_GET['d'] . "'";
  38. }
  39. /* ----- Getting career postings from Intranet ----- */
  40. $sql = <<< SQL
  41. SELECT p.id AS _id, p.purpose, p.hot, e.fst, e.lst, e.email, l.name AS _plant, d.name AS _dept, v.BTNAME AS _vendor, DATE_FORMAT(FROM_UNIXTIME( p.reqDate),'%a, %d %b %Y %T') AS postdate
  42. FROM PO p
  43. LEFT JOIN Standards.Employees e ON e.eid=p.req
  44. LEFT JOIN Standards.Plants l ON l.id=p.plant
  45. LEFT JOIN Standards.Department d ON d.id=p.department
  46. LEFT JOIN Standards.Vendor v ON v.BTVEND=p.sup
  47. LEFT JOIN Authorization a ON a.type_id=p.id
  48. WHERE $search_query AND p.status='N'
  49. ORDER BY p.id DESC
  50. SQL;
  51. $query = $dbh->prepare($sql);
  52. /* ------------------ END DATABASE CONNECTIONS ----------------------- */
  53. /* ------------------ START VARIABLES ----------------------- */
  54. /* Generate at RFC 2822 formatted date */
  55. $pubDate = date("r");
  56. /* ------------------ END VARIABLES ----------------------- */
  57. /* ------------------------------------------ CREATE RSS 2.0 FILE ----------------------------------------- */
  58. header('Content-Type: text/xml');
  59. header('Pragma: public');
  60. header('Cache-control: private');
  61. header('Expires: -1');
  62. $rss = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  63. $rss .= "<rss version=\"2.0\">\n";
  64. $rss .= " <channel>\n";
  65. $rss .= " <title>Purchase Requisition System - Custom</title>\n";
  66. $rss .= " <link>http://www.yourdomain.com/go/Request/index.php</link>\n";
  67. $rss .= " <description>Custom Purchase Requisition System RSS Feed</description>\n";
  68. $rss .= " <pubDate>$pubDate</pubDate>\n";
  69. $rss .= " <copyright>2007 Your Company, LLC.</copyright>\n";
  70. $rss .= " <webMaster>tlezotte@Company.com</webMaster>\n";
  71. $rss .= " <image>\n";
  72. $rss .= " <title>Your Company, LLC.</title>\n";
  73. $rss .= " <url>http://www.Company.com/images/CompanyRSS.gif</url>\n";
  74. $rss .= " <width>144</width>\n";
  75. $rss .= " <height>48</height>\n";
  76. $rss .= " <link>http://www.Company.com</link>\n";
  77. $rss .= " </image>\n";
  78. $sth = $dbh->execute($query);
  79. while($sth->fetchInto($POST)) {
  80. $hot = ($POST['hot'] == 'yes') ? Hot : Normal;
  81. $rss .= " <item>\n";
  82. $rss .= " <title><![CDATA[(" . $POST['_id'] . ") " . html_entity_decode($POST['purpose']) . "]]></title>\n";
  83. $rss .= " <link><![CDATA[http://www.yourdomain.com/go/Request/PO/detail.php?id=" . $POST['_id'] . "]]></link>\n";
  84. $rss .= " <author>" . $POST['email'] . " (" . ucwords(strtolower($POST['fst'])) . " " . ucwords(strtolower($POST['lst'])) .")</author>\n";
  85. $rss .= " <description><![CDATA[" . html_entity_decode($POST['purpose']) . "]]></description>\n";
  86. $rss .= " <category>" . ucwords(strtolower($POST['_plant'])) . "</category>\n";
  87. $rss .= " <category>" . ucwords(strtolower($POST['_dept'])) . "</category>\n";
  88. $rss .= " <category><![CDATA[" . html_entity_decode(ucwords(strtolower($POST['_vendor']))) . "]]></category>\n";
  89. $rss .= " <category>" . $hot . "</category>\n";
  90. $rss .= " <pubDate>" . $POST['postdate'] . " -0400</pubDate>\n";
  91. $rss .= " </item>\n";
  92. }
  93. $rss .= " </channel>\n";
  94. $rss .= "</rss>\n";
  95. /* ------------------------------------------ CREATE RSS 2.0 FILE ----------------------------------------- */
  96. print $rss;
  97. /**
  98. * - Display Debug Information
  99. */
  100. include_once('debug/footer.php');
  101. /**
  102. * - Disconnect from database
  103. */
  104. $dbh_int->disconnect();
  105. ?>