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