<commit_before><?php

$tikiId =  "Tiki CMS/Groupware";
$rsslang = $tikilib->get_preference("rssfeed_language","en-us");
$rsseditor = $tikilib->get_preference("rssfeed_editor","");
$rsspublisher = $tikilib->get_preference("rssfeed_publisher","");
$rsswebmaster = $tikilib->get_preference("rssfeed_webmaster","");
$rsscreator = $tikilib->get_preference("rssfeed_creator","");

$rsscategorydomain = ""; // TODO: make configurable, currently unused
$rsscategory = ""; // TODO: make configurable, currently unused

$rss_use_css = false; // default is: do not use css
if (isset($_REQUEST["css"])) {
	$rss_use_css = true;
}

// date format for RDF 2.0
if (($rss_version > 1) && ($rss_version < 5)) {
$datenow = htmlspecialchars(gmdate('D, d M Y H:i:s T', date("U")));
} else $datenow = htmlspecialchars($tikilib->iso_8601(date("U")));

$url = $_SERVER["REQUEST_URI"];
$url = substr($url, 0, strpos($url."?", "?")); // strip all parameters from url
$urlarray = parse_url($url);

$pagename = substr($urlarray["path"], strrpos($urlarray["path"], '/') + 1);

$home = htmlspecialchars(httpPrefix().str_replace($pagename, $tikiIndex, $urlarray["path"]));
$img = htmlspecialchars(httpPrefix().str_replace($pagename, "img/tiki.jpg", $urlarray["path"]));

$read = httpPrefix().str_replace($pagename, "$readrepl", $urlarray["path"]);

$url = htmlspecialchars(httpPrefix().$url);
$title = htmlspecialchars($title);
$desc = htmlspecialchars($desc);
$url = htmlspecialchars($url);
$css = htmlspecialchars(httpPrefix().str_replace($pagename, "lib/rss/rss-style.css", $urlarray["path"]));

