tiki-directories_rss.php 1.76 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// 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.
changi67's avatar
changi67 committed
9 10
// $Id$

11 12 13
require_once ('tiki-setup.php');
require_once ('lib/tikilib.php');
require_once ('lib/rss/rsslib.php');
14
if ($prefs['feed_directories'] != 'y') {
15
	$errmsg = tra("rss feed disabled");
16 17 18
	require_once ('tiki-rss_error.php');
}
if ($prefs['feature_directory'] != 'y') {
19 20
	$errmsg = tra("This feature is disabled") . ": feature_directory";
	require_once ('tiki-rss_error.php');
21
}
22
$res = $access->authorize_rss(
23 24 25 26
	array(
		'tiki_p_view_directory',
		'tiki_p_admin_directory'
	)
27
);
28 29 30 31 32 33 34
if ($res) {
	if ($res['header'] == 'y') {
		header('WWW-Authenticate: Basic realm="' . $tikidomain . '"');
		header('HTTP/1.0 401 Unauthorized');
	}
	$errmsg = $res['msg'];
	require_once ('tiki-rss_error.php');
35 36 37 38
}
$feed = "directories";
$uniqueid = $feed;
$output = $rsslib->get_from_cache($uniqueid);
39
if ($output["data"] == "EMPTY") {
40 41
	$title = $prefs['feed_directories_title'];
	$desc = $prefs['feed_directories_desc'];
42 43 44 45 46
	$id = "siteId";
	$titleId = "name";
	$descId = "description";
	$dateId = "created";
	$readrepl = "tiki-directory_redirect.php?$id=%s";
47
	$tmp = $prefs['feed_' . $feed . '_title'];
48 49 50
	if ($tmp <> '') {
		$title = $tmp;
	}
51
	$tmp = $prefs['feed_' . $feed . '_desc'];
52 53 54
	if ($desc <> '') {
		$desc = $tmp;
	}
55
	$changes = $tikilib->dir_list_all_valid_sites2(0, $prefs['feed_directories_max'], $dateId . '_desc', '');
56 57
	$output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, '', $id, $title, $titleId, $desc, $descId, $dateId, '');
}
58
header("Content-type: " . $output["content-type"]);
59
print $output["data"];