-
Notifications
You must be signed in to change notification settings - Fork 15
/
shared.php
executable file
·238 lines (205 loc) · 6.37 KB
/
shared.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/*
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
*
* shared.php - display shared items for a user
*
*
* Copyright (C) 2004-2007 Stephen Minutillo
* [email protected] - http://minutillo.com/steve/
*
* Distributed under the GPL - see LICENSE
*
*/
$fof_no_login = true;
include_once "fof-main.php";
include_once "fof-render.php";
if (!isset($_GET['user'])) {
die();
}
$user = $_GET['user'];
$format = isset($_GET['format']) ? $_GET['format'] : NULL;
$prefs = new FoF_Prefs($user);
$sharing = $prefs->get("sharing");
if ($sharing == "no") {
die;
}
$name = $prefs->get("sharedname");
$url = $prefs->get("sharedurl");
$offset = $prefs->get('tzoffset');
$which = ($sharing == "all") ? "all" : "shared";
if (isset($_GET['which'])) {
$which = ($sharing == "all" || $sharing == "all_tagged") ? $_GET['which'] : "shared " . $_GET['which'];
$extratitle = " items tagged " . $_GET['which'];
} else {
$extratitle = '';
}
$feed = NULL;
if (isset($_GET['feed'])) {
$feed = $_GET['feed'];
$r = fof_db_get_feed_by_id($feed);
$extratitle .= " from <a href='" . $r['feed_link'] . "'>" . $r['feed_title'] . "</a>";
}
$result = fof_get_items($user, $feed, $which, NULL, 0, 100);
$qv = array('user' => $user,
'which' => isset($_GET['which']) ? $_GET['which'] : NULL,
'feed' => isset($_GET['feed']) ? $_GET['feed'] : NULL,
);
$baseurl = fof_base_url();
$shared_feed = fof_url($baseurl, array_merge($qv, array('format' => 'atom')));
$shared_link = fof_url($baseurl, $qv);
if ($format == 'atom') {
fof_set_content_type('application/atom+xml');
echo '<?xml version="1.0"?>';
?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Feed on Feeds - Shared Items<?php if ($name) {
echo " from $name";
}
if ($extratitle) {
echo " " . strip_tags($extratitle);
}
?></title>
<updated><?php echo gmdate('Y-m-d\TH:i:s\Z') ?></updated>
<generator uri="http://feedonfeeds.com/">Feed on Feeds</generator>
<?php if ($name) {
echo "<author><name>$name</name></author>";
}
?>
<id><?php echo $shared_feed ?></id>
<link href="<?php echo $shared_feed ?>" rel="self" type="application/atom+xml"/>
<link href="<?php echo $shared_link ?>" rel="alternate"/>
<?php
foreach ($result as $item) {
$feed_link = htmlspecialchars($item['feed_link']);
$feed_url = htmlspecialchars($item['feed_url']);
$feed_title = htmlspecialchars($item['feed_title']);
$item_link = htmlspecialchars($item['item_link']);
$item_guid = $item['item_guid'];
if (!preg_match("/^[a-z0-9\.\+\-]+:/", $item_guid)) {
$item_guid = $feed_link . '#' . $item_guid;
}
$item_guid = htmlspecialchars($item_guid);
$item_title = htmlspecialchars($item['item_title']);
$item_content = htmlspecialchars($item['item_content']);
$item_published = gmdate('Y-m-d\TH:i:s\Z', $item['item_published']);
$item_cached = gmdate('Y-m-d\TH:i:s\Z', $item['item_cached']);
$item_updated = gmdate('Y-m-d\TH:i:s\Z', $item['item_updated']);
if (!$item_title) {
$item_title = "[no title]";
}
?>
<entry>
<id><?php echo $item_guid ?></id>
<link href="<?php echo $item_link ?>" rel="alternate" type="text/html"/>
<title type="html"><?php echo $item_title ?></title>
<summary type="html"><?php echo $item_content ?></summary>
<updated><?php echo $item_updated ?></updated>
<source>
<id><?php echo $feed_link ?></id>
<link href="<?php echo $feed_link ?>" rel="alternate" type="text/html"/>
<link href="<?php echo $feed_url ?>" rel="self" type="application/atom+xml"/>
<title><?php echo $feed_title ?></title>
</source>
</entry>
<?php
}
echo '</feed>';
} else /* format != 'atom' */
{
fof_set_content_type();
?>
<!DOCTYPE html>
<html>
<head>
<link rel="alternate" href="<?php echo $shared_feed ?>" type="application/atom+xml"/>
<title>Feed on Feeds - Shared Items<?php if ($name) {
echo " from $name";
}
if ($extratitle) {
echo " " . strip_tags($extratitle);
}
?></title>
<link rel="stylesheet" href="fof.css" media="screen" />
<?php if (is_readable('./fof-custom.css')) {?><link rel="stylesheet" href="fof-custom.css" media="screen" /><?php }?>
<style>
.box
{
font-family: georgia;
background: #eee;
border: 1px solid black;
width: 30em;
margin: 10px auto 20px;
padding: 1em;
text-align: center;
}
</style>
</head>
<body>
<h1 class="box"><a href="http://feedonfeeds.com/">Feed on Feeds</a> - Shared Items
<?php
if ($name) {
echo " from ";
}
if ($url) {
echo "<a href='$url'>";
}
if ($name) {
echo "$name";
}
if ($url) {
echo "</a>";
}
if ($extratitle) {
echo "<br><i>$extratitle</i>"
;
}
?>
</h1>
<div id="items">
<?php
$first = true;
foreach ($result as $item) {
$item_id = $item['item_id'];
echo '<div class="item shown" id="i' . $item_id . '">';
$feed_link = $item['feed_link'];
$feed_title = $item['feed_title'];
$feed_image = $item['feed_image'];
$feed_description = $item['feed_description'];
$item_link = $item['item_link'];
$item_id = $item['item_id'];
$item_title = $item['item_title'];
$item_content = $item['item_content'];
$item_published = gmdate("Y-n-d g:ia", $item['item_published'] + $offset * 60 * 60);
$item_cached = gmdate("Y-n-d g:ia", $item['item_cached'] + $offset * 60 * 60);
$item_updated = gmdate("Y-n-d g:ia", $item['item_updated'] + $offset * 60 * 60);
if (!$item_title) {
$item_title = "[no title]";
}
?>
<div class="header">
<h1>
<a href="<?php echo $item_link ?>">
<?php echo $item_title ?>
</a>
</h1>
<span class='dash'> - </span>
<h2>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><img src="<?php echo $feed_image ?>" height="16" width="16" border="0" /></a>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><?php echo $feed_title ?></a>
</h2>
<span class="meta">on <?php echo $item_published ?> GMT</span>
</div>
<div class="body"><?php echo $item_content ?></div>
<div class="clearer"></div>
</div>
<?php
}
if (count($result) == 0) {
echo "<p><i>No shared items.</i></p>";
}
?>
</div></body></html>
<?php
}
?>