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