Our mission is to manage and conserve the natural and cultural resources of Texas and to provide hunting, fishing and outdoor recreation opportunities for the use and enjoyment of present and future generations.
http://www.tpwd.state.tx.us
$v) {
// $ttr[$v] = utf8_encode($k);
//}
# generate RSS
echo makeRSS();
function encodeAsUTF($text) {
//global $ttr;
//$text = strtr($text, $ttr);
$text = html_entity_decode($text);
return $text;
}
function makeRSS() {
global $now;
include_once(‘/home/Connections/connect_to_public_db.inc’);
$connection = connect_to_public_db_mysqli();
$sql = ‘SELECT slug, lede, nrid, pub_date, id FROM news_releases ‘;
$sql.= ‘WHERE pub_date < ''.$now.''';
$sql.= 'ORDER BY nrid DESC '; // pub_date DESC,
$sql.= 'LIMIT 15';
$result = mysqli_query($connection, $sql) or die('Query failed (makeRSS): ' . mysqli_error($connection));
while ($row = mysqli_fetch_assoc($result)) {
$rss.='’ . “n”;
$rss.=’
$rss.=substr($row[‘pub_date’], 5, 5).’ | ‘;
$rss.=encodeAsUTF(
str_replace(‘&’,’and’,str_replace(‘ & ‘,’and’,str_replace(‘“’,'”‘,str_replace(‘”’,'”‘,str_replace(‘‘’,”’,str_replace(‘’’,”’,str_replace(‘–’,’-‘,str_replace(‘&mdash’,’–‘,str_replace(‘—’,’–‘,strip_tags($row[‘slug’])))))))))));
$rss.=’
$rss.=”;
# for some unknown reason/s the & char causes XML parsers to choke (even though they were converted from HTML entities to begin with),
# consequently, it’s been replaced with ‘and’
//$rss.=html_entity_decode(str_replace(‘—’,’–‘,strip_tags($row[‘lede’])), ENT_QUOTES, ‘UTF-8’);
$rss.=encodeAsUTF(str_replace(‘&’, ‘and’, str_replace(‘ & ‘,’and’,str_replace(‘“’,'”‘,str_replace(‘”’,'”‘,str_replace(‘‘’,”’,str_replace(‘’’,”’,str_replace(‘–’,’-‘,str_replace(‘&mdash’,’–‘,str_replace(‘—’,’–‘,strip_tags($row[‘lede’])))))))))));
# uncomment to see sql statement
//$rss.=str_replace(‘&’,’and’,encodeAsUTF(str_replace(‘‘’,”’,str_replace(‘’’,”’,str_replace(‘–’,’-‘,str_replace(‘—’,’–‘,strip_tags($sql)))))));
$rss.=” . “n”;
$rss.=”;
$rss.=’http://www.tpwd.state.tx.us/newsmedia/releases/?req=’.$row[‘nrid’];
$rss.=” . “n”;
$rss.=”;
$rss.=$row[‘nrid’];
$rss.=” . “n”;
$rss.=” . “n”;
}
return $rss;
}
echo $rss;
?>
Original Source: http://tpwd.texas.gov/feeds/newsreleases/rss.xml


Leave a Reply