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