| 1 |
<?php |
|---|
| 2 |
global $CFG; |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
require_once(dirname(dirname(__FILE__))."/includes.php"); |
|---|
| 8 |
|
|---|
| 9 |
run("profile:init"); |
|---|
| 10 |
run("friends:init"); |
|---|
| 11 |
run("weblogs:init"); |
|---|
| 12 |
|
|---|
| 13 |
global $page_owner; |
|---|
| 14 |
$tag = trim(optional_param('tag')); |
|---|
| 15 |
$modifier = optional_param('modifier'); |
|---|
| 16 |
|
|---|
| 17 |
if ($modifier == "all") { |
|---|
| 18 |
$page_owner = -1; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
if (isset($page_owner)) { |
|---|
| 22 |
|
|---|
| 23 |
if ($page_owner != -1) { |
|---|
| 24 |
$username = user_info('username', $page_owner); |
|---|
| 25 |
} else { |
|---|
| 26 |
$username = "news"; |
|---|
| 27 |
} |
|---|
| 28 |
if ($username) { |
|---|
| 29 |
|
|---|
| 30 |
if (!isset($_REQUEST['tag']) || trim($_REQUEST['tag'])=="" ) { |
|---|
| 31 |
// no tag, serve plain file |
|---|
| 32 |
$publish_folder = substr($username,0,1); |
|---|
| 33 |
NOTE THAT IF THIS GETS UNCOMMENTED THIS NEEDS TO CHANGE TO BE INSIDE DATAROOT NOW. (Penny) |
|---|
| 34 |
$rssfile = path . "_rss/data/" . $publish_folder . "/" . $username . "/weblog.xml"; |
|---|
| 35 |
$rssurl = url . $username . "/weblog/rss2/"; |
|---|
| 36 |
|
|---|
| 37 |
if (!file_exists($rssfile)) { |
|---|
| 38 |
$rssresult = run("weblogs:rss:publish", array($page_owner, false)); |
|---|
| 39 |
} |
|---|
| 40 |
header("{$_SERVER['SERVER_PROTOCOL']} 301 Moved Permanently"); |
|---|
| 41 |
header("Location: $rssurl"); |
|---|
| 42 |
exit; |
|---|
| 43 |
} else { |
|---|
| 44 |
// a tag has been set |
|---|
| 45 |
// not using static file for tags, because number of tags * number of users... |
|---|
| 46 |
*/ |
|---|
| 47 |
$sitename = sitename; |
|---|
| 48 |
|
|---|
| 49 |
$output = ""; |
|---|
| 50 |
if ($tag) { |
|---|
| 51 |
$rssweblog = sprintf(__gettext("Weblog items tagged with %s"),$tag); |
|---|
| 52 |
$tagurl = urlencode($tag) . '/'; |
|---|
| 53 |
} else { |
|---|
| 54 |
$rssweblog = __gettext("Weblog items"); |
|---|
| 55 |
$tagurl = ''; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
if ($page_owner == -1 || $info = get_record('users','ident',$page_owner)) { |
|---|
| 59 |
if ($page_owner == -1) { |
|---|
| 60 |
$info = (object) ""; |
|---|
| 61 |
$name = __gettext("All users"); |
|---|
| 62 |
|
|---|
| 63 |
$xslurl = ""; |
|---|
| 64 |
} else { |
|---|
| 65 |
$mainurl = $CFG->wwwroot . $info->username . "/weblog/"; |
|---|
| 66 |
$rssurl = $mainurl . "rss/" . $tagurl; |
|---|
| 67 |
$xslurl = $mainurl . "rss/" . $tagurl . "rssstyles.xsl"; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
switch($modifier) { |
|---|
| 71 |
|
|---|
| 72 |
case "all": $rssurl = $CFG->wwwroot . "_weblog/rss2.php?page_owner=-1&modifier=all"; |
|---|
| 73 |
$mainurl = $CFG->wwwroot . "_weblog/everyone.php"; |
|---|
| 74 |
$rssdescription = sprintf(__gettext("The most recent weblog posts on %s."),$sitename); |
|---|
| 75 |
$rssweblog = $rssdescription; |
|---|
| 76 |
break; |
|---|
| 77 |
default: $name = (stripslashes(user_name($info->ident))); |
|---|
| 78 |
$rssdescription = sprintf(__gettext("The weblog for %s, hosted on %s."),$name,$sitename); |
|---|
| 79 |
break; |
|---|
| 80 |
|
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
/* <?xml-stylesheet type="text/xsl" href="{$rssurl}/rssstyles.xsl"?> */ |
|---|
| 85 |
if (!empty($xslurl)) { |
|---|
| 86 |
$output .= "<?xml-stylesheet type=\"text/xsl\" href=\"{$xslurl}\"?>\n\n"; |
|---|
| 87 |
} |
|---|
| 88 |
$output .= <<< END |
|---|
| 89 |
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'> |
|---|
| 90 |
<channel xml:base='$mainurl'> |
|---|
| 91 |
<title><![CDATA[$name : $rssweblog]]></title> |
|---|
| 92 |
<description><![CDATA[$rssdescription]]></description> |
|---|
| 93 |
<link>$mainurl</link> |
|---|
| 94 |
END; |
|---|
| 95 |
$modifier = optional_param('modifier'); |
|---|
| 96 |
$output .= run("weblogs:rss:getitems", array($page_owner, 10, $tag, $modifier)); |
|---|
| 97 |
|
|---|
| 98 |
$output .= <<< END |
|---|
| 99 |
|
|---|
| 100 |
</channel> |
|---|
| 101 |
</rss> |
|---|
| 102 |
END; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
if ($output) { |
|---|
| 106 |
header("Pragma: public"); |
|---|
| 107 |
header("Cache-Control: public"); |
|---|
| 108 |
header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT"); |
|---|
| 109 |
|
|---|
| 110 |
$if_none_match = (isset($_SERVER['HTTP_IF_NONE_MATCH'])) ? preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']) : false; |
|---|
| 111 |
|
|---|
| 112 |
$etag = md5($output); |
|---|
| 113 |
header('ETag: "' . $etag . '"'); |
|---|
| 114 |
|
|---|
| 115 |
if ($if_none_match && $if_none_match == $etag) { |
|---|
| 116 |
header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); |
|---|
| 117 |
exit; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
header("Content-Length: " . strlen($output)); |
|---|
| 121 |
|
|---|
| 122 |
header("Content-type: text/xml; charset=utf-8"); |
|---|
| 123 |
echo $output; |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
} |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|