<commit_before><?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-image_galleries_rss.php,v 1.12 2003-08-21 00:51:20 redflo Exp $

// Copyright (c) 2002-2003, <NAME>, <NAME>, <NAME>, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

  require_once('tiki-setup.php');
  require_once('lib/tikilib.php'); # httpScheme()
  require_once('lib/imagegals/imagegallib.php');

  if($rss_image_galleries != 'y') {
   die;
  }

  // This check should be done before checking individual permissions
  if($tiki_p_view_image_gallery != 'y') {
    $smarty->assign('msg',tra("Permission denied you can not view this section"));
    $smarty->display("styles/$style_base/error.tpl");
    die;  
  }

  header("content-type: text/xml");
  $foo = parse_url($_SERVER["REQUEST_URI"]);
  $foo1=str_replace("tiki-image_galleries_rss.php",$tikiIndex,$foo["path"]);
  $foo2=str_replace("tiki-image_galleries_rss.php","img/tiki.jpg",$foo["path"]);
  $foo3=str_replace("tiki-image_galleries_rss","tiki-browse_image",$foo["path"]);
  $foo4=str_replace("tiki-image_galleries_rss.php","lib/rss/rss-style.css",$foo["path"]);

  $home = httpPrefix().$foo1;
  $img = httpPrefix().$foo2;
  $read = httpPrefix().$foo3;
  $css = httpPrefix().$foo4;
  
  $title = $tikilib->get_preference("title","Tiki RSS feed for image galleries");
  $title = "Tiki RSS feed for image galleries";
  $desc = "Last images uploaded to the image galleries.";
  $now = date("U");
  $changes = $imagegallib->list_images(0,$max_rss_image_galleries,'created_desc', '');

print '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
print '<?xml-stylesheet href="' . $css . '" type="text/css"?>' . "\n";

?>

<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/">
	<channel rdf:about = "<?php echo $home; ?>">
		<title><?php

		echo $title;

		?>

		</title>

		<link>
			<?php

			echo $home;

			?>

		</link>

		<description>
			<?php

			echo $desc;

			?>

		</description>

		<image rdf:about = "<?php echo $img; ?>"> <title><?php

		echo $title;

		?>

		</title>

		<link>
			<?php

			echo $home

			?>

		</link> </image>

		<items>
			<rdf:Seq>
				<?php

			// LOOP collecting last changes to image galleries (index)
			foreach ($changes["data"] as $chg) {
				print ('        <rdf:li resource="' . $read . '?imageId=' . $chg["imageId"] . '" />' . "\n");
			}

			?>

			</rdf:Seq>
		</items>
	</channel>

	<?php

	// LOOP collecting last changes to image galleries
	foreach ($changes["data"] as $chg) {
		print ('<item rdf:about="' . $read . '?imageId=' . $chg["imageId"] . '">' . "\n");

		print ('<title>' . htmlspecialchars($chg["name"]). '</title>' . "\n");
		print ('<link>' . $read . '?imageId=' . $chg["imageId"] . '</link>' . "\n");
		$data = $tikilib->date_format($tikilib->get_short_datetime_format(), $chg["created"]);
		print ('<description>' . htmlspecialchars($chg["description"]). '</description>' . "\n");
		print ('</item>' . "\n\n");
	}

	?>

</rdf:RDF><commit_msg>rss image galleries feed with rss 1.0+2.0+css support<commit_after><?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-image_galleries_rss.php,v 1.13 2003-10-09 21:44:27 ohertel Exp $

// Copyright (c) 2002-2003, <NAME>, <NAME>, <NAME>, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

require_once ('tiki-setup.php');
require_once ('lib/tikilib.php');
require_once('lib/imagegals/imagegallib.php');

// object specific things:
if ($rss_image_galleries != 'y') {
	$smarty -> assign('msg', tra("This feature is disabled"));
	$smarty -> display("styles/$style_base/error.tpl");
	die; // TODO: output of rss file with message: rss disabled
}

if($tiki_p_view_image_gallery != 'y') {
  $smarty->assign('msg',tra("Permission denied you cannot view this section"));
  $smarty->display("styles/$style_base/error.tpl");
  die; // TODO: output of rss file with message: permission denied
}

