]> git.mxchange.org Git - friendica.git/blob - mod/bookmarklet.php
Merge pull request #6977 from annando/fix-reshare
[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 use Friendica\Util\Strings;
13
14 function bookmarklet_init()
15 {
16         $_GET["mode"] = "minimal";
17 }
18
19 function bookmarklet_content(App $a)
20 {
21         if (!local_user()) {
22                 $o = '<h2>' . L10n::t('Login') . '</h2>';
23                 $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? false : true);
24                 return $o;
25         }
26
27         $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', ''));
28         $page = Strings::normaliseLink(System::baseUrl() . "/bookmarklet");
29
30         if (!strstr($referer, $page)) {
31                 if (empty($_REQUEST["url"])) {
32                         System::httpExit(400, ["title" => L10n::t('Bad Request')]);
33                 }
34
35                 $content = add_page_info($_REQUEST["url"]);
36
37                 $x = [
38                         'is_owner' => true,
39                         'allow_location' => $a->user['allow_location'],
40                         'default_location' => $a->user['default-location'],
41                         'nickname' => $a->user['nickname'],
42                         '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'),
43                         'default_perms' => ACL::getDefaultUserPermissions($a->user),
44                         'acl' => ACL::getFullSelectorHTML($a->user, true),
45                         'bang' => '',
46                         'visitor' => 'block',
47                         'profile_uid' => local_user(),
48                         'title' => trim(defaults($_REQUEST, 'title', ''), "*"),
49                         'content' => $content
50                 ];
51                 $o = status_editor($a, $x, 0, false);
52                 $o .= "<script>window.resizeTo(800,550);</script>";
53         } else {
54                 $o = '<h2>' . L10n::t('The post was created') . '</h2>';
55                 $o .= "<script>window.close()</script>";
56         }
57
58         return $o;
59 }