]> git.mxchange.org Git - friendica.git/blob - mod/bookmarklet.php
Correct content type
[friendica.git] / mod / bookmarklet.php
1 <?php
2 /**
3  * @file mod/bookmarklet.php
4  */
5
6 use Friendica\App;
7 use Friendica\Core\ACL;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Core\System;
11 use Friendica\Module\Login;
12
13 require_once 'include/conversation.php';
14 require_once 'include/items.php';
15
16 function bookmarklet_init()
17 {
18         $_GET["mode"] = "minimal";
19 }
20
21 function bookmarklet_content(App $a)
22 {
23         if (!local_user()) {
24                 $o = '<h2>' . L10n::t('Login') . '</h2>';
25                 $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true);
26                 return $o;
27         }
28
29         $referer = normalise_link(defaults($_SERVER, 'HTTP_REFERER', ''));
30         $page = normalise_link(System::baseUrl() . "/bookmarklet");
31
32         if (!strstr($referer, $page)) {
33                 if (empty($_REQUEST["url"])) {
34                         System::httpExit(400, ["title" => L10n::t('Bad Request')]);
35                 }
36
37                 $content = add_page_info($_REQUEST["url"]);
38
39                 $x = [
40                         'is_owner' => true,
41                         'allow_location' => $a->user['allow_location'],
42                         'default_location' => $a->user['default-location'],
43                         'nickname' => $a->user['nickname'],
44                         'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
45                         'default_perms' => ACL::getDefaultUserPermissions($a->user),
46                         'acl' => ACL::getFullSelectorHTML($a->user, true),
47                         'bang' => '',
48                         'visitor' => 'block',
49                         'profile_uid' => local_user(),
50                         'title' => trim(defaults($_REQUEST, 'title', ''), "*"),
51                         'content' => $content
52                 ];
53                 $o = status_editor($a, $x, 0, false);
54                 $o .= "<script>window.resizeTo(800,550);</script>";
55         } else {
56                 $o = '<h2>' . L10n::t('The post was created') . '</h2>';
57                 $o .= "<script>window.close()</script>";
58         }
59
60         return $o;
61 }