Location: PHPKode > scripts > AskPeople-Free PHP survey application > AskPeople_2_2_2/rssreport.php
<?php

session_start();

require_once('includes/config.inc.php');
require_once('includes/functions.inc.php');

$configpath = "surveys/config_" . $_REQUEST['sid'] . ".php";	
include_once($configpath); // load survey settings

$rss_template = "<?xml version=\"1.0\" ?>
<rss version=\"2.0\">
<channel>
	<title>AskPeople Survey Responses</title>
	<description>Live project status (requires login to view results)</description>
	<link>[[PROJ-LINK]]</link>
    <language>en-gb</language>
    <pubDate>[[NOW]]</pubDate>
    <lastBuildDate>[[NOW]]</lastBuildDate>
    <generator>AskPeople 2.2</generator>
	<item>
		<title>[[TITLE]]</title>
		<description>[[COUNT]] responses received as of [[NOW]].</description>
		<link>[[ITEM-LINK]]</link>
	</item>
</channel>
</rss>";

if ($_REQUEST['sid']) {
	$_SESSION['admin_sid'] = $_REQUEST['sid'];
}

if ($surveysettings['makeRSS'] == "TRUE") {
	
	$now = date("r");
	
	$directory = (substr(dirname($_SERVER['PHP_SELF']),-1) == "/") ? dirname($_SERVER['PHP_SELF']) : dirname($_SERVER['PHP_SELF']) . "/";
	$projlink = $protocol . $_SERVER['HTTP_HOST'] . $directory . "survey.php?sid=".$_SESSION['admin_sid'];
	$reportlink = $protocol . $_SERVER['HTTP_HOST'] . $directory . "respondentreport.php?sid=".$_SESSION['admin_sid'];
	
	$datafile = "surveys/data_" . $_SESSION['admin_sid'] . ".dat";
	$rawdata = loadFile($datafile);
	$rawdata_array = explode("\n",$rawdata);
	$counter = 0;
	for ($r=0;$r<count($rawdata_array);$r++) {
		if (strlen($rawdata_array[$r])>0 && $rawdata_array[$r] != "Array") { // some data for this row
			$counter++;
		}
	}
		
	$qid = "surveys/quest_" . $_SESSION['admin_sid'] . ".xml";
	$polldata = file_get_contents($qid);
	preg_match_all("/<title>(.*?)<\/title>/si",$polldata,$title);
	$title = $title[1][0] . ": ". $counter . " responses";

	$rss_template = str_replace("[[PROJ-LINK]]",$projlink,$rss_template);
	$rss_template = str_replace("[[ITEM-LINK]]",$reportlink,$rss_template);
	$rss_template = str_replace("[[NOW]]",$now,$rss_template);
	$rss_template = str_replace("[[TITLE]]",$title,$rss_template);
	$rss_template = str_replace("[[COUNT]]",$counter,$rss_template);

	if ($_REQUEST['file'] == "TRUE") { // for output to a static file
		$rss_filename = "rss/rss_".$_SESSION['admin_sid'] . ".xml";
		$saved = saveFile($rss_filename,$rss_template);
	} else {
		echo ($rss_template);
	}

}

?>
Return current item: AskPeople-Free PHP survey application