Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7KB

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