]>
Commit | Line | Data |
---|---|---|
5f0a3741 | 1 | <?php |
369dbc19 | 2 | class Handler_Public extends Handler { |
5f0a3741 | 3 | |
79178062 | 4 | private function generate_syndicated_feed($owner_uid, $feed, $is_cat, |
9090b874 | 5 | $limit, $offset, $search, |
d1e631f3 | 6 | $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) { |
79178062 AD |
7 | |
8 | require_once "lib/MiniTemplator.class.php"; | |
9 | ||
10 | $note_style = "background-color : #fff7d5; | |
11 | border-width : 1px; ". | |
12 | "padding : 5px; border-style : dashed; border-color : #e7d796;". | |
13 | "margin-bottom : 1em; color : #9a8c59;"; | |
14 | ||
2faef834 | 15 | if (!$limit) $limit = 60; |
79178062 | 16 | |
8aa01d79 | 17 | $date_sort_field = "date_entered DESC, updated DESC"; |
84c53d0e | 18 | $date_check_field = "date_entered"; |
79178062 | 19 | |
84c53d0e | 20 | if ($feed == -2 && !$is_cat) { |
7ef7dd31 | 21 | $date_sort_field = "last_published DESC"; |
84c53d0e AD |
22 | $date_check_field = "last_published"; |
23 | } else if ($feed == -1 && !$is_cat) { | |
7ef7dd31 | 24 | $date_sort_field = "last_marked DESC"; |
84c53d0e AD |
25 | $date_check_field = "last_marked"; |
26 | } | |
008ebad9 | 27 | |
25051fb8 AD |
28 | switch ($order) { |
29 | case "title": | |
81d96c0d | 30 | $date_sort_field = "ttrss_entries.title, date_entered, updated"; |
25051fb8 AD |
31 | break; |
32 | case "date_reverse": | |
33 | $date_sort_field = "date_entered, updated"; | |
34 | break; | |
35 | case "feed_dates": | |
36 | $date_sort_field = "updated DESC"; | |
37 | break; | |
38 | } | |
39 | ||
f5a0fb8b AD |
40 | $params = array( |
41 | "owner_uid" => $owner_uid, | |
42 | "feed" => $feed, | |
43 | "limit" => 1, | |
44 | "view_mode" => $view_mode, | |
45 | "cat_view" => $is_cat, | |
46 | "search" => $search, | |
47 | "override_order" => $date_sort_field, | |
48 | "include_children" => true, | |
49 | "ignore_vfeed_group" => true, | |
50 | "offset" => $offset, | |
51 | "start_ts" => $start_ts | |
52 | ); | |
53 | ||
aeb1abed | 54 | $qfh_ret = Feeds::queryFeedHeadlines($params); |
2e35a707 AD |
55 | |
56 | $result = $qfh_ret[0]; | |
57 | ||
d9c85e0f | 58 | if ($this->dbh->num_rows($result) != 0) { |
84c53d0e AD |
59 | |
60 | $ts = strtotime($this->dbh->fetch_result($result, 0, $date_check_field)); | |
2e35a707 AD |
61 | |
62 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && | |
d6ba77f3 | 63 | strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) { |
2e35a707 AD |
64 | header('HTTP/1.0 304 Not Modified'); |
65 | return; | |
66 | } | |
67 | ||
68 | $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT"; | |
69 | header("Last-Modified: $last_modified", true); | |
70 | } | |
71 | ||
f5a0fb8b AD |
72 | $params = array( |
73 | "owner_uid" => $owner_uid, | |
74 | "feed" => $feed, | |
75 | "limit" => $limit, | |
76 | "view_mode" => $view_mode, | |
77 | "cat_view" => $is_cat, | |
78 | "search" => $search, | |
79 | "override_order" => $date_sort_field, | |
80 | "include_children" => true, | |
81 | "ignore_vfeed_group" => true, | |
82 | "offset" => $offset, | |
83 | "start_ts" => $start_ts | |
84 | ); | |
85 | ||
aeb1abed | 86 | $qfh_ret = Feeds::queryFeedHeadlines($params); |
2e35a707 | 87 | |
79178062 AD |
88 | $result = $qfh_ret[0]; |
89 | $feed_title = htmlspecialchars($qfh_ret[1]); | |
90 | $feed_site_url = $qfh_ret[2]; | |
4a80c57c | 91 | /* $last_error = $qfh_ret[3]; */ |
79178062 AD |
92 | |
93 | $feed_self_url = get_self_url_prefix() . | |
39119f02 JT |
94 | "/public.php?op=rss&id=$feed&key=" . |
95 | get_feed_access_key($feed, false, $owner_uid); | |
79178062 AD |
96 | |
97 | if (!$feed_site_url) $feed_site_url = get_self_url_prefix(); | |
98 | ||
2ebf38a9 AD |
99 | if ($format == 'atom') { |
100 | $tpl = new MiniTemplator; | |
79178062 | 101 | |
2ebf38a9 | 102 | $tpl->readTemplateFromFile("templates/generated_feed.txt"); |
79178062 | 103 | |
2ebf38a9 AD |
104 | $tpl->setVariable('FEED_TITLE', $feed_title, true); |
105 | $tpl->setVariable('VERSION', VERSION, true); | |
106 | $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true); | |
79178062 | 107 | |
2ebf38a9 | 108 | $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); |
d9c85e0f | 109 | while ($line = $this->dbh->fetch_assoc($result)) { |
399678a1 | 110 | |
2f1a29d9 | 111 | $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); |
bc262b67 | 112 | |
891e36f5 | 113 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
114 | $line = $p->hook_query_headlines($line); | |
115 | } | |
2e35a707 | 116 | |
399678a1 | 117 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) { |
92322838 | 118 | $line = $p->hook_article_export_feed($line, $feed, $is_cat); |
399678a1 AD |
119 | } |
120 | ||
fcf6bfba AD |
121 | $tpl->setVariable('ARTICLE_ID', |
122 | htmlspecialchars($orig_guid ? $line['link'] : | |
f75e7c64 | 123 | $this->make_article_tag_uri($line['id'], $line['date_entered'])), true); |
2ebf38a9 AD |
124 | $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); |
125 | $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); | |
67631438 | 126 | $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true); |
79178062 | 127 | |
4b19d4ac | 128 | $content = sanitize($line["content"], false, $owner_uid, |
3261dbfa | 129 | $feed_site_url, false, $line["id"]); |
79178062 | 130 | |
2ebf38a9 AD |
131 | if ($line['note']) { |
132 | $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" . | |
133 | $content; | |
e9c6e27d | 134 | $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true); |
135 | } | |
2ebf38a9 AD |
136 | |
137 | $tpl->setVariable('ARTICLE_CONTENT', $content, true); | |
138 | ||
139 | $tpl->setVariable('ARTICLE_UPDATED_ATOM', | |
140 | date('c', strtotime($line["updated"])), true); | |
141 | $tpl->setVariable('ARTICLE_UPDATED_RFC822', | |
142 | date(DATE_RFC822, strtotime($line["updated"])), true); | |
143 | ||
144 | $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true); | |
145 | ||
4b7391de | 146 | $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true); |
0ee126ee | 147 | $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true); |
2ebf38a9 | 148 | |
7e5f8d9f | 149 | $tags = Article::get_article_tags($line["id"], $owner_uid); |
2ebf38a9 AD |
150 | |
151 | foreach ($tags as $tag) { | |
152 | $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true); | |
153 | $tpl->addBlock('category'); | |
154 | } | |
79178062 | 155 | |
7e5f8d9f | 156 | $enclosures = Article::get_article_enclosures($line["id"]); |
79178062 | 157 | |
2ebf38a9 AD |
158 | foreach ($enclosures as $e) { |
159 | $type = htmlspecialchars($e['content_type']); | |
160 | $url = htmlspecialchars($e['content_url']); | |
4b7391de | 161 | $length = $e['duration'] ? $e['duration'] : 1; |
9c97041d | 162 | |
2ebf38a9 AD |
163 | $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true); |
164 | $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true); | |
165 | $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true); | |
79178062 | 166 | |
2ebf38a9 AD |
167 | $tpl->addBlock('enclosure'); |
168 | } | |
79178062 | 169 | |
2ebf38a9 | 170 | $tpl->addBlock('entry'); |
79178062 AD |
171 | } |
172 | ||
2ebf38a9 AD |
173 | $tmp = ""; |
174 | ||
175 | $tpl->addBlock('feed'); | |
176 | $tpl->generateOutputToString($tmp); | |
177 | ||
10bdeb4b AD |
178 | if (@!$_REQUEST["noxml"]) { |
179 | header("Content-Type: text/xml; charset=utf-8"); | |
180 | } else { | |
181 | header("Content-Type: text/plain; charset=utf-8"); | |
182 | } | |
2ebf38a9 AD |
183 | |
184 | print $tmp; | |
185 | } else if ($format == 'json') { | |
79178062 | 186 | |
2ebf38a9 | 187 | $feed = array(); |
79178062 | 188 | |
2ebf38a9 AD |
189 | $feed['title'] = $feed_title; |
190 | $feed['version'] = VERSION; | |
191 | $feed['feed_url'] = $feed_self_url; | |
79178062 | 192 | |
2ebf38a9 AD |
193 | $feed['self_url'] = get_self_url_prefix(); |
194 | ||
195 | $feed['articles'] = array(); | |
196 | ||
d9c85e0f | 197 | while ($line = $this->dbh->fetch_assoc($result)) { |
399678a1 | 198 | |
2f1a29d9 | 199 | $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); |
399678a1 | 200 | |
891e36f5 | 201 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
202 | $line = $p->hook_query_headlines($line, 100); | |
203 | } | |
399678a1 AD |
204 | |
205 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) { | |
92322838 | 206 | $line = $p->hook_article_export_feed($line, $feed, $is_cat); |
399678a1 AD |
207 | } |
208 | ||
2ebf38a9 | 209 | $article = array(); |
79178062 | 210 | |
2ebf38a9 AD |
211 | $article['id'] = $line['link']; |
212 | $article['link'] = $line['link']; | |
213 | $article['title'] = $line['title']; | |
67631438 | 214 | $article['excerpt'] = $line["content_preview"]; |
3261dbfa | 215 | $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]); |
2ebf38a9 | 216 | $article['updated'] = date('c', strtotime($line["updated"])); |
79178062 | 217 | |
2ebf38a9 AD |
218 | if ($line['note']) $article['note'] = $line['note']; |
219 | if ($article['author']) $article['author'] = $line['author']; | |
79178062 | 220 | |
2ed0d6c4 | 221 | $tags = Article::get_article_tags($line["id"], $owner_uid); |
2ebf38a9 AD |
222 | |
223 | if (count($tags) > 0) { | |
224 | $article['tags'] = array(); | |
225 | ||
226 | foreach ($tags as $tag) { | |
227 | array_push($article['tags'], $tag); | |
228 | } | |
229 | } | |
230 | ||
7e5f8d9f | 231 | $enclosures = Article::get_article_enclosures($line["id"]); |
2ebf38a9 AD |
232 | |
233 | if (count($enclosures) > 0) { | |
234 | $article['enclosures'] = array(); | |
235 | ||
236 | foreach ($enclosures as $e) { | |
237 | $type = $e['content_type']; | |
238 | $url = $e['content_url']; | |
239 | $length = $e['duration']; | |
240 | ||
241 | array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length)); | |
242 | } | |
243 | } | |
244 | ||
245 | array_push($feed['articles'], $article); | |
246 | } | |
247 | ||
10bdeb4b | 248 | header("Content-Type: text/json; charset=utf-8"); |
2ebf38a9 AD |
249 | print json_encode($feed); |
250 | ||
251 | } else { | |
252 | header("Content-Type: text/plain; charset=utf-8"); | |
253 | print json_encode(array("error" => array("message" => "Unknown format"))); | |
254 | } | |
79178062 AD |
255 | } |
256 | ||
5f0a3741 | 257 | function getUnread() { |
d9c85e0f | 258 | $login = $this->dbh->escape_string($_REQUEST["login"]); |
5f0a3741 AD |
259 | $fresh = $_REQUEST["fresh"] == "1"; |
260 | ||
d9c85e0f | 261 | $result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '$login'"); |
5f0a3741 | 262 | |
d9c85e0f AD |
263 | if ($this->dbh->num_rows($result) == 1) { |
264 | $uid = $this->dbh->fetch_result($result, 0, "id"); | |
5f0a3741 | 265 | |
a230bf88 | 266 | print Feeds::getGlobalUnread($uid); |
5f0a3741 AD |
267 | |
268 | if ($fresh) { | |
269 | print ";"; | |
86a8351c | 270 | print Feeds::getFeedArticles(-3, false, true, $uid); |
5f0a3741 AD |
271 | } |
272 | ||
273 | } else { | |
274 | print "-1;User not found"; | |
275 | } | |
276 | ||
277 | } | |
278 | ||
279 | function getProfiles() { | |
d9c85e0f | 280 | $login = $this->dbh->escape_string($_REQUEST["login"]); |
5f0a3741 | 281 | |
0806d68b | 282 | $result = $this->dbh->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users |
97acbaf1 | 283 | WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title"); |
5f0a3741 | 284 | |
eeee2ccf | 285 | print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>"; |
5f0a3741 | 286 | |
97acbaf1 | 287 | print "<option value='0'>" . __("Default profile") . "</option>"; |
5f0a3741 | 288 | |
d9c85e0f | 289 | while ($line = $this->dbh->fetch_assoc($result)) { |
97acbaf1 AD |
290 | $id = $line["id"]; |
291 | $title = $line["title"]; | |
5f0a3741 | 292 | |
97acbaf1 | 293 | print "<option value='$id'>$title</option>"; |
5f0a3741 | 294 | } |
97acbaf1 AD |
295 | |
296 | print "</select>"; | |
5f0a3741 AD |
297 | } |
298 | ||
5f0a3741 AD |
299 | function logout() { |
300 | logout_user(); | |
301 | header("Location: index.php"); | |
302 | } | |
303 | ||
5f0a3741 | 304 | function share() { |
d9c85e0f | 305 | $uuid = $this->dbh->escape_string($_REQUEST["key"]); |
5f0a3741 | 306 | |
d9c85e0f | 307 | $result = $this->dbh->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE |
5f0a3741 AD |
308 | uuid = '$uuid'"); |
309 | ||
d9c85e0f | 310 | if ($this->dbh->num_rows($result) != 0) { |
5f0a3741 AD |
311 | header("Content-Type: text/html"); |
312 | ||
d9c85e0f AD |
313 | $id = $this->dbh->fetch_result($result, 0, "ref_id"); |
314 | $owner_uid = $this->dbh->fetch_result($result, 0, "owner_uid"); | |
5f0a3741 | 315 | |
7e5f8d9f | 316 | $article = Article::format_article($id, false, true, $owner_uid); |
5f0a3741 AD |
317 | |
318 | print_r($article['content']); | |
319 | ||
320 | } else { | |
321 | print "Article not found."; | |
322 | } | |
323 | ||
324 | } | |
325 | ||
326 | function rss() { | |
d9c85e0f AD |
327 | $feed = $this->dbh->escape_string($_REQUEST["id"]); |
328 | $key = $this->dbh->escape_string($_REQUEST["key"]); | |
356e13b1 | 329 | $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]); |
d9c85e0f AD |
330 | $limit = (int)$this->dbh->escape_string($_REQUEST["limit"]); |
331 | $offset = (int)$this->dbh->escape_string($_REQUEST["offset"]); | |
5f0a3741 | 332 | |
d9c85e0f | 333 | $search = $this->dbh->escape_string($_REQUEST["q"]); |
d9c85e0f | 334 | $view_mode = $this->dbh->escape_string($_REQUEST["view-mode"]); |
25051fb8 | 335 | $order = $this->dbh->escape_string($_REQUEST["order"]); |
d1e631f3 | 336 | $start_ts = $this->dbh->escape_string($_REQUEST["ts"]); |
5f0a3741 | 337 | |
d9c85e0f | 338 | $format = $this->dbh->escape_string($_REQUEST['format']); |
5bcb7b61 | 339 | $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]); |
2ebf38a9 AD |
340 | |
341 | if (!$format) $format = 'atom'; | |
342 | ||
5f0a3741 | 343 | if (SINGLE_USER_MODE) { |
a42c55f0 | 344 | authenticate_user("admin", null); |
5f0a3741 AD |
345 | } |
346 | ||
347 | $owner_id = false; | |
348 | ||
349 | if ($key) { | |
d9c85e0f | 350 | $result = $this->dbh->query("SELECT owner_uid FROM |
5f0a3741 AD |
351 | ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'"); |
352 | ||
d9c85e0f AD |
353 | if ($this->dbh->num_rows($result) == 1) |
354 | $owner_id = $this->dbh->fetch_result($result, 0, "owner_uid"); | |
5f0a3741 AD |
355 | } |
356 | ||
357 | if ($owner_id) { | |
2fb947eb | 358 | $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit, |
9090b874 | 359 | $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts); |
5f0a3741 AD |
360 | } else { |
361 | header('HTTP/1.1 403 Forbidden'); | |
362 | } | |
363 | } | |
364 | ||
910592b4 | 365 | function updateTask() { |
4a80c57c | 366 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false); |
910592b4 AD |
367 | } |
368 | ||
4e5ddeaf | 369 | function housekeepingTask() { |
4a80c57c | 370 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", false); |
4e5ddeaf AD |
371 | } |
372 | ||
07391e36 | 373 | function globalUpdateFeeds() { |
113c3dec | 374 | RPC::updaterandomfeed_real($this->dbh); |
cda55d67 | 375 | |
4a80c57c | 376 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false); |
07391e36 | 377 | } |
8361e724 AD |
378 | |
379 | function sharepopup() { | |
61a748f8 | 380 | if (SINGLE_USER_MODE) { |
6322ac79 | 381 | login_sequence(); |
61a748f8 AD |
382 | } |
383 | ||
8361e724 | 384 | header('Content-Type: text/html; charset=utf-8'); |
d0ee0f52 AD |
385 | print "<html><head><title>Tiny Tiny RSS</title> |
386 | <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\"> | |
387 | <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">"; | |
9a2aed91 | 388 | |
cdbcb277 | 389 | echo stylesheet_tag("css/utility.css"); |
6214a076 | 390 | echo stylesheet_tag("css/dijit.css"); |
cdbcb277 | 391 | echo javascript_tag("lib/prototype.js"); |
6214a076 | 392 | echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls"); |
9a2aed91 AD |
393 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> |
394 | </head><body id='sharepopup'>"; | |
8361e724 AD |
395 | |
396 | $action = $_REQUEST["action"]; | |
397 | ||
398 | if ($_SESSION["uid"]) { | |
399 | ||
d493aba2 | 400 | if ($action == 'share') { |
8361e724 | 401 | |
d9c85e0f AD |
402 | $title = $this->dbh->escape_string(strip_tags($_REQUEST["title"])); |
403 | $url = $this->dbh->escape_string(strip_tags($_REQUEST["url"])); | |
404 | $content = $this->dbh->escape_string(strip_tags($_REQUEST["content"])); | |
405 | $labels = $this->dbh->escape_string(strip_tags($_REQUEST["labels"])); | |
8361e724 | 406 | |
a42c55f0 | 407 | Article::create_published_article($title, $url, $content, $labels, |
1b4d1a6b | 408 | $_SESSION["uid"]); |
8361e724 | 409 | |
d493aba2 AD |
410 | print "<script type='text/javascript'>"; |
411 | print "window.close();"; | |
412 | print "</script>"; | |
8361e724 | 413 | |
d493aba2 | 414 | } else { |
8361e724 AD |
415 | $title = htmlspecialchars($_REQUEST["title"]); |
416 | $url = htmlspecialchars($_REQUEST["url"]); | |
417 | ||
d493aba2 | 418 | ?> |
8361e724 | 419 | |
d493aba2 AD |
420 | <table height='100%' width='100%'><tr><td colspan='2'> |
421 | <h1><?php echo __("Share with Tiny Tiny RSS") ?></h1> | |
422 | </td></tr> | |
8361e724 | 423 | |
d493aba2 | 424 | <form id='share_form' name='share_form'> |
8361e724 | 425 | |
d493aba2 AD |
426 | <input type="hidden" name="op" value="sharepopup"> |
427 | <input type="hidden" name="action" value="share"> | |
8361e724 | 428 | |
22439dad | 429 | <tr><td align='right'><?php echo __("Title:") ?></td> |
d493aba2 | 430 | <td width='80%'><input name='title' value="<?php echo $title ?>"></td></tr> |
22439dad | 431 | <tr><td align='right'><?php echo __("URL:") ?></td> |
d493aba2 | 432 | <td><input name='url' value="<?php echo $url ?>"></td></tr> |
22439dad | 433 | <tr><td align='right'><?php echo __("Content:") ?></td> |
d493aba2 | 434 | <td><input name='content' value=""></td></tr> |
1b4d1a6b AD |
435 | <tr><td align='right'><?php echo __("Labels:") ?></td> |
436 | <td><input name='labels' id="labels_value" | |
437 | placeholder='Alpha, Beta, Gamma' value=""> | |
438 | </td></tr> | |
439 | ||
440 | <tr><td> | |
441 | <div class="autocomplete" id="labels_choices" | |
442 | style="display : block"></div></td></tr> | |
8361e724 | 443 | |
d493aba2 | 444 | <script type='text/javascript'>document.forms[0].title.focus();</script> |
8361e724 | 445 | |
1b4d1a6b AD |
446 | <script type='text/javascript'> |
447 | new Ajax.Autocompleter('labels_value', 'labels_choices', | |
448 | "backend.php?op=rpc&method=completeLabels", | |
449 | { tokens: ',', paramName: "search" }); | |
450 | </script> | |
451 | ||
d493aba2 AD |
452 | <tr><td colspan='2'> |
453 | <div style='float : right' class='insensitive-small'> | |
454 | <?php echo __("Shared article will appear in the Published feed.") ?> | |
455 | </div> | |
456 | <button type="submit"><?php echo __('Share') ?></button> | |
457 | <button onclick="return window.close()"><?php echo __('Cancel') ?></button> | |
f5a0fb8b | 458 | </td> |
8361e724 | 459 | |
d493aba2 AD |
460 | </form> |
461 | </td></tr></table> | |
462 | </body></html> | |
463 | <?php | |
8361e724 | 464 | |
8361e724 AD |
465 | } |
466 | ||
467 | } else { | |
468 | ||
d493aba2 AD |
469 | $return = urlencode($_SERVER["REQUEST_URI"]) |
470 | ?> | |
471 | ||
472 | <form action="public.php?return=<?php echo $return ?>" | |
22439dad | 473 | method="POST" id="loginForm" name="loginForm"> |
d493aba2 AD |
474 | |
475 | <input type="hidden" name="op" value="login"> | |
476 | ||
477 | <table height='100%' width='100%'><tr><td colspan='2'> | |
22439dad | 478 | <h1><?php echo __("Not logged in") ?></h1></td></tr> |
d493aba2 AD |
479 | |
480 | <tr><td align="right"><?php echo __("Login:") ?></td> | |
481 | <td align="right"><input name="login" | |
482 | value="<?php echo $_SESSION["fake_login"] ?>"></td></tr> | |
483 | <tr><td align="right"><?php echo __("Password:") ?></td> | |
484 | <td align="right"><input type="password" name="password" | |
485 | value="<?php echo $_SESSION["fake_password"] ?>"></td></tr> | |
d493aba2 AD |
486 | <tr><td colspan='2'> |
487 | <button type="submit"> | |
488 | <?php echo __('Log in') ?></button> | |
489 | ||
490 | <button onclick="return window.close()"> | |
491 | <?php echo __('Cancel') ?></button> | |
492 | </td></tr> | |
493 | </table> | |
494 | ||
495 | </form> | |
496 | <?php | |
8361e724 AD |
497 | } |
498 | } | |
499 | ||
97acbaf1 | 500 | function login() { |
97acbaf1 AD |
501 | if (!SINGLE_USER_MODE) { |
502 | ||
d9c85e0f | 503 | $login = $this->dbh->escape_string($_POST["login"]); |
97acbaf1 | 504 | $password = $_POST["password"]; |
aadd636a | 505 | $remember_me = $_POST["remember_me"]; |
97acbaf1 | 506 | |
f231f438 AD |
507 | if ($remember_me) { |
508 | session_set_cookie_params(SESSION_COOKIE_LIFETIME); | |
509 | } else { | |
510 | session_set_cookie_params(0); | |
511 | } | |
512 | ||
aadd636a | 513 | @session_start(); |
60ed4c9a | 514 | |
a42c55f0 | 515 | if (authenticate_user($login, $password)) { |
97acbaf1 AD |
516 | $_POST["password"] = ""; |
517 | ||
b18d109f AD |
518 | if (get_schema_version() >= 120) { |
519 | $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]); | |
520 | } | |
521 | ||
a42c55f0 | 522 | $_SESSION["ref_schema_version"] = get_schema_version(true); |
97acbaf1 AD |
523 | $_SESSION["bw_limit"] = !!$_POST["bw_limit"]; |
524 | ||
525 | if ($_POST["profile"]) { | |
526 | ||
d9c85e0f | 527 | $profile = $this->dbh->escape_string($_POST["profile"]); |
97acbaf1 | 528 | |
d9c85e0f | 529 | $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles |
97acbaf1 AD |
530 | WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]); |
531 | ||
d9c85e0f | 532 | if ($this->dbh->num_rows($result) != 0) { |
97acbaf1 | 533 | $_SESSION["profile"] = $profile; |
97acbaf1 AD |
534 | } |
535 | } | |
536 | } else { | |
537 | $_SESSION["login_error_msg"] = __("Incorrect username or password"); | |
fd94d631 | 538 | user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); |
97acbaf1 AD |
539 | } |
540 | ||
541 | if ($_REQUEST['return']) { | |
542 | header("Location: " . $_REQUEST['return']); | |
543 | } else { | |
b2d42e96 | 544 | header("Location: " . get_self_url_prefix()); |
97acbaf1 AD |
545 | } |
546 | } | |
547 | } | |
548 | ||
f7439d69 | 549 | /* function subtest() { |
97b7d5c0 AD |
550 | header("Content-type: text/plain; charset=utf-8"); |
551 | ||
552 | $url = $_REQUEST["url"]; | |
553 | ||
554 | print "$url\n\n"; | |
555 | ||
556 | ||
557 | print_r(get_feeds_from_html($url, fetch_file_contents($url))); | |
558 | ||
f7439d69 | 559 | } */ |
97b7d5c0 | 560 | |
97acbaf1 | 561 | function subscribe() { |
61a748f8 | 562 | if (SINGLE_USER_MODE) { |
6322ac79 | 563 | login_sequence(); |
61a748f8 AD |
564 | } |
565 | ||
97acbaf1 AD |
566 | if ($_SESSION["uid"]) { |
567 | ||
d9c85e0f | 568 | $feed_url = $this->dbh->escape_string(trim($_REQUEST["feed_url"])); |
97acbaf1 AD |
569 | |
570 | header('Content-Type: text/html; charset=utf-8'); | |
571 | print "<html> | |
572 | <head> | |
573 | <title>Tiny Tiny RSS</title> | |
5bbc4bb4 | 574 | <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\"> |
97acbaf1 | 575 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> |
d0ee0f52 AD |
576 | <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\"> |
577 | <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\"> | |
578 | ||
97acbaf1 AD |
579 | </head> |
580 | <body> | |
884d1650 | 581 | <img class=\"floatingLogo\" src=\"images/logo_small.png\" |
97acbaf1 | 582 | alt=\"Tiny Tiny RSS\"/> |
884d1650 | 583 | <h1>".__("Subscribe to feed...")."</h1><div class='content'>"; |
97acbaf1 | 584 | |
86a8351c | 585 | $rc = Feeds::subscribe_to_feed($feed_url); |
97acbaf1 AD |
586 | |
587 | switch ($rc['code']) { | |
588 | case 0: | |
589 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); | |
590 | break; | |
591 | case 1: | |
592 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); | |
593 | break; | |
594 | case 2: | |
595 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); | |
596 | break; | |
597 | case 3: | |
598 | print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url)); | |
599 | break; | |
600 | case 4: | |
601 | print_notice(__("Multiple feed URLs found.")); | |
759e5132 | 602 | $feed_urls = $rc["feeds"]; |
97acbaf1 AD |
603 | break; |
604 | case 5: | |
605 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url)); | |
606 | break; | |
607 | } | |
608 | ||
609 | if ($feed_urls) { | |
610 | ||
611 | print "<form action=\"public.php\">"; | |
612 | print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">"; | |
613 | ||
614 | print "<select name=\"feed_url\">"; | |
615 | ||
616 | foreach ($feed_urls as $url => $name) { | |
617 | $url = htmlspecialchars($url); | |
618 | $name = htmlspecialchars($name); | |
619 | ||
620 | print "<option value=\"$url\">$name</option>"; | |
621 | } | |
622 | ||
623 | print "<input type=\"submit\" value=\"".__("Subscribe to selected feed"). | |
624 | "\">"; | |
625 | ||
626 | print "</form>"; | |
627 | } | |
628 | ||
629 | $tp_uri = get_self_url_prefix() . "/prefs.php"; | |
630 | $tt_uri = get_self_url_prefix(); | |
631 | ||
632 | if ($rc['code'] <= 2){ | |
d9c85e0f | 633 | $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE |
97acbaf1 AD |
634 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); |
635 | ||
d9c85e0f | 636 | $feed_id = $this->dbh->fetch_result($result, 0, "id"); |
97acbaf1 AD |
637 | } else { |
638 | $feed_id = 0; | |
639 | } | |
640 | print "<p>"; | |
641 | ||
642 | if ($feed_id) { | |
643 | print "<form method=\"GET\" style='display: inline' | |
644 | action=\"$tp_uri\"> | |
645 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
646 | <input type=\"hidden\" name=\"method\" value=\"editFeed\"> | |
647 | <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\"> | |
648 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
649 | </form>"; | |
650 | } | |
651 | ||
652 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> | |
653 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
654 | </form></p>"; | |
655 | ||
884d1650 | 656 | print "</div></body></html>"; |
97acbaf1 AD |
657 | |
658 | } else { | |
6322ac79 | 659 | render_login_form(); |
97acbaf1 AD |
660 | } |
661 | } | |
662 | ||
97acbaf1 AD |
663 | function index() { |
664 | header("Content-Type: text/plain"); | |
27f7b593 | 665 | print error_json(13); |
97acbaf1 AD |
666 | } |
667 | ||
f43e9e97 | 668 | function forgotpass() { |
67e0cf9a AD |
669 | startup_gettext(); |
670 | ||
5303f9a7 AD |
671 | @$hash = $_REQUEST["hash"]; |
672 | ||
f43e9e97 | 673 | header('Content-Type: text/html; charset=utf-8'); |
d0ee0f52 AD |
674 | print "<html><head><title>Tiny Tiny RSS</title> |
675 | <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\"> | |
676 | <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">"; | |
e216d302 | 677 | |
cdbcb277 AD |
678 | echo stylesheet_tag("css/utility.css"); |
679 | echo javascript_tag("lib/prototype.js"); | |
e216d302 AD |
680 | |
681 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> | |
682 | </head><body id='forgotpass'>"; | |
f43e9e97 | 683 | |
884d1650 | 684 | print '<div class="floatingLogo"><img src="images/logo_small.png"></div>'; |
483f15d5 | 685 | print "<h1>".__("Password recovery")."</h1>"; |
884d1650 | 686 | print "<div class='content'>"; |
f43e9e97 AD |
687 | |
688 | @$method = $_POST['method']; | |
689 | ||
5303f9a7 | 690 | if ($hash) { |
2352c320 | 691 | $login = $this->dbh->escape_string($_REQUEST["login"]); |
5303f9a7 AD |
692 | |
693 | if ($login) { | |
694 | $result = $this->dbh->query("SELECT id, resetpass_token FROM ttrss_users | |
695 | WHERE login = '$login'"); | |
696 | ||
697 | if ($this->dbh->num_rows($result) != 0) { | |
698 | $id = $this->dbh->fetch_result($result, 0, "id"); | |
699 | $resetpass_token_full = $this->dbh->fetch_result($result, 0, "resetpass_token"); | |
700 | list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full); | |
701 | ||
702 | if ($timestamp && $resetpass_token && | |
703 | $timestamp >= time() - 15*60*60 && | |
704 | $resetpass_token == $hash) { | |
705 | ||
706 | $result = $this->dbh->query("UPDATE ttrss_users SET resetpass_token = NULL | |
707 | WHERE id = $id"); | |
708 | ||
709 | Pref_Users::resetUserPassword($id, true); | |
710 | ||
711 | print "<p>"."Completed."."</p>"; | |
712 | ||
713 | } else { | |
714 | print_error("Some of the information provided is missing or incorrect."); | |
715 | } | |
716 | } else { | |
717 | print_error("Some of the information provided is missing or incorrect."); | |
718 | } | |
719 | } else { | |
720 | print_error("Some of the information provided is missing or incorrect."); | |
721 | } | |
722 | ||
723 | print "<form method=\"GET\" action=\"index.php\"> | |
724 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
725 | </form>"; | |
726 | ||
727 | } else if (!$method) { | |
728 | print_notice(__("You will need to provide valid account name and email. A password reset link will be sent to your email address.")); | |
483f15d5 | 729 | |
f43e9e97 | 730 | print "<form method='POST' action='public.php'>"; |
f43e9e97 AD |
731 | print "<input type='hidden' name='method' value='do'>"; |
732 | print "<input type='hidden' name='op' value='forgotpass'>"; | |
733 | ||
734 | print "<fieldset>"; | |
735 | print "<label>".__("Login:")."</label>"; | |
736 | print "<input type='text' name='login' value='' required>"; | |
737 | print "</fieldset>"; | |
738 | ||
739 | print "<fieldset>"; | |
740 | print "<label>".__("Email:")."</label>"; | |
741 | print "<input type='email' name='email' value='' required>"; | |
742 | print "</fieldset>"; | |
743 | ||
744 | print "<fieldset>"; | |
745 | print "<label>".__("How much is two plus two:")."</label>"; | |
746 | print "<input type='text' name='test' value='' required>"; | |
747 | print "</fieldset>"; | |
748 | ||
749 | print "<p/>"; | |
750 | print "<button type='submit'>".__("Reset password")."</button>"; | |
751 | ||
752 | print "</form>"; | |
753 | } else if ($method == 'do') { | |
754 | ||
d9c85e0f AD |
755 | $login = $this->dbh->escape_string($_POST["login"]); |
756 | $email = $this->dbh->escape_string($_POST["email"]); | |
757 | $test = $this->dbh->escape_string($_POST["test"]); | |
f43e9e97 AD |
758 | |
759 | if (($test != 4 && $test != 'four') || !$email || !$login) { | |
760 | print_error(__('Some of the required form parameters are missing or incorrect.')); | |
761 | ||
483f15d5 AD |
762 | print "<form method=\"GET\" action=\"public.php\"> |
763 | <input type=\"hidden\" name=\"op\" value=\"forgotpass\"> | |
764 | <input type=\"submit\" value=\"".__("Go back")."\"> | |
765 | </form>"; | |
f43e9e97 | 766 | |
e216d302 | 767 | } else { |
f43e9e97 | 768 | |
5303f9a7 AD |
769 | print_notice("Password reset instructions are being sent to your email address."); |
770 | ||
d9c85e0f | 771 | $result = $this->dbh->query("SELECT id FROM ttrss_users |
f43e9e97 AD |
772 | WHERE login = '$login' AND email = '$email'"); |
773 | ||
d9c85e0f AD |
774 | if ($this->dbh->num_rows($result) != 0) { |
775 | $id = $this->dbh->fetch_result($result, 0, "id"); | |
f43e9e97 | 776 | |
5303f9a7 AD |
777 | if ($id) { |
778 | $resetpass_token = sha1(get_random_bytes(128)); | |
779 | $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token . | |
780 | "&login=" . urlencode($login); | |
781 | ||
782 | require_once 'classes/ttrssmailer.php'; | |
783 | require_once "lib/MiniTemplator.class.php"; | |
784 | ||
785 | $tpl = new MiniTemplator; | |
786 | ||
787 | $tpl->readTemplateFromFile("templates/resetpass_link_template.txt"); | |
788 | ||
789 | $tpl->setVariable('LOGIN', $login); | |
790 | $tpl->setVariable('RESETPASS_LINK', $resetpass_link); | |
791 | ||
792 | $tpl->addBlock('message'); | |
793 | ||
794 | $message = ""; | |
f43e9e97 | 795 | |
5303f9a7 | 796 | $tpl->generateOutputToString($message); |
483f15d5 | 797 | |
5303f9a7 AD |
798 | $mail = new ttrssMailer(); |
799 | ||
800 | $rc = $mail->quickMail($email, $login, | |
801 | __("[tt-rss] Password reset request"), | |
802 | $message, false); | |
803 | ||
804 | if (!$rc) print_error($mail->ErrorInfo); | |
805 | ||
806 | $resetpass_token_full = $this->dbh->escape_string(time() . ":" . $resetpass_token); | |
807 | ||
808 | $result = $this->dbh->query("UPDATE ttrss_users | |
809 | SET resetpass_token = '$resetpass_token_full' | |
810 | WHERE login = '$login' AND email = '$email'"); | |
811 | ||
812 | //Pref_Users::resetUserPassword($id, false); | |
813 | ||
814 | print "<p>"; | |
815 | ||
816 | print "<p>"."Completed."."</p>"; | |
817 | } else { | |
818 | print_error("User ID not found."); | |
819 | } | |
483f15d5 AD |
820 | |
821 | print "<form method=\"GET\" action=\"index.php\"> | |
822 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
823 | </form>"; | |
f43e9e97 AD |
824 | |
825 | } else { | |
826 | print_error(__("Sorry, login and email combination not found.")); | |
483f15d5 AD |
827 | |
828 | print "<form method=\"GET\" action=\"public.php\"> | |
829 | <input type=\"hidden\" name=\"op\" value=\"forgotpass\"> | |
830 | <input type=\"submit\" value=\"".__("Go back")."\"> | |
831 | </form>"; | |
832 | ||
f43e9e97 | 833 | } |
f43e9e97 AD |
834 | } |
835 | ||
836 | } | |
837 | ||
884d1650 | 838 | print "</div>"; |
f43e9e97 AD |
839 | print "</body>"; |
840 | print "</html>"; | |
841 | ||
b4c47f7e AD |
842 | } |
843 | ||
844 | function dbupdate() { | |
67e0cf9a AD |
845 | startup_gettext(); |
846 | ||
f240d26e AD |
847 | if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) { |
848 | $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script."); | |
6322ac79 | 849 | render_login_form(); |
f240d26e AD |
850 | exit; |
851 | } | |
852 | ||
853 | ?><html> | |
854 | <head> | |
855 | <title>Database Updater</title> | |
856 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
5bbc4bb4 | 857 | <link rel="stylesheet" type="text/css" href="css/utility.css"/> |
d0ee0f52 AD |
858 | <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\"> |
859 | <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\"> | |
f240d26e AD |
860 | </head> |
861 | <style type="text/css"> | |
862 | span.ok { color : #009000; font-weight : bold; } | |
863 | span.err { color : #ff0000; font-weight : bold; } | |
864 | </style> | |
865 | <body> | |
866 | <script type='text/javascript'> | |
867 | function confirmOP() { | |
868 | return confirm("Update the database?"); | |
869 | } | |
870 | </script> | |
871 | ||
872 | <div class="floatingLogo"><img src="images/logo_small.png"></div> | |
873 | ||
874 | <h1><?php echo __("Database Updater") ?></h1> | |
875 | ||
876 | <div class="content"> | |
877 | ||
878 | <?php | |
879 | @$op = $_REQUEST["subop"]; | |
0630a100 | 880 | $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION); |
f240d26e AD |
881 | |
882 | if ($op == "performupdate") { | |
883 | if ($updater->isUpdateRequired()) { | |
884 | ||
885 | print "<h2>Performing updates</h2>"; | |
886 | ||
887 | print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>"; | |
888 | ||
889 | print "<ul>"; | |
890 | ||
891 | for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { | |
892 | print "<li>Performing update up to version $i..."; | |
893 | ||
977cea14 | 894 | $result = $updater->performUpdateTo($i, true); |
f240d26e AD |
895 | |
896 | if (!$result) { | |
897 | print "<span class='err'>FAILED!</span></li></ul>"; | |
898 | ||
899 | print_warning("One of the updates failed. Either retry the process or perform updates manually."); | |
900 | print "<p><form method=\"GET\" action=\"index.php\"> | |
901 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
902 | </form>"; | |
903 | ||
977cea14 | 904 | return; |
f240d26e AD |
905 | } else { |
906 | print "<span class='ok'>OK!</span></li>"; | |
907 | } | |
908 | } | |
909 | ||
910 | print "</ul>"; | |
b4c47f7e | 911 | |
f240d26e | 912 | print_notice("Your Tiny Tiny RSS database is now updated to the latest version."); |
b4c47f7e | 913 | |
f240d26e AD |
914 | print "<p><form method=\"GET\" action=\"index.php\"> |
915 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
916 | </form>"; | |
917 | ||
918 | } else { | |
919 | print "<h2>Your database is up to date.</h2>"; | |
920 | ||
921 | print "<p><form method=\"GET\" action=\"index.php\"> | |
922 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
923 | </form>"; | |
924 | } | |
925 | } else { | |
926 | if ($updater->isUpdateRequired()) { | |
927 | ||
928 | print "<h2>Database update required</h2>"; | |
b4c47f7e | 929 | |
b8774453 AD |
930 | print_notice("<h4>". |
931 | sprintf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", | |
932 | $updater->getSchemaVersion(), SCHEMA_VERSION). | |
933 | "</h4>"); | |
b4c47f7e | 934 | |
f240d26e | 935 | print_warning("Please backup your database before proceeding."); |
b4c47f7e | 936 | |
f240d26e AD |
937 | print "<form method='POST'> |
938 | <input type='hidden' name='subop' value='performupdate'> | |
939 | <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'> | |
940 | </form>"; | |
941 | ||
942 | } else { | |
943 | ||
3c200461 | 944 | print_notice("Tiny Tiny RSS database is up to date."); |
f240d26e AD |
945 | |
946 | print "<p><form method=\"GET\" action=\"index.php\"> | |
947 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
948 | </form>"; | |
949 | ||
950 | } | |
951 | } | |
952 | ?> | |
b4c47f7e | 953 | |
f240d26e AD |
954 | </div> |
955 | </body> | |
956 | </html> | |
957 | <?php | |
f43e9e97 AD |
958 | } |
959 | ||
41bead9b | 960 | function cached_url() { |
0c6f7b31 AD |
961 | @$hash = basename($_GET['hash']); |
962 | ||
41bead9b AD |
963 | // we don't need an extension to find the file, hash is a complete URL |
964 | $hash = preg_replace("/\.[^\.]*$/", "", $hash); | |
965 | ||
0c6f7b31 AD |
966 | if ($hash) { |
967 | ||
0442cbb6 | 968 | $filename = CACHE_DIR . '/images/' . $hash; |
0c6f7b31 AD |
969 | |
970 | if (file_exists($filename)) { | |
38b3998b | 971 | header("Content-Disposition: inline; filename=\"$hash\""); |
8b73bd28 AD |
972 | |
973 | send_local_file($filename); | |
974 | ||
0c6f7b31 AD |
975 | } else { |
976 | header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); | |
977 | echo "File not found."; | |
978 | } | |
979 | } | |
980 | } | |
981 | ||
f75e7c64 | 982 | private function make_article_tag_uri($id, $timestamp) { |
4b7391de AD |
983 | |
984 | $timestamp = date("Y-m-d", strtotime($timestamp)); | |
985 | ||
986 | return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id"; | |
987 | } | |
4daaf234 AD |
988 | |
989 | // this should be used very carefully because this endpoint is exposed to unauthenticated users | |
990 | // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available | |
991 | // in general, don't do anything user-related in here and do not modify $_SESSION | |
992 | public function pluginhandler() { | |
993 | $host = new PluginHost(); | |
994 | ||
995 | $plugin = basename($_REQUEST["plugin"]); | |
996 | $method = $_REQUEST["pmethod"]; | |
997 | ||
998 | $host->load($plugin, PluginHost::KIND_USER, 0); | |
999 | $host->load_data(); | |
1000 | ||
1001 | $pclass = $host->get_plugin($plugin); | |
1002 | ||
1003 | if ($pclass) { | |
1004 | if (method_exists($pclass, $method)) { | |
1005 | if ($pclass->is_public_method($method)) { | |
1006 | $pclass->$method(); | |
1007 | } else { | |
1008 | header("Content-Type: text/json"); | |
1009 | print error_json(6); | |
1010 | } | |
1011 | } else { | |
1012 | header("Content-Type: text/json"); | |
1013 | print error_json(13); | |
1014 | } | |
1015 | } else { | |
1016 | header("Content-Type: text/json"); | |
1017 | print error_json(14); | |
1018 | } | |
1019 | } | |
5f0a3741 | 1020 | } |
2352c320 | 1021 | ?> |