forked from pebosi/ilias
-
Notifications
You must be signed in to change notification settings - Fork 0
/
privfeed.php
129 lines (103 loc) · 3.9 KB
/
privfeed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* News feed script.
*
* @author Alex Killing <alex.killing@gmx.de>
* @version $Id$
*/
// this should bring us all session data of the desired
// client
if (isset($_GET["client_id"]))
{
$cookie_domain = $_SERVER['SERVER_NAME'];
$cookie_path = dirname( $_SERVER['PHP_SELF'] );
/* if ilias is called directly within the docroot $cookie_path
is set to '/' expecting on servers running under windows..
here it is set to '\'.
in both cases a further '/' won't be appended due to the following regex
*/
$cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
if($cookie_path == "\\") $cookie_path = '/';
$cookie_domain = ''; // Temporary Fix
setcookie("ilClientId", $_GET["client_id"], 0, $cookie_path, $cookie_domain);
$_COOKIE["ilClientId"] = $_GET["client_id"];
}
include_once "Services/Context/classes/class.ilContext.php";
ilContext::init(ilContext::CONTEXT_RSS_AUTH);
require_once("Services/Init/classes/class.ilInitialisation.php");
ilInitialisation::initILIAS();
global $lng, $ilSetting;
$feed_set = new ilSetting("news");
if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_USER']))
{
Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}
else
{
if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" &&
(md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) &&
$_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"]))
&& $feed_set->get("enable_private_feed"))
{
include_once("./Services/Feeds/classes/class.ilUserFeedWriter.php");
// Third parameter is true for private feed
$writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
$writer->showFeed();
}
else if ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
{
include_once("./Services/Feeds/classes/class.ilObjectFeedWriter.php");
// Second parameter is optional to pass on to database-level to get news for logged-in users
$writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
$writer->showFeed();
}
else {
// send appropriate header, if password is wrong, otherwise
// there is no chance to re-enter it (unless, e.g. the browser is closed)
if (md5($_SERVER['PHP_AUTH_PW']) != ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
{
Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}
include_once("./Services/Feeds/classes/class.ilFeedItem.php");
include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
$blankFeedWriter = new ilFeedWriter();
$feed_item = new ilFeedItem();
$lng->loadLanguageModule("news");
if ($ilSetting->get('short_inst_name') != "")
{
$blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
}
else
{
$blankFeedWriter->setChannelTitle("ILIAS");
}
if (!$feed_set->get("enable_private_feed"))
{
$blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
$blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
// title
$feed_item->setTitle($lng->txt("priv_feed_no_access_title"));
// description
$feed_item->setDescription($lng->txt("priv_feed_no_access_body"));
$feed_item->setLink(ILIAS_HTTP_PATH);
}
else
{
$blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
$blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
// title
$feed_item->setTitle($lng->txt("priv_feed_no_auth_title"));
// description
$feed_item->setDescription($lng->txt("priv_feed_no_auth_body"));
$feed_item->setLink(ILIAS_HTTP_PATH);
}
$blankFeedWriter->addItem($feed_item);
$blankFeedWriter->showFeed();
}
}
?>