All pastes #2081870 Raw Edit

Stuff

public text v1 · immutable
#2081870 ·published 2011-09-21 16:31 UTC
rendered paste body
<?php
//load function library
require('include/editnews_functions.php');

//get config data
require('include/editnews_config.php');

//read news data
$newsdata = readDatabaseFile($newsfilename);

if (strpos($_SERVER['PHP_SELF'],"/include/")) die; //prevent include being accessed directly 
	
	$myFile = "rss.xml";
	$fh = fopen($myFile, 'w') or die("can't open file");
	
	fwrite($fh, '<?xml version="1.0" encoding="ISO-8859-1"?>
	<rss version="2.0">
	<channel>
	<title>Visual Identity Creative Ltd</title>
	<description>Visual Identity Creative Ltd</description>
	<link>http://www.visualidentity.co.uk</link>');
	
		for ($i = 0; $i<count($newsdata); $i++) {
	
	$titleprefix = "\n<item>\n<title>";
	$titlesuffix = "</title>";
	$title = htmlspecialchars($newsdata[$i]['news_title']);
	$titledata = $titleprefix.$title.$titlesuffix;
	fwrite($fh, $titledata);
	
	
	$descprefix = "\n<description>";
	$descsuffix = "</description>";
	$desc = stripslashes(strip_tags($newsdata[$i]['news_body'], ''));
	
	if ((strlen($desc) > 400) && (strlen($desc) > 1)) { 
	$whitespaceposition = strpos($desc," ",375); 
	$desc = substr($desc, 0, $whitespaceposition);
	$descend = "...";
	$desc = $desc.$descend;
	}
	
	$descdata = $descprefix.$desc.$descsuffix;
	fwrite($fh, $descdata);
	
	
	$linkprefix = "\n<link>http://www.visualidentity.co.uk/newsite/blog.php#";
	$linksuffix = "</link>\n</item>";
	$link = htmlspecialchars($newsdata[$i]['news_title']);
	$linkdata = $linkprefix.$link.$linksuffix;
	fwrite($fh, $linkdata);
	
	print_r($title);
		print_r($desc);
		print_r($link);	
}	
	fwrite($fh, '</channel>
	</rss>');
	
	fclose($fh);
	?>