if ($rss_version >= 5)
{
	require ("tiki-atom.php");
} else {

	// --- output starts here 
	header("content-type: text/xml");
	
	print '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
	print '<!--  RSS generated by TikiWiki CMS (tikiwiki.org) on '.$datenow.' -->'."\n";
	
	if ($rss_use_css) {
		print '<?xml-stylesheet href="'.$css.'" type="text/css"?>'."\n";
	}
	
	if (!isset($output)) $output="";
	
	if ($output == "")
	{
	  if ($rss_version > 1) {
	  	$output .= '<rss version="2.0">'."\n";
	  	$output .= "<channel>\n";
	  } else {
	  	$output .= '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">'."\n";
	  	$output .= '<channel rdf:about="'.$url.'">'."\n";
	  }
	
	  $output .= "<title>".$title."</title>\n";
	  $output .= "<link>".$home."</link>\n";
	  $output .= "<description>".$desc."</description>\n";
	
	  if ($rss_version < 2) {
	  	$output .= "<dc:language>".$rsslang."</dc:language>\n";
	  	$output .= "<dc:date>".$datenow."</dc:date>\n";
	    if ($rsspublisher <> "") $output .= "<dc:publisher>".$rsspublisher."</dc:publisher>\n";
	    if ($rsscreator <> "") $output .= "<dc:creator>".$rsscreator."</dc:creator>\n";
	  }
	  else
	  {
	  	$output .= "<language>".$rsslang."</language>\n";
	  	$output .= "<docs>http://backend.userland.com/rss</docs>\n";
	  	$output .= "<pubDate>".$datenow."</pubDate>\n";
	  	$output .= "<generator>".$tikiId."</generator>\n";
	  	// $output .= "<category domain=\"".$rsscategorydomain."\">".$rsscategory."</category>\n";
	    if ($rsseditor <> "")  $output .= "<managingEditor>".$rsseditor."</managingEditor>\n";
	    if ($rsswebmaster <> "")  $output .= "<webMaster>".$rsswebmaster."</webMaster>\n";
	  }
	
	  $output .= "\n";
	
	  if ($rss_version < 2) {
	  	$output .= "<items>\n";
	  	$output .= "<rdf:Seq>\n";
	  	// LOOP collecting last changes (index)
	  	foreach ($changes["data"] as $chg) {
	  		$resource=$read.$chg["$id"];
	  		if ($id == "blogId") { $resource .= "&postId=".$chg["postId"]; }
	  	// forums have threads, add those to the url:
	  		if ($id == "forumId") { $resource .= "&comments_parentId=".$chg["threadId"]; }
	  		$resource = htmlspecialchars($resource);		
	  		$output .= '        <rdf:li rdf:resource="'.$resource.'" />'."\n";
	  	}
	  	$output .= "</rdf:Seq>\n";
	  	$output .= "</items>\n";
	  	if ($rss_version < 2) {
	  		$output .= '<image rdf:resource="'.$img.'" />'."\n";
	  	}
	  	$output .= "</channel>\n\n";
	  }
	  
	  if ($rss_version < 2) {
	  	$output .= '<image rdf:about="'.$img.'">'."\n";
	  }
	  else
	  {
	  	$output .= '<image>'."\n";
	  }
	  $output .= "<title>".$title."</title>\n";
	  $output .= "<link>".$home."</link>\n";
	  $output .= "<url>".$img."</url>\n";
	  $output .= "</image>\n\n";
	
	  // LOOP collecting last changes to image galleries
	  foreach ($changes["data"] as $chg) {
	
	    $date = htmlspecialchars(gmdate('D, d M Y H:i:s T', $chg["$dateId"]));
		  if ($rss_version < 2) {
				$date = htmlspecialchars($tikilib->iso_8601($chg["$dateId"]));
		  }
	  	$about = $read.$chg["$id"];
	  	// blogs have posts, add those to the url:
	  	if ($id == "blogId") { $about .= "&postId=".$chg["postId"]; }		
	  	// forums have threads, add those to the url:
	  	if ($id == "forumId") { $about .= "&comments_parentId=".$chg["threadId"]; }
	    $about = htmlspecialchars($about);
	
			$title = $chg["$titleId"]; 
		  if ($titleId == "title") { 
		    // blog posts have titles, use them 
		    $title = $title; 
  		} else if ($titleId == "created") { 
    		// blog post titles are dates, so make them readable 
    		$title = gmdate('D, d M Y H:i:s T', $title); 
		  }
	    if (($title == "") && array_key_exists("created", $chg)) {
    		$title = gmdate('D, d M Y H:i:s T', $chg["created"]); 
	    }
  
	  	// titles for blogs are dates, so make them readable:
	  	if ($titleId == "created") { $title = gmdate('D, d M Y H:i:s T', $title); }		
	    $title = htmlspecialchars($title);
	
			$description = $chg["$descId"];
			if ($description <> "") $description = htmlspecialchars($tikilib->parse_data($description));
	
	  	if ($rss_version < 2) {
	  		$output .= '<item rdf:about="'.$about.'">'."\n";
	  	} else {
	  		$output .= "<item>\n";
	  	}
	  	$output .= '  <title>'.$title.'</title>'."\n";
	  	$output .= '  <link>'.$about.'</link>'."\n";<commit_msg>Blog feeds show correct 'title' for posts now.<commit_after><?php

$tikiId =  "Tiki CMS/Groupware";
$rsslang = $tikilib->get_preference("rssfeed_language","en-us");
$rsseditor = $tikilib->get_preference("rssfeed_editor","");
$rsspublisher = $tikilib->get_preference("rssfeed_publisher","");
$rsswebmaster = $tikilib->get_preference("rssfeed_webmaster","");
$rsscreator = $tikilib->get_preference("rssfeed_creator","");

$rsscategorydomain = ""; // TODO: make configurable, currently unused
$rsscategory = ""; // TODO: make configurable, currently unused

$rss_use_css = false; // default is: do not use css
if (isset($_REQUEST["css"])) {
	$rss_use_css = true;
}

// date format for RDF 2.0
if (($rss_version > 1) && ($rss_version < 5)) {
$datenow = htmlspecialchars(gmdate('D, d M Y H:i:s T', date("U")));
} else $datenow = htmlspecialchars($tikilib->iso_8601(date("U")));

$url = $_SERVER["REQUEST_URI"];
$url = substr($url, 0, strpos($url."?", "?")); // strip all parameters from url
$urlarray = parse_url($url);

$pagename = substr($urlarray["path"], strrpos($urlarray["path"], '/') + 1);

$home = htmlspecialchars(httpPrefix().str_replace($pagename, $tikiIndex, $urlarray["path"]));
$img = htmlspecialchars(httpPrefix().str_replace($pagename, "img/tiki.jpg", $urlarray["path"]));

$read = httpPrefix().str_replace($pagename, "$readrepl", $urlarray["path"]);

$url = htmlspecialchars(httpPrefix().$url);
$title = htmlspecialchars($title);
$desc = htmlspecialchars($desc);
$url = htmlspecialchars($url);
$css = htmlspecialchars(httpPrefix().str_replace($pagename, "lib/rss/rss-style.css", $urlarray["path"]));

if ($rss_version >= 5)
{
	require ("tiki-atom.php");
} else {

	// --- output starts here 
	header("content-type: text/xml");
	
	print '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
	print '<!--  RSS generated by TikiWiki CMS (tikiwiki.org) on '.$datenow.' -->'."\n";
	
	if ($rss_use_css) {
		print '<?xml-stylesheet href="'.$css.'" type="text/css"?>'."\n";
	}
	
	if (!isset($output)) $output="";
	
	if ($output == "")
	{
	  if ($rss_version > 1) {
	  	$output .= '<rss version="2.0">'."\n";
	  	$output .= "<channel>\n";
	  } else {
	  	$output .= '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">'."\n";
	  	$output .= '<channel rdf:about="'.$url.'">'."\n";
	  }
	
	  $output .= "<title>".$title."</title>\n";
	  $output .= "<link>".$home."</link>\n";
	  $output .= "<description>".$desc."</description>\n";
	
	  if ($rss_version < 2) {
	  	$output .= "<dc:language>".$rsslang."</dc:language>\n";
	  	$output .= "<dc:date>".$datenow."</dc:date>\n";
	    if ($rsspublisher <> "") $output .= "<dc:publisher>".$rsspublisher."</dc:publisher>\n";
	    if ($rsscreator <> "") $output .= "<dc:creator>".$rsscreator."</dc:creator>\n";
	  }
	  else
	  {
	  	$output .= "<language>".$rsslang."</language>\n";
	  	$output .= "<docs>http://backend.userland.com/rss</docs>\n";
	  	$output .= "<pubDate>".$datenow."</pubDate>\n";
	  	$output .= "<generator>".$tikiId."</generator>\n";
	  	// $output .= "<category domain=\"".$rsscategorydomain."\">".$rsscategory."</category>\n";
	    if ($rsseditor <> "")  $output .= "<managingEditor>".$rsseditor."</managingEditor>\n";
	    if ($rsswebmaster <> "")  $output .= "<webMaster>".$rsswebmaster."</webMaster>\n";
	  }
	
	  $output .= "\n";
	
	  if ($rss_version < 2) {
	  	$output .= "<items>\n";
	  	$output .= "<rdf:Seq>\n";
	  	// LOOP collecting last changes (index)
	  	foreach ($changes["data"] as $chg) {
	  		$resource=$read.$chg["$id"];
	  		if ($id == "blogId") { $resource .= "&postId=".$chg["postId"]; }
	  	// forums have threads, add those to the url:
	  		if ($id == "forumId") { $resource .= "&comments_parentId=".$chg["threadId"]; }
	  		$resource = htmlspecialchars($resource);		
	  		$output .= '        <rdf:li rdf:resource="'.$resource.'" />'."\n";
	  	}
	  	$output .= "</rdf:Seq>\n";
	  	$output .= "</items>\n";
	  	if ($rss_version < 2) {
	  		$output .= '<image rdf:resource="'.$img.'" />'."\n";
	  	}
	  	$output .= "</channel>\n\n";
	  }
	  
	  if ($rss_version < 2) {
	  	$output .= '<image rdf:about="'.$img.'">'."\n";
	  }
	  else
	  {
	  	$output .= '<image>'."\n";
	  }
	  $output .= "<title>".$title."</title>\n";
	  $output .= "<link>".$home."</link>\n";
	  $output .= "<url>".$img."</url>\n";
	  $output .= "</image>\n\n";
	
	  // LOOP collecting last changes to image galleries
	  foreach ($changes["data"] as $chg) {
	
	    $date = htmlspecialchars(gmdate('D, d M Y H:i:s T', $chg["$dateId"]));
		  if ($rss_version < 2) {
				$date = htmlspecialchars($tikilib->iso_8601($chg["$dateId"]));
		  }
	  	$about = $read.$chg["$id"];
	  	// blogs have posts, add those to the url:
	  	if ($id == "blogId") { $about .= "&postId=".$chg["postId"]; }		
	  	// forums have threads, add those to the url:
	  	if ($id == "forumId") { $about .= "&comments_parentId=".$chg["threadId"]; }
	    $about = htmlspecialchars($about);
	
			$title = $chg["$titleId"]; 
		  if ($id == "blogId") { 
		    // blog posts have titles, use them 
		    $title = $chg["title"]; 
  		} else if ($titleId == "created") { 
    		// blog post titles are dates, so make them readable 
    		$title = gmdate('D, d M Y H:i:s T', $title); 
		  }
	    if (($title == "") && array_key_exists("created", $chg)) {
    		$title = gmdate('D, d M Y H:i:s T', $chg["created"]); 
	    }
  
	  	// titles for blogs are dates, so make them readable:
	  	if ($titleId == "created") { $title = gmdate('D, d M Y H:i:s T', $title); }		
	    $title = htmlspecialchars($title);
	
			$description = $chg["$descId"];
			if ($description <> "") $description = htmlspecialchars($tikilib->parse_data($description));
	
	  	if ($rss_version < 2) {
	  		$output .= '<item rdf:about="'.$about.'">'."\n";
	  	} else {
	  		$output .= "<item>\n";
	  	}
	  	$output .= '  <title>'.$title.'</title>'."\n";
	  	$output .= '  <link>'.$about.'</link>'."\n";
{'fraction_non_alphanumeric': 0.25179555704025386, 'fraction_numerical': 0.007516285284783698, 'mean_word_length': 3.4766355140186915, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 2, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4387473', 'n_tokens_mistral': 4738, 'n_tokens_neox': 4454, 'n_words': 826}