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