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