// RSS feeds must be enabled site-wide.
if (empty($CFG->enablerssfeeds)) {
- debugging('DISABLED (admin variables)');
rss_error();
}
if (empty($context)) {
// This shouldnt happen. something bad is going on.
- rss_error('rsserror');
+ rss_error();
}
// Make sure that $CFG->siteguest is set.
if (empty($CFG->siteguest)) {
if (!$guestid = $DB->get_field('user', 'id', array('username' => 'guest', 'mnethostid' => $CFG->mnet_localhost_id))) {
// Guest does not exist yet, weird.
- rss_error('rsserror');
+ rss_error();
}
set_config('siteguest', $guestid);
}
// Authenticate the user from the token.
$userid = rss_get_userid_from_token($token);
if (!$userid) {
- rss_error('rsserrorauth');
+ rss_error('rsserrorauth', 'rss.xml', 0, '403 Forbidden');
}
}
require_login($course, $autologinguest, $cm, $setwantsurltome, $preventredirect);
} catch (Exception $e) {
if (isguestuser()) {
- rss_error('rsserrorguest');
+ rss_error('rsserrorguest', 'rss.xml', 0, '403 Forbidden');
} else {
- rss_error('rsserrorauth');
+ rss_error('rsserrorauth', 'rss.xml', 0, '403 Forbidden');
}
}
* @category rss
*
* @param string $error the error type, default is rsserror
- * @param string $filename the name of the file to create (NOT USED)
- * @param int $lifetime UNSURE (NOT USED)
+ * @param string $filename the name of the file to created
+ * @param int $unused
+ * @param $statuscode http 1.1 statuscode indicicating the error
* @uses exit
*/
-function rss_error($error='rsserror', $filename='rss.xml', $lifetime=0) {
- send_file(rss_geterrorxmlfile($error), $filename, $lifetime, false, true);
+function rss_error($error='rsserror', $filename='rss.xml', $unused=0, $statuscode='404 Not Found') {
+ header("HTTP/1.1 $statuscode");
+ header('Content-Disposition: inline; filename="'.$filename.'"');
+ header('Content-Type: application/xml');
+ echo rss_geterrorxmlfile($error);
exit;
}