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