]> git.wh0rd.org - tt-rss.git/blame - classes/handler/public.php
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS
[tt-rss.git] / classes / handler / public.php
CommitLineData
5f0a3741 1<?php
369dbc19 2class Handler_Public extends Handler {
5f0a3741 3
79178062 4 private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
2ebf38a9 5 $limit, $search, $search_mode, $match_on, $view_mode = false, $format = 'atom') {
79178062
AD
6
7 require_once "lib/MiniTemplator.class.php";
8
9 $note_style = "background-color : #fff7d5;
10 border-width : 1px; ".
11 "padding : 5px; border-style : dashed; border-color : #e7d796;".
12 "margin-bottom : 1em; color : #9a8c59;";
13
c3d2cda8 14 if (!$limit) $limit = 100;
79178062
AD
15
16 if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
17 $date_sort_field = "updated";
18 } else {
19 $date_sort_field = "date_entered";
20 }
21
22 $qfh_ret = queryFeedHeadlines($this->link, $feed,
23 $limit, $view_mode, $is_cat, $search, $search_mode,
24 $match_on, "$date_sort_field DESC", 0, $owner_uid);
25
26 $result = $qfh_ret[0];
27 $feed_title = htmlspecialchars($qfh_ret[1]);
28 $feed_site_url = $qfh_ret[2];
29 $last_error = $qfh_ret[3];
30
31 $feed_self_url = get_self_url_prefix() .
32 "/public.php?op=rss&id=-2&key=" .
2fb947eb 33 get_feed_access_key($this->link, -2, false, $owner_uid);
79178062
AD
34
35 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
36
2ebf38a9
AD
37 if ($format == 'atom') {
38 $tpl = new MiniTemplator;
79178062 39
2ebf38a9 40 $tpl->readTemplateFromFile("templates/generated_feed.txt");
79178062 41
2ebf38a9
AD
42 $tpl->setVariable('FEED_TITLE', $feed_title, true);
43 $tpl->setVariable('VERSION', VERSION, true);
44 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
79178062 45
2ebf38a9
AD
46 if (PUBSUBHUBBUB_HUB && $feed == -2) {
47 $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
48 $tpl->addBlock('feed_hub');
49 }
79178062 50
2ebf38a9 51 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
79178062 52
2ebf38a9
AD
53 while ($line = db_fetch_assoc($result)) {
54 $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
55 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
56 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
57 $tpl->setVariable('ARTICLE_EXCERPT',
58 truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
79178062 59
2ebf38a9 60 $content = sanitize($this->link, $line["content_preview"], false, $owner_uid);
79178062 61
2ebf38a9
AD
62 if ($line['note']) {
63 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
64 $content;
65 }
66
67 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
68
69 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
70 date('c', strtotime($line["updated"])), true);
71 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
72 date(DATE_RFC822, strtotime($line["updated"])), true);
73
74 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
75
76 $tags = get_article_tags($this->link, $line["id"], $owner_uid);
77
78 foreach ($tags as $tag) {
79 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
80 $tpl->addBlock('category');
81 }
79178062 82
2ebf38a9 83 $enclosures = get_article_enclosures($this->link, $line["id"]);
79178062 84
2ebf38a9
AD
85 foreach ($enclosures as $e) {
86 $type = htmlspecialchars($e['content_type']);
87 $url = htmlspecialchars($e['content_url']);
88 $length = $e['duration'];
9c97041d 89
2ebf38a9
AD
90 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
91 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
92 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
79178062 93
2ebf38a9
AD
94 $tpl->addBlock('enclosure');
95 }
79178062 96
2ebf38a9 97 $tpl->addBlock('entry');
79178062
AD
98 }
99
2ebf38a9
AD
100 $tmp = "";
101
102 $tpl->addBlock('feed');
103 $tpl->generateOutputToString($tmp);
104
105 header("Content-Type: text/xml; charset=utf-8");
106
107 print $tmp;
108 } else if ($format == 'json') {
79178062 109
2ebf38a9 110 $feed = array();
79178062 111
2ebf38a9
AD
112 $feed['title'] = $feed_title;
113 $feed['version'] = VERSION;
114 $feed['feed_url'] = $feed_self_url;
79178062 115
2ebf38a9
AD
116 if (PUBSUBHUBBUB_HUB && $feed == -2) {
117 $feed['hub_url'] = PUBSUBHUBBUB_HUB;
79178062
AD
118 }
119
2ebf38a9
AD
120 $feed['self_url'] = get_self_url_prefix();
121
122 $feed['articles'] = array();
123
124 while ($line = db_fetch_assoc($result)) {
125 $article = array();
79178062 126
2ebf38a9
AD
127 $article['id'] = $line['link'];
128 $article['link'] = $line['link'];
129 $article['title'] = $line['title'];
130 $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
131 $article['content'] = sanitize($this->link, $line["content_preview"], false, $owner_uid);
132 $article['updated'] = date('c', strtotime($line["updated"]));
79178062 133
2ebf38a9
AD
134 if ($line['note']) $article['note'] = $line['note'];
135 if ($article['author']) $article['author'] = $line['author'];
79178062 136
2ebf38a9
AD
137 $tags = get_article_tags($this->link, $line["id"], $owner_uid);
138
139 if (count($tags) > 0) {
140 $article['tags'] = array();
141
142 foreach ($tags as $tag) {
143 array_push($article['tags'], $tag);
144 }
145 }
146
147 $enclosures = get_article_enclosures($this->link, $line["id"]);
148
149 if (count($enclosures) > 0) {
150 $article['enclosures'] = array();
151
152 foreach ($enclosures as $e) {
153 $type = $e['content_type'];
154 $url = $e['content_url'];
155 $length = $e['duration'];
156
157 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
158 }
159 }
160
161 array_push($feed['articles'], $article);
162 }
163
164 header("Content-Type: text/plain; charset=utf-8");
165
166 print json_encode($feed);
167
168 } else {
169 header("Content-Type: text/plain; charset=utf-8");
170 print json_encode(array("error" => array("message" => "Unknown format")));
171 }
79178062
AD
172 }
173
5f0a3741
AD
174 function getUnread() {
175 $login = db_escape_string($_REQUEST["login"]);
176 $fresh = $_REQUEST["fresh"] == "1";
177
178 $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
179
180 if (db_num_rows($result) == 1) {
181 $uid = db_fetch_result($result, 0, "id");
182
183 print getGlobalUnread($this->link, $uid);
184
185 if ($fresh) {
186 print ";";
187 print getFeedArticles($this->link, -3, false, true, $uid);
188 }
189
190 } else {
191 print "-1;User not found";
192 }
193
194 }
195
196 function getProfiles() {
197 $login = db_escape_string($_REQUEST["login"]);
5f0a3741 198
97acbaf1
AD
199 $result = db_query($this->link, "SELECT * FROM ttrss_settings_profiles,ttrss_users
200 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
5f0a3741 201
eeee2ccf 202 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
5f0a3741 203
97acbaf1 204 print "<option value='0'>" . __("Default profile") . "</option>";
5f0a3741 205
97acbaf1
AD
206 while ($line = db_fetch_assoc($result)) {
207 $id = $line["id"];
208 $title = $line["title"];
5f0a3741 209
97acbaf1 210 print "<option value='$id'>$title</option>";
5f0a3741 211 }
97acbaf1
AD
212
213 print "</select>";
5f0a3741
AD
214 }
215
216 function pubsub() {
217 $mode = db_escape_string($_REQUEST['hub_mode']);
218 $feed_id = (int) db_escape_string($_REQUEST['id']);
219 $feed_url = db_escape_string($_REQUEST['hub_topic']);
220
221 if (!PUBSUBHUBBUB_ENABLED) {
222 header('HTTP/1.0 404 Not Found');
223 echo "404 Not found";
224 return;
225 }
226
227 // TODO: implement hub_verifytoken checking
228
229 $result = db_query($this->link, "SELECT feed_url FROM ttrss_feeds
230 WHERE id = '$feed_id'");
231
232 if (db_num_rows($result) != 0) {
233
234 $check_feed_url = db_fetch_result($result, 0, "feed_url");
235
236 if ($check_feed_url && ($check_feed_url == $feed_url || !$feed_url)) {
237 if ($mode == "subscribe") {
238
239 db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 2
240 WHERE id = '$feed_id'");
241
242 print $_REQUEST['hub_challenge'];
243 return;
244
245 } else if ($mode == "unsubscribe") {
246
247 db_query($this->link, "UPDATE ttrss_feeds SET pubsub_state = 0
248 WHERE id = '$feed_id'");
249
250 print $_REQUEST['hub_challenge'];
251 return;
252
253 } else if (!$mode) {
254
255 // Received update ping, schedule feed update.
256 //update_rss_feed($this->link, $feed_id, true, true);
257
258 db_query($this->link, "UPDATE ttrss_feeds SET
259 last_update_started = '1970-01-01',
260 last_updated = '1970-01-01' WHERE id = '$feed_id'");
261
262 }
263 } else {
264 header('HTTP/1.0 404 Not Found');
265 echo "404 Not found";
266 }
267 } else {
268 header('HTTP/1.0 404 Not Found');
269 echo "404 Not found";
270 }
271
272 }
273
274 function logout() {
275 logout_user();
276 header("Location: index.php");
277 }
278
279 function fbexport() {
280
281 $access_key = db_escape_string($_POST["key"]);
282
283 // TODO: rate limit checking using last_connected
284 $result = db_query($this->link, "SELECT id FROM ttrss_linked_instances
285 WHERE access_key = '$access_key'");
286
287 if (db_num_rows($result) == 1) {
288
289 $instance_id = db_fetch_result($result, 0, "id");
290
291 $result = db_query($this->link, "SELECT feed_url, site_url, title, subscribers
292 FROM ttrss_feedbrowser_cache ORDER BY subscribers DESC LIMIT 100");
293
294 $feeds = array();
295
296 while ($line = db_fetch_assoc($result)) {
297 array_push($feeds, $line);
298 }
299
300 db_query($this->link, "UPDATE ttrss_linked_instances SET
301 last_status_in = 1 WHERE id = '$instance_id'");
302
303 print json_encode(array("feeds" => $feeds));
304 } else {
305 print json_encode(array("error" => array("code" => 6)));
306 }
307 }
308
309 function share() {
310 $uuid = db_escape_string($_REQUEST["key"]);
311
312 $result = db_query($this->link, "SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
313 uuid = '$uuid'");
314
315 if (db_num_rows($result) != 0) {
316 header("Content-Type: text/html");
317
318 $id = db_fetch_result($result, 0, "ref_id");
319 $owner_uid = db_fetch_result($result, 0, "owner_uid");
320
64436e10 321 $article = format_article($this->link, $id, false, true, $owner_uid);
5f0a3741
AD
322
323 print_r($article['content']);
324
325 } else {
326 print "Article not found.";
327 }
328
329 }
330
331 function rss() {
5f0a3741
AD
332 $feed = db_escape_string($_REQUEST["id"]);
333 $key = db_escape_string($_REQUEST["key"]);
334 $is_cat = $_REQUEST["is_cat"] != false;
335 $limit = (int)db_escape_string($_REQUEST["limit"]);
336
337 $search = db_escape_string($_REQUEST["q"]);
338 $match_on = db_escape_string($_REQUEST["m"]);
339 $search_mode = db_escape_string($_REQUEST["smode"]);
340 $view_mode = db_escape_string($_REQUEST["view-mode"]);
341
2ebf38a9
AD
342 $format = db_escape_string($_REQUEST['format']);
343
344 if (!$format) $format = 'atom';
345
5f0a3741
AD
346 if (SINGLE_USER_MODE) {
347 authenticate_user($this->link, "admin", null);
348 }
349
350 $owner_id = false;
351
352 if ($key) {
353 $result = db_query($this->link, "SELECT owner_uid FROM
354 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
355
356 if (db_num_rows($result) == 1)
357 $owner_id = db_fetch_result($result, 0, "owner_uid");
358 }
359
360 if ($owner_id) {
2fb947eb 361 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
2ebf38a9 362 $search, $search_mode, $match_on, $view_mode, $format);
5f0a3741
AD
363 } else {
364 header('HTTP/1.1 403 Forbidden');
365 }
366 }
367
07391e36
AD
368 function globalUpdateFeeds() {
369 include "rssfuncs.php";
5f0a3741 370 // Update all feeds needing a update.
036cd3a4 371 update_daemon_common($this->link, 0, true, false);
07391e36 372 }
8361e724
AD
373
374 function sharepopup() {
375 header('Content-Type: text/html; charset=utf-8');
376 print "<html>
377 <head>
378 <title>Tiny Tiny RSS</title>
379 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
380 <script type=\"text/javascript\" src=\"lib/prototype.js\"></script>
381 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
382 </head>
383 <body id='sharepopup'>";
384
385 $action = $_REQUEST["action"];
386
387 if ($_SESSION["uid"]) {
388
d493aba2 389 if ($action == 'share') {
8361e724 390
d493aba2
AD
391 $title = db_escape_string(strip_tags($_REQUEST["title"]));
392 $url = db_escape_string(strip_tags($_REQUEST["url"]));
393 $content = db_escape_string(strip_tags($_REQUEST["content"]));
8361e724 394
d493aba2 395 create_published_article($this->link, $title, $url, $content, $_SESSION["uid"]);
8361e724 396
d493aba2
AD
397 print "<script type='text/javascript'>";
398 print "window.close();";
399 print "</script>";
8361e724 400
d493aba2 401 } else {
8361e724
AD
402 $title = htmlspecialchars($_REQUEST["title"]);
403 $url = htmlspecialchars($_REQUEST["url"]);
404
d493aba2 405 ?>
8361e724 406
d493aba2
AD
407 <table height='100%' width='100%'><tr><td colspan='2'>
408 <h1><?php echo __("Share with Tiny Tiny RSS") ?></h1>
409 </td></tr>
8361e724 410
d493aba2 411 <form id='share_form' name='share_form'>
8361e724 412
d493aba2
AD
413 <input type="hidden" name="op" value="sharepopup">
414 <input type="hidden" name="action" value="share">
8361e724 415
d493aba2
AD
416 <tr><td><?php echo __("Title:") ?></td>
417 <td width='80%'><input name='title' value="<?php echo $title ?>"></td></tr>
418 <tr><td><?php echo __("URL:") ?></td>
419 <td><input name='url' value="<?php echo $url ?>"></td></tr>
420 <tr><td><?php __("Content:") ?></td>
421 <td><input name='content' value=""></td></tr>
8361e724 422
d493aba2 423 <script type='text/javascript'>document.forms[0].title.focus();</script>
8361e724 424
d493aba2
AD
425 <tr><td colspan='2'>
426 <div style='float : right' class='insensitive-small'>
427 <?php echo __("Shared article will appear in the Published feed.") ?>
428 </div>
429 <button type="submit"><?php echo __('Share') ?></button>
430 <button onclick="return window.close()"><?php echo __('Cancel') ?></button>
431 </div>
8361e724 432
d493aba2
AD
433 </form>
434 </td></tr></table>
435 </body></html>
436 <?php
8361e724 437
8361e724
AD
438 }
439
440 } else {
441
d493aba2
AD
442 $return = urlencode($_SERVER["REQUEST_URI"])
443 ?>
444
445 <form action="public.php?return=<?php echo $return ?>"
446 method="POST" id="loginForm" name="loginForm" onsubmit="return validateLoginForm(this)">
447
448 <input type="hidden" name="op" value="login">
449
450 <table height='100%' width='100%'><tr><td colspan='2'>
451 <tr><td colspan='2'><h1><?php echo __("Not logged in") ?></h1></td></tr>
452
453 <tr><td align="right"><?php echo __("Login:") ?></td>
454 <td align="right"><input name="login"
455 value="<?php echo $_SESSION["fake_login"] ?>"></td></tr>
456 <tr><td align="right"><?php echo __("Password:") ?></td>
457 <td align="right"><input type="password" name="password"
458 value="<?php echo $_SESSION["fake_password"] ?>"></td></tr>
459 <tr><td align="right"><?php echo __("Language:") ?></td>
460 <td align="right">
461 <?php
462 print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
463 "style='width : 100%''");
464
465 ?>
466 </td></tr>
467 <tr><td colspan='2'>
468 <button type="submit">
469 <?php echo __('Log in') ?></button>
470
471 <button onclick="return window.close()">
472 <?php echo __('Cancel') ?></button>
473 </td></tr>
474 </table>
475
476 </form>
477 <?php
8361e724
AD
478 }
479 }
480
97acbaf1
AD
481 function login() {
482
97acbaf1
AD
483 $_SESSION["prefs_cache"] = array();
484
485 if (!SINGLE_USER_MODE) {
486
487 $login = db_escape_string($_POST["login"]);
488 $password = $_POST["password"];
489 $remember_me = $_POST["remember_me"];
490
491 if (authenticate_user($this->link, $login, $password)) {
492 $_POST["password"] = "";
493
494 $_SESSION["language"] = $_POST["language"];
495 $_SESSION["ref_schema_version"] = get_schema_version($this->link, true);
496 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
497
498 if ($_POST["profile"]) {
499
500 $profile = db_escape_string($_POST["profile"]);
501
502 $result = db_query($this->link, "SELECT id FROM ttrss_settings_profiles
503 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
504
505 if (db_num_rows($result) != 0) {
506 $_SESSION["profile"] = $profile;
507 $_SESSION["prefs_cache"] = array();
508 }
509 }
510 } else {
511 $_SESSION["login_error_msg"] = __("Incorrect username or password");
512 }
513
514 if ($_REQUEST['return']) {
515 header("Location: " . $_REQUEST['return']);
516 } else {
517 header("Location: " . SELF_URL_PATH);
518 }
519 }
520 }
521
522 function subscribe() {
523 if ($_SESSION["uid"]) {
524
525 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
526
527 header('Content-Type: text/html; charset=utf-8');
528 print "<html>
529 <head>
530 <title>Tiny Tiny RSS</title>
531 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
532 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
533 </head>
534 <body>
535 <img class=\"floatingLogo\" src=\"images/logo_wide.png\"
536 alt=\"Tiny Tiny RSS\"/>
537 <h1>".__("Subscribe to feed...")."</h1>";
538
539 $rc = subscribe_to_feed($this->link, $feed_url);
540
541 switch ($rc['code']) {
542 case 0:
543 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
544 break;
545 case 1:
546 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
547 break;
548 case 2:
549 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
550 break;
551 case 3:
552 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
553 break;
554 case 4:
555 print_notice(__("Multiple feed URLs found."));
556 $feed_urls = get_feeds_from_html($feed_url);
557 break;
558 case 5:
559 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
560 break;
561 }
562
563 if ($feed_urls) {
564
565 print "<form action=\"public.php\">";
566 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
567
568 print "<select name=\"feed_url\">";
569
570 foreach ($feed_urls as $url => $name) {
571 $url = htmlspecialchars($url);
572 $name = htmlspecialchars($name);
573
574 print "<option value=\"$url\">$name</option>";
575 }
576
577 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
578 "\">";
579
580 print "</form>";
581 }
582
583 $tp_uri = get_self_url_prefix() . "/prefs.php";
584 $tt_uri = get_self_url_prefix();
585
586 if ($rc['code'] <= 2){
587 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
588 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
589
590 $feed_id = db_fetch_result($result, 0, "id");
591 } else {
592 $feed_id = 0;
593 }
594 print "<p>";
595
596 if ($feed_id) {
597 print "<form method=\"GET\" style='display: inline'
598 action=\"$tp_uri\">
599 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
600 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
601 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
602 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
603 </form>";
604 }
605
606 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
607 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
608 </form></p>";
609
610 print "</body></html>";
611
612 } else {
613 render_login_form($this->link);
614 }
615 }
616
617 function subscribe2() {
618 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
619 $cat_id = db_escape_string($_REQUEST["cat_id"]);
620 $from = db_escape_string($_REQUEST["from"]);
621
622 /* only read authentication information from POST */
623
624 $auth_login = db_escape_string(trim($_POST["auth_login"]));
625 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
626
627 $rc = subscribe_to_feed($this->link, $feed_url, $cat_id, $auth_login, $auth_pass);
628
629 switch ($rc) {
630 case 1:
631 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
632 break;
633 case 2:
634 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
635 break;
636 case 3:
637 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
638 break;
639 case 0:
640 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
641 break;
642 case 4:
643 print_notice(__("Multiple feed URLs found."));
644
645 $feed_urls = get_feeds_from_html($feed_url);
646 break;
647 case 5:
648 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
649 break;
650 }
651
652 if ($feed_urls) {
653 print "<form action=\"backend.php\">";
654 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
655 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
656 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
657
658 print "<select name=\"feed_url\">";
659
660 foreach ($feed_urls as $url => $name) {
661 $url = htmlspecialchars($url);
662 $name = htmlspecialchars($name);
663 print "<option value=\"$url\">$name</option>";
664 }
665
666 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
667 print "</form>";
668 }
669
670 $tp_uri = get_self_url_prefix() . "/prefs.php";
671 $tt_uri = get_self_url_prefix();
672
673 if ($rc <= 2){
674 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
675 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
676
677 $feed_id = db_fetch_result($result, 0, "id");
678 } else {
679 $feed_id = 0;
680 }
681
682 print "<p>";
683
684 if ($feed_id) {
685 print "<form method=\"GET\" style='display: inline'
686 action=\"$tp_uri\">
687 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
688 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
689 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
690 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
691 </form>";
692 }
693
694 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
695 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
696 </form></p>";
697
698 print "</body></html>";
699 }
700
701 function index() {
702 header("Content-Type: text/plain");
703 print json_encode(array("error" => array("code" => 7)));
704 }
705
5f0a3741
AD
706}
707?>