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