str('title');
}
}
else if($argc > 1) {
$title = $argv[1];
}
else if(isset($_GET) && isset($_GET['feed'])) {
$title = $INPUT->str('feed');
}
if(isset($_POST) || isset($_GET) ) {
if(isset($_REQUEST['test']) && !is_writable(DOKU_INC) ) {
echo DOKU_INC . " is not writable by the web server.
Please check your permissions.";
return;
}
}
$minute = 60;
$default_ttl = 720*$minute;
$ttl = 0;
$filetime = 0;
$curent_time = time();
if($title) {
$xml_file = DOKU_INC . $title . '_news.xml';
}
else {
$xml_file = DOKU_INC . 'news_feed.xml';
}
if(file_exists($newsfeed_ini)) {
$ini_array = parse_ini_file($newsfeed_ini, true);
$which = isset($ini_array[$title]) ? $title : 'default';
$newsChannelTitle = $ini_array[$which]['title'];
$newsChannelDescription = $ini_array[$which]['description'] ;
$newsChannelTtl = isset($ini_array[$which]['ttl']) ? $ini_array[$which]['ttl'] : $helper->ttl();
}
if(isset($conf['plugin']['news'])) {
if(isset($conf['plugin']['news']['ttl'])) {
$ttl = $conf['plugin']['news']['ttl'];
if($ttl) $ttl *= $minute;
}
if(!$newsChannelTitle && isset($conf['plugin']['news']['title'])) {
$newsChannelTitle = $conf['plugin']['news']['title'];
}
if(!$newsChannelDescription && isset($conf['plugin']['news']['desc'])) {
$newsChannelDescription = $conf['plugin']['news']['desc'];
}
if(!$newsChannelTtl && isset($conf['plugin']['news']['ttl'])) {
$newsChannelTtl = $conf['plugin']['news']['ttl'];
}
if(isset($conf['plugin']['news']['url'])) {
$newsFeedURL = $conf['plugin']['news']['url'];
}
}
if(!$ttl) $ttl = $default_ttl;
if(@file_exists($xml_file)) {
$filetime = filemtime($xml_file);
}
$time_elapsed = ($curent_time - $filetime);
if($time_elapsed >= $ttl || $lib_exe || $refresh) {
new externalNewsFeed($xml_file,$ttl/$minute,$title);
if($lib_exe) {
chmod($xml_file, 0666);
}
}
if(!$lib_exe && ! $refresh) {
header('Content-type: application/xml');
readfile($xml_file);
}
if($refresh) {
header('Content-type: text/html');
if(@file_exists($xml_file)) {
$create_time= filectime($xml_file);
if($create_time >= $current_time) {
echo '';
echo 'Feed generated: ' . date('r',$create_time) , '
';
}
else echo "New Feed may not have been not created
";
}
$id = htmlentities(urldecode($INPUT->str('feed_ref')));
$ret_url = DOKU_URL . 'doku.php?id=' . $id;
echo '
Return to ' . $id . '';
}
exit;
?>