diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php deleted file mode 100644 index f15d12d6d1..0000000000 --- a/mod/bookmarklet.php +++ /dev/null @@ -1,59 +0,0 @@ -' . L10n::t('Login') . ''; - $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? false : true); - return $o; - } - - $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', '')); - $page = Strings::normaliseLink(System::baseUrl() . "/bookmarklet"); - - if (!strstr($referer, $page)) { - if (empty($_REQUEST["url"])) { - throw new \Friendica\Network\HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.')); - } - - $content = add_page_info($_REQUEST["url"]); - - $x = [ - 'is_owner' => true, - 'allow_location' => $a->user['allow_location'], - 'default_location' => $a->user['default-location'], - 'nickname' => $a->user['nickname'], - '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'), - 'default_perms' => ACL::getDefaultUserPermissions($a->user), - 'acl' => ACL::getFullSelectorHTML($a->user, true), - 'bang' => '', - 'visitor' => 'block', - 'profile_uid' => local_user(), - 'title' => trim(defaults($_REQUEST, 'title', ''), "*"), - 'content' => $content - ]; - $o = status_editor($a, $x, 0, false); - $o .= ""; - } else { - $o = '

' . L10n::t('The post was created') . '

'; - $o .= ""; - } - - return $o; -} diff --git a/src/App/Router.php b/src/App/Router.php index f4d5d6dfe3..83cdf42554 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -88,6 +88,7 @@ class Router $this->routeCollector->addRoute(['GET'], '/apps', Module\Apps::class); $this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class); $this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class); + $this->routeCollector->addRoute(['GET'], '/bookmarklet', Module\BookMarklet::class); $this->routeCollector->addGroup('/contact', function (RouteCollector $collector) { $collector->addRoute(['GET'], '[/]', Module\Contact::class); $collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', Module\Contact::class); diff --git a/src/Module/BookMarklet.php b/src/Module/BookMarklet.php new file mode 100644 index 0000000000..51feb25d7b --- /dev/null +++ b/src/Module/BookMarklet.php @@ -0,0 +1,63 @@ +getConfig(); + + if (!local_user()) { + $output = '

' . L10n::t('Login') . '

'; + $output .= Login::form($app->query_string, intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true); + return $output; + } + + $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', '')); + $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet"); + + if (!strstr($referer, $page)) { + if (empty($_REQUEST["url"])) { + throw new HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.')); + } + + $content = add_page_info($_REQUEST["url"]); + + $x = [ + 'is_owner' => true, + 'allow_location' => $app->user['allow_location'], + 'default_location' => $app->user['default-location'], + 'nickname' => $app->user['nickname'], + 'lockstate' => ((is_array($app->user) && ((strlen($app->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($app->user['deny_cid'])) || (strlen($app->user['deny_gid'])))) ? 'lock' : 'unlock'), + 'default_perms' => ACL::getDefaultUserPermissions($app->user), + 'acl' => ACL::getFullSelectorHTML($app->user, true), + 'bang' => '', + 'visitor' => 'block', + 'profile_uid' => local_user(), + 'title' => trim(defaults($_REQUEST, 'title', ''), '*'), + 'content' => $content + ]; + $output = status_editor($app, $x, 0, false); + $output .= ""; + } else { + $output = '

' . L10n::t('The post was created') . '

'; + $output .= ""; + } + + return $output; + } +}