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