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.

52 lines
1006B

  1. <?php
  2. use Friendica\App;
  3. use Friendica\Core\System;
  4. use Friendica\Model\Item;
  5. use Friendica\Util\Strings;
  6. function like_content(App $a) {
  7. if (!local_user() && !remote_user()) {
  8. return false;
  9. }
  10. $verb = Strings::escapeTags(trim($_GET['verb']));
  11. if (!$verb) {
  12. $verb = 'like';
  13. }
  14. $item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
  15. $r = Item::performLike($item_id, $verb);
  16. if (!$r) {
  17. return;
  18. }
  19. // See if we've been passed a return path to redirect to
  20. $return_path = defaults($_REQUEST, 'return', '');
  21. like_content_return($a, $return_path);
  22. killme(); // NOTREACHED
  23. }
  24. // Decide how to return. If we were called with a 'return' argument,
  25. // then redirect back to the calling page. If not, just quietly end
  26. function like_content_return(App $a, $return_path) {
  27. if ($return_path) {
  28. $rand = '_=' . time();
  29. if (strpos($return_path, '?')) {
  30. $rand = "&$rand";
  31. } else {
  32. $rand = "?$rand";
  33. }
  34. $a->internalRedirect($return_path . $rand);
  35. }
  36. killme();
  37. }