<?php
header('Content-Type: text/xml');
include_once 'common.php';
include_once 'db.php';
$base_url = 'http://www.mesotheliomalawyer4u.com';
$interval_hrs = 6;
$transformations = array('&'=>'&amp;');
echo get_contents(50, False);

function get_contents($num_rows, $inc_content) {
	global $base_url;
	global $wpdb;
	global $interval_hrs;
	global $transformations;
	ini_set('display_errors', $display_errors);
	// Connecting, selecting database

	$contents = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
	$contents .= "	<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
	$contents .= "		<channel>\n";
	$contents .= "			<title>Mesothelioma Lawyer and Legal resources</title>\n";
	$contents .= "			<description>The latest Mesothelioma and asbestos related legal and medical information</description>\n";
	$contents .= "			<link>http://www.mesotheliomalawyer4u.com</link>\n";
	$contents .= "			<atom:link href=\"$base_url/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n";



	$query = "SELECT p.ID, p.PAGE, p.DESCRIPTION, p.TITLE, DATE_FORMAT(p.PINGBACK_UPDATES, '%Y-%m-%dT%H:%i:%S') DATE_ENTERED FROM page p WHERE p.PINGBACK_UPDATES IS NOT NULL AND (p.PINGBACK_UPDATES > SUBDATE(NOW(), INTERVAL $interval_hrs HOUR))";
	if ($num_rows) {
		$query .= " LIMIT $num_rows ";
	}
	$res = $wpdb->get_results($query, ARRAY_A);
	if (is_array($res) && count($res) > 0) {
		foreach($res as $line) {
			$link = strtr($base_url . $line['PAGE'], $transformations);
			$contents .= "			<item>\n";
			$contents .= "				<title>" . htmlspecialchars($line["TITLE"]) . "</title>\n";
			$contents .= "				<description>" . htmlspecialchars($line["DESCRIPTION"]) . "</description>\n";
			$contents .= "				<link>" . $link . "</link>\n";
			$contents .= "				<dc:date>" . $line['DATE_ENTERED'] . "+01:00</dc:date>\n";
			$contents .= "				<dc:publisher>Mesothelioma Lawyer 4U.com</dc:publisher>\n";
			$contents .= "				<dc:creator>Mesothelioma Lawyer 4U.com</dc:creator>\n";
			$contents .= "				<guid>" . $link . "</guid>\n";
			if ($inc_content) {
				$contents .= "				<content:encoded>" . $line['DESCRIPTION'] . $GLOBALS["article_footnote_encoded"] . "</content:encoded>\n";
			}
			$contents .= "			</item>\n";
		}
	}
	$contents .= "		</channel>\n";
	$contents .= "	</rss>\n";

	return $contents;
}



?>