$title = "Tiki RSS feed for image galleries";
$now = date("U");
$desc = "Last images uploaded to the image galleries.";
$changes = $imagegallib->list_images(0,$max_rss_image_galleries,'created_desc', '');

// --- object independend things: (TODO: cleaning up not yet finished)

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

$rss_version = 1; // default is: rss v1.0 - TODO: make this configurable
if (isset($_REQUEST["ver"]))
	if (substr($_REQUEST["ver"],0,1) == '2') {
		$rss_version = 2;
	}

$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 = httpPrefix().str_replace($pagename, $tikiIndex, $urlarray["path"]);
$img = httpPrefix().str_replace($pagename, "img/tiki.jpg", $urlarray["path"]);
$read = httpPrefix().str_replace($pagename, "tiki-browse_image.php", $urlarray["path"]);
$url = httpPrefix().$url;

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

// --- output starts here 
header("content-type: text/xml");
print '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
print '<!--  RSS generated by TikiWiki CMS (www.tikiwiki.org) on '.date('r').' -->'."\n";

if ($rss_use_css) {
	print '<?xml-stylesheet href="'.htmlspecialchars($css).'" type="text/css"?>'."\n";
}

if ($rss_version == 2) {
	print '<rss version="2.0">'."\n";
	print "<channel>\n";
} else {
	print '<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";
	print '<channel rdf:about="'.htmlspecialchars($url).'">'."\n";
}

print "<title>".htmlspecialchars($title)."</title>\n";
print "<link>".htmlspecialchars($home)."</link>\n";
print "<description>".rawurlencode($desc)."</description>\n";

if ($rss_version == 2) {
	print "<language>en-us</language>\n";
} // TODO: make language configurable

print "\n";

if ($rss_version == 2) {
	print '<image>'."\n";
} else {
	print '<image rdf:about="'.htmlspecialchars($url).'" rdf:url="'.htmlspecialchars($img).'">'."\n";
}
print "<title>".rawurlencode($title)."</title>\n";
print "<link>".htmlspecialchars($home)."</link>\n";
print "<url>".htmlspecialchars($url)."</url>\n";
print "</image>\n\n";

if ($rss_version == 1) {
	print "<items>\n";
	print "<rdf:Seq>\n";
	// LOOP collecting last changes to image galleries (index)
	foreach ($changes["data"] as $chg) {
		print ('        <rdf:li resource="'.htmlspecialchars($read."?imageId=".$chg["imageId"]).'" />'."\n");
	}
	print "</rdf:Seq>\n";
	print "</items>\n";

	print "</channel>\n";
}

// LOOP collecting last changes to image galleries
foreach ($changes["data"] as $chg) {
	if ($rss_version == 2) {
		print ("<item>\n");
	} else {
		print ('<item rdf:about="'.htmlspecialchars($read."?imageId=".$chg["imageId"]).'">'."\n");
	}
	print ('  <title>'.rawurlencode($chg["name"].': '.$tikilib -> date_format($tikilib -> get_short_datetime_format(), $chg["created"])).'</title>'."\n");
	print ('  <link>'.htmlspecialchars($read."?imageId=".$chg["imageId"]).'</link>'."\n");

  $date = $tikilib -> date_format($tikilib -> get_short_datetime_format(), $chg["created"]);
	if ($rss_version == 2) {
		print ('<description>'.rawurlencode($chg["description"]).'</description>'."\n");
		// print("<author>".rawurlencode($chg["user"])."</author>\n"); // TODO: email address of author
		print ('<guid isPermaLink="true">'.htmlspecialchars($read."?imageId=".$chg["imageId"]).'</guid>'."\n");
		print ("<pubDate>".rawurlencode($date)."</pubDate>\n");
	} else {
		print ('  <description>'.rawurlencode($chg["description"]).'</description>'."\n");
	}
	print ('</item>'."\n\n");
}

if ($rss_version == 2) {
	print "</channel>\n";
	print "</rss>\n";
} else {
	print "</rdf:RDF>\n";
}
?>
{'fraction_non_alphanumeric': 0.2344632768361582, 'fraction_numerical': 0.015229673298943749, 'mean_word_length': 4.389146260754467, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 2, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, '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': '5505464', 'n_tokens_mistral': 3184, 'n_tokens_neox': 2964, 'n_words': 594}