1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11require_once('tiki-setup.php'); 12$tikilib = TikiLib::lib('tiki'); 13$histlib = TikiLib::lib('hist'); 14$wikilib = TikiLib::lib('wiki'); 15$rsslib = TikiLib::lib('rss'); 16 17$access->check_feature('feature_wiki'); 18 19if ($prefs['feed_wiki'] != 'y') { 20 $errmsg = tra("rss feed disabled"); 21 require_once('tiki-rss_error.php'); 22} 23 24$res = $access->authorize_rss(['tiki_p_view', 'tiki_p_wiki_view_ref']); 25if ($res) { 26 if ($res['header'] == 'y') { 27 header('WWW-Authenticate: Basic realm="' . $tikidomain . '"'); 28 header('HTTP/1.0 401 Unauthorized'); 29 } 30 $errmsg = $res['msg']; 31 require_once('tiki-rss_error.php'); 32} 33 34$feed = "wiki"; 35$uniqueid = $feed; 36$output = $rsslib->get_from_cache($uniqueid); 37 38if ($output["data"] == "EMPTY") { 39 $title = $prefs['feed_wiki_title']; 40 $desc = $prefs['feed_wiki_desc']; 41 $id = "pageName"; 42 $titleId = "pageName"; 43 $descId = "data"; 44 $dateId = "lastModif"; 45 $authorId = "user"; 46 // if param &diff=1 exists, link to diff, not to page itself 47 if (isset($_REQUEST["diff"])) { 48 $readrepl = "tiki-pagehistory.php?page=%s&compare=1&oldver=%s&newver=0&diff_style=minsidediff"; 49 } else { 50 $readrepl = "tiki-index.php?page=%s"; 51 } 52 $param = "previous"; 53 54 $changes = $tikilib -> list_pages(0, $prefs['feed_wiki_max'], 'lastModif_desc', '', '', true, false, false, false, '', false, 'y'); 55 $tmp = []; 56 foreach ($changes["data"] as $data) { 57 $result = ''; 58 if ($tiki_p_view != 'y') { 59 $data['sefurl'] = $wikilib->sefurl($data['pageName']); 60 unset($data['data']); 61 $tmp[] = $data; 62 continue; 63 } 64 // get last 2 versions of the page and parse them 65 $curr_page = $tikilib->get_page_info($data["pageName"]); 66 $pageversion = (int) $histlib->get_page_latest_version($data["pageName"]); 67 if ($pageversion == false) { 68 $prev_page = $curr_page; 69 $prev_page["data"] = ""; 70 } else { 71 $prev_page = $histlib->get_page_from_history($data["pageName"], $pageversion, true); 72 } 73 $_REQUEST['redirectpage'] = 'y';//block the redirect interpretation 74 $_REQUEST['page'] = $data["pageName"]; 75 $curr_page_p = TikiLib::lib('parser')->parse_data($curr_page[$descId], ['print' => true, 'is_html' => $curr_page['is_html']]); 76 $prev_page_p = TikiLib::lib('parser')->parse_data($prev_page[$descId], ['print' => true, 'is_html' => $curr_page['is_html']]); 77 78 // do a diff between both pages 79 require_once('lib/diff/difflib.php'); 80 $diff = diff2($prev_page_p, $curr_page_p, $curr_page['is_html'] ? 'htmldiff' : 'unidiff'); 81 82 83 if (is_array($diff)) { 84 foreach ($diff as $part) { 85 if ($part["type"] == "diffdeleted") { 86 foreach ($part["data"] as $chunk) { 87 $result .= "<blockquote>- $chunk</blockquote>"; 88 } 89 } 90 if ($part["type"] == "diffadded") { 91 foreach ($part["data"] as $chunk) { 92 $result .= "<blockquote>+ $chunk</blockquote>"; 93 } 94 } 95 } 96 } else { 97 $result = strpos($diff, '<tr>') === 0 ? '<table>' . $diff . '</table>' : $diff; 98 } 99 100 $data["$descId"] = $result; 101 102 // hand over the version of the second page 103 $data["$param"] = $prev_page["version"]; 104 $tmp[] = $data; 105 } 106 $changes["data"] = $tmp; 107 108 $tmp = null; 109 $output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, $param, $id, $title, $titleId, $desc, $descId, $dateId, $authorId); 110} 111header("Content-type: " . $output["content-type"]); 112print $output["data"]; 113