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